You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.9 KiB

5 years ago
  1. #ifndef ControlState_h
  2. #define ControlState_h
  3. #include <States.h>
  4. #include <AT24C32.h>
  5. #include <DS3231.h>
  6. /*
  7. abstract control state
  8. */
  9. class ControlState
  10. {
  11. public:
  12. virtual void leftPressed(ViewStates &viewState, ControlStates &controlState) = 0;
  13. virtual void rightPressed(ViewStates &viewState, ControlStates &controlState) = 0;
  14. virtual void enterPressed(ViewStates &viewState, ControlStates &controlState) = 0;
  15. virtual void decrementPressed(ViewStates &viewState, ControlStates &controlState) = 0;
  16. virtual void incrementPressed(ViewStates &viewState, ControlStates &controlState) = 0;
  17. };
  18. /*
  19. control view state
  20. */
  21. class ControlViewState : public ControlState
  22. {
  23. public:
  24. ControlViewState(AT24C32 &_at24c32);
  25. void leftPressed(ViewStates &viewState, ControlStates &controlState);
  26. void rightPressed(ViewStates &viewState, ControlStates &controlState);
  27. void enterPressed(ViewStates &viewState, ControlStates &controlState);
  28. void decrementPressed(ViewStates &viewState, ControlStates &controlState);
  29. void incrementPressed(ViewStates &viewState, ControlStates &controlState);
  30. protected:
  31. AT24C32 at24c32;
  32. };
  33. /*
  34. control time state
  35. */
  36. class ControlTimeState : public ControlState
  37. {
  38. public:
  39. ControlTimeState(DS3231 &_ds3231, AT24C32 &_at24c32);
  40. void leftPressed(ViewStates &viewState, ControlStates &controlState);
  41. void rightPressed(ViewStates &viewState, ControlStates &controlState);
  42. void enterPressed(ViewStates &viewState, ControlStates &controlState);
  43. void decrementPressed(ViewStates &viewState, ControlStates &controlState);
  44. void incrementPressed(ViewStates &viewState, ControlStates &controlState);
  45. protected:
  46. DS3231 ds3231;
  47. AT24C32 at24c32;
  48. };
  49. /*
  50. control seconds state
  51. */
  52. class ControlSecondsState : public ControlState
  53. {
  54. public:
  55. ControlSecondsState(DS3231 &_ds3231);
  56. void leftPressed(ViewStates &viewState, ControlStates &controlState);
  57. void rightPressed(ViewStates &viewState, ControlStates &controlState);
  58. void enterPressed(ViewStates &viewState, ControlStates &controlState);
  59. void decrementPressed(ViewStates &viewState, ControlStates &controlState);
  60. void incrementPressed(ViewStates &viewState, ControlStates &controlState);
  61. protected:
  62. DS3231 ds3231;
  63. };
  64. /*
  65. control date state
  66. */
  67. class ControlDateState : public ControlState
  68. {
  69. public:
  70. ControlDateState(DS3231 &_ds3231);
  71. void leftPressed(ViewStates &viewState, ControlStates &controlState);
  72. void rightPressed(ViewStates &viewState, ControlStates &controlState);
  73. void enterPressed(ViewStates &viewState, ControlStates &controlState);
  74. void decrementPressed(ViewStates &viewState, ControlStates &controlState);
  75. void incrementPressed(ViewStates &viewState, ControlStates &controlState);
  76. protected:
  77. DS3231 ds3231;
  78. };
  79. /*
  80. control color value state
  81. */
  82. class ControlColorState : public ControlState
  83. {
  84. public:
  85. ControlColorState(AT24C32 &_at24c32);
  86. void leftPressed(ViewStates &viewState, ControlStates &controlState);
  87. void rightPressed(ViewStates &viewState, ControlStates &controlState);
  88. void enterPressed(ViewStates &viewState, ControlStates &controlState);
  89. void decrementPressed(ViewStates &viewState, ControlStates &controlState);
  90. void incrementPressed(ViewStates &viewState, ControlStates &controlState);
  91. protected:
  92. AT24C32 at24c32;
  93. void decrementColorR();
  94. void incrementColorR();
  95. void decrementColorG();
  96. void incrementColorG();
  97. void decrementColorB();
  98. void incrementColorB();
  99. };
  100. /*
  101. control text state
  102. */
  103. class ControlTextState : public ControlState
  104. {
  105. public:
  106. ControlTextState(AT24C32 &_at24c32);
  107. void leftPressed(ViewStates &viewState, ControlStates &controlState);
  108. void rightPressed(ViewStates &viewState, ControlStates &controlState);
  109. void enterPressed(ViewStates &viewState, ControlStates &controlState);
  110. void decrementPressed(ViewStates &viewState, ControlStates &controlState);
  111. void incrementPressed(ViewStates &viewState, ControlStates &controlState);
  112. protected:
  113. AT24C32 at24c32;
  114. };
  115. #endif