diff --git a/libraries/AP_Notify/SITL_SFML_LED.cpp b/libraries/AP_Notify/SITL_SFML_LED.cpp index c270c0041e..6bb96be714 100644 --- a/libraries/AP_Notify/SITL_SFML_LED.cpp +++ b/libraries/AP_Notify/SITL_SFML_LED.cpp @@ -25,14 +25,6 @@ #include "SITL_SFML_LED.h" -SITL_SFML_LED::SITL_SFML_LED(): - RGBLed((uint8_t)brightness::LED_OFF, - (uint8_t)brightness::LED_HIGH, - (uint8_t)brightness::LED_MEDIUM, - (uint8_t)brightness::LED_LOW) -{ -} - /* return layout size for a LED layout scheme */ @@ -176,37 +168,9 @@ void SITL_SFML_LED::update_serial_LEDs() void SITL_SFML_LED::update_thread(void) { - sf::RenderWindow *w = nullptr; - { - WITH_SEMAPHORE(AP::notify().sf_window_mutex); - w = new sf::RenderWindow(sf::VideoMode(width, height), "LED"); - } - - if (!w) { - AP_HAL::panic("Unable to create RGBLed window"); - } - while (true) { { WITH_SEMAPHORE(AP::notify().sf_window_mutex); - sf::Event event; - while (w->pollEvent(event)) { - if (event.type == sf::Event::Closed) { - w->close(); - break; - } - } - if (!w->isOpen()) { - break; - } - const uint32_t colour = red<<16 | green<<8 | blue; - if (colour != last_colour) { - last_colour = colour; - - w->clear(sf::Color(red, green, blue, 255)); - w->display(); - } - update_serial_LEDs(); } usleep(10000); @@ -227,12 +191,9 @@ bool SITL_SFML_LED::init() return true; } -bool SITL_SFML_LED::hw_set_rgb(uint8_t _red, uint8_t _green, uint8_t _blue) +void SITL_SFML_LED::update() { - red = _red; - green = _green; - blue = _blue; - - return true; + // all updates are done in the thread } + #endif diff --git a/libraries/AP_Notify/SITL_SFML_LED.h b/libraries/AP_Notify/SITL_SFML_LED.h index 2e45c5bf5d..cd1fd61848 100644 --- a/libraries/AP_Notify/SITL_SFML_LED.h +++ b/libraries/AP_Notify/SITL_SFML_LED.h @@ -31,22 +31,18 @@ #ifdef WITH_SITL_RGBLED -#include "RGBLed.h" - #ifdef HAVE_SFML_GRAPHICS_H #include #else #include #endif -class SITL_SFML_LED: public RGBLed +class SITL_SFML_LED : public NotifyDevice { public: - SITL_SFML_LED(); + SITL_SFML_LED() {} bool init(void) override; - -protected: - bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override; + void update() override; private: @@ -55,24 +51,8 @@ private: void update_serial_LEDs(void); static void *update_thread_start(void *obj); - static constexpr uint8_t height = 50; - static constexpr uint8_t width = height; - static constexpr uint8_t serialLED_size = 16; - enum class brightness { - LED_LOW = 0x33, - LED_MEDIUM = 0x7F, - LED_HIGH = 0xFF, - LED_OFF = 0x00 - }; - - uint32_t last_colour; - - uint8_t red; - uint8_t green; - uint8_t blue; - static const uint8_t MAX_LEDS = 64; // LED layout control