From 95c66a794e1e1382d1d29bcf0f7802a20e3312d2 Mon Sep 17 00:00:00 2001 From: Angus Peart Date: Tue, 12 May 2015 18:30:15 +0800 Subject: [PATCH] AP_Notify: sync oreoleds before a reboot --- libraries/AP_Notify/OreoLED_PX4.cpp | 29 +++++++++++++++++++++++++++++ libraries/AP_Notify/OreoLED_PX4.h | 8 ++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Notify/OreoLED_PX4.cpp b/libraries/AP_Notify/OreoLED_PX4.cpp index b394e589f7..33db5976a0 100644 --- a/libraries/AP_Notify/OreoLED_PX4.cpp +++ b/libraries/AP_Notify/OreoLED_PX4.cpp @@ -89,6 +89,8 @@ void OreoLED_PX4::update() // handle firmware update event if (AP_Notify::flags.firmware_update) { + // Force a syncronisation before setting the free-running colour cycle macro + send_sync(); set_macro(OREOLED_INSTANCE_ALL, OREOLED_PARAM_MACRO_COLOUR_CYCLE); return; } @@ -290,6 +292,28 @@ void OreoLED_PX4::set_macro(uint8_t instance, oreoled_macro macro) _state_desired_semaphore = false; } +// set_macro - set macro for one or all LEDs +void OreoLED_PX4::send_sync(void) +{ + // return immediately if no healthy leds + if (!_overall_health) { + return; + } + + // set semaphore + _state_desired_semaphore = true; + + for (uint8_t i=0; i