Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
Menu.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file Menu.h
3 * @brief Defines the menu classes used by the SoloController app
4 ******************************************************************************/
5
6#ifndef MENU_INCLUDED
7#define MENU_INCLUDED
8
9#include "Canvas.h"
10#include "Button.h"
11#include "Sensor.h"
12#include "TextBox.h"
13
15using namespace std;
16
17/******************************************************************************/
18/*** ***/
19/*** Class Definition: SoloMenu ***/
20/*** ***/
21/******************************************************************************
22 * @brief Base class used by all menus.
23 *
24 * @details
25 * This menu provides the core functionality for the menu system. Each menu
26 * displayed on the TFT will derive from this class. The primary responsibility
27 * for this class is to manage all Button, Labels, and Submenus, ensuring
28 * that requests to update graphics or handle presses to the TFT touch screen
29 * are handled properly. All menus are intended to be Singleton objects.
30 * Each object uses significant DRAM resources.
31 ******************************************************************************/
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 0
242class MainMenu : public SoloMenu
243{
244
245 Canvas _PrimaryCanvas; // Primary Canvas is the one displayed in the TFT
246/* ROM_Canvas _SecondaryNormalCvs; // Canvas that holds a 2nd image of the Main Menu
247 ROM_Canvas _SecondaryAlarmCvs; // Canvas that holds an image of an alarmed Main Menu
248 ROM_Canvas _ButtonCanvas; // Canvas containing button images used by the menu
249
250 // The various buttons used by the menu
251 ToggleButton _KettleTempAlarmButton;
252 ToggleButton _KettleVolAlamButton;
253 ToggleButton _ChillerTempAlarmButton;
254 ToggleButton _ModeButton;
255 ToggleButton _PumpButton;
256 ToggleButton _AuxButton;
257 MomentaryButton _SetupButton; */
258
259 // Button array contains pointers to (above) buttons
260 Button *_buttonArr[NUM_MAINMENU_BUTTONS];
261
262 // Instance of the singleton
263 static MainMenu *_instance;
264
270 MainMenu(void);
271
277 ~MainMenu(void) = default;
278
279public:
285 static MainMenu &getInstance(void)
286 {
287 if (!_instance)
288 _instance = new MainMenu();
289 return *_instance;
290 };
291
293 MainMenu(const MainMenu &) = delete;
294
296 MainMenu &operator=(const MainMenu &) = delete;
297
303 void begin(void) override;
304
310 void update(void) override;
311
317 inline void show(void) override
318 {
319 menu = this;
320 _PrimaryCanvas.setMainWindow();
321 }
322};
323
324extern SoloMenu *setupMenu;
325
326/******************************************************************************/
327/*** ***/
328/*** Class Definition: SetupVolMenu ***/
329/*** ***/
330/******************************************************************************/
332#define NUM_SETUPVOLMENU_BUTTONS 0
340class SetupVolMenu : public SoloMenu
341{
342
343 ROM_Canvas _PrimaryCanvas; // Primary Canvas displayed on the TFT
344
345 // The various buttons used by the menu
346/* ImmediateButton _TempSetup;
347 ImmediateButton _PID_Setup;
348 MomentaryButton _DoneButton;
349 ToggleButton _CalPoint1;
350 ToggleButton _CalPoint2; */
351
352 // Button array contains pointers to (above) buttons
353 Button *_buttonArr[NUM_SETUPVOLMENU_BUTTONS];
354
355 // Singleton instance of the SetupVolMenu menu
356 static SetupVolMenu *_instance;
357
363 SetupVolMenu(void);
364
370 ~SetupVolMenu(void) = default;
371
372public:
378 static SetupVolMenu &getInstance(void)
379 {
380 if (!_instance)
381 _instance = new SetupVolMenu();
382 return *_instance;
383 };
384
386 SetupVolMenu(const SetupVolMenu &) = delete;
387
389 SetupVolMenu &operator=(const SetupVolMenu &) = delete;
390
396 void begin(void) override;
397
403 void update(void) override;
404
410 inline void show(void) override
411 {
412 menu = this;
413 setupMenu = this;
414 _PrimaryCanvas.setMainWindow();
415 }
416};
417
418/******************************************************************************/
419/*** ***/
420/*** Class Definition: SetupTempMenu ***/
421/*** ***/
422/******************************************************************************/
424#define NUM_SETUPTEMPMENU_BUTTONS 0
430class SetupTempMenu : public SoloMenu
431{
432
433 ROM_Canvas _PrimaryCanvas; // Primary Canvas displayed on the TFT
434
435 // The various buttons used by the menu
436/* ImmediateButton _VolSetup;
437 ImmediateButton _PID_Setup;
438 MomentaryButton _DoneButton;
439 ToggleButton _KettleProbe;
440 ToggleButton _ChillerProbe;
441
442 // Button array contains pointers to (above) buttons
443 Button *_buttonArr[NUM_SETUPTEMPMENU_BUTTONS]; */
444
445 // Singleton instance of SetupTempMenu
446 static SetupTempMenu *_instance;
447
453 SetupTempMenu(void);
454
460 ~SetupTempMenu(void) = default;
461
462public:
468 static SetupTempMenu &getInstance(void)
469 {
470 if (!_instance)
471 _instance = new SetupTempMenu();
472 return *_instance;
473 };
474
476 SetupTempMenu(const SetupTempMenu &) = delete;
477
479 SetupTempMenu &operator=(const SetupTempMenu &) = delete;
480
486 void begin(void) override;
487
493 void update(void) override;
494
500 inline void show(void) override
501 {
502 menu = this;
503 setupMenu = this;
504 _PrimaryCanvas.setMainWindow();
505 }
506};
507
508/******************************************************************************/
509/*** ***/
510/*** Class Definition: SetupPID_Menu ***/
511/*** ***/
512/******************************************************************************/
514#define NUM_SETUPPIDMENU_BUTTONS 0
520class SetupPID_Menu : public SoloMenu
521{
522
523 ROM_Canvas _PrimaryCanvas; // Primary Canvas displayed on the TFT
524
525/* // The various buttons used by the menu
526 ImmediateButton _VolSetup;
527 ImmediateButton _TempSetup;
528 MomentaryButton _DoneButton;
529 ToggleButton _AutoTune; */
530
531 // Button array contains pointers to (above) buttons
532 Button *_buttonArr[NUM_SETUPPIDMENU_BUTTONS];
533
534 // Singleton instance of SetupPID_Menu
535 static SetupPID_Menu *_instance;
536
542 SetupPID_Menu(void);
543
549 ~SetupPID_Menu(void) = default;
550
551public:
557 static SetupPID_Menu &getInstance(void)
558 {
559 if (!_instance)
560 _instance = new SetupPID_Menu();
561 return *_instance;
562 };
563
565 SetupPID_Menu(const SetupPID_Menu &) = delete;
566
568 SetupPID_Menu &operator=(const SetupPID_Menu &) = delete;
569
575 void begin(void) override;
576
582 void update(void) override;
583
589 inline void show(void) override
590 {
591 menu = this;
592 setupMenu = this;
593 _PrimaryCanvas.setMainWindow();
594 }
595};
596
597/******************************************************************************/
598/*** ***/
599/*** Callback Functions ***/
600/*** ***/
601/******************************************************************************/
602
606namespace CB
607{
608
612 namespace MAIN
613 {
614
621 void kettleTempAlarmOn(void);
622 void kettleTempAlarmOff(void);
623 void kettleVolAlarmOn(void);
624 void kettleVolAlarmOff(void);
625 void chillerTempAlarmOn(void);
626 void chillerTempAlarmOff(void);
627 void elementOn(void);
628 void elementOff(void);
629 void boilModeOn(void);
630 void mashModeOn(void);
631 void pumpOn(void);
632 void pumpOff(void);
633 void auxOn(void);
634 void auxOff(void);
635 void setupButtonPressed(void);
636
642 void setBoilRate(sensorVal_t boilRate);
643 void setMashTemp(sensorVal_t mashTemp);
644 void setKettleTempSV(sensorVal_t kettleTempSV);
645 void setKettleVolSV(sensorVal_t kettleVolSV);
646 void setChillerTempSV(sensorVal_t chillerTempSV);
647
649 }
650
654 namespace SETUP
655 {
660 void volSetup(void);
661 void tempSetup(void);
662 void PID_Setup(void);
663 void returnToMainMenu(void);
664
668 namespace VOL
669 {
670 void calPoint1(void);
671 void calPoint2(void);
673 }
674
678 namespace TEMP
679 {
680 void kettleProbe(void);
681 void chillerProbe(void);
682 }
683
687 namespace PID
688 {
689 void autoTune(void);
690 }
691 }
692}
693
694#endif
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:332
Sensor::sensorVal_t sensorVal_t
Definition Menu.h:14
#define NUM_SETUPPIDMENU_BUTTONS
Definition Menu.h:514
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_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
Definition Button.h:24
Definition Canvas.h:33
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:246
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:317
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:265
static MainMenu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:285
Definition Canvas.h:373
float sensorVal_t
Type definition used by Sensor class.
Definition Sensor.h:25
Setup menu for the SoloController application. Note that the callback functions used by SetupTempMenu...
Definition Menu.h:521
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:642
void begin(void) override
Initializes the SetupMenu object. Should be called before first use.
Definition Menu.cpp:631
static SetupPID_Menu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:557
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:589
Setup menu for the SoloController application. Note that the callback functions used by SetupTempMenu...
Definition Menu.h:431
void begin(void) override
Initializes the SetupMenu object. Should be called before first use.
Definition Menu.cpp:554
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:565
static SetupTempMenu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:468
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:500
Setup menu for the SoloController application.
Definition Menu.h:341
void show(void) override
Shows the menu in the TFT.
Definition Menu.h:410
void update(void) override
Updates the values and graphics displayed in the menu.
Definition Menu.cpp:452
void begin(void) override
Initializes the SetupMenu object. Should be called before first use.
Definition Menu.cpp:441
static SetupVolMenu & getInstance(void)
Returns reference to the ErrMsg object.
Definition Menu.h:378
Definition Menu.h:33
virtual void update(void)
Updates the Button, Menu, and Label objects managed by this class.
Definition Menu.cpp:61
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:85
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:132
virtual void releaseButton(void)
Releases the currently pressed button.
Definition Menu.cpp:122
void _register(Button **buttonPtrArray, uint8_t nButtons)
Registers an array of buttons with this class.
Definition Menu.cpp:158
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
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:65
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
Callback functions used by the MainMenu class.
Definition Menu.h:613
void setMashTemp(sensorVal_t mashTemp)
Initiate Data Entry for Mash Temp.
Definition Menu.cpp:357
void kettleTempAlarmOn(void)
Definition Menu.cpp:275
void chillerTempAlarmOff(void)
Definition Menu.cpp:300
void mashModeOn(void)
Definition Menu.cpp:320
void boilModeOn(void)
Definition Menu.cpp:315
void pumpOn(void)
Definition Menu.cpp:325
void auxOn(void)
Definition Menu.cpp:335
void kettleVolAlarmOff(void)
Definition Menu.cpp:290
void kettleVolAlarmOn(void)
Definition Menu.cpp:285
void setKettleVolSV(sensorVal_t kettleVolSV)
Initiate Data Entry for Kettle Volume Set Value.
Definition Menu.cpp:369
void setKettleTempSV(sensorVal_t kettleTempSV)
Initiate Data Entry for Kettle Temp Set Value.
Definition Menu.cpp:363
void kettleTempAlarmOff(void)
Definition Menu.cpp:280
void elementOff(void)
Definition Menu.cpp:310
void pumpOff(void)
Definition Menu.cpp:330
void setChillerTempSV(sensorVal_t chillerTempSV)
Initiate Data Entry for Chiller Temp Set Value.
Definition Menu.cpp:375
void chillerTempAlarmOn(void)
Definition Menu.cpp:295
void setBoilRate(sensorVal_t boilRate)
Initiate Data Entry for Boil Rate.
Definition Menu.cpp:351
void elementOn(void)
Definition Menu.cpp:305
void auxOff(void)
Definition Menu.cpp:340
void setupButtonPressed(void)
Definition Menu.cpp:345
Callback functions that are specific to the SetupPID_Menu class.
Definition Menu.h:688
void autoTune(void)
Definition Menu.cpp:648
Callback functions that are specific to the SetupTempMenu class.
Definition Menu.h:679
void kettleProbe(void)
Calibrate Kettle Probe.
Definition Menu.cpp:571
void chillerProbe(void)
Calibrate Chiller Probe.
Definition Menu.cpp:576
Callback functions that are specific to the SetupVolMenu class.
Definition Menu.h:669
void calPoint1(void)
Set Calibration Point 1.
Definition Menu.cpp:484
void calPoint2(void)
Set Calibration Point 2.
Definition Menu.cpp:489
Callback functions used by the Setup Menus.
Definition Menu.h:655
void PID_Setup(void)
Switch to PID Setup Menu.
Definition Menu.cpp:472
void tempSetup(void)
Switch to Temperature Setup Menu.
Definition Menu.cpp:465
void volSetup(void)
Switch to Volume Setup Menu.
Definition Menu.cpp:458
void returnToMainMenu(void)
Return to the Main Menu.
Definition Menu.cpp:479
Primary namespace for SoloMenu callback functions.
Definition Menu.h:607