MiLightRadioConfig.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <Arduino.h>
  2. #include <PacketFormatter.h>
  3. #include <RgbCctPacketFormatter.h>
  4. #include <RgbwPacketFormatter.h>
  5. #include <CctPacketFormatter.h>
  6. #include <MiLightButtons.h>
  7. #ifndef _MILIGHT_RADIO_CONFIG
  8. #define _MILIGHT_RADIO_CONFIG
  9. class MiLightRadioConfig {
  10. public:
  11. static const size_t NUM_CHANNELS = 3;
  12. MiLightRadioConfig(const uint16_t syncword0,
  13. const uint16_t syncword3,
  14. PacketFormatter* packetFormatter,
  15. const MiLightRadioType type,
  16. const char* name,
  17. const uint8_t channel0,
  18. const uint8_t channel1,
  19. const uint8_t channel2)
  20. : syncword0(syncword0),
  21. syncword3(syncword3),
  22. packetFormatter(packetFormatter),
  23. type(type),
  24. name(name)
  25. {
  26. channels[0] = channel0;
  27. channels[1] = channel1;
  28. channels[2] = channel2;
  29. }
  30. const uint16_t syncword0;
  31. const uint16_t syncword3;
  32. uint8_t channels[3];
  33. PacketFormatter* packetFormatter;
  34. const MiLightRadioType type;
  35. const char* name;
  36. static const size_t NUM_CONFIGS = 3;
  37. static const MiLightRadioConfig* ALL_CONFIGS[NUM_CONFIGS];
  38. static MiLightRadioConfig* fromString(const String& s);
  39. size_t getPacketLength() const;
  40. };
  41. static MiLightRadioConfig MilightRgbwConfig(
  42. 0x147A, 0x258B, new RgbwPacketFormatter(8), RGBW, "rgbw", 9, 40, 71
  43. );
  44. static MiLightRadioConfig MilightCctConfig(
  45. 0x050A, 0x55AA, new CctPacketFormatter(8), CCT, "cct", 4, 39, 74
  46. );
  47. static MiLightRadioConfig MilightRgbCctConfig(
  48. 0x7236, 0x1809, new RgbCctPacketFormatter(9), RGB_CCT, "rgb_cct", 8, 39, 70
  49. );
  50. #endif