Skip to content

Commit ee66ac9

Browse files
authored
Merge pull request #727 from espressif/petr/fix/lvgl_port_encoder
Add encoder event and filter indev readings by event types
2 parents acc2fdf + a8feac2 commit ee66ac9

File tree

12 files changed

+49
-57
lines changed

12 files changed

+49
-57
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Here is a summary of the available examples:
7575
| [Camera Example](examples/display_camera) | Stream camera output to display (LVGL) | <details><summary>4 boards</summary>[esp32_s2_kaluga_kit](bsp/esp32_s2_kaluga_kit)<br/>[esp32_s3_eye](bsp/esp32_s3_eye)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_camera-) |
7676
| [Camera Example (MIPI-CSI)](examples/display_camera_csi) | Stream camera (MIPI-CSI) output to display (LVGL) | <details><summary>3 boards</summary>[esp32_p4_eye](bsp/esp32_p4_eye)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_camera-) |
7777
| [LVGL Benchmark Example](examples/display_lvgl_benchmark) | Run LVGL benchmark tests | <details><summary>10 boards</summary>[esp-box](bsp/esp-box)<br/>[esp-box-3](bsp/esp-box-3)<br/>[esp-box-lite](bsp/esp-box-lite)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s2_kaluga_kit](bsp/esp32_s2_kaluga_kit)<br/>[esp32_s3_eye](bsp/esp32_s3_eye)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp32_s3_lcd_ev_board](bsp/esp32_s3_lcd_ev_board)<br/>[m5dial](bsp/m5dial)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)</details> | - |
78-
| [LVGL Demos Example](examples/display_lvgl_demos) | Run the LVGL demo player - all LVGL examples are included (LVGL) | <details><summary>12 boards</summary>[esp-box](bsp/esp-box)<br/>[esp-box-3](bsp/esp-box-3)<br/>[esp-box-lite](bsp/esp-box-lite)<br/>[esp32_p4_eye](bsp/esp32_p4_eye)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s2_kaluga_kit](bsp/esp32_s2_kaluga_kit)<br/>[esp32_s3_eye](bsp/esp32_s3_eye)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp32_s3_lcd_ev_board](bsp/esp32_s3_lcd_ev_board)<br/>[m5dial](bsp/m5dial)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_lvgl_demos-) |
78+
| [LVGL Demos Example](examples/display_lvgl_demos) | Run the LVGL demo player - all LVGL examples are included (LVGL) | <details><summary>11 boards</summary>[esp-box](bsp/esp-box)<br/>[esp-box-3](bsp/esp-box-3)<br/>[esp-box-lite](bsp/esp-box-lite)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s2_kaluga_kit](bsp/esp32_s2_kaluga_kit)<br/>[esp32_s3_eye](bsp/esp32_s3_eye)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp32_s3_lcd_ev_board](bsp/esp32_s3_lcd_ev_board)<br/>[m5dial](bsp/m5dial)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_lvgl_demos-) |
7979
| [Display Rotation Example](examples/display_rotation) | Rotate screen using buttons or an accelerometer (`BSP_CAPS_IMU`, if available) | <details><summary>11 boards</summary>[esp-box](bsp/esp-box)<br/>[esp-box-3](bsp/esp-box-3)<br/>[esp-box-lite](bsp/esp-box-lite)<br/>[esp32_p4_eye](bsp/esp32_p4_eye)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[esp32_s3_lcd_ev_board](bsp/esp32_s3_lcd_ev_board)<br/>[m5dial](bsp/m5dial)<br/>[m5stack_core](bsp/m5stack_core)<br/>[m5stack_core_s3](bsp/m5stack_core_s3)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_rotation-) |
8080
| [Display SD card Example](examples/display_sdcard) | Example of mounting an SD card using SD-MMC/SPI with display interaction. This example is also supported on boards without a display. | <details><summary>4 boards</summary>[esp-box-3](bsp/esp-box-3)<br/>[esp32_p4_function_ev_board](bsp/esp32_p4_function_ev_board)<br/>[esp32_s3_korvo_2](bsp/esp32_s3_korvo_2)<br/>[m5stack_tab5](bsp/m5stack_tab5)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sdcard) |
8181
| [Sensors Example](examples/display_sensors) | Display sensor data on a monochrome screen (LVGL) | <details><summary>1 board</summary>[esp32_azure_iot_kit](bsp/esp32_azure_iot_kit)</details> | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_sensors-) |

bsp/esp32_p4_eye/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ ESP32-P4-EYE is a vision development board based on the ESP32-P4 chip, mainly ta
5656
| ------- | ----------- | ---------------------- |
5757
| [Display Example](https://github.com/espressif/esp-bsp/tree/master/examples/display) | Show an image on the screen with a simple startup animation (LVGL) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display-) |
5858
| [Camera Example (MIPI-CSI)](https://github.com/espressif/esp-bsp/tree/master/examples/display_camera_csi) | Stream camera (MIPI-CSI) output to display (LVGL) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_camera-) |
59-
| [LVGL Demos Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_lvgl_demos) | Run the LVGL demo player - all LVGL examples are included (LVGL) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_lvgl_demos-) |
6059
| [Display Rotation Example](https://github.com/espressif/esp-bsp/tree/master/examples/display_rotation) | Rotate screen using buttons or an accelerometer (`BSP_CAPS_IMU`, if available) | [Flash Example](https://espressif.github.io/esp-launchpad/?flashConfigURL=https://espressif.github.io/esp-bsp/config.toml&app=display_rotation-) |
6160

6261
<!-- END_EXAMPLES -->
63-
</div>
62+
</div>

components/esp_lvgl_port/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 2.7.2
4+
5+
### Features
6+
7+
- Added a new event type for encoder events
8+
9+
### Fixes
10+
11+
- Encoder usage no longer causes unexpected touch controller readings - https://github.com/espressif/esp-bsp/issues/700
12+
313
## 2.7.1
414

515
### Features

components/esp_lvgl_port/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "2.7.1"
1+
version: "2.7.2"
22
description: ESP LVGL port
33
url: https://github.com/espressif/esp-bsp/tree/master/components/esp_lvgl_port
44
dependencies:

components/esp_lvgl_port/include/esp_lvgl_port.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern "C" {
3434
typedef enum {
3535
LVGL_PORT_EVENT_DISPLAY = 0x01,
3636
LVGL_PORT_EVENT_TOUCH = 0x02,
37+
LVGL_PORT_EVENT_ENCODER = 0x04,
3738
LVGL_PORT_EVENT_USER = 0x80,
3839
} lvgl_port_event_type_t;
3940

components/esp_lvgl_port/src/lvgl9/esp_lvgl_port.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static lvgl_port_ctx_t lvgl_port_ctx;
4848
static void lvgl_port_task(void *arg);
4949
static esp_err_t lvgl_port_tick_init(void);
5050
static void lvgl_port_task_deinit(void);
51+
static inline bool indev_matches_event(const lv_indev_t *indev, EventBits_t event);
5152

5253
/*******************************************************************************
5354
* Public API functions
@@ -225,11 +226,13 @@ static void lvgl_port_task(void *arg)
225226
if (lv_display_get_default() && lvgl_port_lock(0)) {
226227

227228
/* Call read input devices */
228-
if (events & LVGL_PORT_EVENT_TOUCH) {
229+
if (events & LVGL_PORT_EVENT_TOUCH || events & LVGL_PORT_EVENT_ENCODER) {
229230
xSemaphoreTake(lvgl_port_ctx.timer_mux, portMAX_DELAY);
230231
indev = lv_indev_get_next(NULL);
231232
while (indev != NULL) {
232-
lv_indev_read(indev);
233+
if (indev_matches_event(indev, events)) {
234+
lv_indev_read(indev);
235+
}
233236
indev = lv_indev_get_next(indev);
234237
}
235238
xSemaphoreGive(lvgl_port_ctx.timer_mux);
@@ -302,3 +305,23 @@ static esp_err_t lvgl_port_tick_init(void)
302305
"Creating LVGL timer filed!");
303306
return esp_timer_start_periodic(lvgl_port_ctx.tick_timer, lvgl_port_ctx.timer_period_ms * 1000);
304307
}
308+
309+
static inline bool indev_matches_event(const lv_indev_t *indev, EventBits_t event)
310+
{
311+
assert(indev != NULL);
312+
313+
bool does_match = false;
314+
315+
switch (lv_indev_get_type(indev)) {
316+
case LV_INDEV_TYPE_KEYPAD:
317+
case LV_INDEV_TYPE_POINTER:
318+
does_match = event & LVGL_PORT_EVENT_TOUCH;
319+
break;
320+
case LV_INDEV_TYPE_ENCODER:
321+
does_match = event & LVGL_PORT_EVENT_ENCODER;
322+
break;
323+
default:
324+
does_match = false;
325+
}
326+
return does_match;
327+
}

components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_button.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void lvgl_port_btn_down_handler(void *arg, void *arg2)
203203
}
204204

205205
/* Wake LVGL task, if needed */
206-
lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev);
206+
lvgl_port_task_wake(LVGL_PORT_EVENT_ENCODER, ctx->indev);
207207
}
208208

209209
static void lvgl_port_btn_up_handler(void *arg, void *arg2)
@@ -226,5 +226,5 @@ static void lvgl_port_btn_up_handler(void *arg, void *arg2)
226226
}
227227

228228
/* Wake LVGL task, if needed */
229-
lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev);
229+
lvgl_port_task_wake(LVGL_PORT_EVENT_ENCODER, ctx->indev);
230230
}

components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_knob.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void lvgl_port_encoder_btn_down_handler(void *button_handle, void *usr_da
169169
}
170170

171171
/* Wake LVGL task, if needed */
172-
lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev);
172+
lvgl_port_task_wake(LVGL_PORT_EVENT_ENCODER, ctx->indev);
173173
}
174174

175175
static void lvgl_port_encoder_btn_up_handler(void *button_handle, void *usr_data)
@@ -184,7 +184,7 @@ static void lvgl_port_encoder_btn_up_handler(void *button_handle, void *usr_data
184184
}
185185

186186
/* Wake LVGL task, if needed */
187-
lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev);
187+
lvgl_port_task_wake(LVGL_PORT_EVENT_ENCODER, ctx->indev);
188188
}
189189

190190
static void lvgl_port_encoder_left_handler(void *arg, void *arg2)
@@ -198,7 +198,7 @@ static void lvgl_port_encoder_left_handler(void *arg, void *arg2)
198198
ctx->diff = (ctx->diff > 0) ? diff : ctx->diff + diff;
199199
}
200200
/* Wake LVGL task, if needed */
201-
lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev);
201+
lvgl_port_task_wake(LVGL_PORT_EVENT_ENCODER, ctx->indev);
202202
}
203203
}
204204

@@ -213,7 +213,7 @@ static void lvgl_port_encoder_right_handler(void *arg, void *arg2)
213213
ctx->diff = (ctx->diff < 0) ? diff : ctx->diff + diff;
214214
}
215215
/* Wake LVGL task, if needed */
216-
lvgl_port_task_wake(LVGL_PORT_EVENT_TOUCH, ctx->indev);
216+
lvgl_port_task_wake(LVGL_PORT_EVENT_ENCODER, ctx->indev);
217217
}
218218
}
219219

examples/display_lvgl_demos/partitions.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
33
nvs, data, nvs, 0x9000, 0x6000,
44
phy_init, data, phy, 0xf000, 0x1000,
5-
factory, app, factory, 0x10000, 0x160000,
5+
factory, app, factory, 0x10000, 0x180000,

examples/display_lvgl_demos/sdkconfig.bsp.esp32_p4_eye

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)