Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lvgl/contrib: allow for SDL display driver height/width to be adjusted #18463

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lvgl/contrib: allow for SDL display driver height/width to be adjusted
Enables the SDL driver for LVGL to utilize a user prescribed width/height for display resolution when utilizing SDL, or rely on the SDL_HOR/VER_RES provided by lv_drv_conf.h in lv_drivers
  • Loading branch information
tvanfossen committed Sep 2, 2022
commit 4831fd68ab3cfa6dd0475fc1e9c50fda7130c6b0
15 changes: 15 additions & 0 deletions pkg/lvgl/contrib/lvgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
#define LVGL_THREAD_FLAG (1 << 7)
#endif

#if IS_USED(MODULE_LV_DRIVERS_SDL)

#ifndef LCD_SCREEN_WIDTH
#define LCD_SCREEN_WIDTH SDL_HOR_RES
#endif

#ifndef LCD_SCREEN_HEIGHT
#define LCD_SCREEN_HEIGHT SDL_VER_RES
#endif

#endif

static kernel_pid_t _task_thread_pid;

static lv_disp_draw_buf_t disp_buf;
Expand All @@ -79,6 +91,7 @@ static void _disp_map(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *col
const disp_dev_area_t disp_area = {
area->x1, area->x2, area->y1, area->y2
};

disp_dev_map(_screen_dev->display, &disp_area, (const uint16_t *)color_p);

LOG_DEBUG("[lvgl] flush display\n");
Expand Down Expand Up @@ -141,6 +154,8 @@ void lvgl_init(screen_dev_t *screen_dev)
sdl_init();
/* Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing) */
disp_drv.flush_cb = sdl_display_flush;
disp_drv.hor_res = LCD_SCREEN_WIDTH;
disp_drv.ver_res = LCD_SCREEN_HEIGHT;
#else
disp_drv.flush_cb = _disp_map;
/* Configure horizontal and vertical resolutions based on the
Expand Down