Skip to content

Commit

Permalink
modules: lvgl: retain last event for button/pointer device
Browse files Browse the repository at this point in the history
Adds saving of the last lv_indev_data_t for button and pointer type
devices. This is needed because there is currently no way to tell LVGL in
the read callback that no event is pending. Preservation of the last state
is expected to happen in the port layer for the input devices.
This resolves issue zephyrproject-rtos#62512.

Signed-off-by: Fabian Blatz <[email protected]>
  • Loading branch information
faxe1008 authored and fabiobaltieri committed Sep 19, 2023
1 parent b142e9d commit 2ea2d37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/lvgl/include/lvgl_common_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct lvgl_common_input_data {
lv_indev_drv_t indev_drv;
lv_indev_t *indev;
lv_indev_data_t pending_event;
lv_indev_data_t previous_event;
};

int lvgl_input_register_driver(lv_indev_type_t indev_type, const struct device *dev);
Expand Down
12 changes: 11 additions & 1 deletion modules/lvgl/input/lvgl_common_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ static void lvgl_input_read_cb(lv_indev_drv_t *drv, lv_indev_data_t *data)
{
const struct device *dev = drv->user_data;
const struct lvgl_common_input_config *cfg = dev->config;
struct lvgl_common_input_data *common_data = dev->data;

if (k_msgq_get(cfg->event_msgq, data, K_NO_WAIT) != 0) {
memcpy(data, &common_data->previous_event, sizeof(lv_indev_data_t));
if (drv->type == LV_INDEV_TYPE_ENCODER) {
data->enc_diff = 0; /* For encoders, clear last movement */
}
data->continue_reading = false;
return;
}

k_msgq_get(cfg->event_msgq, data, K_NO_WAIT);
memcpy(&common_data->previous_event, data, sizeof(lv_indev_data_t));
data->continue_reading = k_msgq_num_used_get(cfg->event_msgq) > 0;
}

Expand Down

0 comments on commit 2ea2d37

Please sign in to comment.