File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
src/components/i2c/drivers Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -124,11 +124,23 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
124
124
WS_DEBUG_PRINTLN (" " );
125
125
if (c == ' \\ ' && cur_idx + 1 < message_length &&
126
126
(message[cur_idx + 1 ] == ' n' || message[cur_idx + 1 ] == ' r' )) {
127
- cur_idx += 2 ; // Skip the '\n' or '\r' character in the buffer
128
- break ; // and move to the next row
127
+ WS_DEBUG_PRINTLN (" CharLCD: Detected newline sequence" );
128
+ // Handle \r\n sequence as a single newline
129
+ if (message[cur_idx + 1 ] == ' r' && cur_idx + 3 < message_length &&
130
+ message[cur_idx + 2 ] == ' \\ ' && message[cur_idx + 3 ] == ' n' ) {
131
+ cur_idx += 4 ; // Skip \r\n and don't move the cursor two rows
132
+ } else {
133
+ cur_idx += 2 ; // Skip either the \n or \r
134
+ }
135
+ break ; // and move to the next row
129
136
} else if ((c == 0x0A || c == 0x0D ) && cur_idx + 1 < message_length) {
130
- cur_idx += 1 ; // Skip the UTF-8 sequence for \n or \r
131
- break ; // and move to the next row
137
+ if (c == 0x0A && cur_idx + 1 < message_length &&
138
+ message[cur_idx + 1 ] == 0x0D ) {
139
+ cur_idx += 2 ; // Skip both LF and CR characters
140
+ } else {
141
+ cur_idx += 1 ; // Skip single newline character
142
+ }
143
+ break ; // and move to the next row
132
144
} else if (c == 194 && cur_idx + 1 < message_length &&
133
145
message[cur_idx + 1 ] == 176 ) {
134
146
cur_idx += 2 ; // Skip the degree symbol sequence in the buffer
You can’t perform that action at this time.
0 commit comments