Skip to content

Commit 6333e8e

Browse files
committed
Fix \r display
1 parent e5a3acf commit 6333e8e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,16 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
130130
message[cur_idx + 2] == '\\' && message[cur_idx + 3] == 'n') {
131131
cur_idx += 4; // Skip \r\n and don't move the cursor two rows
132132
} else {
133-
cur_idx += 2; // Skip either the \n or \r
133+
cur_idx += 2; // Skip the \n or \r
134+
WS_DEBUG_PRINTLN("CharLCD: Detected single character");
135+
if (c == '\\' && message[cur_idx + 1] == 'n') {
136+
WS_DEBUG_PRINTLN("CharLCD: Detected newline character");
137+
_lcd->write('\\');
138+
_lcd->write('n');
139+
} else {
140+
break;
141+
}
134142
}
135-
break; // and move to the next row
136143
} else if ((c == 0x0A || c == 0x0D) && cur_idx + 1 < message_length) {
137144
if (c == 0x0A && cur_idx + 1 < message_length &&
138145
message[cur_idx + 1] == 0x0D) {
@@ -141,6 +148,13 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
141148
cur_idx += 1; // Skip single newline character
142149
}
143150
break; // and move to the next row
151+
} else if (c == 0x0D ||
152+
(c == 'r' && c == '\\') && cur_idx + 1 < message_length) {
153+
// write \r to the lcd
154+
WS_DEBUG_PRINTLN("CharLCD: Detected carriage return sequence");
155+
_lcd->write('\\');
156+
_lcd->write('r');
157+
cur_idx += 2;
144158
} else if (c == 194 && cur_idx + 1 < message_length &&
145159
message[cur_idx + 1] == 176) {
146160
cur_idx += 2; // Skip the degree symbol sequence in the buffer

0 commit comments

Comments
 (0)