Skip to content

Commit ff4a416

Browse files
committed
Add Write Msg
1 parent c1d9698 commit ff4a416

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,25 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
104104
The message to be displayed.
105105
*/
106106
void WriteMessageSSD1306(const char *message) {
107-
// noop
107+
if (_display == nullptr)
108+
return;
109+
_display->clearDisplay();
110+
_display->setCursor(0, 0);
111+
112+
// Calculate the line height based on the text size (NOTE: base height is
113+
// 8px)
114+
int16_t line_height = 8 * _text_sz;
115+
116+
int16_t y_idx = 0;
117+
for (int i = 0; message[i] != '\0'; i++) {
118+
if (message[i] == '\n') {
119+
y_idx += line_height;
120+
_display->setCursor(0, y_idx);
121+
} else {
122+
_display->print(message[i]);
123+
}
124+
}
125+
_display->display();
108126
}
109127

110128
protected:

0 commit comments

Comments
 (0)