mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 02:01:36 +08:00
lib/led: make sure to do an orb_copy on startup
This commit is contained in:
+10
-6
@@ -51,18 +51,22 @@ int LedController::update(LedControlData &control_data)
|
|||||||
|
|
||||||
orb_check(_led_control_sub, &updated);
|
orb_check(_led_control_sub, &updated);
|
||||||
|
|
||||||
while (updated) {
|
while (updated || _force_update) {
|
||||||
// handle new state
|
// handle new state
|
||||||
led_control_s led_control;
|
led_control_s led_control;
|
||||||
orb_copy(ORB_ID(led_control), _led_control_sub, &led_control);
|
|
||||||
|
|
||||||
// don't apply the new state just yet to avoid interrupting an ongoing blinking state
|
if (orb_copy(ORB_ID(led_control), _led_control_sub, &led_control) == 0) {
|
||||||
for (int i = 0; i < BOARD_MAX_LEDS; ++i) {
|
|
||||||
if (led_control.led_mask & (1 << i)) {
|
// don't apply the new state just yet to avoid interrupting an ongoing blinking state
|
||||||
_states[i].next_state.set(led_control);
|
for (int i = 0; i < BOARD_MAX_LEDS; ++i) {
|
||||||
|
if (led_control.led_mask & (1 << i)) {
|
||||||
|
_states[i].next_state.set(led_control);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_force_update = false;
|
||||||
|
|
||||||
orb_check(_led_control_sub, &updated);
|
orb_check(_led_control_sub, &updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,5 +143,6 @@ private:
|
|||||||
|
|
||||||
int _led_control_sub = -1; ///< uorb subscription
|
int _led_control_sub = -1; ///< uorb subscription
|
||||||
hrt_abstime _last_update_call;
|
hrt_abstime _last_update_call;
|
||||||
|
bool _force_update = true; ///< force an orb_copy in the beginning
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user