[OpenWrt-Devel] [PATCH v2 7/8] base-files: added option to configure the gpio led trigger in uci-defaults
Günther Kelleter
guenther.kelleter at devolo.de
Thu Jul 2 07:47:22 EDT 2015
Signed-off-by: Günther Kelleter <guenther.kelleter at devolo.de>
---
package/base-files/files/etc/init.d/led | 7 +++++++
.../base-files/files/lib/functions/uci-defaults.sh | 20 ++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led
index 1a57e8a..3f45732 100755
--- a/package/base-files/files/etc/init.d/led
+++ b/package/base-files/files/etc/init.d/led
@@ -26,6 +26,8 @@ load_led() {
config_get port_state $1 port_state
config_get delay $1 delay "150"
config_get message $1 message ""
+ config_get gpio $1 gpio "0"
+ config_get inverted $1 inverted "0"
if [ "$trigger" = "rssi" ]; then
# handled by rssileds userspace process
@@ -80,6 +82,11 @@ load_led() {
echo $delay > /sys/class/leds/${sysfs}/delay
;;
+ "gpio")
+ echo $gpio > /sys/class/leds/${sysfs}/gpio
+ echo $inverted > /sys/class/leds/${sysfs}/inverted
+ ;;
+
switch[0-9]*)
local port_mask
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 5a8809d..93997b2 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -157,6 +157,26 @@ EOF
UCIDEF_LEDS_CHANGED=1
}
+ucidef_set_led_gpio() {
+ local cfg="led_$1"
+ local name=$2
+ local sysfs=$3
+ local gpio=$4
+ local inverted=$5
+
+ uci -q get system.$cfg && return 0
+
+ uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='gpio'
+set system.$cfg.gpio='$gpio'
+set system.$cfg.inverted='$inverted'
+EOF
+ UCIDEF_LEDS_CHANGED=1
+}
+
ucidef_set_rssimon() {
local dev="$1"
local refresh="$2"
--
2.4.4.88.gac2ab0d
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list