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

using lv_gpu_sdl #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions lv_conf.h
Original file line number Diff line number Diff line change
@@ -132,6 +132,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/
#define LV_USE_GPU_NXP_VG_LITE 0

/*Use SDL's accelerated API*/
#define LV_USE_GPU_SDL 0

/*-------------
* Logging
*-----------*/
23 changes: 23 additions & 0 deletions lv_drv_conf.h
Original file line number Diff line number Diff line change
@@ -104,6 +104,29 @@
# define MONITOR_DUAL 0
#endif

/*---------------------------------
* SDL with Hardware Acceleration
*--------------------------------*/
#ifndef USE_SDL_GPU
# define USE_SDL_GPU 0
#endif

#if USE_SDL_GPU
# define SDL_HOR_RES 800
# define SDL_VER_RES 600
# define MONITOR_HOR_RES SDL_HOR_RES
# define MONITOR_VER_RES SDL_VER_RES

/* Scale window by this factor (useful when simulating small screens) */
# define SDL_ZOOM 1

/*Eclipse: <SDL2/SDL.h> Visual Studio: <SDL.h>*/
# define SDL_INCLUDE_PATH <SDL2/SDL.h>

/*Open two windows to test multi display support*/
# define SDL_DUAL_DISPLAY 0
#endif

/*-----------------------------------
* Native Windows (including mouse)
*----------------------------------*/
2 changes: 1 addition & 1 deletion lvgl
Submodule lvgl updated 551 files
33 changes: 10 additions & 23 deletions main/src/main.c
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@
* STATIC PROTOTYPES
**********************/
static void hal_init(void);
static int tick_thread(void *data);

/**********************
* STATIC VARIABLES
@@ -123,20 +122,24 @@ static void hal_init(void)
{
/* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
monitor_init();
/* Tick init.
* You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about
* how much time were elapsed Create an SDL thread to do this*/
SDL_CreateThread(tick_thread, "tick", NULL);

/*Create a display buffer*/
static lv_disp_draw_buf_t disp_buf1;
#if USE_SDL_GPU
sdl_gpu_disp_draw_buf_init(&disp_buf1);
#else
static lv_color_t buf1_1[MONITOR_HOR_RES * 100];
static lv_color_t buf1_2[MONITOR_HOR_RES * 100];
lv_disp_draw_buf_init(&disp_buf1, buf1_1, buf1_2, MONITOR_HOR_RES * 100);
#endif

/*Create a display*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
#if USE_SDL_GPU
sdl_gpu_disp_drv_init(&disp_drv); /*Basic initialization*/
#else
lv_disp_drv_init(&disp_drv);
#endif
disp_drv.draw_buf = &disp_buf1;
disp_drv.flush_cb = monitor_flush;
disp_drv.hor_res = MONITOR_HOR_RES;
@@ -183,20 +186,4 @@ static void hal_init(void)
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/
}

/**
* A task to measure the elapsed time for LVGL
* @param data unused
* @return never return
*/
static int tick_thread(void *data) {
(void)data;

while(1) {
SDL_Delay(5);
lv_tick_inc(5); /*Tell LittelvGL that 5 milliseconds were elapsed*/
}

return 0;
}
}