Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/st77xx: implement initialization #19827

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
267 changes: 267 additions & 0 deletions drivers/include/st77xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,273 @@
extern "C" {
#endif

/**
* @brief ST7735 Customized Configuration Enable
*
* Define CONFIG_ST7735_CUSTOM_CONFIG=1 to use customized voltage
* configurations. Otherwise ST7735 is using reset defaults.
*/
#ifndef CONFIG_ST7735_CUSTOM_CONFIG
#define CONFIG_ST7735_CUSTOM_CONFIG 0
#endif

/**
* @brief ST7735 AVDD voltage (in millivolts)
*
* A default voltage of 4.9V is used for AVDD.
* Valid values must be in the range of 4500 (4.5V) to 5100 (5.1V)
* in steps of 100.
*/
#ifndef CONFIG_ST7735_AVDD
#define CONFIG_ST7735_AVDD 4900
#endif

/**
* @brief ST7735 GVDD voltage (in millivolts)
*
* A default voltage of 4.6V is used for GVDD (gamma reference positive voltage).
* Valid values must be in the range of 3150 (3.15V) to 4700 (4.7V)
* in steps of 50.
*/
#ifndef CONFIG_ST7735_GVDD
#define CONFIG_ST7735_GVDD 4600
#endif

/**
* @brief ST7735 GVL voltage (in millivolts)
*
* A default voltage of -4.6V is used for GVCL (gamma reference negative voltage).
* Valid values must be in the range of -4700 (-4.7V) to -3150 (-3.15V)
* in steps of 50.
*/
#ifndef CONFIG_ST7735_GVCL
#define CONFIG_ST7735_GVCL -4600
#endif

/**
* @brief ST7735 VCOM voltage (in millivolts)
*
* A default voltage of -0.425V is used for VCOM. VCOM needs to be adjusted
* to match the capacitance and performance specifications of the TFT panel
* to maximize contrast and minimize flickering.
* Valid values must be in the range of -2000 (-2.0V) to -425 (-0.425V)
* in steps of 25.
*/
#ifndef CONFIG_ST7735_VCOM
#define CONFIG_ST7735_VCOM -775
#endif

/**
* @brief ST7735 VGH voltage (in millivolts)
*
* A default voltage of 14.7V is used for VGH, the high voltage for gate drivers.
* Valid values must be in the range of 10000 (10V) to 15000 (15V) and
* in the range of (2 * AVDD + 2.1V) and (3 * AVDD + 2.4 V).
*/
#ifndef CONFIG_ST7735_VGH
#define CONFIG_ST7735_VGH 14700
#endif

/**
* @brief ST7735 VGL voltage (in millivolts)
*
* A default voltage of -10V is used for VGL, the low voltage for gate drivers.
* Valid values must be in the range of -13000 (-13V) to -7500 (-7.5V)
* in steps of 2500.
*/
#ifndef CONFIG_ST7735_VGL
#define CONFIG_ST7735_VGL -10000
#endif

/**
* @brief ST7789 Customized Configuration Enable
*
* Define CONFIG_ST7789_CUSTOM_CONFIG=1 to use customized voltage
* configurations. Otherwise ST7735 is using reset defaults.
*/
#ifndef CONFIG_ST7789_CUSTOM_CONFIG
#define CONFIG_ST7789_CUSTOM_CONFIG 0
#endif

/**
* @brief ST7789 AVDD voltage (in millivolts)
*
* A default voltage of 6.8V is used for AVDD.
* Valid values must be in the range of 6400 (6.4V) to 6800 (6.8V)
* in steps of 100.
*/
#ifndef CONFIG_ST7789_AVDD
#define CONFIG_ST7789_AVDD 6800
#endif

/**
* @brief ST7789 AVCL voltage (in millivolts)
*
* A default voltage of -4.8V is used for AVCL.
* Valid values must be in the range of -5000 (-5.0V) to -4400 (-4.4V)
* in steps of 100.
*/
#ifndef CONFIG_ST7789_AVCL
#define CONFIG_ST7789_AVCL -4800
#endif

/**
* @brief ST7789 VCOM voltage (in millivolts)
*
* A default voltage of 0.9V is used for VCOM. VCOM needs to be adjusted
* to match the capacitance and performance specifications of the TFT panel
* to maximize contrast and minimize flickering. VCOM is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET + (0.5 * VDV)
* GVCL = -VRH + VCOM + VCOM_OFFSET - (0.5 * VDV)
*
* Valid values must be in the range of 100 (0.1V) to 1675 (1.675V)
* in steps of 25.
*/
#ifndef CONFIG_ST7789_VCOM
#define CONFIG_ST7789_VCOM 900
#endif

/**
* @brief ST7789 VCOM voltage offset (in millivolts)
*
* A default voltage of 0V is used for VCOM voltage offset (VCOM_OFFSET).
* VCOM_OFFSET is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET + (0.5 * VDV)
* GVCL = -VRH + VCOM + VCOM_OFFSET - (0.5 * VDV)
*
* Valid values must be in the range of -800 (-0.8V) to 775 (0.775V)
* in steps of 25.
*/
#ifndef CONFIG_ST7789_VCOM_OFFSET
#define CONFIG_ST7789_VCOM_OFFSET 0
#endif

/**
* @brief ST7789 VDV voltage (in millivolts)
*
* A default voltage of 0V is used for VDV. VDV is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET + (0.5 * VDV)
* GVCL = -VRH + VCOM + VCOM_OFFSET - (0.5 * VDV)
*
* Valid values must be in the range of -800 (-0.8V) to 775 (0.775V)
* in steps of 25.
*/
#ifndef CONFIG_ST7789_VDV
#define CONFIG_ST7789_VDV 0
#endif

/**
* @brief ST7789 VRH voltage (in millivolts)
*
* A default voltage of 4.1V is used for VRH. VRH is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET + (0.5 * VDV)
* GVCL = -VRH + VCOM + VCOM_OFFSET - (0.5 * VDV)
*
* Valid values must be in the range of 3350 (3.35V) to 5500 (5.5V)
* in steps of 50.
*/
#ifndef CONFIG_ST7789_VRH
#define CONFIG_ST7789_VRH 4100
#endif

/**
* @brief ST7796 Customized Configuration Enable
*
* Define CONFIG_ST7796_CUSTOM_CONFIG=1 to use customized voltage
* configurations. Otherwise ST7735 is using reset defaults.
*/
#ifndef CONFIG_ST7796_CUSTOM_CONFIG
#define CONFIG_ST7796_CUSTOM_CONFIG 0
#endif

/**
* @brief ST7796 AVDD voltage (in millivolts)
*
* A default voltage of 6.6V is used for AVDD.
* Valid values must be in the range of 6200 (6.2V) to 6800 (6.8V)
* in steps of 100.
*/
#ifndef CONFIG_ST7796_AVDD
#define CONFIG_ST7796_AVDD 6600
#endif

/**
* @brief ST7796 AVCL voltage (in millivolts)
*
* A default voltage of -4.4V is used for AVCL.
* Valid values must be in the range of -5000 (-5.0V) to -4400 (-4.4V)
* in steps of 100.
*/
#ifndef CONFIG_ST7796_AVCL
#define CONFIG_ST7796_AVCL -4400
#endif

/**
* @brief ST7796 VCOM voltage (in millivolts)
*
* A default voltage of 1.0V is used for VCOM. VCOM needs to be adjusted
* to match the capacitance and performance specifications of the TFT panel
* to maximize contrast and minimize flickering. VCOM is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET
* GVCL = -VRH + VCOM + VCOM_OFFSET
*
* Valid values must be in the range of 100 (0.1V) to 1875 (1.875V)
* in steps of 25.
*/
#ifndef CONFIG_ST7796_VCOM
#define CONFIG_ST7796_VCOM 1000
#endif

/**
* @brief ST7796 VCOM voltage offset (in millivolts)
*
* A default voltage of 0V is used for VCOM voltage offset (VCOM_OFFSET).
* VCOM_OFFSET is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET
* GVCL = -VRH + VCOM + VCOM_OFFSET
*
* Valid values must be in the range of -800 (-0.8V) to 775 (0.775V)
* in steps of 25.
*/
#ifndef CONFIG_ST7796_VCOM_OFFSET
#define CONFIG_ST7796_VCOM_OFFSET 0
#endif

/**
* @brief ST7796 VRH voltage (in millivolts)
*
* A default voltage of 4.1V is used for VRH. VRH is used to derive
* the GVDD (gamma reference positive voltage) and
* the GVCL (gamma reference negative voltage) as follows:
*
* GDDV = +VRH + VCOM + VCOM_OFFSET
* GVCL = -VRH + VCOM + VCOM_OFFSET
*
* Valid values must be in the range of 3350 (3.35V) to 5500 (5.5V)
* in steps of 50.
*/
#ifndef CONFIG_ST7796_VRH
#define CONFIG_ST7796_VRH 4100
#endif

/**
* @name ST77xx display rotation modes
* @{
Expand Down
3 changes: 3 additions & 0 deletions drivers/lcd/include/lcd_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ extern "C" {
#define LCD_CMD_MADCTL 0x36 /**< Memory data access control */
#define LCD_CMD_IDMOFF 0x38 /**< Idle Mode OFF */
#define LCD_CMD_IDMON 0x39 /**< Idle Mode ON */
#define LCD_CMD_TEOFF 0x34 /**< Tearing Effect Line Off */
#define LCD_CMD_TEON 0x35 /**< Tearing Effect Line On */
#define LCD_CMD_COLMOD 0x3A /**< Interface Pixel Format Set */
#define LCD_CMD_PIXSET 0x3A /**< COLMOD: Pixel Format Set */
#define LCD_CMD_WRDISBV 0x51 /**< Write Display Brightness */
#define LCD_CMD_WRCTRLD 0x53 /**< Write Control Display */
Expand Down
9 changes: 3 additions & 6 deletions drivers/lcd/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ int lcd_init(lcd_t *dev, const lcd_params_t *params)
}
ztimer_sleep(ZTIMER_MSEC, 120);

if (dev->driver->init) {
return dev->driver->init(dev, params);
}
else {
return -ENOTSUP;
}
/* controller-specific init function has to be defined */
assert(dev->driver->init);
return dev->driver->init(dev, params);
}

void lcd_write_cmd(const lcd_t *dev, uint8_t cmd, const uint8_t *data,
Expand Down
68 changes: 68 additions & 0 deletions drivers/st77xx/Kconfig.st7735
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,72 @@ config MODULE_ST7735
help
ST7735 display controller is used

if MODULE_ST7735

menuconfig ST7735_CUSTOM_CONFIG
bool "ST7735 Custom Configuration"
help
Enable if customized configuration of voltages are needed. Otherwise
reset default values are used.

if ST7735_CUSTOM_CONFIG

config ST7735_AVDD
int "AVDD voltage (in millivolts)"
default 4900
range 4500 5100
help
Configure the AVDD voltage for analog circuits in millivolts.
Valid values must be in the range of 4500 (4.5V) to 5100 (5.1V)
in steps of 100.

config ST7735_GVDD
int "GVDD voltage (in millivolts)"
default 4600
range 3150 4700
help
Configure the GVDD voltage, the gamma reference positive voltage.
Valid values must be in the range of 3150 (3.15V) to 4700 (4.7V)
in steps of 50.

config ST7735_GVCL
int "GVCL voltage (in millivolts)"
default -4600
range -4700 -3150
help
Configure the GVCL voltage, the gamma reference negative voltage.
Valid values must be in the range of -4700 (-4.7V) to -3150 (-3.15V)
in steps of 50.

config ST7735_VCOM
int "VCOM voltage (in millivolts)"
default -775
range -2000 -425
help
Configure the VCOM voltage. VCOM needs to be adjusted to match the
capacitance and performance specifications of the TFT panel to
maximize contrast and minimize flickering.
Valid values must be in the range of -2000 (-2.0V) to -425 (-0.425V)
in steps of 25.

config ST7735_VGH
int "VGH voltage (in millivolts)"
default 14700
range 10000 15000
help
Configure the high voltage for gate drivers in millivolts.
Valid values must be in the range of 10000 (10V) to 15000 (15V) and
in the range of (2 * AVDD + 2.1V) and (3 * AVDD + 2.4 V).

config ST7735_VGL
int "VGL voltage (in millivolts)"
default -10000
range -13000 -7500
help
Configure the low voltage for gate drivers in millivolts.
Valid values must be in the range of -13000 (-13V) to -7500 (-7.5V)
in steps of 2500.

endif # ST7735_CUSTOM_CONFIG
endif # MODULE_ST7735
endif # MODULE_ST77XX
Loading