@@ -117,9 +117,30 @@ class WipperSnapper_I2C_Driver_Out_CharLcd
117117 cur_col++) {
118118 char c = message[cur_idx];
119119 if (c == ' \\ ' && cur_idx + 1 < message_length &&
120- message[cur_idx + 1 ] == ' n' ) {
121- cur_idx += 2 ; // Skip the '\n' character in the buffer
122- break ; // and move to the next row
120+ (message[cur_idx + 1 ] == ' n' || message[cur_idx + 1 ] == ' r' )) {
121+ // Handle \r\n sequence as a single newline
122+ if (message[cur_idx + 1 ] == ' r' && cur_idx + 3 < message_length &&
123+ message[cur_idx + 2 ] == ' \\ ' && message[cur_idx + 3 ] == ' n' ) {
124+ cur_idx += 4 ; // Skip \r\n and don't move the cursor two rows
125+ break ; // Move to the next row
126+ } else {
127+ if (message[cur_idx + 1 ] == ' r' ) {
128+ _lcd->write (' \\ ' );
129+ _lcd->write (' r' );
130+ cur_idx += 2 ; // Skip the \r
131+ } else {
132+ cur_idx += 2 ; // Skip the \n
133+ break ; // Move to the next row
134+ }
135+ }
136+ } else if ((c == 0x0A || c == 0x0D ) && cur_idx + 1 < message_length) {
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
123144 } else if (c == 194 && cur_idx + 1 < message_length &&
124145 message[cur_idx + 1 ] == 176 ) {
125146 cur_idx += 2 ; // Skip the degree symbol sequence in the buffer
0 commit comments