SITL_SFML_LED.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Copyright (C) 2019 Peter Barker. All rights reserved.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <AP_HAL/AP_HAL.h>
  16. #ifdef WITH_SITL_RGBLED
  17. #include "RGBLed.h"
  18. #ifdef HAVE_SFML_GRAPHICS_H
  19. #include <SFML/Graphics.h>
  20. #else
  21. #include <SFML/Graphics.hpp>
  22. #endif
  23. class SITL_SFML_LED: public RGBLed
  24. {
  25. public:
  26. SITL_SFML_LED();
  27. protected:
  28. bool hw_init(void) override;
  29. bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b) override;
  30. private:
  31. pthread_t thread;
  32. void update_thread(void);
  33. static void *update_thread_start(void *obj);
  34. static constexpr uint8_t height = 50;
  35. static constexpr uint8_t width = height;
  36. enum class brightness {
  37. LED_LOW = 0x33,
  38. LED_MEDIUM = 0x7F,
  39. LED_HIGH = 0xFF,
  40. LED_OFF = 0x00
  41. };
  42. uint32_t last_colour;
  43. uint8_t red;
  44. uint8_t green;
  45. uint8_t blue;
  46. };
  47. #endif