Browse Source

lib/led: add some clarifying comments

sbg
Beat Küng 8 years ago committed by Lorenz Meier
parent
commit
b7f5d92b21
  1. 4
      src/lib/led/led.cpp
  2. 14
      src/lib/led/led.h

4
src/lib/led/led.cpp

@ -70,7 +70,7 @@ int LedController::update(LedControlData &control_data)
// handle state updates // handle state updates
hrt_abstime now = hrt_absolute_time(); hrt_abstime now = hrt_absolute_time();
uint16_t blink_delta_t = (uint16_t)((now - _last_update_call) / 100); uint16_t blink_delta_t = (uint16_t)((now - _last_update_call) / 100); // Note: this is in 0.1ms
for (int i = 0; i < BOARD_MAX_LEDS; ++i) { for (int i = 0; i < BOARD_MAX_LEDS; ++i) {
bool do_not_change_state = false; bool do_not_change_state = false;
@ -106,7 +106,7 @@ int LedController::update(LedControlData &control_data)
_states[i].current_blinking_time -= current_blink_duration; _states[i].current_blinking_time -= current_blink_duration;
if (cur_data.blink_times_left == 254) { if (cur_data.blink_times_left == 254) {
// handle toggling for infinite case // handle toggling for infinite case: toggle between 254 and 255
cur_data.blink_times_left = 255; cur_data.blink_times_left = 255;
do_not_change_state = true; do_not_change_state = true;

14
src/lib/led/led.h

@ -91,12 +91,12 @@ public:
*/ */
int update(LedControlData &control_data); int update(LedControlData &control_data);
static const int BLINK_FAST_DURATION = 100 * static const int BLINK_FAST_DURATION = 100 * 1000; /**< duration of half a blinking cycle
1000; ///< duration of half a blinking cycle (on-to-off and off-to-on) in us (on-to-off and off-to-on) in us */
static const int BLINK_NORMAL_DURATION = 500 * static const int BLINK_NORMAL_DURATION = 500 * 1000; /**< duration of half a blinking cycle
1000; ///< duration of half a blinking cycle (on-to-off and off-to-on) in us (on-to-off and off-to-on) in us */
static const int BLINK_SLOW_DURATION = 2000 * static const int BLINK_SLOW_DURATION = 2000 * 1000; /**< duration of half a blinking cycle
1000; ///< duration of half a blinking cycle (on-to-off and off-to-on) in us (on-to-off and off-to-on) in us */
int led_control_subscription() const { return _led_control_sub; } int led_control_subscription() const { return _led_control_sub; }
@ -135,7 +135,7 @@ private:
struct PerLedData { struct PerLedData {
PerPriorityData priority[led_control_s::MAX_PRIORITY + 1]; PerPriorityData priority[led_control_s::MAX_PRIORITY + 1];
uint16_t current_blinking_time = 0; ///< how long the Led was in current state (in 0.1 ms) uint16_t current_blinking_time = 0; ///< how long the Led was in current state (in 0.1 ms, wraps if > 6.5s)
NextState next_state; NextState next_state;
}; };

Loading…
Cancel
Save