MiLightRadioConfig.h 1.6 KB

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