From 742302c53f32f716b8a05a44b8375befdfdca8fc Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 10 Dec 2022 07:20:37 +0100 Subject: [PATCH] Makerfabs esp32-s3 p16 ili9488 --- lib/lib_display/UDisplay/uDisplay.cpp | 99 +++++++------------ .../displaydesc/MF_ILI9488_p16_display.ini | 30 ++++++ 2 files changed, 68 insertions(+), 61 deletions(-) create mode 100644 tasmota/displaydesc/MF_ILI9488_p16_display.ini diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index af5835e3f..d3b55316e 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -670,10 +670,10 @@ Renderer *uDisplay::Init(void) { } } else { for (uint32_t cnt = 0; cnt < 8; cnt ++) { - bus_config.data_gpio_nums[cnt] = par_dbh[cnt]; + bus_config.data_gpio_nums[cnt] = par_dbl[cnt]; } for (uint32_t cnt = 0; cnt < 8; cnt ++) { - bus_config.data_gpio_nums[cnt + 8] = par_dbl[cnt]; + bus_config.data_gpio_nums[cnt + 8] = par_dbh[cnt]; } } @@ -2490,6 +2490,8 @@ void uDisplay::_setup_dma_desc_links(const uint8_t *data, int32_t len) { */ } +#define WAIT_LCD_NOT_BUSY while (*reg_lcd_user & LCD_CAM_LCD_START) {} + void uDisplay::pb_beginTransaction(void) { auto dev = _dev; @@ -2533,84 +2535,60 @@ bool uDisplay::pb_busy(void) { } bool uDisplay::pb_writeCommand(uint32_t data, uint_fast8_t bit_length) { - if (interface == _UDSP_PAR8) { + auto dev = _dev; + auto reg_lcd_user = &(dev->lcd_user.val); + dev->lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE | LCD_CAM_LCD_CD_CMD_SET; + + if (interface == _UDSP_PAR8) { // 8bit bus auto bytes = bit_length >> 3; - auto dev = _dev; - auto reg_lcd_user = &(dev->lcd_user.val); - dev->lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE | LCD_CAM_LCD_CD_CMD_SET; do { dev->lcd_cmd_val.lcd_cmd_value = data; data >>= 8; - while (*reg_lcd_user & LCD_CAM_LCD_START) {} + WAIT_LCD_NOT_BUSY *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; } while (--bytes); return true; - } else { - // 16 bit bus - if (_has_align_data) { _send_align_data(); } - auto dev = _dev; - auto reg_lcd_user = &(dev->lcd_user.val); - dev->lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE | LCD_CAM_LCD_CD_CMD_SET; + } else { dev->lcd_cmd_val.val = data; - - if (bit_length <= 16) { - while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; - return true; - } - - while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + WAIT_LCD_NOT_BUSY + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; return true; - } - } - + } +} void uDisplay::pb_writeData(uint32_t data, uint_fast8_t bit_length) { - if (interface == _UDSP_PAR8) { - auto bytes = bit_length >> 3; - auto dev = _dev; - auto reg_lcd_user = &(dev->lcd_user.val); - dev->lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE; + auto dev = _dev; + auto reg_lcd_user = &(dev->lcd_user.val); + dev->lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE; + auto bytes = bit_length >> 3; + if (interface == _UDSP_PAR8) { uint8_t shift = (bytes - 1) * 8; for (uint32_t cnt = 0; cnt < bytes; cnt++) { dev->lcd_cmd_val.lcd_cmd_value = (data >> shift) & 0xff; shift -= 8; - while (*reg_lcd_user & LCD_CAM_LCD_START) {} + WAIT_LCD_NOT_BUSY *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; } return; } else { - auto bytes = bit_length >> 3; - auto dev = _dev; - auto reg_lcd_user = &(dev->lcd_user.val); - dev->lcd_misc.val = LCD_CAM_LCD_CD_IDLE_EDGE; - if (_has_align_data) { - _has_align_data = false; - dev->lcd_cmd_val.val = _align_data | (data << 8); - while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; - if (--bytes == 0) { return; } - data >>= 8; + if (bytes == 1 || bytes == 4) { + uint8_t shift = (bytes - 1) * 8; + for (uint32_t cnt = 0; cnt < bytes; cnt++) { + dev->lcd_cmd_val.lcd_cmd_value = (data >> shift) & 0xff; + shift -= 8; + WAIT_LCD_NOT_BUSY + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + } + return; } - if (bytes > 1) { - dev->lcd_cmd_val.val = data; - if (bytes == 4) { - while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_CMD_2_CYCLE_EN | LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; - return; - } - while (*reg_lcd_user & LCD_CAM_LCD_START) {} - *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; - if (bytes == 2) { return; } - data >>= 16; - } - _has_align_data = true; - _align_data = data; + dev->lcd_cmd_val.val = data; + WAIT_LCD_NOT_BUSY + *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; + return; } } @@ -2626,7 +2604,7 @@ void uDisplay::pb_pushPixels(uint16_t* data, uint32_t length, bool swap_bytes, b while (*reg_lcd_user & LCD_CAM_LCD_START) {} *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; dev->lcd_cmd_val.lcd_cmd_value = *data >> 8; - while (*reg_lcd_user & LCD_CAM_LCD_START) {} + WAIT_LCD_NOT_BUSY *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; data++; } @@ -2636,7 +2614,7 @@ void uDisplay::pb_pushPixels(uint16_t* data, uint32_t length, bool swap_bytes, b while (*reg_lcd_user & LCD_CAM_LCD_START) {} *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; dev->lcd_cmd_val.lcd_cmd_value = *data; - while (*reg_lcd_user & LCD_CAM_LCD_START) {} + WAIT_LCD_NOT_BUSY *reg_lcd_user = LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; data++; } @@ -2648,14 +2626,13 @@ void uDisplay::pb_pushPixels(uint16_t* data, uint32_t length, bool swap_bytes, b iob = *data++; iob = (iob << 8) | (iob >> 8); dev->lcd_cmd_val.lcd_cmd_value = iob; - while (*reg_lcd_user & LCD_CAM_LCD_START) {} + WAIT_LCD_NOT_BUSY *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; - data++; } } else { for (uint32_t cnt = 0; cnt < length; cnt++) { dev->lcd_cmd_val.lcd_cmd_value = *data++; - while (*reg_lcd_user & LCD_CAM_LCD_START) {} + WAIT_LCD_NOT_BUSY *reg_lcd_user = LCD_CAM_LCD_2BYTE_EN | LCD_CAM_LCD_CMD | LCD_CAM_LCD_UPDATE_REG | LCD_CAM_LCD_START; } } diff --git a/tasmota/displaydesc/MF_ILI9488_p16_display.ini b/tasmota/displaydesc/MF_ILI9488_p16_display.ini new file mode 100644 index 000000000..e73eae9f0 --- /dev/null +++ b/tasmota/displaydesc/MF_ILI9488_p16_display.ini @@ -0,0 +1,30 @@ +:H,ILI9488,480,320,16,PAR,16,-1,37,36,35,48,45,47,21,14,13,12,11,10,9,3,8,16,15,7,6,5,4,20 +:S,2,1,1,0,40,20 +:I +E0,0F,00,03,09,08,16,0A,3F,78,4C,09,0A,08,16,1A,0F +E1,0F,00,16,19,03,0F,05,32,45,46,04,0E,0D,35,37,0F +C0,2,17,15 +C1,1,41 +C5,3,00,12,80 +36,1,48 +3A,1,55 +B0,1,80 +B1,1,A0 +B4,1,02 +B6,2,02,02 +E9,1,00 +F7,4,A9,51,2C,82 +11,80 +29,0 +:o,28 +:O,29 +:A,2A,2B,2C,16 +:R,36 +:0,28,00,00,85 +:1,88,00,00,02 +:2,E8,00,00,84 +:3,48,00,00,00 +:i,20,21 +:TI1,38,*,* +:B,20,0 +#