From b6d2dc6c5487ffa957eaa524e02e9699b1f6dacc Mon Sep 17 00:00:00 2001 From: Neo Xu Date: Wed, 2 Oct 2024 12:29:26 +0800 Subject: [PATCH] lcd/st7735: add option to invert display color Signed-off-by: Neo Xu --- drivers/lcd/Kconfig | 4 ++++ drivers/lcd/st7735.c | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/lcd/Kconfig b/drivers/lcd/Kconfig index 35977de702..d3b54b4dda 100644 --- a/drivers/lcd/Kconfig +++ b/drivers/lcd/Kconfig @@ -686,6 +686,10 @@ config LCD_ST7735_BGR bool "Swap R & B channel" default n +config LCD_ST7735_INVCOLOR + bool "Invert display color" + default n + config LCD_ST7735_BPP int "Bit Per Pixel (12, 16 or 18)" default 16 diff --git a/drivers/lcd/st7735.c b/drivers/lcd/st7735.c index 7bd47459f8..04481c8ca8 100644 --- a/drivers/lcd/st7735.c +++ b/drivers/lcd/st7735.c @@ -332,6 +332,21 @@ static void st7735_sleep(FAR struct st7735_dev_s *dev, bool sleep) up_mdelay(120); } +/**************************************************************************** + * Name: st7735_invon + * + * Description: + * Display inversion on or off. + * + ****************************************************************************/ + +#ifdef CONFIG_LCD_ST7735_INVCOLOR +static void st7735_invon(FAR struct st7735_dev_s *dev, bool on) +{ + st7735_sendcmd(dev, on ? ST7735_INVON : ST7735_INVOFF); +} +#endif + /**************************************************************************** * Name: st7735_display * @@ -743,6 +758,9 @@ FAR struct lcd_dev_s *st7735_lcdinitialize(FAR struct spi_dev_s *spi) st7735_sleep(priv, false); st7735_bpp(priv, ST7735_BPP); st7735_setorientation(priv); +#ifdef CONFIG_LCD_ST7735_INVCOLOR + st7735_invon(priv, true); +#endif st7735_display(priv, true); st7735_fill(priv, 0xffff); @@ -750,4 +768,3 @@ FAR struct lcd_dev_s *st7735_lcdinitialize(FAR struct spi_dev_s *spi) } #endif /* CONFIG_LCD_ST7735 */ -