@@ -116,28 +116,20 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
116
116
for (int cur_col = 0 ; cur_col < _cols && cur_idx < message_length;
117
117
cur_col++) {
118
118
char c = message[cur_idx];
119
- WS_DEBUG_PRINTLN (" CharLCD: Writing char: " );
120
- WS_DEBUG_PRINT (c);
121
- WS_DEBUG_PRINT (" | hex:0x" );
122
- // print hex
123
- WS_DEBUG_PRINTHEX (c);
124
- WS_DEBUG_PRINTLN (" " );
125
119
if (c == ' \\ ' && cur_idx + 1 < message_length &&
126
120
(message[cur_idx + 1 ] == ' n' || message[cur_idx + 1 ] == ' r' )) {
127
- WS_DEBUG_PRINTLN (" CharLCD: Detected newline sequence" );
128
121
// Handle \r\n sequence as a single newline
129
122
if (message[cur_idx + 1 ] == ' r' && cur_idx + 3 < message_length &&
130
123
message[cur_idx + 2 ] == ' \\ ' && message[cur_idx + 3 ] == ' n' ) {
131
124
cur_idx += 4 ; // Skip \r\n and don't move the cursor two rows
125
+ break ; // Move to the next row
132
126
} else {
133
127
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' );
128
+ if (c == ' \\ ' && message[cur_idx + 1 ] == ' r' ) {
129
+ _lcd->write (0x2F );
130
+ _lcd->write (' r' );
139
131
} else {
140
- break ;
132
+ break ; // Move to the next row
141
133
}
142
134
}
143
135
} else if ((c == 0x0A || c == 0x0D ) && cur_idx + 1 < message_length) {
@@ -151,7 +143,6 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
151
143
} else if (c == 0x0D ||
152
144
(c == ' r' && c == ' \\ ' ) && cur_idx + 1 < message_length) {
153
145
// write \r to the lcd
154
- WS_DEBUG_PRINTLN (" CharLCD: Detected carriage return sequence" );
155
146
_lcd->write (' \\ ' );
156
147
_lcd->write (' r' );
157
148
cur_idx += 2 ;
0 commit comments