Skip to content

Commit

Permalink
Use driver_data instead of user_data (BSP-600) (#457)
Browse files Browse the repository at this point in the history
* Use driver_data instead of user_data
  • Loading branch information
KenVanHoeylandt authored Jan 3, 2025
1 parent 479cb0a commit 056eb69
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ lv_indev_t *lvgl_port_add_navigation_buttons(const lvgl_port_nav_btns_cfg_t *but
lv_indev_set_mode(indev, LV_INDEV_MODE_EVENT);
lv_indev_set_read_cb(indev, lvgl_port_navigation_buttons_read);
lv_indev_set_disp(indev, buttons_cfg->disp);
lv_indev_set_user_data(indev, buttons_ctx);
lv_indev_set_driver_data(indev, buttons_ctx);
//buttons_ctx->indev->long_press_repeat_time = 300;
buttons_ctx->indev = indev;
lvgl_port_unlock();
Expand All @@ -117,7 +117,7 @@ lv_indev_t *lvgl_port_add_navigation_buttons(const lvgl_port_nav_btns_cfg_t *but
esp_err_t lvgl_port_remove_navigation_buttons(lv_indev_t *buttons)
{
assert(buttons);
lvgl_port_nav_btns_ctx_t *buttons_ctx = (lvgl_port_nav_btns_ctx_t *)lv_indev_get_user_data(buttons);
lvgl_port_nav_btns_ctx_t *buttons_ctx = (lvgl_port_nav_btns_ctx_t *)lv_indev_get_driver_data(buttons);

lvgl_port_lock(0);
/* Remove input device driver */
Expand All @@ -141,7 +141,7 @@ static void lvgl_port_navigation_buttons_read(lv_indev_t *indev_drv, lv_indev_da
static uint32_t last_key = 0;

assert(indev_drv);
lvgl_port_nav_btns_ctx_t *ctx = (lvgl_port_nav_btns_ctx_t *)lv_indev_get_user_data(indev_drv);
lvgl_port_nav_btns_ctx_t *ctx = (lvgl_port_nav_btns_ctx_t *)lv_indev_get_driver_data(indev_drv);
assert(ctx);

/* Buttons */
Expand Down
18 changes: 9 additions & 9 deletions components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ lv_display_t *lvgl_port_add_disp(const lvgl_port_display_cfg_t *disp_cfg)
lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, NULL);

if (disp != NULL) {
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(disp);
/* Set display type */
disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_OTHER;

Expand Down Expand Up @@ -119,7 +119,7 @@ lv_display_t *lvgl_port_add_disp_dsi(const lvgl_port_display_cfg_t *disp_cfg, co
lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg);

if (disp != NULL) {
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(disp);
/* Set display type */
disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_DSI;

Expand Down Expand Up @@ -154,7 +154,7 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co
lv_disp_t *disp = lvgl_port_add_disp_priv(disp_cfg, &priv_cfg);

if (disp != NULL) {
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(disp);
/* Set display type */
disp_ctx->disp_type = LVGL_PORT_DISP_TYPE_RGB;

Expand Down Expand Up @@ -190,7 +190,7 @@ lv_display_t *lvgl_port_add_disp_rgb(const lvgl_port_display_cfg_t *disp_cfg, co
esp_err_t lvgl_port_remove_disp(lv_display_t *disp)
{
assert(disp);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(disp);

lvgl_port_lock(0);
lv_disp_remove(disp);
Expand Down Expand Up @@ -366,7 +366,7 @@ static lv_display_t *lvgl_port_add_disp_priv(const lvgl_port_display_cfg_t *disp
lv_display_add_event_cb(disp, lvgl_port_display_invalidate_callback, LV_EVENT_INVALIDATE_AREA, disp_ctx);
lv_display_add_event_cb(disp, lvgl_port_display_invalidate_callback, LV_EVENT_REFR_REQUEST, disp_ctx);

lv_display_set_user_data(disp, disp_ctx);
lv_display_set_driver_data(disp, disp_ctx);
disp_ctx->disp_drv = disp;

/* Use SW rotation */
Expand Down Expand Up @@ -425,7 +425,7 @@ static bool lvgl_port_flush_dpi_vsync_ready_callback(esp_lcd_panel_handle_t pane

lv_display_t *disp_drv = (lv_display_t *)user_ctx;
assert(disp_drv != NULL);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp_drv);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(disp_drv);
assert(disp_ctx != NULL);

if (disp_ctx->trans_sem) {
Expand All @@ -443,7 +443,7 @@ static bool lvgl_port_flush_rgb_vsync_ready_callback(esp_lcd_panel_handle_t pane

lv_display_t *disp_drv = (lv_display_t *)user_ctx;
assert(disp_drv != NULL);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(disp_drv);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(disp_drv);
assert(disp_ctx != NULL);

if (disp_ctx->trans_sem) {
Expand All @@ -461,7 +461,7 @@ static void _lvgl_port_transform_monochrome(lv_display_t *display, const lv_area
assert(*color_map);
uint8_t *src = *color_map;
lv_color16_t *color = (lv_color16_t *)*color_map;
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(display);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(display);
uint16_t hor_res = lv_display_get_physical_horizontal_resolution(display);
uint16_t ver_res = lv_display_get_physical_vertical_resolution(display);
uint16_t res = hor_res;
Expand Down Expand Up @@ -558,7 +558,7 @@ static void lvgl_port_flush_callback(lv_display_t *drv, const lv_area_t *area, u
assert(drv != NULL);
assert(area != NULL);
assert(color_map != NULL);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_user_data(drv);
lvgl_port_display_ctx_t *disp_ctx = (lvgl_port_display_ctx_t *)lv_display_get_driver_data(drv);
assert(disp_ctx != NULL);

int offsetx1 = area->x1;
Expand Down
6 changes: 3 additions & 3 deletions components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_knob.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ lv_indev_t *lvgl_port_add_encoder(const lvgl_port_encoder_cfg_t *encoder_cfg)
lv_indev_set_mode(indev, LV_INDEV_MODE_EVENT);
lv_indev_set_read_cb(indev, lvgl_port_encoder_read);
lv_indev_set_disp(indev, encoder_cfg->disp);
lv_indev_set_user_data(indev, encoder_ctx);
lv_indev_set_driver_data(indev, encoder_ctx);
encoder_ctx->indev = indev;
lvgl_port_unlock();

Expand All @@ -102,7 +102,7 @@ lv_indev_t *lvgl_port_add_encoder(const lvgl_port_encoder_cfg_t *encoder_cfg)
esp_err_t lvgl_port_remove_encoder(lv_indev_t *encoder)
{
assert(encoder);
lvgl_port_encoder_ctx_t *encoder_ctx = (lvgl_port_encoder_ctx_t *)lv_indev_get_user_data(encoder);
lvgl_port_encoder_ctx_t *encoder_ctx = (lvgl_port_encoder_ctx_t *)lv_indev_get_driver_data(encoder);

if (encoder_ctx->knob_handle != NULL) {
iot_knob_delete(encoder_ctx->knob_handle);
Expand Down Expand Up @@ -132,7 +132,7 @@ static void lvgl_port_encoder_read(lv_indev_t *indev_drv, lv_indev_data_t *data)
{
static int32_t last_v = 0;
assert(indev_drv);
lvgl_port_encoder_ctx_t *ctx = (lvgl_port_encoder_ctx_t *)lv_indev_get_user_data(indev_drv);
lvgl_port_encoder_ctx_t *ctx = (lvgl_port_encoder_ctx_t *)lv_indev_get_driver_data(indev_drv);
assert(ctx);

int32_t invd = iot_knob_get_count_value(ctx->knob_handle);
Expand Down
6 changes: 3 additions & 3 deletions components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ lv_indev_t *lvgl_port_add_touch(const lvgl_port_touch_cfg_t *touch_cfg)
}
lv_indev_set_read_cb(indev, lvgl_port_touchpad_read);
lv_indev_set_disp(indev, touch_cfg->disp);
lv_indev_set_user_data(indev, touch_ctx);
lv_indev_set_driver_data(indev, touch_ctx);
touch_ctx->indev = indev;
lvgl_port_unlock();

Expand All @@ -81,7 +81,7 @@ lv_indev_t *lvgl_port_add_touch(const lvgl_port_touch_cfg_t *touch_cfg)
esp_err_t lvgl_port_remove_touch(lv_indev_t *touch)
{
assert(touch);
lvgl_port_touch_ctx_t *touch_ctx = (lvgl_port_touch_ctx_t *)lv_indev_get_user_data(touch);
lvgl_port_touch_ctx_t *touch_ctx = (lvgl_port_touch_ctx_t *)lv_indev_get_driver_data(touch);

lvgl_port_lock(0);
/* Remove input device driver */
Expand All @@ -107,7 +107,7 @@ esp_err_t lvgl_port_remove_touch(lv_indev_t *touch)
static void lvgl_port_touchpad_read(lv_indev_t *indev_drv, lv_indev_data_t *data)
{
assert(indev_drv);
lvgl_port_touch_ctx_t *touch_ctx = (lvgl_port_touch_ctx_t *)lv_indev_get_user_data(indev_drv);
lvgl_port_touch_ctx_t *touch_ctx = (lvgl_port_touch_ctx_t *)lv_indev_get_driver_data(indev_drv);
assert(touch_ctx);
assert(touch_ctx->handle);

Expand Down
10 changes: 5 additions & 5 deletions components/esp_lvgl_port/src/lvgl9/esp_lvgl_port_usbhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ lv_indev_t *lvgl_port_add_usb_hid_mouse_input(const lvgl_port_hid_mouse_cfg_t *m
lv_indev_set_mode(indev, LV_INDEV_MODE_EVENT);
lv_indev_set_read_cb(indev, lvgl_port_usb_hid_read_mouse);
lv_indev_set_disp(indev, mouse_cfg->disp);
lv_indev_set_user_data(indev, hid_ctx);
lv_indev_set_driver_data(indev, hid_ctx);
hid_ctx->mouse.indev = indev;
lvgl_port_unlock();

Expand Down Expand Up @@ -132,7 +132,7 @@ lv_indev_t *lvgl_port_add_usb_hid_keyboard_input(const lvgl_port_hid_keyboard_cf
lv_indev_set_mode(indev, LV_INDEV_MODE_EVENT);
lv_indev_set_read_cb(indev, lvgl_port_usb_hid_read_kb);
lv_indev_set_disp(indev, keyboard_cfg->disp);
lv_indev_set_user_data(indev, hid_ctx);
lv_indev_set_driver_data(indev, hid_ctx);
hid_ctx->kb.indev = indev;
lvgl_port_unlock();

Expand All @@ -142,7 +142,7 @@ lv_indev_t *lvgl_port_add_usb_hid_keyboard_input(const lvgl_port_hid_keyboard_cf
esp_err_t lvgl_port_remove_usb_hid_input(lv_indev_t *hid)
{
assert(hid);
lvgl_port_usb_hid_ctx_t *hid_ctx = (lvgl_port_usb_hid_ctx_t *)lv_indev_get_user_data(hid);
lvgl_port_usb_hid_ctx_t *hid_ctx = (lvgl_port_usb_hid_ctx_t *)lv_indev_get_driver_data(hid);

lvgl_port_lock(0);
/* Remove input device driver */
Expand Down Expand Up @@ -408,7 +408,7 @@ static void lvgl_port_usb_hid_read_mouse(lv_indev_t *indev_drv, lv_indev_data_t
int16_t width = 0;
int16_t height = 0;
assert(indev_drv);
lvgl_port_usb_hid_ctx_t *ctx = (lvgl_port_usb_hid_ctx_t *)lv_indev_get_user_data(indev_drv);
lvgl_port_usb_hid_ctx_t *ctx = (lvgl_port_usb_hid_ctx_t *)lv_indev_get_driver_data(indev_drv);
assert(ctx);

lv_display_t *disp = lv_indev_get_display(indev_drv);
Expand Down Expand Up @@ -463,7 +463,7 @@ static void lvgl_port_usb_hid_read_mouse(lv_indev_t *indev_drv, lv_indev_data_t
static void lvgl_port_usb_hid_read_kb(lv_indev_t *indev_drv, lv_indev_data_t *data)
{
assert(indev_drv);
lvgl_port_usb_hid_ctx_t *ctx = (lvgl_port_usb_hid_ctx_t *)lv_indev_get_user_data(indev_drv);
lvgl_port_usb_hid_ctx_t *ctx = (lvgl_port_usb_hid_ctx_t *)lv_indev_get_driver_data(indev_drv);
assert(ctx);

data->key = ctx->kb.last_key;
Expand Down

0 comments on commit 056eb69

Please sign in to comment.