HomeWaterLeaksDetection
LCDController.h
Go to the documentation of this file.
1 #ifndef LCD_CONTROLLER_H
2 #define LCD_CONTROLLER_H
3 
4 #include "Arduino.h"
5 #include "Wire.h"
6 #include "LiquidCrystal_I2C.h"
7 #include "vector"
8 #include "Setup.h"
9 #include "DateTime.h"
10 #include "TimePeriod.h"
11 #include "IControllable.h"
12 #include "IDisplayable.h"
13 
14 //====================debugging=========================
15 
16 // if debugging is enabled,
17 // include this file as well
18 #ifdef DEBUG
19 # include <ILoggable.h>
20 #endif
21 
22 #define LCD_ROWS 4
23 
24 //===============LCDController class====================
25 
33 #ifdef DEBUG
34  , public ILoggable
35 #endif
36 {
37 //====================private data======================
38 private:
40  LiquidCrystal_I2C lcd = {0x27, 20, 4};
41  std::vector<IDisplayable *> items;
43  int index;
44 
45 //==================private methods=====================
46 private:
48  LCDController();
49 
52 
54  LCDController& operator=(LCDController const&) { return *this; }
55 
56 //==================public methods======================
57 public:
64  static LCDController* getInstance();
65 
70  void update() override;
71 
74  void addItem(IDisplayable *item);
75 
76 //====================debugging=========================
77 #ifdef DEBUG
78 public:
81  const String getLogDescription() const;
82 
85  const String getLogID() const;
86 #endif
87 };
88 
89 #endif
TimePeriod.h
LCDController::lcd
LiquidCrystal_I2C lcd
0x27 - address of the [20x4] LCD on I2C
Definition: LCDController.h:40
IDisplayable.h
DateTime.h
ILoggable.h
LCDController
Definition: LCDController.h:36
Setup.h
SEC_TO_MILLIS
#define SEC_TO_MILLIS(s)
Converts seconds given as a parameter to milliseconds.
Definition: DateTime.h:61
LCDController::addItem
void addItem(IDisplayable *item)
Adds another source of data for the LCD display (another class)
Definition: LCDController.cpp:16
LCDController::LCDController
LCDController(LCDController const &)
Copy constructor of the class.
Definition: LCDController.h:51
LCDController::delay
TimePeriod delay
delay between displaying two pages
Definition: LCDController.h:42
LCDController::operator=
LCDController & operator=(LCDController const &)
Assignment operator of the class.
Definition: LCDController.h:54
TimePeriod
Definition: TimePeriod.h:14
LCDController::instance
static LCDController * instance
the instance of the class
Definition: LCDController.h:39
ILoggable
Definition: ILoggable.h:13
IDisplayable
Definition: IDisplayable.h:12
LCDController::update
void update() override
Updates the state of the class.
Definition: LCDController.cpp:20
LCDController::getInstance
static LCDController * getInstance()
Returns the instance of the class.
Definition: LCDController.cpp:10
IControllable.h
LCDController::LCDController
LCDController()
Constructor of the class.
Definition: LCDController.cpp:5
IControllable
Definition: IControllable.h:13
LCDController::index
int index
index of the current page
Definition: LCDController.h:43
LCDController::items
std::vector< IDisplayable * > items
collection of classes implementing the interface IDisplayable
Definition: LCDController.h:41