mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-12 06:57:57 +04:00
base-files: add ucidef for LEDs with configurable brightness
Add ucidef_set_led_brightness() to set up a static LED with an optional brightness level, complementing ucidef_set_led_default() for hardware that supports per-channel current or PWM control. The function writes a "brightness" type to board.json alongside the default on/off state. config_generate picks this up and writes the brightness option to the UCI LED config, where the led init script already knows to apply it. Signed-off-by: Manuel Fombuena <fombuena@outlook.com> Link: https://github.com/openwrt/openwrt/pull/23457 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
1 parent
aa773443ce
commit
c5cffacc1d
2 files changed
+17
No files matched your search
@@ -405,6 +405,12 @@ generate_led() {
|
||||
EOF
|
||||
|
||||
case "$type" in
|
||||
brightness)
|
||||
local brightness
|
||||
json_get_vars brightness
|
||||
[ -n "$brightness" ] && uci -q set system.$cfg.brightness="$brightness"
|
||||
;;
|
||||
|
||||
gpio)
|
||||
local gpio inverted
|
||||
json_get_vars gpio inverted
|
||||
|
||||
@@ -416,6 +416,17 @@ ucidef_set_led_ataport() {
|
||||
_ucidef_set_led_trigger "$1" "$2" "$3" ata"$4"
|
||||
}
|
||||
|
||||
ucidef_set_led_brightness() {
|
||||
_ucidef_set_led_common "$1" "$2" "$3"
|
||||
|
||||
json_add_string type brightness
|
||||
json_add_string default "$4"
|
||||
[ -n "$5" ] && json_add_string brightness "$5"
|
||||
json_select ..
|
||||
|
||||
json_select ..
|
||||
}
|
||||
|
||||
_ucidef_set_led_common() {
|
||||
local cfg="led_$1"
|
||||
local name="$2"
|
||||
|
||||
Reference in new issue
Block a user