File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
src/components/i2c/drivers Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -121,17 +121,21 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
121121 uint16_t c_idx = 0 ;
122122 size_t msg_size = strlen (message);
123123 for (size_t i = 0 ; i < msg_size && c_idx < msg_size; i++) {
124- if (message[i] == ' \\ ' && i + 1 < msg_size && message[i + 1 ] == ' n' ) {
125- // detected a newline char sequence (\n)
126- i++;
127- // Skip to the next possible line
128- y_idx += line_height;
129- _display->setCursor (0 , y_idx);
130- } else if (message[i] == ' \\ ' && i + 1 < msg_size &&
131- message[i + 1 ] == ' r' ) {
132- // skip the \r character, continue to the next character
133- i++;
134- continue ;
124+ if (message[i] == ' \\ ' && i + 1 < msg_size &&
125+ (message[i + 1 ] == ' n' || message[i + 1 ] == ' r' )) {
126+ // Handle \r\n sequence as a single newline
127+ if (message[i + 1 ] == ' r' && i + 3 < msg_size &&
128+ message[i + 2 ] == ' \\ ' && message[i + 3 ] == ' n' ) {
129+ // Skip to the next line
130+ y_idx += line_height;
131+ _display->setCursor (0 , y_idx);
132+ i += 3 ;
133+ } else if (message[i + 1 ] == ' n' ) {
134+ // Skip to the next line
135+ y_idx += line_height;
136+ _display->setCursor (0 , y_idx);
137+ i++;
138+ }
135139 } else if (message[i] == 0xC2 && message[i + 1 ] == 0xB0 ) {
136140 _display->write (char (248 ));
137141 _display->display ();
You can’t perform that action at this time.
0 commit comments