This is an automated email from the ASF dual-hosted git repository.

raiden00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 425ddc7f72 lcd/st7789: fix incorrect buffer count for 3 wire RAM write
425ddc7f72 is described below

commit 425ddc7f72c5ab71c715aace67de2c804992c4f8
Author: Michal Lenc <michall...@seznam.cz>
AuthorDate: Mon Feb 17 15:03:27 2025 +0100

    lcd/st7789: fix incorrect buffer count for 3 wire RAM write
    
    If st7789_wrram is called with count = 1, then the entire buffer should
    be sent. However, in 3 wire mode, the driver has to send the buffer
    row by row because of additional data flag. The number of rows (count)
    can't be ST7789_YRES in this case, but only the number of rows in
    the buffer (this is write size / row size , where row size is
    ST7789_XRES * ST7789_BYTESPP). This also applies only if we want to
    write size larger than row size, because st7789_putrun allows to
    write just a part of a row.
    
    This fixes the incorrect behavior of the display in 3 wire mode if
    the display is split into more buffer writes (as in LCD driver for
    example, FB driver did not face this issue).
    
    Signed-off-by: Michal Lenc <michall...@seznam.cz>
    Co-authored-by: Martin Krasula <kras...@atlas.cz>
---
 drivers/lcd/st7789.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/lcd/st7789.c b/drivers/lcd/st7789.c
index e69fb0e2cf..30af6905ea 100644
--- a/drivers/lcd/st7789.c
+++ b/drivers/lcd/st7789.c
@@ -584,19 +584,22 @@ static void st7789_wrram(FAR struct st7789_dev_s *dev,
   size_t i;
 #ifdef CONFIG_LCD_ST7789_3WIRE
   size_t j;
+  size_t rowsiz;
 #endif
 
   st7789_sendcmd(dev, ST7789_RAMWR);
 
 #ifdef CONFIG_LCD_ST7789_3WIRE
-  if (count == 1)
+  rowsiz = ST7789_XRES * ST7789_BYTESPP;
+
+  if (count == 1 && size > rowsiz)
     {
       /* We cannot send the entire buffer at once, split it to
        * separate rows.
        */
 
-      count = ST7789_YRES;
-      size = ST7789_XRES * ST7789_BYTESPP;
+      count = size / rowsiz;
+      size = rowsiz;
     }
 
   st7789_select(dev->spi, LCD_ST7789_SPI_BITS);
@@ -607,7 +610,7 @@ static void st7789_wrram(FAR struct st7789_dev_s *dev,
     {
       /* Copy data to rowbuff and add 9th bit */
 
-      for (j = 0; j < ST7789_XRES * ST7789_BYTESPP; j += 2)
+      for (j = 0; j < size; j += 2)
         {
           /* Take care of correct byte order. */
 

Reply via email to