mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
move lvgl init to hasp_gui
This commit is contained in:
parent
ea7d3757ad
commit
fb9a844fc7
@ -1,18 +1,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
|
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include "display/monitor.h"
|
#include "display/monitor.h"
|
||||||
#include "indev/mouse.h"
|
#include "indev/mouse.h"
|
||||||
#include "indev/mousewheel.h"
|
#include "indev/mousewheel.h"
|
||||||
#include "indev/keyboard.h"
|
#include "indev/keyboard.h"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A task to measure the elapsed time for LittlevGL
|
* A task to measure the elapsed time for LittlevGL
|
||||||
* @param data unused
|
* @param data unused
|
||||||
* @return never return
|
* @return never return
|
||||||
*/
|
*/
|
||||||
static int tick_thread(void * data)
|
static int tick_thread(void* data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
@ -24,52 +23,33 @@ static int tick_thread(void * data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void hal_setup(void)
|
void hal_setup(void)
|
||||||
{
|
{
|
||||||
// Workaround for sdl2 `-m32` crash
|
// Workaround for sdl2 `-m32` crash
|
||||||
// https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1775067/comments/7
|
// https://bugs.launchpad.net/ubuntu/+source/libsdl2/+bug/1775067/comments/7
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
setenv("DBUS_FATAL_WARNINGS", "0", 1);
|
setenv("DBUS_FATAL_WARNINGS", "0", 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Add a display
|
/* Add a display
|
||||||
* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
|
* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
|
||||||
monitor_init();
|
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);
|
|
||||||
|
|
||||||
lv_init();
|
|
||||||
static lv_disp_buf_t disp_buf;
|
|
||||||
static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
|
|
||||||
lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
|
|
||||||
|
|
||||||
lv_disp_drv_t disp_drv;
|
|
||||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
|
||||||
disp_drv.flush_cb = monitor_flush; /*Used when `LV_VDB_SIZE != 0` in lv_conf.h (buffered drawing)*/
|
|
||||||
disp_drv.buffer = &disp_buf;
|
|
||||||
//disp_drv.disp_fill = monitor_fill; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/
|
|
||||||
//disp_drv.disp_map = monitor_map; /*Used when `LV_VDB_SIZE == 0` in lv_conf.h (unbuffered drawing)*/
|
|
||||||
lv_disp_drv_register(&disp_drv);
|
|
||||||
|
|
||||||
/* Add the mouse as input device
|
/* Add the mouse as input device
|
||||||
* Use the 'mouse' driver which reads the PC's mouse*/
|
* Use the 'mouse' driver which reads the PC's mouse*/
|
||||||
mouse_init();
|
mouse_init();
|
||||||
lv_indev_drv_t indev_drv;
|
|
||||||
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
|
||||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
|
||||||
indev_drv.read_cb = mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
|
|
||||||
lv_indev_drv_register(&indev_drv);
|
|
||||||
|
|
||||||
|
|
||||||
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_loop(void)
|
void hal_loop(void)
|
||||||
{
|
{
|
||||||
/*while(1)*/ {
|
// we don't use thise !!
|
||||||
SDL_Delay(5);
|
// while(1) {
|
||||||
lv_task_handler();
|
// SDL_Delay(5);
|
||||||
}
|
// lv_task_handler();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user