GroupState.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <inttypes.h>
  2. #include <Arduino.h>
  3. #include <MiLightButtons.h>
  4. #ifndef _GROUP_STATE_H
  5. #define _GROUP_STATE_H
  6. struct GroupId {
  7. uint16_t deviceId;
  8. uint8_t groupId;
  9. MiLightRemoteType deviceType;
  10. GroupId();
  11. GroupId(const GroupId& other);
  12. GroupId(const uint16_t deviceId, const uint8_t groupId, const MiLightRemoteType deviceType);
  13. bool operator==(const GroupId& other);
  14. void operator=(const GroupId& other);
  15. };
  16. enum BulbMode {
  17. BULB_MODE_WHITE,
  18. BULB_MODE_COLOR,
  19. BULB_MODE_SCENE
  20. };
  21. class GroupState {
  22. public:
  23. GroupState();
  24. // 1 bit
  25. bool isOn();
  26. void setOn(bool on);
  27. // 7 bits
  28. uint8_t getBrightness() const;
  29. void setBrightness(uint8_t brightness);
  30. // 8 bits
  31. uint8_t getHue();
  32. void setHue(uint8_t hue);
  33. // 7 bits
  34. uint8_t getSaturation();
  35. void setSaturation(uint8_t saturation);
  36. // 5 bits
  37. uint8_t getMode();
  38. void setMode(uint8_t mode);
  39. // 7 bits
  40. uint8_t getKelvin();
  41. void setKelvin(uint8_t kelvin);
  42. // 3 bits
  43. BulbMode getBulbMode();
  44. void setBulbMode(BulbMode mode);
  45. private:
  46. uint32_t
  47. _on : 1,
  48. _brightness : 7,
  49. _hue : 8,
  50. _saturation : 7,
  51. _mode : 4,
  52. _bulbMode : 3,
  53. : 2;
  54. uint8_t
  55. _kelvin : 7,
  56. : 1;
  57. };
  58. struct GroupStateNode {
  59. GroupState state;
  60. GroupId nextNode;
  61. GroupId prevNode;
  62. };
  63. #endif