From a9d3e1bd087bac9b4ec79138c250a9bc3ffefb85 Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Wed, 20 Jul 2022 16:22:52 -0300 Subject: [PATCH] lcd/apa102: Fix APA102 RGB LED Matrix interleaving issue I found an issue in the APA102 framebuffer that wasn't spot before by fb test because this application draw symetric squares Normally in a display each line starts at left and increase to the right, however for this APA102 matrix the next line starts at the end of previous line and move the opposite direction, forming a zig-zag pattern. --- drivers/lcd/apa102.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/lcd/apa102.c b/drivers/lcd/apa102.c index 9e70895a4a..1c787f31a2 100644 --- a/drivers/lcd/apa102.c +++ b/drivers/lcd/apa102.c @@ -443,7 +443,15 @@ static int apa102_putrun(FAR struct lcd_dev_s *dev, fb_coord_t row, { uint16_t *ptr = (uint16_t *)buffer; - priv->fb[(row * APA102_XRES) + col + i] = rgb565_apa102(*ptr++); + if (row % 2 == 0) + { + priv->fb[(row * APA102_XRES) + col + i] = rgb565_apa102(*ptr++); + } + else + { + priv->fb[(row * APA102_XRES) + APA102_XRES - col - i - 1] = + rgb565_apa102(*ptr++); + } } /* Update the display with converted data */ @@ -490,8 +498,16 @@ static int apa102_putarea(FAR struct lcd_dev_s *dev, { for (j = col_start; j <= col_end; j++) { - priv->fb[(i * APA102_XRES) + j] = - rgb565_apa102(*(src + (i * APA102_XRES) + j)); + if (i % 2 == 0) + { + priv->fb[(i * APA102_XRES) + j] = + rgb565_apa102(*(src + (i * APA102_XRES) + j)); + } + else + { + priv->fb[(i * APA102_XRES) + APA102_XRES - j - 1] = + rgb565_apa102(*(src + (i * APA102_XRES) + j)); + } } }