Skip to content

Commit

Permalink
[leds] add module for talking to a GPIO daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico committed Oct 4, 2014
1 parent b8c2898 commit 3316e56
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions lib/32-leds-gpiod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# leds

k_leds_gpiod_update() {
local command
command="$1"
k_log 3 "changing leds GPIO #$K_LEDS_GPIOD_NUM, $command"
echo "$command $K_LEDS_GPIOD_NUM" > $K_LEDS_GPIOD_FIFO
sleep 1
}

k_leds_gpiod_init() {
[ -p "$K_LEDS_GPIOD_FIFO" ] || {
k_log 3 "WARNING: gpiod support not found"
return 1
}
k_log 3 "initializing leds GPIO support"
k_leds_gpiod_update 'INIT'
return 0
}

k_leds_gpiod_blink() {
k_leds_gpiod_update 'BLINK'
k_leds_gpiod_update 'BLINK'
}

k_leds_gpiod_on() {
k_leds_gpiod_update 'ON'
}

k_leds_gpiod_off() {
k_leds_gpiod_update 'OFF'
}

k_leds_gpiod_pulse() {
k_leds_gpiod_update 'PULSE'
}

k_leds_gpiod_startup() {
k_leds_gpiod_init || \
return
k_leds_gpiod_pulse
k_hook_register_handler on_media_plugged k_leds_gpiod_off
k_hook_register_handler on_media_removed k_leds_gpiod_pulse
k_hook_register_handler on_copy_started k_leds_gpiod_blink
k_hook_register_handler on_copy_ended k_leds_gpiod_on
k_hook_register_handler on_app_ended k_leds_gpiod_off
}

k_hook_register_handler on_app_started k_leds_gpiod_startup

0 comments on commit 3316e56

Please sign in to comment.