File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
src/components/i2c/drivers Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff 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
110128protected:
You can’t perform that action at this time.
0 commit comments