File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed
src/components/i2c/drivers Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,43 @@ class drvOutCharLcd : public drvOutputBase {
78
78
_enable_backlight = enable_backlight;
79
79
}
80
80
81
+ /* !
82
+ @brief Writes a message to the LCD.
83
+ @param message
84
+ The message to be displayed.
85
+ */
86
+ void WriteMessageCharLCD (const char *message) override {
87
+ if (_lcd == nullptr )
88
+ return ;
89
+
90
+ // Before writing, let's clear the display
91
+ _lcd->clear ();
92
+
93
+ size_t message_length = strlen (message);
94
+ size_t cur_idx = 0 ; // Current index in the message
95
+
96
+ // Write each row until it hits: \n, or the end of the message, or the last
97
+ // column/row position
98
+ for (int cur_row = 0 ; cur_row < _rows && cur_idx < message_length;
99
+ cur_row++) {
100
+ // Write each row out at the beginning of the row
101
+ _lcd->setCursor (0 , cur_row);
102
+ for (int cur_col = 0 ; cur_col < _cols && cur_idx < message_length;
103
+ cur_col++) {
104
+ char c = message[cur_idx];
105
+ if (c == ' \n ' ) {
106
+ cur_idx++;
107
+ break ;
108
+ }
109
+ _lcd->write (c);
110
+ cur_idx++;
111
+ }
112
+ }
113
+ }
114
+
81
115
protected:
82
- Adafruit_LiquidCrystal
83
- *_lcd; // /< Pointer to the Adafruit_LiquidCrystal object
116
+ Adafruit_LiquidCrystal *_lcd =
117
+ nullptr ; // /< Pointer to the Adafruit_LiquidCrystal object
84
118
uint8_t _rows = 2 ; // /< Number of rows in the display
85
119
uint8_t _cols = 16 ; // /< Number of columns in the display
86
120
bool _enable_backlight; // /< Flag to enable/disable backlight
Original file line number Diff line number Diff line change @@ -101,6 +101,15 @@ class drvOutputBase : public drvBase {
101
101
// noop
102
102
}
103
103
104
+ /* !
105
+ @brief Writes a message to the LCD.
106
+ @param message
107
+ The message to be displayed.
108
+ */
109
+ virtual void WriteMessageCharLCD (const char *message) override {
110
+ // noop
111
+ }
112
+
104
113
/* !
105
114
@brief Sets the brightness of the LED backpack.
106
115
@param b
You can’t perform that action at this time.
0 commit comments