1
0

leds.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. # Copyright (C) 2013 OpenWrt.org
  3. led_set_attr() {
  4. [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
  5. }
  6. led_timer() {
  7. led_set_attr $1 "trigger" "timer"
  8. led_set_attr $1 "delay_on" "$2"
  9. led_set_attr $1 "delay_off" "$3"
  10. }
  11. led_on() {
  12. led_set_attr $1 "trigger" "none"
  13. led_set_attr $1 "brightness" 255
  14. }
  15. led_off() {
  16. led_set_attr $1 "trigger" "none"
  17. led_set_attr $1 "brightness" 0
  18. }
  19. status_led_set_timer() {
  20. led_timer $status_led "$1" "$2"
  21. [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2"
  22. }
  23. status_led_set_heartbeat() {
  24. led_set_attr $status_led "trigger" "heartbeat"
  25. }
  26. status_led_on() {
  27. led_on $status_led
  28. [ -n "$status_led2" ] && led_on $status_led2
  29. }
  30. status_led_off() {
  31. led_off $status_led
  32. [ -n "$status_led2" ] && led_off $status_led2
  33. }
  34. status_led_blink_slow() {
  35. led_timer $status_led 1000 1000
  36. }
  37. status_led_blink_fast() {
  38. led_timer $status_led 100 100
  39. }
  40. status_led_blink_preinit() {
  41. led_timer $status_led 100 100
  42. }
  43. status_led_blink_failsafe() {
  44. led_timer $status_led 50 50
  45. }
  46. status_led_blink_preinit_regular() {
  47. led_timer $status_led 200 200
  48. }