diff --git a/platformio.ini b/platformio.ini index e1262d953..bddb00c06 100644 --- a/platformio.ini +++ b/platformio.ini @@ -374,6 +374,7 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_qtpy_esp32s3_n4r2 build_flags = -DARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2 -DBOARD_HAS_PSRAM +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py [env:adafruit_qtpy_esp32s3_with_psram_debug] diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h index 8e3ce8265..e00572c81 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_CharLcd.h @@ -117,9 +117,30 @@ class WipperSnapper_I2C_Driver_Out_CharLcd cur_col++) { char c = message[cur_idx]; if (c == '\\' && cur_idx + 1 < message_length && - message[cur_idx + 1] == 'n') { - cur_idx += 2; // Skip the '\n' character in the buffer - break; // and move to the next row + (message[cur_idx + 1] == 'n' || message[cur_idx + 1] == 'r')) { + // Handle \r\n sequence as a single newline + if (message[cur_idx + 1] == 'r' && cur_idx + 3 < message_length && + message[cur_idx + 2] == '\\' && message[cur_idx + 3] == 'n') { + cur_idx += 4; // Skip \r\n and don't move the cursor two rows + break; // Move to the next row + } else { + if (message[cur_idx + 1] == 'r') { + _lcd->write('\\'); + _lcd->write('r'); + cur_idx += 2; // Skip the \r + } else { + cur_idx += 2; // Skip the \n + break; // Move to the next row + } + } + } else if ((c == 0x0A || c == 0x0D) && cur_idx + 1 < message_length) { + if (c == 0x0A && cur_idx + 1 < message_length && + message[cur_idx + 1] == 0x0D) { + cur_idx += 2; // Skip both LF and CR characters + } else { + cur_idx += 1; // Skip single newline character + } + break; // and move to the next row } else if (c == 194 && cur_idx + 1 < message_length && message[cur_idx + 1] == 176) { cur_idx += 2; // Skip the degree symbol sequence in the buffer diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h index c3bd93870..40bfd95bb 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h @@ -121,12 +121,21 @@ class WipperSnapper_I2C_Driver_Out_Ssd1306 uint16_t c_idx = 0; size_t msg_size = strlen(message); for (size_t i = 0; i < msg_size && c_idx < msg_size; i++) { - if (message[i] == '\\' && i + 1 < msg_size && message[i + 1] == 'n') { - // detected a newline char sequence (\n) - i++; - // Skip to the next possible line - y_idx += line_height; - _display->setCursor(0, y_idx); + if (message[i] == '\\' && i + 1 < msg_size && + (message[i + 1] == 'n' || message[i + 1] == 'r')) { + // Handle \r\n sequence as a single newline + if (message[i + 1] == 'r' && i + 3 < msg_size && + message[i + 2] == '\\' && message[i + 3] == 'n') { + // Skip to the next line + y_idx += line_height; + _display->setCursor(0, y_idx); + i += 3; + } else if (message[i + 1] == 'n') { + // Skip to the next line + y_idx += line_height; + _display->setCursor(0, y_idx); + i++; + } } else if (message[i] == 0xC2 && message[i + 1] == 0xB0) { _display->write(char(248)); _display->display();