This is an automated email from the ASF dual-hosted git repository. acassis 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 c623a7b731 drivers/lcd/st7789: Support mirror X/Y c623a7b731 is described below commit c623a7b7315b7701be5abe2739df51e8cf5a2767 Author: Huang Qi <huang...@xiaomi.com> AuthorDate: Sun Mar 26 10:03:35 2023 +0800 drivers/lcd/st7789: Support mirror X/Y Support mirror display by X/Y axis, it's useful for single portrait/landscape but need to mirror specific direction. Signed-off-by: Huang Qi <huang...@xiaomi.com> --- drivers/lcd/Kconfig | 8 ++++++++ drivers/lcd/st7789.c | 28 ++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/lcd/Kconfig b/drivers/lcd/Kconfig index 80be5c59a2..d978aebade 100644 --- a/drivers/lcd/Kconfig +++ b/drivers/lcd/Kconfig @@ -729,6 +729,14 @@ if LCD_ST7789 ---help--- Specifies the Y offset of the LCD. + config LCD_ST7789_MIRRORX + bool "ST7789 Mirror X" + default n + + config LCD_ST7789_MIRRORY + bool "ST7789 Mirror Y" + default n + config LCD_ST7789_BPP int "Bit Per Pixel (12 or 16)" default 16 diff --git a/drivers/lcd/st7789.c b/drivers/lcd/st7789.c index 55d0476221..de8f2f038e 100644 --- a/drivers/lcd/st7789.c +++ b/drivers/lcd/st7789.c @@ -355,30 +355,46 @@ static void st7789_display(FAR struct st7789_dev_s *dev, bool on) static void st7789_setorientation(FAR struct st7789_dev_s *dev) { - /* No need to change the orientation in PORTRAIT mode */ + /* Default value on reset */ + + uint8_t madctl = 0x00; -#if !defined(CONFIG_LCD_PORTRAIT) st7789_sendcmd(dev, ST7789_MADCTL); st7789_select(dev->spi, 8); +#if !defined(CONFIG_LCD_PORTRAIT) + # if defined(CONFIG_LCD_RLANDSCAPE) /* RLANDSCAPE : MY=1 MV=1 */ - SPI_SEND(dev->spi, 0xa0); + madctl = 0xa0; # elif defined(CONFIG_LCD_LANDSCAPE) /* LANDSCAPE : MX=1 MV=1 */ - SPI_SEND(dev->spi, 0x70); + madctl = 0x70; # elif defined(CONFIG_LCD_RPORTRAIT) /* RPORTRAIT : MX=1 MY=1 */ - SPI_SEND(dev->spi, 0xc0); + madctl = 0xc0; # endif - st7789_deselect(dev->spi); #endif + + /* Mirror X/Y for current setting */ + +#ifdef CONFIG_LCD_ST7789_MIRRORX + madctl ^= 0x40; +#endif + +#ifdef CONFIG_LCD_ST7789_MIRRORY + madctl ^= 0x80; +#endif + + SPI_SEND(dev->spi, madctl); + + st7789_deselect(dev->spi); } /****************************************************************************