MiLightRadioConfig.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 MiLightRadioConfig* ALL_CONFIGS[NUM_CONFIGS];
  39. static MiLightRadioConfig* fromString(const String& s);
  40. static MiLightRadioConfig* fromType(MiLightRadioType type);
  41. size_t getPacketLength() const;
  42. };
  43. static MiLightRadioConfig MilightRgbwConfig(
  44. 0x147A, 0x258B, new RgbwPacketFormatter(), RGBW, "rgbw", 9, 40, 71
  45. );
  46. static MiLightRadioConfig MilightCctConfig(
  47. 0x050A, 0x55AA, new CctPacketFormatter(), CCT, "cct", 4, 39, 74
  48. );
  49. static MiLightRadioConfig MilightRgbCctConfig(
  50. 0x7236, 0x1809, new RgbCctPacketFormatter(), RGB_CCT, "rgb_cct", 8, 39, 70
  51. );
  52. static MiLightRadioConfig MilightRgbConfig(
  53. 0x9AAB, 0xBCCD, new RgbPacketFormatter(), RGB, "rgb", 3, 38, 73
  54. );
  55. #endif