51 if (led_control.
led_mask & (1 << i)) {
74 bool had_changes =
false;
87 int num_blinking_leds = 0;
88 int num_blinking_do_not_change_state = 0;
92 int priority = led_control_s::MAX_PRIORITY;
94 for (; priority >= 0; --priority) {
98 if (cur_data.
mode == led_control_s::MODE_DISABLED) {
103 uint16_t current_blink_duration = 0;
105 switch (cur_data.
mode) {
106 case led_control_s::MODE_FLASH:
107 case led_control_s::MODE_BLINK_FAST:
111 case led_control_s::MODE_BLINK_NORMAL:
115 case led_control_s::MODE_BLINK_SLOW:
119 case led_control_s::MODE_BREATHE:
122 while (
_states[i].current_blinking_time > breathe_duration) {
130 if (current_blink_duration > 0) {
133 if ((
_states[i].current_blinking_time += blink_delta_t) > current_blink_duration) {
141 ++num_blinking_do_not_change_state;
144 cur_data.
mode = led_control_s::MODE_DISABLED;
148 ++num_blinking_do_not_change_state;
154 ++num_blinking_do_not_change_state;
161 current_priorities[i] = priority;
168 if (num_blinking_leds == 0 || num_blinking_leds > num_blinking_do_not_change_state) {
170 if (
_states[i].next_state.is_valid()) {
173 if (next_priority >= current_priorities[i]) {
202 control_data.
leds[i].
color = led_control_s::COLOR_OFF;
205 for (
int priority = led_control_s::MAX_PRIORITY; priority >= 0; --priority) {
206 bool flash_output_active =
true;
209 if (cur_data.
mode == led_control_s::MODE_DISABLED) {
213 switch (cur_data.
mode) {
214 case led_control_s::MODE_ON:
218 case led_control_s::MODE_BREATHE: {
228 case led_control_s::MODE_FLASH:
230 flash_output_active =
false;
234 case led_control_s::MODE_BLINK_FAST:
235 case led_control_s::MODE_BLINK_NORMAL:
236 case led_control_s::MODE_BLINK_SLOW:
PerLedData _states[BOARD_MAX_LEDS]
keep current LED states
void get_control_data(LedControlData &control_data)
set control_data based on current Led states
static constexpr int BREATHE_INTERVAL
single step when in breathe mode
uint8_t color
one of led_control_s::COLOR_*
static led_control_s led_control
LedControlDataSingle leds[BOARD_MAX_LEDS]
static constexpr int BLINK_FAST_DURATION
duration of half a blinking cycle (on-to-off and off-to-on) in us
static constexpr int BREATHE_STEPS
number of steps in breathe mode for a full on-off cycle
hrt_abstime _last_update_call
bool _breathe_enabled
true if at least one of the led's is currently in breathe mode
uint8_t brightness
brightness in [0, 255]
PerPriorityData priority[led_control_s::MAX_PRIORITY+1]
uint8_t color
one of led_control_s::COLOR_*
void set(const led_control_s &led_control)
static constexpr int BLINK_SLOW_DURATION
duration of half a blinking cycle (on-to-off and off-to-on) in us
uint16_t current_blinking_time
how long the Led was in current state (in 0.1 ms, wraps if > 6.5s)
static constexpr int BLINK_NORMAL_DURATION
duration of half a blinking cycle (on-to-off and off-to-on) in us
bool updated()
Check if there is a new update.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
void set(const led_control_s &led_control)
int update(LedControlData &control_data)
Update and retrieve the Led state.
Led controller helper class, used by Led drivers.
uORB::Subscription _led_control_sub
uorb subscription
uint8_t blink_times_left
how many times left to blink (MSB bit is used for infinite case).
uint8_t mode
one of led_control_s::MODE_*
bool copy(void *dst)
Copy the struct.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
bool _force_update
force an orb_copy in the beginning