Skip to content

Commit e2225f5

Browse files
committed
Patch - \r handling
1 parent 4494e3e commit e2225f5

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
120120
message[cur_idx + 1] == 'n') {
121121
cur_idx += 2; // Skip the '\n' character in the buffer
122122
break; // and move to the next row
123+
} else if (c == '\\' && cur_idx + 1 < message_length &&
124+
message[cur_idx + 1] == 'r') {
125+
cur_idx += 2; // Skip the '\r' character in the buffer
126+
continue; // and continue writing on the same row
123127
} else if (c == 194 && cur_idx + 1 < message_length &&
124128
message[cur_idx + 1] == 176) {
125129
cur_idx += 2; // Skip the degree symbol sequence in the buffer

src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306
127127
// Skip to the next possible line
128128
y_idx += line_height;
129129
_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;
130135
} else if (message[i] == 0xC2 && message[i + 1] == 0xB0) {
131136
_display->write(char(248));
132137
_display->display();

0 commit comments

Comments
 (0)