From 7e4cf8308d74d9aa7d9666c88fcf815aecc18775 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Wed, 13 Apr 2022 09:42:50 +0900 Subject: [PATCH] drivers: display: st7735r: added inversion-on property Add 'inversion-on' property to st7735r. Issue INVON(21h) command on initializing if inversion-on was enabled. As a result of this command, the display color is inverted. Otherwise, INVOFF(20h) will be issued. Signed-off-by: TOKITA Hiroshi --- drivers/display/display_st7735r.c | 8 +++++++- dts/bindings/display/sitronix,st7735r.yaml | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/display/display_st7735r.c b/drivers/display/display_st7735r.c index 3309b183f16..f9466a7c3f0 100644 --- a/drivers/display/display_st7735r.c +++ b/drivers/display/display_st7735r.c @@ -50,6 +50,7 @@ struct st7735r_config { uint8_t frmctr3[6]; uint8_t gamctrp1[16]; uint8_t gamctrn1[16]; + bool inversion_on; }; struct st7735r_data { @@ -377,7 +378,11 @@ static int st7735r_lcd_init(const struct device *dev) return ret; } - ret = st7735r_transmit(dev, ST7735R_CMD_INV_OFF, NULL, 0); + if (config->inversion_on) { + ret = st7735r_transmit(dev, ST7735R_CMD_INV_ON, NULL, 0); + } else { + ret = st7735r_transmit(dev, ST7735R_CMD_INV_OFF, NULL, 0); + } if (ret < 0) { return ret; } @@ -545,6 +550,7 @@ static const struct display_driver_api st7735r_api = { .frmctr3 = DT_INST_PROP(inst, frmctr3), \ .gamctrp1 = DT_INST_PROP(inst, gamctrp1), \ .gamctrn1 = DT_INST_PROP(inst, gamctrn1), \ + .inversion_on = DT_INST_PROP(inst, inversion_on), \ }; \ \ static struct st7735r_data st7735r_data_ ## inst = { \ diff --git a/dts/bindings/display/sitronix,st7735r.yaml b/dts/bindings/display/sitronix,st7735r.yaml index d2f0faf22a3..96cf4f2c67f 100644 --- a/dts/bindings/display/sitronix,st7735r.yaml +++ b/dts/bindings/display/sitronix,st7735r.yaml @@ -117,3 +117,9 @@ properties: description: | Display Inversion Control Set dot inversion or line inversion for each normal/idle/partial mode. + + inversion-on: + type: boolean + description: | + Enable Display Inversion + Make a drawing with the inverted color of the frame memory.