RCOutputRGBLed.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include "RGBLed.h"
  3. class RCOutputRGBLed: public RGBLed {
  4. public:
  5. RCOutputRGBLed(uint8_t red_channel, uint8_t green_channel,
  6. uint8_t blue_channel, uint8_t led_off, uint8_t led_full,
  7. uint8_t led_medium, uint8_t led_dim);
  8. RCOutputRGBLed(uint8_t red_channel, uint8_t green_channel,
  9. uint8_t blue_channel);
  10. protected:
  11. bool hw_init() override;
  12. virtual bool hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) override;
  13. virtual uint16_t get_duty_cycle_for_color(const uint8_t color, const uint16_t usec_period) const;
  14. private:
  15. uint8_t _red_channel;
  16. uint8_t _green_channel;
  17. uint8_t _blue_channel;
  18. };
  19. class RCOutputRGBLedInverted : public RCOutputRGBLed {
  20. public:
  21. RCOutputRGBLedInverted(uint8_t red_channel, uint8_t green_channel, uint8_t blue_channel)
  22. : RCOutputRGBLed(red_channel, green_channel, blue_channel)
  23. { }
  24. protected:
  25. virtual uint16_t get_duty_cycle_for_color(const uint8_t color, const uint16_t usec_period) const override;
  26. };
  27. class RCOutputRGBLedOff : public RCOutputRGBLed {
  28. public:
  29. RCOutputRGBLedOff(uint8_t red_channel, uint8_t green_channel,
  30. uint8_t blue_channel, uint8_t led_off)
  31. : RCOutputRGBLed(red_channel, green_channel, blue_channel,
  32. led_off, led_off, led_off, led_off)
  33. { }
  34. /* Override the hw_set_rgb method to turn leds off regardless of the
  35. * values passed */
  36. bool hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue) override
  37. {
  38. return RCOutputRGBLed::hw_set_rgb(_led_off, _led_off, _led_off);
  39. }
  40. };