Various improvements (#21)

* T-Deck stability and naming improvements

* allow main task to clean itself up

* remove unused includes

* various lvgl improvements

* added docs
This commit is contained in:
Ken Van Hoeylandt
2024-01-27 23:13:17 +01:00
committed by GitHub
parent a2f0399c9f
commit 7a7b31e426
17 changed files with 146 additions and 138 deletions
+14 -21
View File
@@ -1,5 +1,3 @@
#include "lvgl_hal.h"
#include "lvgl.h"
#include "tactility_core.h"
#include <sdl/sdl.h>
@@ -8,16 +6,17 @@
#define BUFFER_SIZE (SDL_HOR_RES * SDL_VER_RES * 3)
static lv_disp_t* hal_init() {
/* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
lv_disp_t* lvgl_hal_init() {
// Use the 'monitor' driver to simulate a display on PC
// Note: this is part of lv_drivers and not SDL!
sdl_init();
/*Create a display buffer*/
// Create display buffer
static lv_disp_draw_buf_t disp_buf1;
static lv_color_t buf1_1[BUFFER_SIZE];
lv_disp_draw_buf_init(&disp_buf1, buf1_1, NULL, BUFFER_SIZE);
/*Create a display*/
// Create display
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.draw_buf = &disp_buf1;
@@ -25,20 +24,20 @@ static lv_disp_t* hal_init() {
disp_drv.hor_res = SDL_HOR_RES;
disp_drv.ver_res = SDL_VER_RES;
lv_disp_t* disp = lv_disp_drv_register(&disp_drv);
lv_disp_t* display = lv_disp_drv_register(&disp_drv);
lv_theme_t* th = lv_theme_default_init(
disp,
lv_theme_t* theme = lv_theme_default_init(
display,
lv_palette_main(LV_PALETTE_BLUE),
lv_palette_main(LV_PALETTE_RED),
LV_THEME_DEFAULT_DARK,
LV_FONT_DEFAULT
);
lv_disp_set_theme(disp, th);
lv_disp_set_theme(display, theme);
lv_group_t* g = lv_group_create();
lv_group_set_default(g);
lv_group_t* group = lv_group_create();
lv_group_set_default(group);
/* Add the mouse as input device
* Use the 'mouse' driver which reads the PC's mouse*/
@@ -55,21 +54,15 @@ static lv_disp_t* hal_init() {
indev_drv_2.type = LV_INDEV_TYPE_KEYPAD;
indev_drv_2.read_cb = sdl_keyboard_read;
lv_indev_t* kb_indev = lv_indev_drv_register(&indev_drv_2);
lv_indev_set_group(kb_indev, g);
lv_indev_set_group(kb_indev, group);
static lv_indev_drv_t indev_drv_3;
lv_indev_drv_init(&indev_drv_3); /*Basic initialization*/
indev_drv_3.type = LV_INDEV_TYPE_ENCODER;
indev_drv_3.read_cb = sdl_mousewheel_read;
lv_indev_t* enc_indev = lv_indev_drv_register(&indev_drv_3);
lv_indev_set_group(enc_indev, g);
lv_indev_set_group(enc_indev, group);
return disp;
return display;
}
void lvgl_hal_init() {
TT_LOG_I(TAG, "init: started");
lv_init();
hal_init();
TT_LOG_I(TAG, "init: complete");
}