Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
Menu.h
Go to the documentation of this file.
1/******************************************************************************/
5
6#ifndef MENU_INCLUDED
7#define MENU_INCLUDED
8
9#include "Button.h"
10#include "TextBox.h"
11
12using sensorVal_t = uint16_t;
13using namespace std;
14
15/******************************************************************************/
16/*** ***/
17/*** Class Definition: SoloMenu ***/
18/*** ***/
19/******************************************************************************/
33{
34
35 const uint16_t _x0; // Upper left x-coordinate for the menu in the TFT display
36 const uint16_t _y0; // Upper left y-coordinate for the menu in the TFT display
37 const uint16_t _width; // Width of the menu
38 const uint16_t _height; // Height of the menu
39
40 // Tracks the ID of the button currently pressed
41 int8_t _buttonID = -1;
42
43 /* Pointers to various arrays managed by this class
44 */
45 uint8_t _numButtons = 0;
46 Button **_buttonArr;
47
48protected:
52
59 : _x0{0}, _y0{0}, _width{LCD_XSIZE_TFT}, _height{LCD_YSIZE_TFT} {};
60
69 SoloMenu(uint16_t x0, uint16_t y0, uint16_t width, uint16_t height)
70 : _x0{x0}, _y0{y0}, _width{width}, _height{height} {};
71
77 ~SoloMenu(void) = default;
78
80
81public:
83 SoloMenu(const SoloMenu &) = delete;
84
86 SoloMenu &operator=(const SoloMenu &) = delete;
87
91
97 virtual void begin(void);
98
104 virtual void update(void) {};
105
111 virtual void show(void) = 0;
112
118 void loadConfig(void)
119 {
120 Serial.println("SoloMenu->loadConfig() called");
121 }
122
128 virtual void checkButtons(void);
129
135 virtual void releaseButton(void);
136
143 static bool hasScreenBeenTouched(void);
144
146
150
157 inline uint16_t x(void) const
158 {
159 return _x0;
160 };
161
168 inline uint16_t y(void) const
169 {
170 return _y0;
171 };
172
179 inline uint16_t width(void) const
180 {
181 return _width;
182 };
183
190 inline uint16_t height(void) const
191 {
192 return _height;
193 };
194
196
197protected:
201
209 int8_t _pressButtonIfTouched(void);
210
218 void _register(Button **buttonPtrArray, uint8_t nButtons);
219
221};
222
223extern SoloMenu *menu;
224
225/******************************************************************************/
226/*** ***/
227/*** Class Definition: MainMenu ***/
228/*** ***/
229/******************************************************************************/
231#define NUM_MAINMENU_BUTTONS 14
242class MainMenu : public SoloMenu
243{
244 Canvas _PrimaryCanvas; // Primary Canvas is the one displayed in the TFT
245 ROM_Canvas _NormalMenuCanvas; // Canvas that holds an image of an unalarmed menu background image
246 ROM_Canvas _AlarmMenuCanvas; // Canvas that holds an image of an alarmed Main background image
247
248 // The various buttons used by the menu
249 ToggleButton _KettleTempAlarmButton;
250 ToggleButton _KettleVolAlarmButton;
251 ToggleButton _ChillerTempAlarmButton;
252 ToggleButton _ModeButton;
253 ToggleButton _PumpButton;
254 ToggleButton _AuxButton;
255 MomentaryButton _SetupButton;
256
257 TextBoxButton _KettleTemp;
258 TextBoxButton _SetTemp;
259 TextBoxButton _ElemOut;
260 TextBoxButton _Volume;
261 TextBoxButton _MinVolume;
262 TextBoxButton _ChillerTemp;
263 TextBoxButton _MinChillerTemp;
264
265 // Button array contains pointers to (above) buttons
266 Button *_buttonArr[NUM_MAINMENU_BUTTONS];
267
268 // Instance of the singleton
269 static MainMenu *_instance;
270
276 MainMenu(void);
277
283 ~MainMenu(void) = default;
284
285public:
291 static MainMenu &getInstance(void)
292 {
293 if (!_instance)
294 {
295 _instance = new MainMenu();
296 }
297 return *_instance;
298 };
299
301 MainMenu(const MainMenu &) = delete;
302
304 MainMenu &operator=(const MainMenu &) = delete;
305
311 void begin(void) override;
312
318 void update(void) override;
319
325 inline void show(void) override
326 {
327 menu = this;
328 _PrimaryCanvas.setMainWindow();
329 }
330};
331
332extern SoloMenu *setupMenu;
333
334/******************************************************************************/
335/*** ***/
336/*** Class Definition: SetupVolMenu ***/
337/*** ***/
338/******************************************************************************/
340#define NUM_SETUPVOLMENU_BUTTONS 0
348class SetupVolMenu : public SoloMenu
349{
350
351 ROM_Canvas _PrimaryCanvas; // Primary Canvas displayed on the TFT
352
353 // The various buttons used by the menu
354 /* ImmediateButton _TempSetup;
355 ImmediateButton _PID_Setup;
356 MomentaryButton _DoneButton;
357 ToggleButton _CalPoint1;
358 ToggleButton _CalPoint2; */
359
360 // Button array contains pointers to (above) buttons
361 Button *_buttonArr[NUM_SETUPVOLMENU_BUTTONS];
362
363 // Singleton instance of the SetupVolMenu menu
364 static SetupVolMenu *_instance;
365
371 SetupVolMenu(void);
372
378 ~SetupVolMenu(void) = default;
379
380public:
386 static SetupVolMenu &getInstance(void)
387 {
388 if (!_instance)
389 _instance = new SetupVolMenu();
390 return *_instance;
391 };
392
394 SetupVolMenu(const SetupVolMenu &) = delete;
395
397 SetupVolMenu &operator=(const SetupVolMenu &) = delete;
398
404 void begin(void) override;
405
411 void update(void) override;
412
418 inline void show(void) override
419 {
420 menu = this;
421 setupMenu = this;
422 _PrimaryCanvas.setMainWindow();
423 }
424};
425
426/******************************************************************************/
427/*** ***/
428/*** Class Definition: SetupTempMenu ***/
429/*** ***/
430/******************************************************************************/
432#define NUM_SETUPTEMPMENU_BUTTONS 0
438class SetupTempMenu : public SoloMenu
439{
440
441 ROM_Canvas _PrimaryCanvas; // Primary Canvas displayed on the TFT
442
443 // The various buttons used by the menu
444 /* ImmediateButton _VolSetup;
445 ImmediateButton _PID_Setup;
446 MomentaryButton _DoneButton;
447 ToggleButton _KettleProbe;
448 ToggleButton _ChillerProbe;
449
450 // Button array contains pointers to (above) buttons
451 Button *_buttonArr[NUM_SETUPTEMPMENU_BUTTONS]; */
452
453 // Singleton instance of SetupTempMenu
454 static SetupTempMenu *_instance;
455
461 SetupTempMenu(void);
462
468 ~SetupTempMenu(void) = default;
469
470public:
476 static SetupTempMenu &getInstance(void)
477 {
478 if (!_instance)
479 _instance = new SetupTempMenu();
480 return *_instance;
481 };
482
484 SetupTempMenu(const SetupTempMenu &) = delete;
485
487 SetupTempMenu &operator=(const SetupTempMenu &) = delete;
488
494 void begin(void) override;
495
501 void update(void) override;
502
508 inline void show(void) override
509 {
510 menu = this;
511 setupMenu = this;
512 _PrimaryCanvas.setMainWindow();
513 }
514};
515
516/******************************************************************************/
517/*** ***/
518/*** Class Definition: SetupPID_Menu ***/
519/*** ***/
520/******************************************************************************/
522#define NUM_SETUPPIDMENU_BUTTONS 0
528class SetupPID_Menu : public SoloMenu
529{
530
531 ROM_Canvas _PrimaryCanvas; // Primary Canvas displayed on the TFT
532
533 /* // The various buttons used by the menu
534 ImmediateButton _VolSetup;
535 ImmediateButton _TempSetup;
536 MomentaryButton _DoneButton;
537 ToggleButton _AutoTune; */
538
539 // Button array contains pointers to (above) buttons
540 Button *_buttonArr[NUM_SETUPPIDMENU_BUTTONS];
541
542 // Singleton instance of SetupPID_Menu
543 static SetupPID_Menu *_instance;
544
550 SetupPID_Menu(void);
551
557 ~SetupPID_Menu(void) = default;
558
559public:
565 static SetupPID_Menu &getInstance(void)
566 {
567 if (!_instance)
568 _instance = new SetupPID_Menu();
569 return *_instance;
570 };
571
573 SetupPID_Menu(const SetupPID_Menu &) = delete;
574
576 SetupPID_Menu &operator=(const SetupPID_Menu &) = delete;
577
583 void begin(void) override;
584
590 void update(void) override;
591
597 inline void show(void) override
598 {
599 menu = this;
600 setupMenu = this;
601 _PrimaryCanvas.setMainWindow();
602 }
603};
604
605/******************************************************************************/
606/*** ***/
607/*** Callback Functions ***/
608/*** ***/
609/******************************************************************************/
610
614namespace CB
615{
616
620 namespace MAIN
621 {
622
629 void kettleTempAlarmOn(void);
630 void kettleTempAlarmOff(void);
631 void kettleVolAlarmOn(void);
632 void kettleVolAlarmOff(void);
633 void chillerTempAlarmOn(void);
634 void chillerTempAlarmOff(void);
635 void elementOn(void);
636 void elementOff(void);
637 void boilModeOn(void);
638 void mashModeOn(void);
639 void pumpOn(void);
640 void pumpOff(void);
641 void auxOn(void);
642 void auxOff(void);
643 void setupButtonPressed(void);
644 void dataEntry(void);
645
651 void setBoilRate(sensorVal_t boilRate);
652 void setMashTemp(sensorVal_t mashTemp);
653 void setKettleTempSV(sensorVal_t kettleTempSV);
654 void setKettleVolSV(sensorVal_t kettleVolSV);
655 void setChillerTempSV(sensorVal_t chillerTempSV);
656
658 }
659
663 namespace SETUP
664 {
669 void volSetup(void);
670 void tempSetup(void);
671 void PID_Setup(void);
672 void returnToMainMenu(void);
673
677 namespace VOL
678 {
679 void calPoint1(void);
680 void calPoint2(void);
682 }
683
687 namespace TEMP
688 {
689 void kettleProbe(void);
690 void chillerProbe(void);
691 }
692
696 namespace PID
697 {
698 void autoTune(void);
699 }
700 }
701}
702
703#endif
Defines the Button classes used by the Menu system.
SoloMenu * menu
Pointer to the current, active menu used by the application.
Definition Menu.cpp:28
SoloMenu * setupMenu
Pointer to the current setup menu.
Definition Menu.cpp:36
#define NUM_SETUPVOLMENU_BUTTONS
Definition Menu.h:340
#define NUM_SETUPPIDMENU_BUTTONS
Definition Menu.h:522
SoloMenu * menu
Pointer to the current, active menu used by the application.
Definition Menu.cpp:28
uint16_t sensorVal_t
Definition Menu.h:12
SoloMenu * setupMenu
Pointer to the current setup menu.
Definition Menu.cpp:36
#define NUM_MAINMENU_BUTTONS
Number of buttons managed by the MainMenu.
Definition Menu.h:231
#define LCD_YSIZE_TFT
Definition TFTM070A1.h:25
#define LCD_XSIZE_TFT
Definition TFTM070A1.h:24
Defines TextBox and TextBox which are used to display dynamic text within a canvas.
Abstract class that provides basic button functionality.
Definition Button.h:55
Provides higher level TFT graphic functionality used by the menu system.
Definition Canvas.h:34
Main menu for the SoloController application.
Definition Menu.h:243
void begin(void) override
Initializes the MainMenu object. Should be called before first use.
Definition Menu.cpp:336
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:325
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:378
static MainMenu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:291
Defines a momentary buttons with 2 states. Upon release, the button automatically returns to state 0.
Definition Button.h:403
A variation of the Canvas class that can load imagery from Flash ROM.
Definition Canvas.h:405
Setup menu for the SoloController application. Note that the callback functions used by SetupTempMenu...
Definition Menu.h:529
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:760
void begin(void) override
Initializes the SetupMenu object. Should be called before first use.
Definition Menu.cpp:749
static SetupPID_Menu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:565
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:597
Setup menu for the SoloController application. Note that the callback functions used by SetupTempMenu...
Definition Menu.h:439
void begin(void) override
Initializes the SetupMenu object. Should be called before first use.
Definition Menu.cpp:672
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:683
static SetupTempMenu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:476
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:508
Setup menu for the SoloController application.
Definition Menu.h:349
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:418
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:570
void begin(void) override
Initializes the SetupMenu object. Should be called before first use.
Definition Menu.cpp:559
static SetupVolMenu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:386
Base class used by all menus.
Definition Menu.h:33
virtual void show(void)=0
Shows the menu in the TFT. Derived classes will provide specific functionality.
~SoloMenu(void)=default
Default Destructor.
SoloMenu(void)
Creates a full size menu.
Definition Menu.h:58
uint16_t width(void) const
Width of the menu.
Definition Menu.h:179
void loadConfig(void)
Loads configuration data from EEPROM, placing it into RAM.
Definition Menu.h:118
int8_t _pressButtonIfTouched(void)
Protected method checks to see if one of the buttons has been "touched." If so, this method "presses"...
Definition Menu.cpp:81
uint16_t height(void) const
Height of the menu.
Definition Menu.h:190
static bool hasScreenBeenTouched(void)
Determines if the TFT screen has been touched.
Definition Menu.cpp:121
virtual void releaseButton(void)
Releases the currently pressed button.
Definition Menu.cpp:111
void _register(Button **buttonPtrArray, uint8_t nButtons)
Registers an array of buttons with this class.
Definition Menu.cpp:147
uint16_t x(void) const
Upper-left x-coordinate for menu.
Definition Menu.h:157
virtual void begin(void)
Initializes the Menu object.
Definition Menu.cpp:48
virtual void update(void)
Updates the Button, Menu, and Label objects managed by this class.
Definition Menu.h:104
uint16_t y(void) const
Upper-left y-coordinate for menu.
Definition Menu.h:168
virtual void checkButtons(void)
Check to see if one of the menu's buttons has been pressed.
Definition Menu.cpp:61
SoloMenu(uint16_t x0, uint16_t y0, uint16_t width, uint16_t height)
Creates a menu of the specified size and location.
Definition Menu.h:69
Defines a single state button containing text with both a value and units component.
Definition Button.h:499
Defines a button that toggles between two states.
Definition Button.h:301
Callback functions used by the MainMenu class.
Definition Menu.h:621
void setMashTemp(sensorVal_t mashTemp)
Initiate Data Entry for Mash Temp.
Definition Menu.cpp:470
void kettleTempAlarmOn(void)
Definition Menu.cpp:388
void chillerTempAlarmOff(void)
Definition Menu.cpp:413
void mashModeOn(void)
Definition Menu.cpp:433
void boilModeOn(void)
Definition Menu.cpp:428
void pumpOn(void)
Definition Menu.cpp:438
void auxOn(void)
Definition Menu.cpp:448
void kettleVolAlarmOff(void)
Definition Menu.cpp:403
void kettleVolAlarmOn(void)
Definition Menu.cpp:398
void setKettleVolSV(sensorVal_t kettleVolSV)
Initiate Data Entry for Kettle Volume Set Value.
Definition Menu.cpp:482
void setKettleTempSV(sensorVal_t kettleTempSV)
Initiate Data Entry for Kettle Temp Set Value.
Definition Menu.cpp:476
void kettleTempAlarmOff(void)
Definition Menu.cpp:393
void elementOff(void)
Definition Menu.cpp:423
void pumpOff(void)
Definition Menu.cpp:443
void setChillerTempSV(sensorVal_t chillerTempSV)
Initiate Data Entry for Chiller Temp Set Value.
Definition Menu.cpp:488
void chillerTempAlarmOn(void)
Definition Menu.cpp:408
void setBoilRate(sensorVal_t boilRate)
Initiate Data Entry for Boil Rate.
Definition Menu.cpp:464
void elementOn(void)
Definition Menu.cpp:418
void auxOff(void)
Definition Menu.cpp:453
void setupButtonPressed(void)
Definition Menu.cpp:458
void dataEntry(void)
Definition Menu.cpp:494
Callback functions that are specific to the SetupPID_Menu class.
Definition Menu.h:697
void autoTune(void)
Definition Menu.cpp:766
Callback functions that are specific to the SetupTempMenu class.
Definition Menu.h:688
void kettleProbe(void)
Calibrate Kettle Probe.
Definition Menu.cpp:689
void chillerProbe(void)
Calibrate Chiller Probe.
Definition Menu.cpp:694
Callback functions that are specific to the SetupVolMenu class.
Definition Menu.h:678
void calPoint1(void)
Set Calibration Point 1.
Definition Menu.cpp:602
void calPoint2(void)
Set Calibration Point 2.
Definition Menu.cpp:607
Callback functions used by the Setup Menus.
Definition Menu.h:664
void PID_Setup(void)
Switch to PID Setup Menu.
Definition Menu.cpp:590
void tempSetup(void)
Switch to Temperature Setup Menu.
Definition Menu.cpp:583
void volSetup(void)
Switch to Volume Setup Menu.
Definition Menu.cpp:576
void returnToMainMenu(void)
Return to the Main Menu.
Definition Menu.cpp:597
Primary namespace for SoloMenu callback functions.
Definition Menu.h:615