From dd5ae797725a439a87cc7f717e9ab1e3b2f6e929 Mon Sep 17 00:00:00 2001 From: moononournation Date: Sun, 4 Feb 2024 23:03:46 +0800 Subject: [PATCH] #428 --- src/databus/Arduino_ESP32LCD16.cpp | 9 ++++++--- src/databus/Arduino_ESP32LCD8.cpp | 5 +---- src/databus/Arduino_ESP32QSPI.cpp | 22 ++++++++++++++++------ src/databus/Arduino_ESP32SPI.cpp | 2 +- src/databus/Arduino_ESP32SPIDMA.cpp | 2 +- src/display/Arduino_SH1106.cpp | 2 +- src/display/Arduino_SSD1306.cpp | 2 +- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/databus/Arduino_ESP32LCD16.cpp b/src/databus/Arduino_ESP32LCD16.cpp index 928b7ed0..0964fc28 100644 --- a/src/databus/Arduino_ESP32LCD16.cpp +++ b/src/databus/Arduino_ESP32LCD16.cpp @@ -176,12 +176,15 @@ void Arduino_ESP32LCD16::writeCommand16(uint16_t c) void Arduino_ESP32LCD16::writeCommandBytes(uint8_t *data, uint32_t len) { - DC_LOW(); + LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE | LCD_CAM_LCD_CD_CMD_SET; + while (len--) { - WRITECOMMAND16(*data++); + LCD_CAM.lcd_cmd_val.val = *data++; + WAIT_LCD_NOT_BUSY; + LCD_CAM.lcd_user.val = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; } - DC_HIGH(); + LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE; } void Arduino_ESP32LCD16::write(uint8_t d) diff --git a/src/databus/Arduino_ESP32LCD8.cpp b/src/databus/Arduino_ESP32LCD8.cpp index 77852899..7f9c5d7c 100644 --- a/src/databus/Arduino_ESP32LCD8.cpp +++ b/src/databus/Arduino_ESP32LCD8.cpp @@ -233,13 +233,10 @@ void Arduino_ESP32LCD8::writeCommandBytes(uint8_t *data, uint32_t len) while (len--) { - _data16.value = p; + _data16.value = *data++; LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.msb; WAIT_LCD_NOT_BUSY; LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; - LCD_CAM.lcd_cmd_val.lcd_cmd_value = _data16.lsb; - WAIT_LCD_NOT_BUSY; - LCD_CAM.lcd_user.val = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; } LCD_CAM.lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE; diff --git a/src/databus/Arduino_ESP32QSPI.cpp b/src/databus/Arduino_ESP32QSPI.cpp index 9a82dc74..d1149358 100644 --- a/src/databus/Arduino_ESP32QSPI.cpp +++ b/src/databus/Arduino_ESP32QSPI.cpp @@ -165,14 +165,24 @@ void Arduino_ESP32QSPI::writeCommand16(uint16_t c) void Arduino_ESP32QSPI::writeCommandBytes(uint8_t *data, uint32_t len) { - DC_LOW(); - - while (len--) + CS_LOW(); + uint32_t l; + bool first_send = true; + while (len) { - WRITE(*data++); - } + l = (len >= (ESP32QSPI_MAX_PIXELS_AT_ONCE << 1)) ? (ESP32QSPI_MAX_PIXELS_AT_ONCE << 1) : len; - DC_HIGH(); + _spi_tran_ext.base.flags = SPI_TRANS_MULTILINE_CMD | SPI_TRANS_MULTILINE_ADDR; + _spi_tran_ext.base.tx_buffer = data; + _spi_tran_ext.base.length = l << 3; + + POLL_START(); + POLL_END(); + + len -= l; + data += l; + } + CS_HIGH(); } /** diff --git a/src/databus/Arduino_ESP32SPI.cpp b/src/databus/Arduino_ESP32SPI.cpp index fa50d06f..32040f4f 100644 --- a/src/databus/Arduino_ESP32SPI.cpp +++ b/src/databus/Arduino_ESP32SPI.cpp @@ -441,7 +441,7 @@ void Arduino_ESP32SPI::writeCommandBytes(uint8_t *data, uint32_t len) while (len--) { - WRITE(*data++); + WRITE8BIT(*data++); } DC_HIGH(); diff --git a/src/databus/Arduino_ESP32SPIDMA.cpp b/src/databus/Arduino_ESP32SPIDMA.cpp index 7af843c9..abc5a2c0 100644 --- a/src/databus/Arduino_ESP32SPIDMA.cpp +++ b/src/databus/Arduino_ESP32SPIDMA.cpp @@ -298,7 +298,7 @@ void Arduino_ESP32SPIDMA::writeCommandBytes(uint8_t *data, uint32_t len) DC_LOW(); while (len--) { - WRITE(*data++); + WRITE8BIT(*data++); } DC_HIGH(); } diff --git a/src/display/Arduino_SH1106.cpp b/src/display/Arduino_SH1106.cpp index d91ac212..9bad3274 100644 --- a/src/display/Arduino_SH1106.cpp +++ b/src/display/Arduino_SH1106.cpp @@ -87,7 +87,7 @@ bool Arduino_SH1106::begin(int32_t speed) // WRITE_COMMAND_16, SH110X_MEMORYMODE, 0x10, // 0x20, 0x10 // WRITE_COMMAND_8, SH110X_DISPLAYALLON_RESUME, // 0xA4 - WRITE_COMMANDS, 25, + WRITE_COMMAND_BYTES, 25, SH110X_DISPLAYOFF, SH110X_SETDISPLAYCLOCKDIV, 0x80, // 0xD5, 0x80, SH110X_SETMULTIPLEX, 0x3F, // 0xA8, 0x3F, diff --git a/src/display/Arduino_SSD1306.cpp b/src/display/Arduino_SSD1306.cpp index 04e64ca1..0b066aaa 100644 --- a/src/display/Arduino_SSD1306.cpp +++ b/src/display/Arduino_SSD1306.cpp @@ -70,7 +70,7 @@ bool Arduino_SSD1306::begin(int32_t speed) static const uint8_t init_sequence[] = { BEGIN_WRITE, - WRITE_COMMANDS, 25, + WRITE_COMMAND_BYTES, 25, SSD1306_DISPLAYOFF, // 0xAE SSD1306_SETCONTRAST, _contrast, // 0x81 nn SSD1306_NORMALDISPLAY, // 0xA6