diff --git a/platformio.ini b/platformio.ini index 9ddeb51..f5a39ba 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,13 +20,12 @@ framework = arduino [env:wt32-sc01_plus] board = wt32-sc01_plus board_build.partitions = partitions.csv -build_src_filter = - +<*> ; include all sources - - ; except xyz specific implementations build_flags = -D CORE_DEBUG_LEVEL=4 + -D SCREEN_WIDTH=480 -D SCREEN_HEIGHT=320 -D ESP32S3 + -D WT32SC01PLUS -D BOARD_HAS_PSRAM -D ARDUINO_USB_CDC_ON_BOOT -D LV_CONF_INCLUDE_SIMPLE diff --git a/src/assets/os_railway_icon.c b/src/assets/os_railway_icon_lvgl.c similarity index 99% rename from src/assets/os_railway_icon.c rename to src/assets/os_railway_icon_lvgl.c index 8fdf555..63e52d0 100644 --- a/src/assets/os_railway_icon.c +++ b/src/assets/os_railway_icon_lvgl.c @@ -17,11 +17,11 @@ #define LV_ATTRIBUTE_MEM_ALIGN #endif -#ifndef LV_ATTRIBUTE_IMG_OS_RAILWAY_ICON -#define LV_ATTRIBUTE_IMG_OS_RAILWAY_ICON +#ifndef LV_ATTRIBUTE_IMG_OS_RAILWAY_ICON_LVGL +#define LV_ATTRIBUTE_IMG_OS_RAILWAY_ICON_LVGL #endif -const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_OS_RAILWAY_ICON uint8_t os_railway_icon_map[] = { +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_OS_RAILWAY_ICON_LVGL uint8_t os_railway_icon_lvgl_map[] = { #if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8 /*Pixel format: Alpha 8 bit, Red: 3 bit, Green: 3 bit, Blue: 2 bit*/ 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, 0x97, 0xff, @@ -995,12 +995,12 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_OS_RAILWA #endif }; -const lv_img_dsc_t os_railway_icon = { +const lv_img_dsc_t os_railway_icon_lvgl = { .header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA, .header.always_zero = 0, .header.reserved = 0, .header.w = 240, .header.h = 240, .data_size = 57600 * LV_IMG_PX_SIZE_ALPHA_BYTE, - .data = os_railway_icon_map, + .data = os_railway_icon_lvgl_map, }; diff --git a/src/boards/wt32-sc01_plus/lgfx.cpp b/src/gfx/lgfx.cpp similarity index 93% rename from src/boards/wt32-sc01_plus/lgfx.cpp rename to src/gfx/lgfx.cpp index 5e9322c..9b1c5b6 100644 --- a/src/boards/wt32-sc01_plus/lgfx.cpp +++ b/src/gfx/lgfx.cpp @@ -16,7 +16,7 @@ // along with this program. If not, see . // //---------------------------------------------------------------------------- -#include "boards/lgfx.h" +#include "gfx/lgfx.h" LGFX::LGFX() { @@ -47,8 +47,8 @@ LGFX::LGFX() cfg.pin_cs = -1; cfg.pin_rst = 4; cfg.pin_busy = -1; - cfg.panel_width = 480; - cfg.panel_height = 320; + cfg.panel_width = SCREEN_HEIGHT; + cfg.panel_height = SCREEN_WIDTH; cfg.offset_x = 0; cfg.offset_y = 0; cfg.offset_rotation = 0; @@ -59,8 +59,8 @@ LGFX::LGFX() cfg.rgb_order = false; cfg.dlen_16bit = false; cfg.bus_shared = true; - cfg.memory_width = 480; - cfg.memory_height = 320; + cfg.memory_width = SCREEN_HEIGHT; + cfg.memory_height = SCREEN_WIDTH; _panel_instance.config(cfg); } diff --git a/include/boards/lgfx.h b/src/gfx/lgfx.h similarity index 100% rename from include/boards/lgfx.h rename to src/gfx/lgfx.h diff --git a/src/boards/wt32-sc01_plus/lv_setup.cpp b/src/gfx/lv_setup.cpp similarity index 94% rename from src/boards/wt32-sc01_plus/lv_setup.cpp rename to src/gfx/lv_setup.cpp index 00956b8..2bbfed6 100644 --- a/src/boards/wt32-sc01_plus/lv_setup.cpp +++ b/src/gfx/lv_setup.cpp @@ -16,14 +16,14 @@ // along with this program. If not, see . // //---------------------------------------------------------------------------- -#include "boards/lv_setup.h" +#include "gfx/lv_setup.h" #include +#include -#include "boards/lgfx.h" #include "lv_conf.h" -#define LV_BUF_SIZE (480 * 320) +#define LV_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT) LGFX tft; @@ -94,8 +94,8 @@ void lv_begin() static lv_disp_drv_t disp_drv; lv_disp_drv_init(&disp_drv); - disp_drv.hor_res = 480; - disp_drv.ver_res = 320; + disp_drv.hor_res = SCREEN_WIDTH; + disp_drv.ver_res = SCREEN_HEIGHT; disp_drv.flush_cb = flush_cb; disp_drv.draw_buf = &draw_buf; lv_disp_drv_register(&disp_drv); diff --git a/include/boards/lv_setup.h b/src/gfx/lv_setup.h similarity index 100% rename from include/boards/lv_setup.h rename to src/gfx/lv_setup.h diff --git a/src/main.cpp b/src/main.cpp index b380be7..74c9ee9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ #include -#include "boards/lv_setup.h" +#include "gfx/lv_setup.h" #include "lv_i18n/lv_i18n.h" #include "ui/screens/launch_screen.h" diff --git a/src/ui/screens/launch_screen.cpp b/src/ui/screens/launch_screen.cpp index 1224a88..29adcfe 100644 --- a/src/ui/screens/launch_screen.cpp +++ b/src/ui/screens/launch_screen.cpp @@ -22,7 +22,7 @@ #include "lv_i18n/lv_i18n.h" #include "search_screen.h" -LV_IMG_DECLARE(os_railway_icon); +LV_IMG_DECLARE(os_railway_icon_lvgl); namespace LaunchScreen { @@ -46,7 +46,7 @@ namespace LaunchScreen lv_obj_set_style_bg_color(screen, backgroundColor, 0); auto *logo = lv_img_create(screen); - lv_img_set_src(logo, &os_railway_icon); + lv_img_set_src(logo, &os_railway_icon_lvgl); lv_obj_align(logo, LV_ALIGN_CENTER, 0, 0); auto *label = lv_label_create(screen); diff --git a/src/ui/screens/search_screen.cpp b/src/ui/screens/search_screen.cpp index c32e116..a0bc595 100644 --- a/src/ui/screens/search_screen.cpp +++ b/src/ui/screens/search_screen.cpp @@ -85,9 +85,9 @@ namespace SearchScreen lv_obj_clear_flag(search_screen, LV_OBJ_FLAG_SCROLLABLE); search_data_table = lv_table_create(search_screen); - lv_obj_set_size(search_data_table, lv_pct(100), lv_pct(100)); + lv_obj_set_size(search_data_table, SCREEN_WIDTH, SCREEN_HEIGHT); - lv_table_set_col_width(search_data_table, 0, lv_pct(100) - 3); + lv_table_set_col_width(search_data_table, 0, SCREEN_WIDTH - 3); lv_table_set_row_cnt(search_data_table, ITEM_CNT); /*Not required but avoids a lot of memory reallocation lv_table_set_set_value*/ lv_table_set_col_cnt(search_data_table, 1);