lib/led: add led class with led_control uorb topic

This is the new interface to control external LED's (user-facing).
Features:
- Supports maximum N Leds (where the board can define N)
- on/off/blink M times
- Different priorities
- Allows setting a single led or multiple at once
This commit is contained in:
Beat Küng
2017-02-24 10:04:08 +01:00
committed by Lorenz Meier
parent 5ebbbfc6bf
commit 43b98d9a2f
6 changed files with 480 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# LED control: control a single or multiple LED's.
# These are the externally visible LED's, not the board LED's
# colors
uint8 COLOR_OFF = 0 # this is only used in the drivers
uint8 COLOR_RED = 1
uint8 COLOR_GREEN = 2
uint8 COLOR_BLUE = 3
uint8 COLOR_YELLOW = 4
uint8 COLOR_PURPLE = 5
uint8 COLOR_AMBER = 6
uint8 COLOR_CYAN = 7
uint8 COLOR_WHITE = 8
# LED modes definitions
uint8 MODE_OFF = 0 # turn LED off
uint8 MODE_ON = 1 # turn LED on
uint8 MODE_DISABLED = 2 # disable this priority (switch to lower priority setting)
uint8 MODE_BLINK_SLOW = 3
uint8 MODE_BLINK_NORMAL = 4
uint8 MODE_BLINK_FAST = 5
# uint8 MODE_BREATHE = 6 # not implemented (yet)
uint8 MAX_PRIORITY = 2 # maxium priority (minimum is 0)
uint8 led_mask # bitmask which LED(s) to control, set to 0xff for all
uint8 color # see COLOR_*
uint8 mode # see MODE_*
uint8 num_blinks # how many times to blink (number of on-off cycles if mode is one of MODE_BLINK_*). Set to 0 for infinite
uint8 priority # priority: higher priority events will override current lower priority events (see MAX_PRIORITY)