Skip to content

Commit 3c4399d

Browse files
Update TFT drivers for new backligh control
1 parent fa042b0 commit 3c4399d

22 files changed

+43
-437
lines changed

lvgl_tft/GC9A01.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,14 @@ void GC9A01_init(void)
111111

112112
};
113113

114-
#if GC9A01_BCKL == 15
115-
gpio_config_t io_conf;
116-
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
117-
io_conf.mode = GPIO_MODE_OUTPUT;
118-
io_conf.pin_bit_mask = GPIO_SEL_15;
119-
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
120-
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
121-
gpio_config(&io_conf);
122-
#endif
123-
124114
//Initialize non-SPI GPIOs
125-
gpio_pad_select_gpio(GC9A01_DC);
115+
gpio_pad_select_gpio(GC9A01_DC);
126116
gpio_set_direction(GC9A01_DC, GPIO_MODE_OUTPUT);
127117

128118
#if GC9A01_USE_RST
129-
gpio_pad_select_gpio(GC9A01_RST);
119+
gpio_pad_select_gpio(GC9A01_RST);
130120
gpio_set_direction(GC9A01_RST, GPIO_MODE_OUTPUT);
131-
#endif
132-
133-
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
134-
gpio_pad_select_gpio(GC9A01_BCKL);
135-
gpio_set_direction(GC9A01_BCKL, GPIO_MODE_OUTPUT);
136-
#endif
137121

138-
#if GC9A01_USE_RST
139122
//Reset the display
140123
gpio_set_level(GC9A01_RST, 0);
141124
vTaskDelay(100 / portTICK_RATE_MS);
@@ -156,8 +139,6 @@ void GC9A01_init(void)
156139
cmd++;
157140
}
158141

159-
GC9A01_enable_backlight(true);
160-
161142
GC9A01_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
162143

163144
#if GC9A01_INVERT_COLORS == 1
@@ -197,22 +178,6 @@ void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
197178
GC9A01_send_color((void*)color_map, size * 2);
198179
}
199180

200-
void GC9A01_enable_backlight(bool backlight)
201-
{
202-
#if GC9A01_ENABLE_BACKLIGHT_CONTROL
203-
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
204-
uint32_t tmp = 0;
205-
206-
#if (GC9A01_BCKL_ACTIVE_LVL==1)
207-
tmp = backlight ? 1 : 0;
208-
#else
209-
tmp = backlight ? 0 : 1;
210-
#endif
211-
212-
gpio_set_level(GC9A01_BCKL, tmp);
213-
#endif
214-
}
215-
216181
void GC9A01_sleep_in()
217182
{
218183
uint8_t data[] = {0x08};

lvgl_tft/GC9A01.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,9 @@ extern "C" {
2525
/*********************
2626
* DEFINES
2727
*********************/
28-
#define GC9A01_DC CONFIG_LV_DISP_PIN_DC
29-
#define GC9A01_RST CONFIG_LV_DISP_PIN_RST
30-
#define GC9A01_USE_RST CONFIG_LV_DISP_USE_RST
31-
#define GC9A01_BCKL CONFIG_LV_DISP_PIN_BCKL
32-
33-
#define GC9A01_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
34-
35-
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
36-
#define GC9A01_BCKL_ACTIVE_LVL 1
37-
#else
38-
#define GC9A01_BCKL_ACTIVE_LVL 0
39-
#endif
40-
28+
#define GC9A01_DC CONFIG_LV_DISP_PIN_DC
29+
#define GC9A01_RST CONFIG_LV_DISP_PIN_RST
30+
#define GC9A01_USE_RST CONFIG_LV_DISP_USE_RST
4131
#define GC9A01_INVERT_COLORS CONFIG_LV_INVERT_COLORS
4232

4333
/**********************
@@ -50,7 +40,6 @@ extern "C" {
5040

5141
void GC9A01_init(void);
5242
void GC9A01_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
53-
void GC9A01_enable_backlight(bool backlight);
5443
void GC9A01_sleep_in(void);
5544
void GC9A01_sleep_out(void);
5645

lvgl_tft/hx8357.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,13 @@ static uint8_t displayType = HX8357D;
160160
void hx8357_init(void)
161161
{
162162
//Initialize non-SPI GPIOs
163-
gpio_pad_select_gpio(HX8357_DC);
163+
gpio_pad_select_gpio(HX8357_DC);
164164
gpio_set_direction(HX8357_DC, GPIO_MODE_OUTPUT);
165165

166166
#if HX8357_USE_RST
167-
gpio_pad_select_gpio(HX8357_RST);
167+
gpio_pad_select_gpio(HX8357_RST);
168168
gpio_set_direction(HX8357_RST, GPIO_MODE_OUTPUT);
169-
#endif
170-
171-
#if HX8357_ENABLE_BACKLIGHT_CONTROL
172-
gpio_pad_select_gpio(HX8357_BCKL);
173-
gpio_set_direction(HX8357_BCKL, GPIO_MODE_OUTPUT);
174-
#endif
175169

176-
#if HX8357_USE_RST
177170
//Reset the display
178171
gpio_set_level(HX8357_RST, 0);
179172
vTaskDelay(10 / portTICK_RATE_MS);
@@ -210,8 +203,6 @@ void hx8357_init(void)
210203
#else
211204
hx8357_send_cmd(HX8357_INVOFF);
212205
#endif
213-
214-
hx8357_enable_backlight(true);
215206
}
216207

217208

@@ -248,23 +239,6 @@ void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
248239
hx8357_send_color((void*)color_map, size * 2);
249240
}
250241

251-
void hx8357_enable_backlight(bool backlight)
252-
{
253-
#if HX8357_ENABLE_BACKLIGHT_CONTROL
254-
ESP_LOGD(TAG, "%s backlight.\n", backlight ? "Enabling" : "Disabling");
255-
uint32_t tmp = 0;
256-
257-
#if (HX8357_BCKL_ACTIVE_LVL==1)
258-
tmp = backlight ? 1 : 0;
259-
#else
260-
tmp = backlight ? 0 : 1;
261-
#endif
262-
263-
gpio_set_level(HX8357_BCKL, tmp);
264-
#endif
265-
}
266-
267-
268242
void hx8357_set_rotation(uint8_t r)
269243
{
270244
r = r & 3; // can't be higher than 3

lvgl_tft/hx8357.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,10 @@ extern "C" {
3535
/*********************
3636
* DEFINES
3737
*********************/
38-
#define HX8357_DC CONFIG_LV_DISP_PIN_DC
39-
#define HX8357_RST CONFIG_LV_DISP_PIN_RST
40-
#define HX8357_USE_RST CONFIG_LV_DISP_USE_RST
41-
#define HX8357_BCKL CONFIG_LV_DISP_PIN_BCKL
42-
43-
#define HX8357_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
44-
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
45-
46-
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
47-
#define HX8357_BCKL_ACTIVE_LVL 1
48-
#else
49-
#define HX8357_BCKL_ACTIVE_LVL 0
50-
#endif
38+
#define HX8357_DC CONFIG_LV_DISP_PIN_DC
39+
#define HX8357_RST CONFIG_LV_DISP_PIN_RST
40+
#define HX8357_USE_RST CONFIG_LV_DISP_USE_RST
41+
#define HX8357_INVERT_COLORS CONFIG_LV_INVERT_COLORS
5142

5243

5344
/*******************
@@ -136,7 +127,6 @@ extern "C" {
136127

137128
void hx8357_init(void);
138129
void hx8357_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
139-
void hx8357_enable_backlight(bool backlight);
140130
void hx8357_set_rotation(uint8_t r);
141131

142132
/**********************

lvgl_tft/il3820.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,13 @@ void il3820_init(void)
199199
gpio_pad_select_gpio(IL3820_DC_PIN);
200200
gpio_set_direction(IL3820_DC_PIN, GPIO_MODE_OUTPUT);
201201

202-
#if IL3820_USE_RST
203-
gpio_pad_select_gpio(IL3820_RST_PIN);
204-
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
205-
#endif
206-
207202
gpio_pad_select_gpio(IL3820_BUSY_PIN);
208203
gpio_set_direction(IL3820_BUSY_PIN, GPIO_MODE_INPUT);
209204

210205
#if IL3820_USE_RST
206+
gpio_pad_select_gpio(IL3820_RST_PIN);
207+
gpio_set_direction(IL3820_RST_PIN, GPIO_MODE_OUTPUT);
208+
211209
/* Harware reset */
212210
gpio_set_level( IL3820_RST_PIN, 0);
213211
vTaskDelay(IL3820_RESET_DELAY / portTICK_RATE_MS);

lvgl_tft/ili9163c.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ void ili9163c_init(void)
143143
gpio_pad_select_gpio(ILI9163C_RST);
144144
gpio_set_direction(ILI9163C_RST, GPIO_MODE_OUTPUT);
145145

146-
#if ILI9163C_ENABLE_BACKLIGHT_CONTROL
147-
gpio_pad_select_gpio(ILI9163C_BCKL);
148-
gpio_set_direction(ILI9163C_BCKL, GPIO_MODE_OUTPUT);
149-
#endif
150146
//Reset the display
151147
gpio_set_level(ILI9163C_RST, 0);
152148
vTaskDelay(100 / portTICK_RATE_MS);
@@ -166,8 +162,6 @@ void ili9163c_init(void)
166162
cmd++;
167163
}
168164

169-
ili9163c_enable_backlight(true);
170-
171165
ili9163c_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
172166
}
173167

@@ -199,22 +193,6 @@ void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color
199193
ili9163c_send_color((void *)color_map, size * 2);
200194
}
201195

202-
void ili9163c_enable_backlight(bool backlight)
203-
{
204-
#if ILI9163C_ENABLE_BACKLIGHT_CONTROL
205-
ESP_LOGD(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
206-
uint32_t tmp = 0;
207-
208-
#if (ILI9163C_BCKL_ACTIVE_LVL == 1)
209-
tmp = backlight ? 1 : 0;
210-
#else
211-
tmp = backlight ? 0 : 1;
212-
#endif
213-
214-
gpio_set_level(ILI9163C_BCKL, tmp);
215-
#endif
216-
}
217-
218196
void ili9163c_sleep_in()
219197
{
220198
uint8_t data[] = {0x08};

lvgl_tft/ili9163c.h

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,24 @@ extern "C"
2626
/*********************
2727
* DEFINES
2828
*********************/
29-
#define ILI9163C_DC CONFIG_LV_DISP_PIN_DC
30-
#define ILI9163C_RST CONFIG_LV_DISP_PIN_RST
31-
#define ILI9163C_BCKL CONFIG_LV_DISP_PIN_BCKL
32-
33-
#define ILI9163C_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
34-
35-
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
36-
#define ILI9163C_BCKL_ACTIVE_LVL 1
37-
#else
38-
#define ILI9163C_BCKL_ACTIVE_LVL 0
39-
#endif
40-
29+
#define ILI9163C_DC CONFIG_LV_DISP_PIN_DC
30+
#define ILI9163C_RST CONFIG_LV_DISP_PIN_RST
4131
#define ILI9163C_INVERT_COLORS CONFIG_LV_INVERT_COLORS
4232

43-
/**********************
33+
/**********************
4434
* TYPEDEFS
4535
**********************/
4636

47-
/**********************
37+
/**********************
4838
* GLOBAL PROTOTYPES
4939
**********************/
5040

51-
void ili9163c_init(void);
52-
void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
53-
void ili9163c_enable_backlight(bool backlight);
54-
void ili9163c_sleep_in(void);
55-
void ili9163c_sleep_out(void);
41+
void ili9163c_init(void);
42+
void ili9163c_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
43+
void ili9163c_sleep_in(void);
44+
void ili9163c_sleep_out(void);
5645

57-
/**********************
46+
/**********************
5847
* MACROS
5948
**********************/
6049

lvgl_tft/ili9341.c

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,14 @@ void ili9341_init(void)
8080
{0, {0}, 0xff},
8181
};
8282

83-
#if ILI9341_BCKL == 15
84-
gpio_config_t io_conf;
85-
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
86-
io_conf.mode = GPIO_MODE_OUTPUT;
87-
io_conf.pin_bit_mask = GPIO_SEL_15;
88-
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
89-
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
90-
gpio_config(&io_conf);
91-
#endif
92-
9383
//Initialize non-SPI GPIOs
94-
gpio_pad_select_gpio(ILI9341_DC);
84+
gpio_pad_select_gpio(ILI9341_DC);
9585
gpio_set_direction(ILI9341_DC, GPIO_MODE_OUTPUT);
86+
9687
#if ILI9341_USE_RST
97-
gpio_pad_select_gpio(ILI9341_RST);
88+
gpio_pad_select_gpio(ILI9341_RST);
9889
gpio_set_direction(ILI9341_RST, GPIO_MODE_OUTPUT);
99-
#endif
100-
101-
#if ILI9341_ENABLE_BACKLIGHT_CONTROL
102-
gpio_pad_select_gpio(ILI9341_BCKL);
103-
gpio_set_direction(ILI9341_BCKL, GPIO_MODE_OUTPUT);
104-
#endif
10590

106-
#if ILI9341_USE_RST
10791
//Reset the display
10892
gpio_set_level(ILI9341_RST, 0);
10993
vTaskDelay(100 / portTICK_RATE_MS);
@@ -124,9 +108,7 @@ void ili9341_init(void)
124108
cmd++;
125109
}
126110

127-
ili9341_enable_backlight(true);
128-
129-
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
111+
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
130112

131113
#if ILI9341_INVERT_COLORS == 1
132114
ili9341_send_cmd(0x21);
@@ -158,29 +140,10 @@ void ili9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
158140

159141
/*Memory write*/
160142
ili9341_send_cmd(0x2C);
161-
162-
163143
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
164-
165144
ili9341_send_color((void*)color_map, size * 2);
166145
}
167146

168-
void ili9341_enable_backlight(bool backlight)
169-
{
170-
#if ILI9341_ENABLE_BACKLIGHT_CONTROL
171-
ESP_LOGI(TAG, "%s backlight.", backlight ? "Enabling" : "Disabling");
172-
uint32_t tmp = 0;
173-
174-
#if (ILI9341_BCKL_ACTIVE_LVL==1)
175-
tmp = backlight ? 1 : 0;
176-
#else
177-
tmp = backlight ? 0 : 1;
178-
#endif
179-
180-
gpio_set_level(ILI9341_BCKL, tmp);
181-
#endif
182-
}
183-
184147
void ili9341_sleep_in()
185148
{
186149
uint8_t data[] = {0x08};

lvgl_tft/ili9341.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ extern "C" {
2929
#define ILI9341_DC CONFIG_LV_DISP_PIN_DC
3030
#define ILI9341_USE_RST CONFIG_LV_DISP_USE_RST
3131
#define ILI9341_RST CONFIG_LV_DISP_PIN_RST
32-
#define ILI9341_BCKL CONFIG_LV_DISP_PIN_BCKL
33-
34-
#define ILI9341_ENABLE_BACKLIGHT_CONTROL CONFIG_LV_ENABLE_BACKLIGHT_CONTROL
35-
36-
#if CONFIG_LV_BACKLIGHT_ACTIVE_LVL
37-
#define ILI9341_BCKL_ACTIVE_LVL 1
38-
#else
39-
#define ILI9341_BCKL_ACTIVE_LVL 0
40-
#endif
41-
4232
#define ILI9341_INVERT_COLORS CONFIG_LV_INVERT_COLORS
4333

4434
/**********************
@@ -51,7 +41,6 @@ extern "C" {
5141

5242
void ili9341_init(void);
5343
void ili9341_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map);
54-
void ili9341_enable_backlight(bool backlight);
5544
void ili9341_sleep_in(void);
5645
void ili9341_sleep_out(void);
5746

0 commit comments

Comments
 (0)