Skip to content

Commit 8ba252e

Browse files
authored
Develop (#216)
* Minor fix: add != NULL * Fixed typo in log * Pinned LVGL version to 9.2.0 (exact) * Changed the order of enabling interrupts (#196) Corrected interrupts leven pos/neg edge * Remove sw_rotate (#210) * Remove sw_rotate * Removed unused code * LVGL version to 9.2.2 * Enable all devices * Updated markdown * Lvgl9.2.2 (#211) * Remove sw_rotate * Removed unused code * LVGL version to 9.2.2 * Enable all devices * Updated markdown * Test hardware rotation st7701 * Test use underlying driver for swap and mirror * Reenabled code * test * Use define for DISPLAY_SOFTWARE_ROTATION * Update boards to develop * Added check for rst_gpio_num == GPIO_NUM_NC (#215)
1 parent a6ddcc0 commit 8ba252e

15 files changed

+132
-103
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ The following libraries are used from the [Espressif component registry](https:/
595595

596596
## Version history
597597

598+
- October 2024
599+
- Fix for LVGL 9.2.2 that removed the sw_rotate flag
598600
- August 2024
599601
- LVGL 9.2
600602
- New boards

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@
3535
"frameworks": "arduino",
3636
"platforms": "espressif32",
3737
"dependencies": {
38-
"lvgl/lvgl": "^9.2.0"
38+
"lvgl/lvgl": "^9.2.2"
3939
}
4040
}

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ build_flags =
5959
'-D ESP_LCD_PANEL_IO_ADDITIONS_VER_PATCH=1'
6060

6161
lib_deps =
62-
lvgl/lvgl@^9.2.0
62+
lvgl/lvgl@^9.2.2
6363
# The platformio.test_dir contains the test_main.cpp just to have an setup() and loop() function
6464
# so it will compile
6565
${platformio.test_dir}

src/esp32_smartdisplay.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ void smartdisplay_lcd_set_brightness_cb(smartdisplay_lcd_adaptive_brightness_cb_
9494
log_v("adaptive_brightness_cb:0x%08x, interval:%u", cb, interval);
9595

9696
// Delete current timer if any
97-
if (update_brightness_timer)
97+
if (update_brightness_timer != NULL)
9898
lv_timer_del(update_brightness_timer);
9999

100100
// Use callback for intensity or 50% default
101-
if (cb && interval > 0)
101+
if (cb != NULL && interval > 0)
102102
update_brightness_timer = lv_timer_create(adaptive_brightness, interval, cb);
103103
else
104104
smartdisplay_lcd_set_backlight(0.5f);
@@ -107,7 +107,7 @@ void smartdisplay_lcd_set_brightness_cb(smartdisplay_lcd_adaptive_brightness_cb_
107107
#ifdef BOARD_HAS_RGB_LED
108108
void smartdisplay_led_set_rgb(bool r, bool g, bool b)
109109
{
110-
log_d("R:%d, G:%d, B:%d", r, b, b);
110+
log_d("R:%d, G:%d, B:%d", r, g, b);
111111

112112
digitalWrite(RGB_LED_R, !r);
113113
digitalWrite(RGB_LED_G, !g);
@@ -193,9 +193,11 @@ void smartdisplay_init()
193193
#endif
194194
// Setup TFT display
195195
display = lvgl_lcd_init();
196+
197+
#ifndef DISPLAY_SOFTWARE_ROTATION
196198
// Register callback for hardware rotation
197-
if (!display->sw_rotate)
198-
lv_display_add_event_cb(display, lvgl_display_resolution_changed_callback, LV_EVENT_RESOLUTION_CHANGED, NULL);
199+
lv_display_add_event_cb(display, lvgl_display_resolution_changed_callback, LV_EVENT_RESOLUTION_CHANGED, NULL);
200+
#endif
199201

200202
// Clear screen
201203
lv_obj_clean(lv_scr_act());
@@ -214,10 +216,11 @@ void smartdisplay_init()
214216
#endif
215217
}
216218

219+
#ifndef DISPLAY_SOFTWARE_ROTATION
217220
// Called when driver resolution is updated (including rotation)
218221
// Top of the display is top left when connector is at the bottom
219222
// The rotation values are relative to how you would rotate the physical display in the clockwise direction.
220-
// Thus, LV_DISPLAY_ROTATION_90 means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate.
223+
// So, LV_DISPLAY_ROTATION_90 means you rotate the hardware 90 degrees clockwise, and the display rotates 90 degrees counterclockwise to compensate.
221224
void lvgl_display_resolution_changed_callback(lv_event_t *event)
222225
{
223226
const esp_lcd_panel_handle_t panel_handle = display->user_data;
@@ -240,4 +243,6 @@ void lvgl_display_resolution_changed_callback(lv_event_t *event)
240243
ESP_ERROR_CHECK(esp_lcd_panel_mirror(panel_handle, !DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y));
241244
break;
242245
}
243-
}
246+
}
247+
248+
#endif

src/esp_touch_cst816s.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ esp_err_t cst816s_reset(esp_lcd_touch_handle_t th)
8686
if (th == NULL)
8787
return ESP_ERR_INVALID_ARG;
8888

89+
if (th->config.rst_gpio_num == GPIO_NUM_NC)
90+
{
91+
log_w("No RST pin defined");
92+
return ESP_OK;
93+
}
94+
8995
esp_err_t res;
9096
// Set RST active
9197
if ((res = gpio_set_level(th->config.rst_gpio_num, th->config.levels.reset)) != ESP_OK)
@@ -259,14 +265,29 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
259265
memcpy(&th->config, config, sizeof(esp_lcd_touch_config_t));
260266
portMUX_INITIALIZE(&th->data.lock);
261267

268+
// Reset controller
269+
if ((res = cst816s_reset(th)) != ESP_OK)
270+
{
271+
log_e("GT911 reset failed");
272+
cst816s_del(th);
273+
return res;
274+
}
275+
276+
// Read type and resolution
277+
if ((res = cst816s_read_info(th)) != ESP_OK)
278+
{
279+
log_e("GT911 read info failed");
280+
cst816s_del(th);
281+
return res;
282+
}
283+
262284
if (config->int_gpio_num != GPIO_NUM_NC)
263285
{
264286
esp_rom_gpio_pad_select_gpio(config->int_gpio_num);
265287
const gpio_config_t cfg = {
266288
.pin_bit_mask = BIT64(config->int_gpio_num),
267289
.mode = GPIO_MODE_INPUT,
268-
// If the user has provided a callback routine for the interrupt enable the interrupt mode on the negative edge.
269-
.intr_type = config->interrupt_callback ? GPIO_INTR_NEGEDGE : GPIO_INTR_DISABLE};
290+
.intr_type = config->levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE};
270291
if ((res = gpio_config(&cfg)) != ESP_OK)
271292
{
272293
free(th);
@@ -278,9 +299,11 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
278299
{
279300
if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK)
280301
{
281-
gpio_reset_pin(th->config.int_gpio_num);
302+
if (config->int_gpio_num != GPIO_NUM_NC)
303+
gpio_reset_pin(th->config.int_gpio_num);
304+
282305
free(th);
283-
log_e("Registering INT callback failed");
306+
log_e("Registering interrupt callback failed");
284307
return res;
285308
}
286309
}
@@ -306,22 +329,6 @@ esp_err_t esp_lcd_touch_new_i2c_cst816s(const esp_lcd_panel_io_handle_t io, cons
306329
return res;
307330
}
308331
}
309-
310-
// Reset controller
311-
if ((res = cst816s_reset(th)) != ESP_OK)
312-
{
313-
log_e("GT911 reset failed");
314-
cst816s_del(th);
315-
return res;
316-
}
317-
318-
// Read type and resolution
319-
if ((res = cst816s_read_info(th)) != ESP_OK)
320-
{
321-
log_e("GT911 read info failed");
322-
cst816s_del(th);
323-
return res;
324-
}
325332
}
326333

327334
log_d("handle:0x%08x", th);

src/esp_touch_gt911.c

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ esp_err_t gt911_reset(esp_lcd_touch_handle_t th)
8282
if (th == NULL)
8383
return ESP_ERR_INVALID_ARG;
8484

85+
if (th->config.rst_gpio_num == GPIO_NUM_NC)
86+
{
87+
log_w("No RST pin defined");
88+
return ESP_OK;
89+
}
90+
8591
esp_err_t res;
8692
// Set RST active
8793
if ((res = gpio_set_level(th->config.rst_gpio_num, th->config.levels.reset)) != ESP_OK)
@@ -397,53 +403,19 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const
397403
memcpy(&th->config, config, sizeof(esp_lcd_touch_config_t));
398404
portMUX_INITIALIZE(&th->data.lock);
399405

400-
if (config->int_gpio_num != GPIO_NUM_NC)
406+
// Initialize RST pin
407+
if (config->rst_gpio_num != GPIO_NUM_NC)
401408
{
402-
esp_rom_gpio_pad_select_gpio(config->int_gpio_num);
409+
esp_rom_gpio_pad_select_gpio(config->rst_gpio_num);
403410
const gpio_config_t cfg = {
404-
.pin_bit_mask = BIT64(config->int_gpio_num),
405-
.mode = GPIO_MODE_INPUT,
406-
// If the user has provided a callback routine for the interrupt enable the interrupt mode on the negative edge.
407-
.intr_type = config->interrupt_callback ? GPIO_INTR_NEGEDGE : GPIO_INTR_DISABLE};
411+
.pin_bit_mask = BIT64(config->rst_gpio_num),
412+
.mode = GPIO_MODE_OUTPUT};
408413
if ((res = gpio_config(&cfg)) != ESP_OK)
409414
{
410415
free(th);
411-
log_e("Configuring GPIO for INT failed");
416+
log_e("Configuring or setting GPIO for RST failed");
412417
return res;
413418
}
414-
415-
if (config->interrupt_callback != NULL)
416-
{
417-
if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK)
418-
{
419-
gpio_reset_pin(th->config.int_gpio_num);
420-
free(th);
421-
log_e("Registering INT callback failed");
422-
return res;
423-
}
424-
}
425-
426-
if (config->rst_gpio_num != GPIO_NUM_NC)
427-
{
428-
esp_rom_gpio_pad_select_gpio(config->rst_gpio_num);
429-
const gpio_config_t cfg = {
430-
.pin_bit_mask = BIT64(config->rst_gpio_num),
431-
.mode = GPIO_MODE_OUTPUT};
432-
if ((res = gpio_config(&cfg)) != ESP_OK)
433-
{
434-
if (th->config.int_gpio_num != GPIO_NUM_NC)
435-
{
436-
if (config->interrupt_callback != NULL)
437-
gpio_isr_handler_remove(th->config.int_gpio_num);
438-
439-
gpio_reset_pin(th->config.int_gpio_num);
440-
}
441-
442-
free(th);
443-
log_e("Configuring or setting GPIO for RST failed");
444-
return res;
445-
}
446-
}
447419
}
448420

449421
// Reset controller
@@ -462,6 +434,32 @@ esp_err_t esp_lcd_touch_new_i2c_gt911(const esp_lcd_panel_io_handle_t io, const
462434
return res;
463435
}
464436

437+
if (config->int_gpio_num != GPIO_NUM_NC)
438+
{
439+
esp_rom_gpio_pad_select_gpio(config->int_gpio_num);
440+
const gpio_config_t cfg = {
441+
.pin_bit_mask = BIT64(config->int_gpio_num),
442+
.mode = GPIO_MODE_INPUT,
443+
.intr_type = config->levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE};
444+
if ((res = gpio_config(&cfg)) != ESP_OK)
445+
{
446+
free(th);
447+
log_e("Configuring GPIO for INT failed");
448+
return res;
449+
}
450+
451+
if (config->interrupt_callback != NULL)
452+
{
453+
if ((res = esp_lcd_touch_register_interrupt_callback(th, config->interrupt_callback)) != ESP_OK)
454+
{
455+
gpio_reset_pin(th->config.int_gpio_num);
456+
free(th);
457+
log_e("Registering interrupt callback failed");
458+
return res;
459+
}
460+
}
461+
}
462+
465463
log_d("handle:0x%08x", th);
466464
*handle = th;
467465

src/esp_touch_xpt2046.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ esp_err_t esp_lcd_touch_new_spi_xpt2046(const esp_lcd_panel_io_handle_t io, cons
204204
const gpio_config_t cfg = {
205205
.pin_bit_mask = BIT64(config->int_gpio_num),
206206
.mode = GPIO_MODE_INPUT,
207-
// If the user has provided a callback routine for the interrupt enable the interrupt mode on the negative edge.
208-
.intr_type = config->interrupt_callback ? GPIO_INTR_NEGEDGE : GPIO_INTR_DISABLE};
207+
.intr_type = config->levels.interrupt ? GPIO_INTR_POSEDGE : GPIO_INTR_NEGEDGE};
209208
if ((res = gpio_config(&cfg)) != ESP_OK)
210209
{
211210
free(th);
@@ -219,7 +218,7 @@ esp_err_t esp_lcd_touch_new_spi_xpt2046(const esp_lcd_panel_io_handle_t io, cons
219218
{
220219
gpio_reset_pin(th->config.int_gpio_num);
221220
free(th);
222-
log_e("Registering INT callback failed");
221+
log_e("Registering interrupt callback failed");
223222
return res;
224223
}
225224
}

src/lvgl_panel_gc9a01_spi.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bool gc9a01_color_trans_done(esp_lcd_panel_io_handle_t panel_io_handle, esp_lcd_
1717

1818
void gc9a01_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map)
1919
{
20+
// Hardware rotation is supported
2021
log_v("display:0x%08x, area:%0x%08x, color_map:0x%08x", display, area, px_map);
2122

2223
esp_lcd_panel_handle_t panel_handle = display->user_data;
@@ -40,10 +41,6 @@ lv_display_t *lvgl_lcd_init()
4041
void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS);
4142
lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL);
4243

43-
// Hardware rotation is supported
44-
display->sw_rotate = 0;
45-
display->rotation = LV_DISPLAY_ROTATION_0;
46-
4744
// Create SPI bus
4845
const spi_bus_config_t spi_bus_config = {
4946
.mosi_io_num = GC9A01_SPI_BUS_MOSI_IO_NUM,

src/lvgl_panel_ili9341_spi.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ bool ili9341_color_trans_done(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_
1515

1616
void ili9341_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map)
1717
{
18+
// Hardware rotation is supported
1819
esp_lcd_panel_handle_t panel_handle = display->user_data;
1920
uint32_t pixels = lv_area_get_size(area);
2021
uint16_t *p = (uint16_t *)px_map;
@@ -36,10 +37,6 @@ lv_display_t *lvgl_lcd_init()
3637
void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS);
3738
lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL);
3839

39-
// Hardware rotation is supported
40-
display->sw_rotate = 0;
41-
display->rotation = LV_DISPLAY_ROTATION_0;
42-
4340
// Create SPI bus
4441
const spi_bus_config_t spi_bus_config = {
4542
.mosi_io_num = ILI9341_SPI_BUS_MOSI_IO_NUM,

src/lvgl_panel_st7262_par.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ bool direct_io_frame_trans_done(esp_lcd_panel_handle_t panel, esp_lcd_rgb_panel_
1313

1414
void direct_io_lv_flush(lv_display_t *display, const lv_area_t *area, uint8_t *px_map)
1515
{
16+
// Hardware rotation is not supported
1617
const esp_lcd_panel_handle_t panel_handle = display->user_data;
1718

1819
lv_display_rotation_t rotation = lv_display_get_rotation(display);
@@ -68,10 +69,6 @@ lv_display_t *lvgl_lcd_init()
6869
void *drawBuffer = heap_caps_malloc(drawBufferSize, LVGL_BUFFER_MALLOC_FLAGS);
6970
lv_display_set_buffers(display, drawBuffer, NULL, drawBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL);
7071

71-
// Hardware rotation is not supported
72-
display->sw_rotate = 1;
73-
display->rotation = LV_DISPLAY_ROTATION_0;
74-
7572
// Create direct_io panel handle
7673
const esp_lcd_rgb_panel_config_t rgb_panel_config = {
7774
.clk_src = ST7262_PANEL_CONFIG_CLK_SRC,

0 commit comments

Comments
 (0)