cleanup and improvements
improved driver creation fixed compile warnings in check.h hello_world example is now working again with lvgl
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
#include "nb_lvgl.h"
|
||||
#include "nb_hardware.h"
|
||||
#include <esp_check.h>
|
||||
#include "nb_lvgli.h"
|
||||
#include "nb_hardwarei.h"
|
||||
#include <esp_lvgl_port.h>
|
||||
#include <check.h>
|
||||
|
||||
static const char* TAG = "nb_lvgl";
|
||||
|
||||
nb_lvgl_t nb_lvgl_init(nb_hardware_t* platform) {
|
||||
nb_lvgl_t lvgl;
|
||||
|
||||
nb_lvgl_t nb_lvgl_init(nb_hardware_t _Nonnull* hardware) {
|
||||
const lvgl_port_cfg_t lvgl_cfg = {
|
||||
.task_priority = 4,
|
||||
.task_stack = 4096,
|
||||
@@ -15,8 +13,10 @@ nb_lvgl_t nb_lvgl_init(nb_hardware_t* platform) {
|
||||
.task_max_sleep_ms = 500,
|
||||
.timer_period_ms = 5
|
||||
};
|
||||
|
||||
furi_check(lvgl_port_init(&lvgl_cfg) == ESP_OK, "lvgl port init failed");
|
||||
nb_display_t _Nonnull* display = platform->display;
|
||||
nb_display_t _Nonnull* display = hardware->display;
|
||||
|
||||
// Add display
|
||||
ESP_LOGD(TAG, "lvgl add display");
|
||||
const lvgl_port_display_cfg_t disp_cfg = {
|
||||
@@ -27,28 +27,31 @@ nb_lvgl_t nb_lvgl_init(nb_hardware_t* platform) {
|
||||
.hres = display->horizontal_resolution,
|
||||
.vres = display->vertical_resolution,
|
||||
.monochrome = false,
|
||||
/* Rotation values must be same as defined in driver */
|
||||
// TODO: expose data from driver
|
||||
.rotation = {
|
||||
.swap_xy = false,
|
||||
.mirror_x = true,
|
||||
.mirror_y = false,
|
||||
.mirror_x = display->mirror_x,
|
||||
.mirror_y = display->mirror_y,
|
||||
},
|
||||
.flags = {
|
||||
.buff_dma = true,
|
||||
}
|
||||
};
|
||||
lvgl.disp = lvgl_port_add_disp(&disp_cfg);
|
||||
|
||||
lv_disp_t _Nonnull* disp = lvgl_port_add_disp(&disp_cfg);
|
||||
lv_indev_t _Nullable* touch_indev = NULL;
|
||||
|
||||
// Add touch
|
||||
if (platform->touch != NULL) {
|
||||
if (hardware->touch != NULL) {
|
||||
const lvgl_port_touch_cfg_t touch_cfg = {
|
||||
.disp = lvgl.disp,
|
||||
.handle = platform->touch->touch_handle,
|
||||
.disp = disp,
|
||||
.handle = hardware->touch->touch_handle,
|
||||
};
|
||||
lvgl.touch_indev = lvgl_port_add_touch(&touch_cfg);
|
||||
furi_check(lvgl.touch_indev != NULL, "failed to add touch to lvgl");
|
||||
touch_indev = lvgl_port_add_touch(&touch_cfg);
|
||||
furi_check(touch_indev != NULL, "failed to add touch to lvgl");
|
||||
}
|
||||
|
||||
return lvgl;
|
||||
return (nb_lvgl_t) {
|
||||
.disp = disp,
|
||||
.touch_indev = touch_indev
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user