|
|
|
@ -60,7 +60,21 @@ int LedController::update(LedControlData &control_data)
@@ -60,7 +60,21 @@ int LedController::update(LedControlData &control_data)
|
|
|
|
|
// don't apply the new state just yet to avoid interrupting an ongoing blinking state
|
|
|
|
|
for (int i = 0; i < BOARD_MAX_LEDS; ++i) { |
|
|
|
|
if (led_control.led_mask & (1 << i)) { |
|
|
|
|
_states[i].next_state.set(led_control); |
|
|
|
|
// if next state has already a higher priority state than
|
|
|
|
|
// led_control, set lower prio state directly, so that this
|
|
|
|
|
// information is not lost
|
|
|
|
|
if (_states[i].next_state.is_valid() && led_control.priority < _states[i].next_state.priority) { |
|
|
|
|
_states[i].set(led_control); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
// if a lower prio event is already in next state and a
|
|
|
|
|
// higher prio event is coming in
|
|
|
|
|
if (_states[i].next_state.is_valid() && led_control.priority > _states[i].next_state.priority) { |
|
|
|
|
_states[i].apply_next_state(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_states[i].next_state.set(led_control); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -96,6 +110,7 @@ int LedController::update(LedControlData &control_data)
@@ -96,6 +110,7 @@ int LedController::update(LedControlData &control_data)
|
|
|
|
|
uint16_t current_blink_duration = 0; |
|
|
|
|
|
|
|
|
|
switch (cur_data.mode) { |
|
|
|
|
case led_control_s::MODE_FLASH: |
|
|
|
|
case led_control_s::MODE_BLINK_FAST: |
|
|
|
|
current_blink_duration = BLINK_FAST_DURATION / 100; |
|
|
|
|
break; |
|
|
|
@ -168,15 +183,7 @@ int LedController::update(LedControlData &control_data)
@@ -168,15 +183,7 @@ int LedController::update(LedControlData &control_data)
|
|
|
|
|
had_changes = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_states[i].priority[next_priority].color = _states[i].next_state.color; |
|
|
|
|
_states[i].priority[next_priority].mode = _states[i].next_state.mode; |
|
|
|
|
_states[i].priority[next_priority].blink_times_left = _states[i].next_state.num_blinks * 2; |
|
|
|
|
|
|
|
|
|
if (_states[i].priority[next_priority].blink_times_left == 0) { |
|
|
|
|
// handle infinite case
|
|
|
|
|
_states[i].priority[next_priority].blink_times_left = 254; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_states[i].apply_next_state(); |
|
|
|
|
_states[i].next_state.reset(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -204,6 +211,7 @@ void LedController::get_control_data(LedControlData &control_data)
@@ -204,6 +211,7 @@ void LedController::get_control_data(LedControlData &control_data)
|
|
|
|
|
control_data.leds[i].brightness = 255; |
|
|
|
|
|
|
|
|
|
for (int priority = led_control_s::MAX_PRIORITY; priority >= 0; --priority) { |
|
|
|
|
bool flash_output_active = true; |
|
|
|
|
const PerPriorityData &cur_data = _states[i].priority[priority]; |
|
|
|
|
|
|
|
|
|
if (cur_data.mode == led_control_s::MODE_DISABLED) { |
|
|
|
@ -225,10 +233,16 @@ void LedController::get_control_data(LedControlData &control_data)
@@ -225,10 +233,16 @@ void LedController::get_control_data(LedControlData &control_data)
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case led_control_s::MODE_FLASH: |
|
|
|
|
if (cur_data.blink_times_left % 10 < 6) { // 2 blinks, then turn off for the rest of the cycle
|
|
|
|
|
flash_output_active = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* FALLTHROUGH */ |
|
|
|
|
case led_control_s::MODE_BLINK_FAST: |
|
|
|
|
case led_control_s::MODE_BLINK_NORMAL: |
|
|
|
|
case led_control_s::MODE_BLINK_SLOW: |
|
|
|
|
if (cur_data.blink_times_left % 2 == 0) { |
|
|
|
|
if (cur_data.blink_times_left % 2 == 0 && flash_output_active) { |
|
|
|
|
control_data.leds[i].color = cur_data.color; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|