mirror of https://github.com/ArduPilot/ardupilot
AP_Notify: use simulated toshiba LED for display rather than directly
This commit is contained in:
parent
8f7f0d5e72
commit
abd7fa11c1
|
@ -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
|
||||
|
|
|
@ -31,22 +31,18 @@
|
|||
|
||||
#ifdef WITH_SITL_RGBLED
|
||||
|
||||
#include "RGBLed.h"
|
||||
|
||||
#ifdef HAVE_SFML_GRAPHICS_H
|
||||
#include <SFML/Graphics.h>
|
||||
#else
|
||||
#include <SFML/Graphics.hpp>
|
||||
#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
|
||||
|
|
Loading…
Reference in New Issue