diff --git a/drivers/lcd/Kconfig b/drivers/lcd/Kconfig index d978aebade..2395822e83 100644 --- a/drivers/lcd/Kconfig +++ b/drivers/lcd/Kconfig @@ -737,6 +737,13 @@ if LCD_ST7789 bool "ST7789 Mirror Y" default n + config LCD_ST7789_INVCOLOR + bool "ST7789 Invert Color" + default y + ---help--- + Invert colors of the LCD display. This is useful for implementations + that assume that that colors are inverted by default. + 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 de8f2f038e..38e2007be5 100644 --- a/drivers/lcd/st7789.c +++ b/drivers/lcd/st7789.c @@ -342,7 +342,11 @@ static void st7789_sleep(FAR struct st7789_dev_s *dev, bool sleep) static void st7789_display(FAR struct st7789_dev_s *dev, bool on) { st7789_sendcmd(dev, on ? ST7789_DISPON : ST7789_DISPOFF); +#ifdef CONFIG_LCD_ST7789_INVCOLOR st7789_sendcmd(dev, ST7789_INVON); +#else + st7789_sendcmd(dev, ST7789_INVOFF); +#endif } /**************************************************************************** diff --git a/drivers/lcd/st7789.h b/drivers/lcd/st7789.h index 3d205d0beb..9f3ffd196d 100644 --- a/drivers/lcd/st7789.h +++ b/drivers/lcd/st7789.h @@ -29,26 +29,95 @@ * Pre-processor Definitions ****************************************************************************/ -#define ST7789_NOP 0x00 /* No Operation */ -#define ST7789_SWRESET 0x01 /* Software Reset */ -#define ST7789_RDDID 0x04 /* Read Display ID */ -#define ST7789_RDDST 0x09 /* Read Display Status */ -#define ST7789_RDDPM 0x0a /* Read Display Power */ -#define ST7789_SLPIN 0x10 /* Sleep In & Booster Off */ -#define ST7789_SLPOUT 0x11 /* Sleep Out & Booster On */ -#define ST7789_PTLON 0x12 /* Partial Mode On */ -#define ST7789_NORON 0x13 /* Partial Mode Off */ -#define ST7789_INVOFF 0x20 /* Display Inversion Off */ -#define ST7789_INVON 0x21 /* Display Inversion On */ -#define ST7789_DISPOFF 0x28 /* Display Off */ -#define ST7789_DISPON 0x29 /* Display On */ -#define ST7789_CASET 0x2a /* Column Address Set */ -#define ST7789_RASET 0x2b /* Row Address Set */ -#define ST7789_RAMWR 0x2c /* Memory Write */ -#define ST7789_RAMRD 0x2e /* Memory Read */ -#define ST7789_MADCTL 0x36 /* Memory Data Access Control */ -#define ST7789_IDMOFF 0x38 /* Idle Mode Off */ -#define ST7789_IDMON 0x39 /* Idle Mode On */ -#define ST7789_COLMOD 0x3a /* Interface Pixel Format */ +/* System Function Command Table 1 */ + +#define ST7789_NOP 0x00 /* No Operation */ +#define ST7789_SWRESET 0x01 /* Software Reset */ +#define ST7789_RDDID 0x04 /* Read Display ID */ +#define ST7789_RDDST 0x09 /* Read Display Status */ +#define ST7789_RDDPM 0x0a /* Read Display Power */ +#define ST7789_RDDMADCTL 0x0b /* Read Display MADCTL */ +#define ST7789_RDDCOLMOD 0x0c /* Read Display Pixel Format */ +#define ST7789_RDDIM 0x0d /* Read Display Image Mode */ +#define ST7789_RDDSM 0x0e /* Read Display Signal Mode */ +#define ST7789_RDDSDR 0x0f /* Read Display Self-Diagnostic Result */ +#define ST7789_SLPIN 0x10 /* Sleep In & Booster Off */ +#define ST7789_SLPOUT 0x11 /* Sleep Out & Booster On */ +#define ST7789_PTLON 0x12 /* Partial Mode On */ +#define ST7789_NORON 0x13 /* Partial Mode Off */ +#define ST7789_INVOFF 0x20 /* Display Inversion Off */ +#define ST7789_INVON 0x21 /* Display Inversion On */ +#define ST7789_GAMSET 0x26 /* Gamma Set */ +#define ST7789_DISPOFF 0x28 /* Display Off */ +#define ST7789_DISPON 0x29 /* Display On */ +#define ST7789_CASET 0x2a /* Column Address Set */ +#define ST7789_RASET 0x2b /* Row Address Set */ +#define ST7789_RAMWR 0x2c /* Memory Write */ +#define ST7789_RAMRD 0x2e /* Memory Read */ +#define ST7789_PTLAR 0x30 /* Partial Area */ +#define ST7789_VSCRDEF 0x33 /* Vertical Scrolling Definition */ +#define ST7789_TEOFF 0x34 /* Tearing Effect Line Off */ +#define ST7789_TEON 0x35 /* Tearing Effect Line On */ +#define ST7789_MADCTL 0x36 /* Memory Data Access Control */ +#define ST7789_VSCRSADD 0x37 /* Vertical Scrolling Start Address */ +#define ST7789_IDMOFF 0x38 /* Idle Mode Off */ +#define ST7789_IDMON 0x39 /* Idle Mode On */ +#define ST7789_COLMOD 0x3a /* Interface Pixel Format */ +#define ST7789_RAMWRC 0x3c /* Memory Write Continue */ +#define ST7789_RAMRDC 0x3e /* Memory Read Continue */ +#define ST7789_TESCAN 0x44 /* Set Tear Scanline */ +#define ST7789_RDTESCAN 0x45 /* Get Scanline */ +#define ST7789_WRDISBV 0x51 /* Write Display Brightness */ +#define ST7789_RDDISBV 0x52 /* Read Display Brightness Value */ +#define ST7789_WRCTRLD 0x53 /* Write CTRL Display */ +#define ST7789_RDCTRLD 0x54 /* Read CTRL Value Display */ +#define ST7789_WRCACE 0x55 /* Write Content Adaptive Brightness Control and Color Enhancement */ +#define ST7789_RDCABC 0x56 /* Read Content Adaptive Brightness Control */ +#define ST7789_WRCABCMB 0x5e /* Write CABC Minimum Brightness */ +#define ST7789_RDCABCMB 0x5f /* Read CABC Minimum Brightness */ +#define ST7789_RDABCSDR 0x68 /* Read Automatic Brightness Control Self-Diagnostic Result */ +#define ST7789_RDID1 0xda /* Read ID1 */ +#define ST7789_RDID2 0xdb /* Read ID2 */ +#define ST7789_RDID3 0xdc /* Read ID3 */ + +/* System Function Command Table 2 */ + +#define ST7789_RAMCTRL 0xb0 /* RAM Control */ +#define ST7789_RGBCTRL 0xb1 /* RGB Control */ +#define ST7789_PORCTRL 0xb2 /* Porch Control */ +#define ST7789_FRCTRL1 0xb3 /* Frame Rate Control */ +#define ST7789_PARCTRL 0xb5 /* Partial Control */ +#define ST7789_GCTRL 0xb7 /* Gate Control */ +#define ST7789_GTADJ 0xb8 /* Gate on Timing Adjustment */ +#define ST7789_DGMEN 0xba /* Digital Gamma Enable */ +#define ST7789_VCOMS 0xbb /* VCOMS Setting */ +#define ST7789_POWSAVE 0xbc /* Power Saving Mode */ +#define ST7789_DLPOFFSAVE 0xbd /* Display Off Power Save */ +#define ST7789_LCMCTRL 0xc0 /* LCM Control */ +#define ST7789_IDSET 0xc1 /* ID Setting */ +#define ST7789_VDVVRHEN 0xc2 /* VDV and VRH Command Enable */ +#define ST7789_VRHS 0xc3 /* VRH Set */ +#define ST7789_VDVSET 0xc4 /* VDV Set */ +#define ST7789_VCMOFSET 0xc5 /* VCOMS Offset Set */ +#define ST7789_FRCTR2 0xc6 /* FR Control 2 */ +#define ST7789_CABCCTRL 0xc7 /* CABC Control */ +#define ST7789_REGSEL1 0xc8 /* Register Value Selection 1 */ +#define ST7789_REGSEL2 0xca /* Register Value Selection 2 */ +#define ST7789_PWMFRSEL 0xcc /* PWM Frequency Selection */ +#define ST7789_PWCTRL1 0xd0 /* Power Control 1 */ +#define ST7789_VAPVANEN 0xd2 /* Enable VAP/VAN Signal Output */ +#define ST7789_CMD2EN 0xdf /* Command 2 Enable */ +#define ST7789_PVGAMCTRL 0xe0 /* Positive Voltage Gamma Control */ +#define ST7789_NVGAMCTRL 0xe1 /* Negative Voltage Gamma Control */ +#define ST7789_DGMLUTR 0xe2 /* Digital Gamma Look-Up Table for Red */ +#define ST7789_DGMLUTB 0xe3 /* Digital Gamma Look-Up Table for Blue */ +#define ST7789_GATECTRL 0xe4 /* Gate Control */ +#define ST7789_SPI2EN 0xe7 /* SPI2 Enable */ +#define ST7789_PWCTRL2 0xe8 /* Power Control 2 */ +#define ST7789_EQCTRL 0xe9 /* Equalize Time Control */ +#define ST7789_PROMCTRL 0xec /* Program Control */ +#define ST7789_PROMEN 0xfa /* Program Mode Enable */ +#define ST7789_NVMSET 0xfc /* NVM Setting */ +#define ST7789_PROMACT 0xfe /* Program Action */ #endif /* __DRIVERS_LCD_ST7789_H */