We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c1d9698 commit ff4a416Copy full SHA for ff4a416
1 file changed
src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h
@@ -104,7 +104,25 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
104
The message to be displayed.
105
*/
106
void WriteMessageSSD1306(const char *message) {
107
- // noop
+ 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();
126
}
127
128
protected:
0 commit comments