diff --git a/include/graphics/driver/SDLDriver.h b/include/graphics/driver/SDLDriver.h new file mode 100644 index 00000000..1f0ce966 --- /dev/null +++ b/include/graphics/driver/SDLDriver.h @@ -0,0 +1,22 @@ +#pragma once +#include "graphics/driver/DisplayDriver.h" + +/** + * @brief For simulation on pc/raspberry + * This class provides an SDL GUI on the local desktop; dimensions are defined + * in lv_drv_conf.h Usage: define USE_SDL=1 for the rasbian/portduino target and + * link with -lSDL + */ +class SDLDriver : public DisplayDriver +{ + public: + static SDLDriver &create(uint16_t width, uint16_t height); + void init(DeviceGUI *gui) override; + void task_handler(void) override; + virtual ~SDLDriver() {} + + private: + SDLDriver(uint16_t width, uint16_t height); + + static SDLDriver *SDLdriver; +}; \ No newline at end of file diff --git a/include/graphics/driver/TFTDriver.h b/include/graphics/driver/TFTDriver.h index ab26ffa8..f0ca6d6d 100644 --- a/include/graphics/driver/TFTDriver.h +++ b/include/graphics/driver/TFTDriver.h @@ -25,13 +25,12 @@ template void TFTDriver::init(DeviceGUI *gui) lv_tick_set_cb(xTaskGetTickCount); #else // Create esp timer to call lvgl lv_tick_inc() - const esp_timer_create_args_t lvgl_tick_timer_args = {.callback = [](void *arg) { lv_tick_inc(20); }, .name = "lvgl_tick"}; + const esp_timer_create_args_t lvgl_tick_timer_args = {.callback = [](void *arg) { lv_tick_inc(5); }, .name = "lvgl_tick"}; esp_timer_handle_t lvgl_tick_timer = nullptr; ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer)); - ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, 20000)); + ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, 5000)); #endif #elif defined(ARCH_PORTDUINO) - // for linux we use lv_tick_inc() in DeviceGUI::task_handler() - // lv_tick_set_cb([]() -> uint32_t { return millis(); }); + lv_tick_set_cb([]() -> uint32_t { return millis(); }); #endif } diff --git a/include/graphics/driver/X11Driver.h b/include/graphics/driver/X11Driver.h index 8df5f6fc..44a51371 100644 --- a/include/graphics/driver/X11Driver.h +++ b/include/graphics/driver/X11Driver.h @@ -12,6 +12,7 @@ class X11Driver : public DisplayDriver public: static X11Driver &create(uint16_t width, uint16_t height); void init(DeviceGUI *gui) override; + void task_handler(void) override; virtual ~X11Driver() {} private: diff --git a/include/lv_conf.h b/include/lv_conf.h index 9b10305c..f4055240 100644 --- a/include/lv_conf.h +++ b/include/lv_conf.h @@ -100,6 +100,7 @@ * - LV_OS_RTTHREAD * - LV_OS_WINDOWS * - LV_OS_MQX + * - LV_OS_SDL2 * - LV_OS_CUSTOM */ #define LV_USE_OS LV_OS_NONE @@ -139,10 +140,25 @@ /*The target buffer size for simple layer chunks.*/ #define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/ -/* The stack size of the drawing thread. +/* Limit the max allocated memory for simple and transformed layers. + * It should be at least `LV_DRAW_LAYER_SIMPLE_BUF_SIZE` sized but if transformed layers are also used + * it should be enough to store the largest widget too (width x height x 4 area). + * Set it to 0 to have no limit. */ +#define LV_DRAW_LAYER_MAX_MEMORY 0 /**< No limit by default [bytes]*/ + +/** Stack size of drawing thread. * NOTE: If FreeType or ThorVG is enabled, it is recommended to set it to 32KB or more. */ -#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /*[bytes]*/ +#define LV_DRAW_THREAD_STACK_SIZE (8 * 1024) /**< [bytes]*/ + +/** Thread priority of the drawing task. + * Higher values mean higher priority. + * Can use values from lv_thread_prio_t enum in lv_os.h: LV_THREAD_PRIO_LOWEST, + * LV_THREAD_PRIO_LOW, LV_THREAD_PRIO_MID, LV_THREAD_PRIO_HIGH, LV_THREAD_PRIO_HIGHEST + * Make sure the priority value aligns with the OS-specific priority levels. + * On systems with limited priority levels (e.g., FreeRTOS), a higher value can improve + * rendering performance but might cause other tasks to starve. */ +#define LV_DRAW_THREAD_PRIO LV_THREAD_PRIO_HIGH #define LV_USE_DRAW_SW 1 #if LV_USE_DRAW_SW == 1 @@ -155,18 +171,24 @@ */ #define LV_DRAW_SW_SUPPORT_RGB565 1 + #define LV_DRAW_SW_SUPPORT_RGB565_SWAPPED 1 #define LV_DRAW_SW_SUPPORT_RGB565A8 1 #define LV_DRAW_SW_SUPPORT_RGB888 1 #define LV_DRAW_SW_SUPPORT_XRGB8888 1 #define LV_DRAW_SW_SUPPORT_ARGB8888 1 + #define LV_DRAW_SW_SUPPORT_ARGB8888_PREMULTIPLIED 1 #define LV_DRAW_SW_SUPPORT_L8 1 #define LV_DRAW_SW_SUPPORT_AL88 1 #define LV_DRAW_SW_SUPPORT_A8 1 #define LV_DRAW_SW_SUPPORT_I1 1 - /* Set the number of draw unit. - * > 1 requires an operating system enabled in `LV_USE_OS` - * > 1 means multiple threads will render the screen in parallel */ + /* The threshold of the luminance to consider a pixel as + * active in indexed color format */ + #define LV_DRAW_SW_I1_LUM_THRESHOLD 127 + + /** Set number of draw units. + * - > 1 requires operating system to be enabled in `LV_USE_OS`. + * - > 1 means multiple threads will render the screen in parallel. */ #define LV_DRAW_SW_DRAW_UNIT_CNT 1 /* Use Arm-2D to accelerate the sw render */ @@ -202,28 +224,28 @@ #define LV_USE_DRAW_SW_COMPLEX_GRADIENTS 0 #endif -/* Use NXP's VG-Lite GPU on iMX RTxxx platforms. */ -#define LV_USE_DRAW_VGLITE 0 - -#if LV_USE_DRAW_VGLITE - /* Enable blit quality degradation workaround recommended for screen's dimension > 352 pixels. */ - #define LV_USE_VGLITE_BLIT_SPLIT 0 +/*Use TSi's aka (Think Silicon) NemaGFX */ +#define LV_USE_NEMA_GFX 0 - #if LV_USE_OS - /* Use additional draw thread for VG-Lite processing.*/ - #define LV_USE_VGLITE_DRAW_THREAD 1 - - #if LV_USE_VGLITE_DRAW_THREAD - /* Enable VGLite draw async. Queue multiple tasks and flash them once to the GPU. */ - #define LV_USE_VGLITE_DRAW_ASYNC 1 - #endif +#if LV_USE_NEMA_GFX + /** Select which NemaGFX HAL to use. Possible options: + * - LV_NEMA_HAL_CUSTOM + * - LV_NEMA_HAL_STM32 */ + #define LV_USE_NEMA_HAL LV_NEMA_HAL_CUSTOM + #if LV_USE_NEMA_HAL == LV_NEMA_HAL_STM32 + #define LV_NEMA_STM32_HAL_INCLUDE #endif - /* Enable VGLite asserts. */ - #define LV_USE_VGLITE_ASSERT 0 + /*Enable Vector Graphics Operations. Available only if NemaVG library is present*/ + #define LV_USE_NEMA_VG 0 + #if LV_USE_NEMA_VG + /*Define application's resolution used for VG related buffer allocation */ + #define LV_NEMA_GFX_MAX_RESX 800 + #define LV_NEMA_GFX_MAX_RESY 600 + #endif #endif -/* Use NXP's PXP on iMX RTxxx platforms. */ +/** Use NXP's PXP on iMX RTxxx platforms. */ #define LV_USE_PXP 0 #if LV_USE_PXP @@ -242,11 +264,33 @@ #define LV_USE_PXP_ASSERT 0 #endif -/* Use Renesas Dave2D on RA platforms. */ +/** Use NXP's G2D on MPU platforms. */ +#define LV_USE_DRAW_G2D 0 + +#if LV_USE_DRAW_G2D + /** Maximum number of buffers that can be stored for G2D draw unit. + * Includes the frame buffers and assets. */ + #define LV_G2D_HASH_TABLE_SIZE 50 + + #if LV_USE_OS + /** Use additional draw thread for G2D processing.*/ + #define LV_USE_G2D_DRAW_THREAD 1 + #endif + + /** Enable G2D asserts. */ + #define LV_USE_G2D_ASSERT 0 +#endif + +/** Use Renesas Dave2D on RA platforms. */ #define LV_USE_DRAW_DAVE2D 0 /* Draw using cached SDL textures*/ -#define LV_USE_DRAW_SDL 0 +#ifndef USE_SDL +#define LV_USE_SDL 0 +#else +#define LV_USE_SDL USE_SDL +#endif +#define LV_USE_DRAW_SDL LV_USE_SDL /* Use VG-Lite GPU. */ #define LV_USE_DRAW_VG_LITE 0 @@ -264,7 +308,7 @@ /* Enable border to simulate shadow * NOTE: which usually improves performance, * but does not guarantee the same rendering quality as the software. */ - #define LV_VG_LITE_USE_BOX_SHADOW 0 + #define LV_VG_LITE_USE_BOX_SHADOW 1 /* VG-Lite gradient maximum cache number. * NOTE: The memory usage of a single gradient image is 4K bytes. @@ -275,6 +319,78 @@ */ #define LV_VG_LITE_STROKE_CACHE_CNT 32 + /** Remove VLC_OP_CLOSE path instruction (Workaround for NXP) **/ + #define LV_VG_LITE_DISABLE_VLC_OP_CLOSE 0 + + /** Disable linear gradient extension for some older versions of drivers. */ + #define LV_VG_LITE_DISABLE_LINEAR_GRADIENT_EXT 0 + + /** Enable usage of the LVGL's built-in vg_lite driver */ + #define LV_USE_VG_LITE_DRIVER 0 + #if LV_USE_VG_LITE_DRIVER + /** Used to pick the correct GPU series folder valid options are gc255, gc355 and gc555*/ + #define LV_VG_LITE_HAL_GPU_SERIES gc255 + + /** Used to pick the correct GPU revision header it depends on the vendor */ + #define LV_VG_LITE_HAL_GPU_REVISION 0x40 + + /** Base memory address of the GPU IP it depends on SoC, + * default value is for NXP based devices */ + #define LV_VG_LITE_HAL_GPU_BASE_ADDRESS 0x40240000 + #endif /*LV_USE_VG_LITE_DRIVER*/ + + /** Use ThorVG (a software vector library) as VG-Lite driver to allow testing VGLite on PC + * Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ + #define LV_USE_VG_LITE_THORVG 0 + #if LV_USE_VG_LITE_THORVG + /** Enable LVGL's blend mode support */ + #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 + + /** Enable YUV color format support */ + #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 + + /** Enable Linear gradient extension support */ + #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 + + /** Enable alignment on 16 pixels */ + #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 + + /** Buffer address alignment */ + #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 + + /** Enable multi-thread render */ + #define LV_VG_LITE_THORVG_THREAD_RENDER 0 + #endif /*LV_USE_VG_LITE_THORVG*/ +#endif + +/** Accelerate blends, fills, etc. with STM32 DMA2D */ +#define LV_USE_DRAW_DMA2D 0 +#if LV_USE_DRAW_DMA2D + #define LV_DRAW_DMA2D_HAL_INCLUDE "stm32h7xx_hal.h" + + /* if enabled, the user is required to call `lv_draw_dma2d_transfer_complete_interrupt_handler` + * upon receiving the DMA2D global interrupt + */ + #define LV_USE_DRAW_DMA2D_INTERRUPT 0 +#endif + +/** Draw using cached OpenGLES textures. Requires LV_USE_OPENGLES */ +#define LV_USE_DRAW_OPENGLES 0 +#if LV_USE_DRAW_OPENGLES + #define LV_DRAW_OPENGLES_TEXTURE_CACHE_COUNT 64 +#endif + +/** Draw using espressif PPA accelerator */ +#define LV_USE_PPA 0 +#if LV_USE_PPA + #define LV_USE_PPA_IMG 0 +#endif + +/* Use EVE FT81X GPU. */ +#define LV_USE_DRAW_EVE 0 +#if LV_USE_DRAW_EVE + /* EVE_GEN value: 2, 3, or 4 */ + #define LV_DRAW_EVE_EVE_GENERATION 4 #endif /*======================= @@ -299,7 +415,7 @@ *LV_LOG_LEVEL_USER Only logs added by the user *LV_LOG_LEVEL_NONE Do not log anything*/ - #define LV_LOG_LEVEL LV_LOG_LEVEL_ERROR + #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN /*1: Print the log with 'printf'; *0: User need to register a callback with `lv_log_register_print_cb()`*/ @@ -389,8 +505,12 @@ *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ #define LV_GRADIENT_MAX_STOPS 2 -/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. - * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ +/** Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. + * - 0: round down, + * - 64: round up from x.75, + * - 128: round up from half, + * - 192: round up from x.25, + * - 254: round up */ #define LV_COLOR_MIX_ROUND_OFS 0 /* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */ @@ -399,40 +519,29 @@ /* Add `id` field to `lv_obj_t` */ #define LV_USE_OBJ_ID 0 -/* Use lvgl builtin method for obj ID */ -#define LV_USE_OBJ_ID_BUILTIN 0 - -/*Use obj property set/get API*/ -#define LV_USE_OBJ_PROPERTY 0 - -/*Enable property name support*/ -#define LV_USE_OBJ_PROPERTY_NAME 0 - -/* VG-Lite Simulator */ -/*Requires: LV_USE_THORVG_INTERNAL or LV_USE_THORVG_EXTERNAL */ -#define LV_USE_VG_LITE_THORVG 0 - -#if LV_USE_VG_LITE_THORVG +/** Enable support widget names*/ +#define LV_USE_OBJ_NAME 0 - /*Enable LVGL's blend mode support*/ - #define LV_VG_LITE_THORVG_LVGL_BLEND_SUPPORT 0 +/** Automatically assign an ID when obj is created */ +#define LV_OBJ_ID_AUTO_ASSIGN LV_USE_OBJ_ID - /*Enable YUV color format support*/ - #define LV_VG_LITE_THORVG_YUV_SUPPORT 0 +/** Use builtin obj ID handler functions: +* - lv_obj_assign_id: Called when a widget is created. Use a separate counter for each widget class as an ID. +* - lv_obj_id_compare: Compare the ID to decide if it matches with a requested value. +* - lv_obj_stringify_id: Return string-ified identifier, e.g. "button3". +* - lv_obj_free_id: Does nothing, as there is no memory allocation for the ID. +* When disabled these functions needs to be implemented by the user.*/ +#define LV_USE_OBJ_ID_BUILTIN 1 - /*Enable Linear gradient extension support*/ - #define LV_VG_LITE_THORVG_LINEAR_GRADIENT_EXT_SUPPORT 0 - - /*Enable 16 pixels alignment*/ - #define LV_VG_LITE_THORVG_16PIXELS_ALIGN 1 - - /*Buffer address alignment*/ - #define LV_VG_LITE_THORVG_BUF_ADDR_ALIGN 64 +/** Use obj property set/get API. */ +#define LV_USE_OBJ_PROPERTY 0 - /*Enable multi-thread render*/ - #define LV_VG_LITE_THORVG_THREAD_RENDER 0 +/** Enable property name support. */ +#define LV_USE_OBJ_PROPERTY_NAME 1 -#endif +/* Enable the multi-touch gesture recognition feature */ +/* Gesture recognition requires the use of floats */ +#define LV_USE_GESTURE_RECOGNITION 0 /*===================== * COMPILER SETTINGS @@ -482,8 +591,10 @@ *Requires `LV_USE_FLOAT = 1`*/ #define LV_USE_MATRIX 0 -/*Include `lvgl_private.h` in `lvgl.h` to access internal data and functions by default*/ -#define LV_USE_PRIVATE_API 0 +/** Include `lvgl_private.h` in `lvgl.h` to access internal data and functions by default */ +#ifndef LV_USE_PRIVATE_API + #define LV_USE_PRIVATE_API 0 +#endif /*================== * FONT USAGE @@ -513,11 +624,11 @@ #define LV_FONT_MONTSERRAT_46 0 #define LV_FONT_MONTSERRAT_48 0 -/*Demonstrate special features*/ -#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ -#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ -#define LV_FONT_SIMSUN_14_CJK 0 /*1000 most common CJK radicals*/ -#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ +/* Demonstrate special features */ +#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /**< bpp = 3 */ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /**< Hebrew, Arabic, Persian letters and all their forms */ +#define LV_FONT_SOURCE_HAN_SANS_SC_14_CJK 0 /**< 1338 most common CJK radicals */ +#define LV_FONT_SOURCE_HAN_SANS_SC_16_CJK 0 /**< 1338 most common CJK radicals */ /*Pixel perfect monospace fonts*/ #define LV_FONT_UNSCII_8 0 @@ -585,18 +696,30 @@ *In these languages characters should be replaced with another form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 0 +/*The control character to use for signaling text recoloring*/ +#define LV_TXT_COLOR_CMD "#" + /*================== * WIDGETS *================*/ - -/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ - +/* Documentation for widgets can be found here: https://docs.lvgl.io/master/details/widgets/index.html . */ + +/** 1: Causes these widgets to be given default values at creation time. + * - lv_buttonmatrix_t: Get default maps: {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""}, else map not set. + * - lv_checkbox_t : String label set to "Check box", else set to empty string. + * - lv_dropdown_t : Options set to "Option 1", "Option 2", "Option 3", else no values are set. + * - lv_roller_t : Options set to "Option 1", "Option 2", "Option 3", "Option 4", "Option 5", else no values are set. + * - lv_label_t : Text set to "Text", else empty string. + * - lv_arclabel_t : Text set to "Arced Text", else empty string. + * */ #define LV_WIDGETS_HAS_DEFAULT_VALUE 1 #define LV_USE_ANIMIMG 1 #define LV_USE_ARC 1 +#define LV_USE_ARCLABEL 1 + #define LV_USE_BAR 1 #define LV_USE_BUTTON 1 @@ -669,18 +792,20 @@ #define LV_USE_SWITCH 1 -#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ -#if LV_USE_TEXTAREA != 0 - #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ -#endif - #define LV_USE_TABLE 1 #define LV_USE_TABVIEW 1 -#define LV_USE_TILEVIEW 0 +#define LV_USE_TEXTAREA 1 /**< Requires: lv_label */ +#if LV_USE_TEXTAREA != 0 + #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /**< [ms] */ +#endif -#define LV_USE_WIN 0 +#define LV_USE_TILEVIEW 1 + +#define LV_USE_WIN 1 + +#define LV_USE_3DTEXTURE 0 /*================== * THEMES @@ -782,8 +907,19 @@ #define LV_FS_ARDUINO_SD_LETTER 'S' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ #endif -/*LODEPNG decoder library*/ -#define LV_USE_LODEPNG 1 +/** API for UEFI */ +#define LV_USE_FS_UEFI 0 +#if LV_USE_FS_UEFI + #define LV_FS_UEFI_LETTER '\0' /**< Set an upper-case driver-identifier letter for this driver (e.g. 'A'). */ +#endif + +#define LV_USE_FS_FROGFS 0 +#if LV_USE_FS_FROGFS + #define LV_FS_FROGFS_LETTER '\0' +#endif + +/** LODEPNG decoder library */ +#define LV_USE_LODEPNG 0 /*PNG decoder(libpng) library*/ #define LV_USE_LIBPNG 0 @@ -806,6 +942,8 @@ #define LV_GIF_CACHE_DECODE_DATA 0 #endif +/** GStreamer library */ +#define LV_USE_GSTREAMER 0 /*Decode bin images to RAM*/ #define LV_BIN_DECODER_RAM_LOAD 0 @@ -835,14 +973,18 @@ #if LV_USE_TINY_TTF /* Enable loading TTF data from files */ #define LV_TINY_TTF_FILE_SUPPORT 0 - #define LV_TINY_TTF_CACHE_GLYPH_CNT 256 + #define LV_TINY_TTF_CACHE_GLYPH_CNT 128 + #define LV_TINY_TTF_CACHE_KERNING_CNT 256 #endif /*Rlottie library*/ #define LV_USE_RLOTTIE 0 -/*Enable Vector Graphic APIs - *Requires `LV_USE_MATRIX = 1`*/ +/** Requires `LV_USE_3DTEXTURE = 1` */ +#define LV_USE_GLTF 0 + +/** Enable Vector Graphic APIs + * Requires `LV_USE_MATRIX = 1` */ #define LV_USE_VECTOR_GRAPHIC 0 /* Enable ThorVG (vector graphics library) from the src/libs folder */ @@ -857,17 +999,28 @@ /*Use external LZ4 library*/ #define LV_USE_LZ4_EXTERNAL 0 -/*FFmpeg library for image decoding and playing videos - *Supports all major image formats so do not enable other image decoder with it*/ +/*SVG library + * - Requires `LV_USE_VECTOR_GRAPHIC = 1` */ +#define LV_USE_SVG 0 +#define LV_USE_SVG_ANIMATION 0 +#define LV_USE_SVG_DEBUG 0 + +/** FFmpeg library for image decoding and playing videos. + * Supports all major image formats so do not enable other image decoder with it. */ #define LV_USE_FFMPEG 0 #if LV_USE_FFMPEG /*Dump input information to stderr*/ #define LV_FFMPEG_DUMP_FORMAT 0 + /** Use lvgl file path in FFmpeg Player widget + * You won't be able to open URLs after enabling this feature. + * Note that FFmpeg image decoder will always use lvgl file system. */ + #define LV_FFMPEG_PLAYER_USE_LV_FS 0 #endif /*================== * OTHERS *==================*/ +/* Documentation for several of the below items can be found here: https://docs.lvgl.io/master/details/auxiliary-modules/index.html . */ /*1: Enable API to take snapshot for object*/ #define LV_USE_SNAPSHOT 0 @@ -880,6 +1033,13 @@ #if LV_USE_SYSMON /*Get the idle percentage. E.g. uint32_t my_get_idle(void);*/ #define LV_SYSMON_GET_IDLE lv_timer_get_idle + /** 1: Enable usage of lv_os_get_proc_idle_percent.*/ + #define LV_SYSMON_PROC_IDLE_AVAILABLE 0 + #if LV_SYSMON_PROC_IDLE_AVAILABLE + /** Get the applications idle percentage. + * - Requires `LV_USE_OS == LV_OS_PTHREAD` */ + #define LV_SYSMON_GET_PROC_IDLE lv_os_get_proc_idle_percent + #endif /*1: Show CPU usage and FPS count * Requires `LV_USE_SYSMON = 1`*/ @@ -915,6 +1075,8 @@ #if LV_USE_PROFILER_BUILTIN /*Default profiler trace buffer size*/ #define LV_PROFILER_BUILTIN_BUF_SIZE (16 * 1024) /*[bytes]*/ + #define LV_PROFILER_BUILTIN_DEFAULT_ENABLE 1 + #define LV_USE_PROFILER_BUILTIN_POSIX 0 /**< Enable POSIX profiler port */ #endif /*Header to include for the profiler*/ @@ -961,6 +1123,9 @@ /*Enable cache profiler*/ #define LV_PROFILER_CACHE 1 + + /*Enable event profiler*/ + #define LV_PROFILER_EVENT 1 #endif /*1: Enable Monkey test*/ @@ -1007,12 +1172,38 @@ #define LV_FILE_EXPLORER_QUICK_ACCESS 1 #endif +/** 1: Enable Font manager */ +#define LV_USE_FONT_MANAGER 0 +#if LV_USE_FONT_MANAGER + +/**Font manager name max length*/ +#define LV_FONT_MANAGER_NAME_MAX_LEN 32 + +#endif + +/** Enable emulated input devices, time emulation, and screenshot compares. */ +#define LV_USE_TEST 0 +#if LV_USE_TEST + +/** Enable `lv_test_screenshot_compare`. + * Requires lodepng and a few MB of extra RAM. */ +#define LV_USE_TEST_SCREENSHOT_COMPARE 0 +#endif /*LV_USE_TEST*/ + +/** Enable loading XML UIs runtime */ +#define LV_USE_XML 0 + +/** 1: Enable text translation support */ +#define LV_USE_TRANSLATION 0 + +/*1: Enable color filter style*/ +#define LV_USE_COLOR_FILTER 0 + /*================== * DEVICES *==================*/ /*Use SDL to open window on PC and handle mouse and keyboard*/ -#define LV_USE_SDL 0 #if LV_USE_SDL #define LV_SDL_INCLUDE_PATH #define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/ @@ -1024,7 +1215,11 @@ #endif /*Use X11 to open window on Linux desktop and handle mouse and keyboard*/ +#ifndef USE_X11 +#define LV_USE_X11 0 +#else #define LV_USE_X11 USE_X11 +#endif #if LV_USE_X11 #define LV_X11_DIRECT_EXIT 1 /*Exit the application when all X11 windows have been closed*/ #define LV_X11_DOUBLE_BUFFER 1 /*Use double buffers for endering*/ @@ -1037,8 +1232,11 @@ /*Use Wayland to open a window and handle input on Linux or BSD desktops */ #define LV_USE_WAYLAND 0 #if LV_USE_WAYLAND - #define LV_WAYLAND_WINDOW_DECORATIONS 0 /*Draw client side window decorations only necessary on Mutter/GNOME*/ - #define LV_WAYLAND_WL_SHELL 0 /*Use the legacy wl_shell protocol instead of the default XDG shell*/ + #define LV_WAYLAND_BUF_COUNT 1 /**< Use 1 for single buffer with partial render mode or 2 for double buffer with full render mode*/ + #define LV_WAYLAND_USE_DMABUF 0 /**< Use DMA buffers for frame buffers. Requires LV_DRAW_USE_G2D */ + #define LV_WAYLAND_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL /**< DMABUF supports LV_DISPLAY_RENDER_MODE_FULL and LV_DISPLAY_RENDER_MODE_DIRECT*/ + /**< When LV_WAYLAND_USE_DMABUF is disabled, only LV_DISPLAY_RENDER_MODE_PARTIAL is supported*/ + #define LV_WAYLAND_WINDOW_DECORATIONS 0 /**< Draw client side window decorations only necessary on Mutter/GNOME. Not supported using DMABUF*/ #endif /*Driver for /dev/fb*/ @@ -1048,12 +1246,18 @@ #define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL #define LV_LINUX_FBDEV_BUFFER_COUNT 0 #define LV_LINUX_FBDEV_BUFFER_SIZE 60 + #define LV_LINUX_FBDEV_MMAP 1 #endif /*Use Nuttx to open window and handle touchscreen*/ #define LV_USE_NUTTX 0 #if LV_USE_NUTTX + #define LV_USE_NUTTX_INDEPENDENT_IMAGE_HEAP 0 + + /** Use independent image heap for default draw buffer */ + #define LV_NUTTX_DEFAULT_DRAW_BUF_USE_INDEPENDENT_IMAGE_HEAP 0 + #define LV_USE_NUTTX_LIBUV 0 /*Use Nuttx custom init API to open window and handle touchscreen*/ @@ -1069,18 +1273,50 @@ /*Driver for /dev/input*/ #define LV_USE_NUTTX_TOUCHSCREEN 0 + /** Touchscreen cursor size in pixels(<=0: disable cursor) */ + #define LV_NUTTX_TOUCHSCREEN_CURSOR_SIZE 0 + + /** Driver for /dev/mouse */ + #define LV_USE_NUTTX_MOUSE 0 + + /** Mouse movement step (pixels) */ + #define LV_USE_NUTTX_MOUSE_MOVE_STEP 1 + + /*NuttX trace file and its path*/ + #define LV_USE_NUTTX_TRACE_FILE 0 + #if LV_USE_NUTTX_TRACE_FILE + #define LV_NUTTX_TRACE_FILE_PATH "/data/lvgl-trace.log" + #endif + #endif -/*Driver for /dev/dri/card*/ +/** Driver for /dev/dri/card */ #define LV_USE_LINUX_DRM 0 -/*Interface for TFT_eSPI*/ +#if LV_USE_LINUX_DRM + + /* Use the MESA GBM library to allocate DMA buffers that can be + * shared across sub-systems and libraries using the Linux DMA-BUF API. + * The GBM library aims to provide a platform independent memory management system + * it supports the major GPU vendors - This option requires linking with libgbm */ + #define LV_USE_LINUX_DRM_GBM_BUFFERS 0 + + #define LV_LINUX_DRM_USE_EGL 0 +#endif + +/** Interface for TFT_eSPI */ #define LV_USE_TFT_ESPI 0 -/*Driver for evdev input devices*/ -#ifndef LV_USE_EVDEV +/** Interface for Lovyan_GFX */ +#define LV_USE_LOVYAN_GFX 0 + +#if LV_USE_LOVYAN_GFX + #define LV_LGFX_USER_INCLUDE "lv_lgfx_user.hpp" + +#endif /*LV_USE_LOVYAN_GFX*/ + +/** Driver for evdev input devices */ #define LV_USE_EVDEV 0 -#endif /*Driver for libinput input devices*/ #ifndef LV_USE_LIBINPUT @@ -1103,77 +1339,134 @@ #define LV_USE_ST7789 0 #define LV_USE_ST7796 0 #define LV_USE_ILI9341 0 +#define LV_USE_FT81X 0 +#define LV_USE_NV3007 0 -#define LV_USE_GENERIC_MIPI (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341) +#if (LV_USE_ST7735 | LV_USE_ST7789 | LV_USE_ST7796 | LV_USE_ILI9341 | LV_USE_NV3007) + #define LV_USE_GENERIC_MIPI 1 +#else + #define LV_USE_GENERIC_MIPI 0 +#endif /*Driver for Renesas GLCD*/ #define LV_USE_RENESAS_GLCDC 0 -/* LVGL Windows backend */ +/** Driver for ST LTDC */ +#define LV_USE_ST_LTDC 0 +#if LV_USE_ST_LTDC + /* Only used for partial. */ + #define LV_ST_LTDC_USE_DMA2D_FLUSH 0 +#endif + +/** Driver for NXP ELCDIF */ +#define LV_USE_NXP_ELCDIF 0 + +/** LVGL Windows backend */ #define LV_USE_WINDOWS 0 -/* Use OpenGL to open window on PC and handle mouse and keyboard */ +/** LVGL UEFI backend */ +#define LV_USE_UEFI 0 +#if LV_USE_UEFI + #define LV_USE_UEFI_INCLUDE "myefi.h" /**< Header that hides the actual framework (EDK2, gnu-efi, ...) */ + #define LV_UEFI_USE_MEMORY_SERVICES 0 /**< Use the memory functions from the boot services table */ +#endif + +/** Use a generic OpenGL driver that can be used to embed in other applications or used with GLFW/EGL */ #define LV_USE_OPENGLES 0 #if LV_USE_OPENGLES #define LV_USE_OPENGLES_DEBUG 1 /* Enable or disable debug for opengles */ #endif -/* QNX Screen display and input drivers */ +/** Use GLFW to open window on PC and handle mouse and keyboard. Requires*/ +#define LV_USE_GLFW 0 + + +/** QNX Screen display and input drivers */ #define LV_USE_QNX 0 #if LV_USE_QNX #define LV_QNX_BUF_COUNT 1 /*1 or 2*/ #endif -/*================== -* EXAMPLES -*==================*/ +/*===================== +* BUILD OPTIONS +*======================*/ -/*Enable the examples to be built with the library*/ +/** Enable examples to be built with the library. */ #define LV_BUILD_EXAMPLES 0 +/** Build the demos */ +#define LV_BUILD_DEMOS 0 + /*=================== * DEMO USAGE ====================*/ -/*Show some widget. It might be required to increase `LV_MEM_SIZE` */ -#define LV_USE_DEMO_WIDGETS 0 +#if LV_BUILD_DEMOS + /** Show some widgets. This might be required to increase `LV_MEM_SIZE`. */ + #define LV_USE_DEMO_WIDGETS 0 -/*Demonstrate the usage of encoder and keyboard*/ -#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 + /** Demonstrate usage of encoder and keyboard. */ + #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 -/*Benchmark your system*/ -#define LV_USE_DEMO_BENCHMARK 0 + /** Benchmark your system */ + #define LV_USE_DEMO_BENCHMARK 0 -/*Render test for each primitives. Requires at least 480x272 display*/ -#define LV_USE_DEMO_RENDER 0 + #if LV_USE_DEMO_BENCHMARK + /** Use fonts where bitmaps are aligned 16 byte and has Nx16 byte stride */ + #define LV_DEMO_BENCHMARK_ALIGNED_FONTS 0 + #endif -/*Stress test for LVGL*/ -#define LV_USE_DEMO_STRESS 0 + /** Render test for each primitive. + * - Requires at least 480x272 display. */ + #define LV_USE_DEMO_RENDER 0 + + /** Stress test for LVGL */ + #define LV_USE_DEMO_STRESS 0 + + /** Music player demo */ + #define LV_USE_DEMO_MUSIC 0 + #if LV_USE_DEMO_MUSIC + #define LV_DEMO_MUSIC_SQUARE 0 + #define LV_DEMO_MUSIC_LANDSCAPE 0 + #define LV_DEMO_MUSIC_ROUND 0 + #define LV_DEMO_MUSIC_LARGE 0 + #define LV_DEMO_MUSIC_AUTO_PLAY 0 + #endif -/*Music player demo*/ -#define LV_USE_DEMO_MUSIC 0 -#if LV_USE_DEMO_MUSIC - #define LV_DEMO_MUSIC_SQUARE 0 - #define LV_DEMO_MUSIC_LANDSCAPE 0 - #define LV_DEMO_MUSIC_ROUND 0 - #define LV_DEMO_MUSIC_LARGE 0 - #define LV_DEMO_MUSIC_AUTO_PLAY 0 -#endif + /** Vector graphic demo */ + #define LV_USE_DEMO_VECTOR_GRAPHIC 0 + + /** GLTF demo */ + #define LV_USE_DEMO_GLTF 0 + + /*--------------------------- + * Demos from lvgl/lv_demos + ---------------------------*/ -/*Flex layout demo*/ -#define LV_USE_DEMO_FLEX_LAYOUT 0 + /** Flex layout demo */ + #define LV_USE_DEMO_FLEX_LAYOUT 0 -/*Smart-phone like multi-language demo*/ -#define LV_USE_DEMO_MULTILANG 0 + /** Smart-phone like multi-language demo */ + #define LV_USE_DEMO_MULTILANG 0 -/*Widget transformation demo*/ -#define LV_USE_DEMO_TRANSFORM 0 + /** Widget transformation demo */ + #define LV_USE_DEMO_TRANSFORM 0 + + /** Demonstrate scroll settings */ + #define LV_USE_DEMO_SCROLL 0 + + /*E-bike demo with Lottie animations (if LV_USE_LOTTIE is enabled)*/ + #define LV_USE_DEMO_EBIKE 0 + #if LV_USE_DEMO_EBIKE + #define LV_DEMO_EBIKE_PORTRAIT 0 /*0: for 480x270..480x320, 1: for 480x800..720x1280*/ + #endif -/*Demonstrate scroll settings*/ -#define LV_USE_DEMO_SCROLL 0 + /** High-resolution demo */ + #define LV_USE_DEMO_HIGH_RES 0 -/*Vector graphic demo*/ -#define LV_USE_DEMO_VECTOR_GRAPHIC 0 + /* Smart watch demo */ + #define LV_USE_DEMO_SMARTWATCH 0 +#endif /* LV_BUILD_DEMOS */ /*--END OF LV_CONF_H--*/ diff --git a/library.json b/library.json index 627c5be9..db66b9cd 100644 --- a/library.json +++ b/library.json @@ -21,7 +21,7 @@ "headers": ["DeviceScreen.h", "SharedQueue.h"], "dependencies": { "ArduinoThread": "https://github.com/meshtastic/ArduinoThread/archive/7c3ee9e1951551b949763b1f5280f8db1fa4068d.zip", - "lvgl/lvgl": "9.3.0", + "lvgl/lvgl": "https://github.com/lvgl/lvgl/archive/283d49ef82ce746f0c0dde8ea4e0f9c3d31b51e8.zip", "greiman/SdFat": "https://github.com/mverch67/SdFat/archive/152a52251fc5e1d581303b42378ea712ab229246.zip", "nanopb/Nanopb": "0.4.91" }, diff --git a/source/graphics/DeviceGUI.cpp b/source/graphics/DeviceGUI.cpp index 03a89fba..18c3e9e0 100644 --- a/source/graphics/DeviceGUI.cpp +++ b/source/graphics/DeviceGUI.cpp @@ -3,7 +3,6 @@ #include "graphics/driver/DisplayDriverConfig.h" #include "input/I2CKeyboardScanner.h" #include "input/InputDriver.h" -#include #include "input/I2CKeyboardInputDriver.h" static I2CKeyboardInputDriver *keyboardDriver = nullptr; @@ -84,28 +83,9 @@ void DeviceGUI::init(IClientBase *client) displaydriver->printConfig(); } -/** - * Linux: measure how long it takes to call displaydriver->task_handler(). - * Then tell the lvgl library how long it took via lv_tick_inc(). - */ void DeviceGUI::task_handler(void) { -#if defined(ARCH_PORTDUINO) - int ms = 10; - auto start = std::chrono::high_resolution_clock::now(); displaydriver->task_handler(); - auto stop = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast(stop - start); - if (duration.count() < ms) { - std::this_thread::sleep_for(std::chrono::milliseconds(ms - duration.count())); - lv_tick_inc(ms); - } else { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - lv_tick_inc(duration.count() + 1); - } -#else - displaydriver->task_handler(); -#endif }; DeviceGUI::~DeviceGUI() diff --git a/source/graphics/TFT/TFTView_320x240.cpp b/source/graphics/TFT/TFTView_320x240.cpp index aba55926..7e413ea1 100644 --- a/source/graphics/TFT/TFTView_320x240.cpp +++ b/source/graphics/TFT/TFTView_320x240.cpp @@ -238,7 +238,7 @@ bool TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig &uiconfig) Themes::recolorButton(objects.home_bell_button, false); Themes::recolorText(objects.home_bell_label, false); - lv_obj_set_style_bg_img_recolor(objects.home_button, colorMesh, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_recolor(objects.home_button, colorMesh, LV_PART_MAIN); // set brightness if (displaydriver->hasLight()) @@ -318,14 +318,14 @@ bool TFTView_320x240::setupUIConfig(const meshtastic_DeviceUIConfig &uiconfig) lv_img_set_zoom(img, 256); lv_obj_set_pos(img, x - 20, y - 24); // img has 40x35 size, needle at 24 lv_image_set_inner_align(img, LV_IMAGE_ALIGN_TOP_MID); - // lv_obj_set_style_align(img->spec_attr->children[0], LV_ALIGN_BOTTOM_MID, LV_PART_MAIN | LV_STATE_DEFAULT); + // lv_obj_set_style_align(img->spec_attr->children[0], LV_ALIGN_BOTTOM_MID, LV_PART_MAIN); } else { // circle image lv_img_set_src(img, &img_circle_image); lv_img_set_zoom(img, (zoom - 1) * 50 + 80); lv_obj_set_pos(img, x - 20, y - 17); // img has 40x35 size, circle at center lv_image_set_inner_align(img, LV_IMAGE_ALIGN_CENTER); - // lv_obj_set_style_align(img->spec_attr->children[0], LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + // lv_obj_set_style_align(img->spec_attr->children[0], LV_ALIGN_CENTER, LV_PART_MAIN); } }; @@ -408,14 +408,14 @@ void TFTView_320x240::init_screens(void) lv_slider_set_range(objects.rssi_slider, -150, -50); lv_label_set_text(objects.signal_scanner_snr_scale_label, "14.0\n12.0\n10.0\n8.0\n6.0\n4.0\n2.0\n0.0\n-2.0\n-4.0\n-8.0\n-10.0\n-12.0\n-14.0\n-16.0"); - lv_obj_set_style_text_line_space(objects.signal_scanner_snr_scale_label, -2, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_line_space(objects.signal_scanner_snr_scale_label, -2, LV_PART_MAIN); lv_slider_set_range(objects.snr_slider, -17, 15); #else lv_label_set_text(objects.signal_scanner_rssi_scale_label, "-20\n-30\n-40\n-50\n-60\n-70\n-80\n-90\n-100\n-110\n-120"); lv_slider_set_range(objects.rssi_slider, -125, -25); lv_label_set_text(objects.signal_scanner_snr_scale_label, "8.0\n6.0\n4.0\n2.0\n0.0\n-2.0\n-4.0\n-8.0\n-10.0\n-12.0\n-14.0\n-16.0\n-18.0"); - lv_obj_set_style_text_line_space(objects.signal_scanner_snr_scale_label, -2, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_line_space(objects.signal_scanner_snr_scale_label, -2, LV_PART_MAIN); lv_slider_set_range(objects.snr_slider, -20, 9); #endif @@ -454,14 +454,14 @@ void TFTView_320x240::init_screens(void) void TFTView_320x240::ui_set_active(lv_obj_t *b, lv_obj_t *p, lv_obj_t *tp) { if (activeButton) { - lv_obj_set_style_border_width(activeButton, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(activeButton, 0, LV_PART_MAIN); if (Themes::get() == Themes::eDark) - lv_obj_set_style_bg_img_recolor_opa(activeButton, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor(activeButton, colorGray, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_recolor_opa(activeButton, 0, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor(activeButton, colorGray, LV_PART_MAIN); } - lv_obj_set_style_border_width(b, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor(b, colorMesh, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(b, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(b, 3, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor(b, colorMesh, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(b, 255, LV_PART_MAIN); if (activePanel) { lv_obj_add_flag(activePanel, LV_OBJ_FLAG_HIDDEN); @@ -532,7 +532,7 @@ void TFTView_320x240::enterProgrammingMode(void) state = MeshtasticView::eProgrammingMode; lv_label_set_text(objects.meshtastic_url, _(">> Programming mode <<")); lv_label_set_text_fmt(objects.firmware_label, "%06d", db.config.bluetooth.fixed_pin); - lv_obj_set_style_text_font(objects.firmware_label, &ui_font_montserrat_20, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_font(objects.firmware_label, &ui_font_montserrat_20, LV_PART_MAIN); lv_obj_add_flag(objects.boot_logo, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(objects.boot_logo_button, LV_OBJ_FLAG_HIDDEN); lv_obj_remove_flag(objects.bluetooth_button, LV_OBJ_FLAG_HIDDEN); @@ -582,7 +582,7 @@ void TFTView_320x240::apply_hotfix(void) buttonSize = 36; } if (h > 400) { - lv_obj_set_style_text_font(objects.home_qr_label, &ui_font_montserrat_16, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_font(objects.home_qr_label, &ui_font_montserrat_16, LV_PART_MAIN); } lv_obj_move_foreground(objects.keyboard); @@ -673,12 +673,12 @@ void TFTView_320x240::updateTheme(void) Themes::recolorText(objects.home_memory_label, (bool)objects.home_memory_button->user_data); lv_opa_t opa = (Themes::get() == Themes::eDark) ? 0 : 255; - lv_obj_set_style_bg_img_recolor_opa(objects.home_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.nodes_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.groups_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.messages_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.map_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.settings_button, opa, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_recolor_opa(objects.home_button, opa, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.nodes_button, opa, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.groups_button, opa, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.messages_button, opa, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.map_button, opa, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.settings_button, opa, LV_PART_MAIN); for (int i = 0; i < c_max_channels; i++) { if (db.channel[i].role != meshtastic_Channel_Role_DISABLED) @@ -1212,7 +1212,7 @@ void TFTView_320x240::ui_event_ChatButton(lv_event_t *e) ignoreClicked = false; return; } - lv_obj_set_style_border_color(target, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(target, colorMidGray, LV_PART_MAIN); uint32_t channelOrNode = (unsigned long)e->user_data; if (channelOrNode < c_max_channels) { @@ -2318,14 +2318,14 @@ void TFTView_320x240::ui_event_lockGps(lv_event_t *e) void TFTView_320x240::ui_event_mapBrightnessSlider(lv_event_t *e) { uint32_t br = lv_slider_get_value(objects.map_brightness_slider); - lv_obj_set_style_bg_color(objects.map_panel, lv_color_make(br, br, br), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(objects.raw_map_panel, lv_color_make(br, br, br), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(objects.map_panel, lv_color_make(br, br, br), LV_PART_MAIN); + lv_obj_set_style_bg_color(objects.raw_map_panel, lv_color_make(br, br, br), LV_PART_MAIN); } void TFTView_320x240::ui_event_mapContrastSlider(lv_event_t *e) { uint32_t ct = lv_slider_get_value(objects.map_contrast_slider); - lv_obj_set_style_opa(objects.raw_map_panel, ct, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_opa(objects.raw_map_panel, ct, LV_PART_MAIN); } void TFTView_320x240::ui_event_map_style_dropdown(lv_event_t *e) @@ -2653,23 +2653,23 @@ void TFTView_320x240::addOrUpdateMap(uint32_t nodeNum, int32_t lat, int32_t lon) lv_obj_set_size(img, 40, 35); lv_img_set_src(img, &img_circle_image); lv_image_set_inner_align(img, LV_IMAGE_ALIGN_TOP_MID); - lv_obj_set_style_opa(img, 180, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_image_recolor(img, lv_color_hex(bgColor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_image_recolor_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(img, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(img, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(img, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(img, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_opa(img, 180, LV_PART_MAIN); + lv_obj_set_style_image_recolor(img, lv_color_hex(bgColor), LV_PART_MAIN); + lv_obj_set_style_image_recolor_opa(img, 255, LV_PART_MAIN); + lv_obj_set_style_pad_top(img, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(img, 0, LV_PART_MAIN); + lv_obj_set_style_pad_left(img, 0, LV_PART_MAIN); + lv_obj_set_style_pad_right(img, 0, LV_PART_MAIN); lv_obj_t *lbl = lv_label_create(img); lv_obj_set_pos(lbl, 0, 0); lv_obj_set_size(lbl, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_text_color(lbl, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_image_recolor_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_font(lbl, &lv_font_montserrat_10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_align(lbl, LV_ALIGN_BOTTOM_MID, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_align(lbl, LV_ALIGN_BOTTOM_MID, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(lbl, lv_color_black(), LV_PART_MAIN); + lv_obj_set_style_opa(img, 255, LV_PART_MAIN); + lv_obj_set_style_image_recolor_opa(img, 255, LV_PART_MAIN); + lv_obj_set_style_text_font(lbl, &lv_font_montserrat_10, LV_PART_MAIN); + lv_obj_set_style_align(lbl, LV_ALIGN_BOTTOM_MID, LV_PART_MAIN); + lv_obj_set_style_align(lbl, LV_ALIGN_BOTTOM_MID, LV_PART_MAIN); lv_obj_t *p = nodes[nodeNum]; lv_label_set_text_fmt(lbl, "%s", lv_label_get_text(p->LV_OBJ_IDX(node_lbs_idx))); @@ -2791,7 +2791,7 @@ void TFTView_320x240::ui_event_signal_scanner_start(lv_event_t *e) lv_spinner_set_anim_params(obj, 5000, 300); lv_obj_set_pos(obj, 0, -50); lv_obj_set_size(obj, 68, 68); - lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN); add_style_spinner_style(obj); lv_label_set_text(objects.signal_scanner_start_label, "30s"); THIS->scans = 6 + 1; @@ -2876,7 +2876,7 @@ void TFTView_320x240::ui_event_trace_route_start(lv_event_t *e) lv_spinner_set_anim_params(obj, 5000, 300); lv_obj_set_pos(obj, 0, 0); lv_obj_set_size(obj, 68, 68); - lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN); add_style_spinner_style(obj); lv_label_set_text(objects.trace_route_start_label, "30s"); @@ -3107,9 +3107,9 @@ void TFTView_320x240::writePacketLog(const meshtastic_MeshPacket &p) lv_obj_set_size(pLabel, LV_PCT(100), LV_SIZE_CONTENT); uint32_t bgColor, fgColor; std::tie(bgColor, fgColor) = nodeColor(p.from); - lv_obj_set_style_bg_color(pLabel, lv_color_hex(bgColor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_color(pLabel, lv_color_hex(fgColor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(pLabel, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(pLabel, lv_color_hex(bgColor), LV_PART_MAIN); + lv_obj_set_style_text_color(pLabel, lv_color_hex(fgColor), LV_PART_MAIN); + lv_obj_set_style_bg_opa(pLabel, 255, LV_PART_MAIN); lv_label_set_text(pLabel, buf); // auto-scroll if last item is visible @@ -3314,22 +3314,17 @@ void TFTView_320x240::updateSignalStrength(int32_t rssi, float snr) sprintf(buf, "(%d%%)", pct); lv_label_set_text(objects.home_signal_pct_label, buf); if (pct > 80) { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_signal_button_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_signal_button_image, LV_PART_MAIN); } else if (pct > 60) { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_strong_signal_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_strong_signal_image, LV_PART_MAIN); } else if (pct > 40) { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_good_signal_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_good_signal_image, LV_PART_MAIN); } else if (pct > 20) { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_fair_signal_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_fair_signal_image, LV_PART_MAIN); } else if (pct > 1) { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_weak_signal_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_weak_signal_image, LV_PART_MAIN); } else { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_no_signal_image, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_no_signal_image, LV_PART_MAIN); } } } @@ -3984,7 +3979,7 @@ void TFTView_320x240::ui_event_ok(lv_event_t *e) THIS->setTheme(value); THIS->db.uiConfig.theme = meshtastic_Theme(value); THIS->controller->storeUIConfig(THIS->db.uiConfig); - lv_obj_set_style_bg_img_recolor(objects.settings_button, colorMesh, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_recolor(objects.settings_button, colorMesh, LV_PART_MAIN); } lv_obj_add_flag(objects.settings_theme_panel, LV_OBJ_FLAG_HIDDEN); @@ -4367,9 +4362,9 @@ void TFTView_320x240::showUserWidget(UserWidgetFunc createWidget) lv_obj_set_size(obj, LV_PCT(88), LV_PCT(90)); lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_style_bg_color(obj, colorDarkGray, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_radius(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(obj, colorDarkGray, LV_PART_MAIN); + lv_obj_set_style_border_width(obj, 0, LV_PART_MAIN); + lv_obj_set_style_radius(obj, 0, LV_PART_MAIN); activeWidget = obj; createWidget(activeWidget, NULL, 0); @@ -4424,14 +4419,14 @@ void TFTView_320x240::addMessage(lv_obj_t *container, uint32_t msgTime, uint32_t lv_obj_set_height(hiddenPanel, LV_SIZE_CONTENT); lv_obj_set_align(hiddenPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(hiddenPanel, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_style_radius(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(hiddenPanel, 0, LV_PART_MAIN); add_style_panel_style(hiddenPanel); - lv_obj_set_style_border_width(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_left(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_right(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_top(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(hiddenPanel, 0, LV_PART_MAIN); hiddenPanel->user_data = (void *)requestId; // add timestamp @@ -4442,7 +4437,8 @@ void TFTView_320x240::addMessage(lv_obj_t *container, uint32_t msgTime, uint32_t lv_obj_t *textLabel = lv_label_create(hiddenPanel); // calculate expected size of text bubble, to make it look nicer - lv_coord_t width = lv_txt_get_width(buf, strlen(buf), &ui_font_montserrat_12, 0); + lv_text_attributes_t text{}; + lv_coord_t width = lv_txt_get_width(buf, strlen(buf), &ui_font_montserrat_12, &text); lv_obj_set_width(textLabel, std::max(std::min(width, 200) + 10, 40)); lv_obj_set_height(textLabel, LV_SIZE_CONTENT); lv_obj_set_y(textLabel, 0); @@ -4456,13 +4452,13 @@ void TFTView_320x240::addMessage(lv_obj_t *container, uint32_t msgTime, uint32_t switch (status) { case LogMessage::eHeard: - lv_obj_set_style_border_color(textLabel, colorYellow, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(textLabel, colorYellow, LV_PART_MAIN); break; case LogMessage::eAcked: - lv_obj_set_style_border_color(textLabel, colorBlueGreen, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(textLabel, colorBlueGreen, LV_PART_MAIN); break; case LogMessage::eFailed: - lv_obj_set_style_border_color(textLabel, colorRed, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(textLabel, colorRed, LV_PART_MAIN); break; default: break; @@ -4504,8 +4500,8 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_obj_set_pos(p, LV_PCT(0), 0); lv_obj_set_size(p, LV_PCT(100), 53); lv_obj_set_align(p, LV_ALIGN_CENTER); - lv_obj_set_style_pad_top(p, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(p, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_top(p, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(p, 0, LV_PART_MAIN); lv_obj_remove_flag(p, lv_obj_flag_t(LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_PRESS_LOCK | LV_OBJ_FLAG_CLICK_FOCUSABLE | LV_OBJ_FLAG_GESTURE_BUBBLE | LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLLABLE)); add_style_node_panel_style(p); @@ -4516,12 +4512,12 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_obj_set_pos(img, -5, 3); lv_obj_set_size(img, 32, 32); lv_obj_clear_flag(img, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_style_radius(img, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(img, 2, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(img, 6, LV_PART_MAIN); + lv_obj_set_style_bg_opa(img, 255, LV_PART_MAIN); + lv_obj_set_style_border_opa(img, 255, LV_PART_MAIN); + lv_obj_set_style_border_width(img, 2, LV_PART_MAIN); if (!hasKey) { - lv_obj_set_style_border_color(img, colorRed, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(img, colorRed, LV_PART_MAIN); } if (unmessagable) { // node role icon is not clickable and replaced with a cancelled icon @@ -4537,9 +4533,9 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor add_style_node_button_style(nodeButton); lv_obj_set_align(nodeButton, LV_ALIGN_CENTER); lv_obj_add_flag(nodeButton, LV_OBJ_FLAG_SCROLL_ON_FOCUS); - lv_obj_set_style_shadow_width(nodeButton, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_max_height(nodeButton, 132, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_min_height(nodeButton, 50, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_shadow_width(nodeButton, 0, LV_PART_MAIN); + lv_obj_set_style_max_height(nodeButton, 132, LV_PART_MAIN); + lv_obj_set_style_min_height(nodeButton, 50, LV_PART_MAIN); nodeButton->user_data = _lv_ll_get_tail(lv_group_ll); // UserNameLabel @@ -4549,17 +4545,18 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_label_set_long_mode(ln_lbl, LV_LABEL_LONG_SCROLL); lv_label_set_text(ln_lbl, userLong); ln_lbl->user_data = (void *)nodeNum; - lv_obj_set_style_align(ln_lbl, LV_ALIGN_TOP_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(ln_lbl, LV_ALIGN_TOP_LEFT, LV_PART_MAIN); // UserNameShortLabel lv_obj_t *sn_lbl = lv_label_create(p); lv_obj_set_pos(sn_lbl, 30, 10); lv_obj_set_size(sn_lbl, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_label_set_long_mode(sn_lbl, LV_LABEL_LONG_WRAP); - lv_obj_set_style_align(sn_lbl, LV_ALIGN_TOP_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_font(sn_lbl, &ui_font_montserrat_14, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(sn_lbl, LV_ALIGN_TOP_LEFT, LV_PART_MAIN); + lv_obj_set_style_text_font(sn_lbl, &ui_font_montserrat_14, LV_PART_MAIN); // if short name contains only non-printable glyphs replace with short id - if (lv_txt_get_width(userShort, strlen(userShort), &ui_font_montserrat_14, 0) <= 4) { + lv_text_attributes_t text{}; + if (lv_txt_get_width(userShort, strlen(userShort), &ui_font_montserrat_14, &text) <= 4) { lv_label_set_text_fmt(sn_lbl, "%04x", nodeNum & 0xffff); } else { lv_label_set_text(sn_lbl, userShort); @@ -4587,13 +4584,13 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_obj_set_size(ui_BatteryLabel, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_obj_set_align(ui_BatteryLabel, LV_ALIGN_TOP_RIGHT); lv_label_set_text(ui_BatteryLabel, ""); - lv_obj_set_style_text_align(ui_BatteryLabel, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_align(ui_BatteryLabel, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN); ui_BatteryLabel->user_data = (void *)hasKey; // LastHeardLabel lv_obj_t *ui_lastHeardLabel = lv_label_create(p); lv_obj_set_pos(ui_lastHeardLabel, 8, 33); lv_obj_set_size(ui_lastHeardLabel, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_align(ui_lastHeardLabel, LV_ALIGN_TOP_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(ui_lastHeardLabel, LV_ALIGN_TOP_RIGHT, LV_PART_MAIN); lv_label_set_long_mode(ui_lastHeardLabel, LV_LABEL_LONG_CLIP); // TODO: devices without actual time will report all nodes as lastseen = now @@ -4610,7 +4607,7 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_label_set_text(ui_lastHeardLabel, ""); } - lv_obj_set_style_text_align(ui_lastHeardLabel, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_align(ui_lastHeardLabel, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN); ui_lastHeardLabel->user_data = (void *)lastHeard; // SignalLabel / hopsAway lv_obj_t *ui_SignalLabel = lv_label_create(p); @@ -4626,8 +4623,8 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_obj_set_size(ui_PositionLabel, 120, LV_SIZE_CONTENT); lv_label_set_long_mode(ui_PositionLabel, LV_LABEL_LONG_CLIP); lv_label_set_text(ui_PositionLabel, ""); - lv_obj_set_style_align(ui_PositionLabel, LV_ALIGN_TOP_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_color(ui_PositionLabel, colorBlueGreen, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(ui_PositionLabel, LV_ALIGN_TOP_LEFT, LV_PART_MAIN); + lv_obj_set_style_text_color(ui_PositionLabel, colorBlueGreen, LV_PART_MAIN); ui_PositionLabel->user_data = 0; // store latitude // Position2Label lv_obj_t *ui_Position2Label = lv_label_create(p); @@ -4635,7 +4632,7 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_obj_set_size(ui_Position2Label, 108, LV_SIZE_CONTENT); lv_label_set_long_mode(ui_Position2Label, LV_LABEL_LONG_SCROLL); lv_label_set_text(ui_Position2Label, ""); - lv_obj_set_style_align(ui_Position2Label, LV_ALIGN_TOP_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(ui_Position2Label, LV_ALIGN_TOP_LEFT, LV_PART_MAIN); ui_Position2Label->user_data = 0; // store longitude // Telemetry1Label lv_obj_t *ui_Telemetry1Label = lv_label_create(p); @@ -4643,16 +4640,16 @@ void TFTView_320x240::addNode(uint32_t nodeNum, uint8_t ch, const char *userShor lv_obj_set_size(ui_Telemetry1Label, 130, LV_SIZE_CONTENT); lv_label_set_long_mode(ui_Telemetry1Label, LV_LABEL_LONG_CLIP); lv_label_set_text(ui_Telemetry1Label, ""); - lv_obj_set_style_align(ui_Telemetry1Label, LV_ALIGN_TOP_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_align(ui_Telemetry1Label, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(ui_Telemetry1Label, LV_ALIGN_TOP_RIGHT, LV_PART_MAIN); + lv_obj_set_style_text_align(ui_Telemetry1Label, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN); // Telemetry2Label lv_obj_t *ui_Telemetry2Label = lv_label_create(p); lv_obj_set_pos(ui_Telemetry2Label, 8, 63); lv_obj_set_size(ui_Telemetry2Label, 130, LV_SIZE_CONTENT); lv_label_set_long_mode(ui_Telemetry2Label, LV_LABEL_LONG_CLIP); lv_label_set_text(ui_Telemetry2Label, ""); - lv_obj_set_style_align(ui_Telemetry2Label, LV_ALIGN_TOP_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_align(ui_Telemetry2Label, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(ui_Telemetry2Label, LV_ALIGN_TOP_RIGHT, LV_PART_MAIN); + lv_obj_set_style_text_align(ui_Telemetry2Label, LV_TEXT_ALIGN_RIGHT, LV_PART_MAIN); lv_obj_add_event_cb(nodeButton, ui_event_NodeButton, LV_EVENT_ALL, (void *)nodeNum); @@ -4757,10 +4754,10 @@ void TFTView_320x240::updateNode(uint32_t nodeNum, uint8_t ch, const meshtastic_ if (cfg.public_key.size != 0) { // set border color to bg color - lv_color_t color = lv_obj_get_style_bg_color(it->second->LV_OBJ_IDX(node_img_idx), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_color(it->second->LV_OBJ_IDX(node_img_idx), color, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_color_t color = lv_obj_get_style_bg_color(it->second->LV_OBJ_IDX(node_img_idx), LV_PART_MAIN); + lv_obj_set_style_border_color(it->second->LV_OBJ_IDX(node_img_idx), color, LV_PART_MAIN); } else { - lv_obj_set_style_border_color(it->second->LV_OBJ_IDX(node_img_idx), colorRed, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(it->second->LV_OBJ_IDX(node_img_idx), colorRed, LV_PART_MAIN); } // update chat name @@ -4917,32 +4914,27 @@ void TFTView_320x240::updateMetrics(uint32_t nodeNum, uint32_t bat_level, float BatteryLevel::Status status = level.calcStatus(bat_level, voltage); switch (status) { case BatteryLevel::Plugged: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_plug_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_plug_image, LV_PART_MAIN); if (shown_level == 100) buf[0] = '\0'; break; case BatteryLevel::Charging: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_bolt_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_bolt_image, LV_PART_MAIN); break; case BatteryLevel::Full: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_full_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_full_image, LV_PART_MAIN); break; case BatteryLevel::Mid: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_mid_image, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_mid_image, LV_PART_MAIN); break; case BatteryLevel::Low: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_low_image, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_low_image, LV_PART_MAIN); break; case BatteryLevel::Empty: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_empty_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_empty_image, LV_PART_MAIN); break; case BatteryLevel::Warn: - lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_empty_warn_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.battery_image, &img_battery_empty_warn_image, LV_PART_MAIN); buf[0] = '\0'; alert = true; break; @@ -4951,7 +4943,7 @@ void TFTView_320x240::updateMetrics(uint32_t nodeNum, uint32_t bat_level, float break; } Themes::recolorTopLabel(objects.battery_percentage_label, alert); - lv_obj_set_style_bg_image_recolor_opa(objects.battery_image, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_recolor_opa(objects.battery_image, 255, LV_PART_MAIN); lv_label_set_text(objects.battery_percentage_label, buf); } } @@ -5063,11 +5055,9 @@ void TFTView_320x240::updateConnectionStatus(const meshtastic_DeviceConnectionSt Themes::recolorButton(objects.home_wlan_button, true); Themes::recolorText(objects.home_wlan_label, true); if (status.wifi.status.is_connected) { - lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_button_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_button_image, LV_PART_MAIN); } else { - lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_off_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_off_image, LV_PART_MAIN); } if (status.wifi.status.is_mqtt_connected) { @@ -5088,7 +5078,7 @@ void TFTView_320x240::updateConnectionStatus(const meshtastic_DeviceConnectionSt Themes::recolorButton(objects.home_mqtt_button, db.module_config.mqtt.enabled, 100); Themes::recolorText(objects.home_mqtt_label, false); } - lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_off_image, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_src(objects.home_wlan_button, &img_home_wlan_off_image, LV_PART_MAIN); } } else { lv_obj_add_flag(objects.home_wlan_label, LV_OBJ_FLAG_HIDDEN); @@ -5100,24 +5090,21 @@ void TFTView_320x240::updateConnectionStatus(const meshtastic_DeviceConnectionSt if (status.bluetooth.is_connected) { char buf[20]; uint32_t mac = ownNode; - lv_obj_set_style_text_color(objects.home_bluetooth_label, colorLightGray, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(objects.home_bluetooth_label, colorLightGray, LV_PART_MAIN); sprintf(buf, "??:??:%02x:%02x:%02x:%02x", mac & 0xff, (mac & 0xff00) >> 8, (mac & 0xff0000) >> 16, (mac & 0xff000000) >> 24); lv_label_set_text(objects.home_bluetooth_label, buf); - lv_obj_set_style_bg_opa(objects.home_bluetooth_button, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_src(objects.home_bluetooth_button, &img_home_bluetooth_on_button_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(objects.home_bluetooth_button, 0, LV_PART_MAIN); + lv_obj_set_style_bg_img_src(objects.home_bluetooth_button, &img_home_bluetooth_on_button_image, LV_PART_MAIN); } else { - lv_obj_set_style_text_color(objects.home_bluetooth_label, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_src(objects.home_bluetooth_button, &img_home_bluetooth_on_button_image, - LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.home_bluetooth_button, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(objects.home_bluetooth_label, colorMidGray, LV_PART_MAIN); + lv_obj_set_style_bg_img_src(objects.home_bluetooth_button, &img_home_bluetooth_on_button_image, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.home_bluetooth_button, 255, LV_PART_MAIN); } } else { - lv_obj_set_style_text_color(objects.home_bluetooth_label, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_src(objects.home_bluetooth_button, &img_home_bluetooth_off_button_image, - LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_img_recolor_opa(objects.home_bluetooth_button, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(objects.home_bluetooth_label, colorMidGray, LV_PART_MAIN); + lv_obj_set_style_bg_img_src(objects.home_bluetooth_button, &img_home_bluetooth_off_button_image, LV_PART_MAIN); + lv_obj_set_style_bg_img_recolor_opa(objects.home_bluetooth_button, 255, LV_PART_MAIN); } } else { lv_obj_add_flag(objects.home_bluetooth_label, LV_OBJ_FLAG_HIDDEN); @@ -5130,11 +5117,11 @@ void TFTView_320x240::updateConnectionStatus(const meshtastic_DeviceConnectionSt uint32_t mac = ownNode; sprintf(buf, "??:??:%02x:%02x:%02x:%02x", mac & 0xff000000, mac & 0xff0000, mac & 0xff00, mac & 0xff); lv_label_set_text(objects.home_ethernet_label, buf); - lv_obj_set_style_text_color(objects.home_ethernet_label, colorLightGray, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(objects.home_ethernet_button, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(objects.home_ethernet_label, colorLightGray, LV_PART_MAIN); + lv_obj_set_style_bg_opa(objects.home_ethernet_button, 0, LV_PART_MAIN); } else { - lv_obj_set_style_bg_img_recolor_opa(objects.home_ethernet_button, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_color(objects.home_ethernet_label, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_recolor_opa(objects.home_ethernet_button, 255, LV_PART_MAIN); + lv_obj_set_style_text_color(objects.home_ethernet_label, colorMidGray, LV_PART_MAIN); } } else { lv_obj_add_flag(objects.home_ethernet_label, LV_OBJ_FLAG_HIDDEN); @@ -5210,10 +5197,8 @@ void TFTView_320x240::handleResponse(uint32_t from, const uint32_t id, const mes if ((unsigned long)nodes[from]->LV_OBJ_IDX(node_bat_idx)->user_data == 1) { ILOG_DEBUG("public key mismatch"); nodes[from]->LV_OBJ_IDX(node_bat_idx)->user_data = (void *)2; - lv_obj_set_style_border_color(nodes[from]->LV_OBJ_IDX(node_img_idx), colorRed, - LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_slash_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(nodes[from]->LV_OBJ_IDX(node_img_idx), colorRed, LV_PART_MAIN); + lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_slash_image, LV_PART_MAIN); } } } else { @@ -5287,8 +5272,7 @@ void TFTView_320x240::handleTraceRouteResponse(const meshtastic_Routing &routing } else { // we got a first ACK to our route request if (spinnerButton) { - lv_obj_set_style_outline_color(objects.trace_route_start_button, lv_color_hex(0xDBD251), - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_outline_color(objects.trace_route_start_button, lv_color_hex(0xDBD251), LV_PART_MAIN); } } } @@ -5328,14 +5312,14 @@ void TFTView_320x240::addNodeToTraceRoute(uint32_t nodeNum, lv_obj_t *panel) lv_obj_set_pos(btn, 0, 0); lv_obj_set_size(btn, LV_PCT(100), 38); add_style_settings_button_style(btn); - lv_obj_set_style_align(btn, LV_ALIGN_TOP_MID, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(btn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(btn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_radius(btn, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_shadow_ofs_y(btn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(btn, 1, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_color(btn, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(btn, LV_ALIGN_TOP_MID, LV_PART_MAIN); + lv_obj_set_style_pad_top(btn, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(btn, 0, LV_PART_MAIN); + lv_obj_set_style_radius(btn, 6, LV_PART_MAIN); + lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN); + lv_obj_set_style_shadow_ofs_y(btn, 0, LV_PART_MAIN); + lv_obj_set_style_border_width(btn, 1, LV_PART_MAIN); + lv_obj_set_style_border_color(btn, colorMidGray, LV_PART_MAIN); { { lv_obj_t *img = lv_img_create(btn); @@ -5348,11 +5332,11 @@ void TFTView_320x240::addNodeToTraceRoute(uint32_t nodeNum, lv_obj_t *panel) lv_obj_set_pos(img, -5, 3); lv_obj_set_size(img, 32, 32); lv_obj_clear_flag(img, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_style_border_width(img, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_image_recolor_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_align(img, LV_ALIGN_TOP_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_radius(img, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(img, 3, LV_PART_MAIN); + lv_obj_set_style_image_recolor_opa(img, 255, LV_PART_MAIN); + lv_obj_set_style_align(img, LV_ALIGN_TOP_LEFT, LV_PART_MAIN); + lv_obj_set_style_radius(img, 6, LV_PART_MAIN); + lv_obj_set_style_bg_opa(img, 255, LV_PART_MAIN); } { // TraceRouteToButtonLabel @@ -5377,8 +5361,8 @@ void TFTView_320x240::addNodeToTraceRoute(uint32_t nodeNum, lv_obj_t *panel) } else lv_label_set_text(label, _("unknown")); } - lv_obj_set_style_align(label, LV_ALIGN_TOP_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(label, LV_ALIGN_TOP_LEFT, LV_PART_MAIN); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN); } } } @@ -5538,20 +5522,20 @@ bool TFTView_320x240::applyNodesFilter(uint32_t nodeNum, bool reset) if (lv_obj_has_state(objects.nodes_hl_active_chat_switch, LV_STATE_CHECKED)) { auto it = chats.find(nodeNum); if (it != nodes.end()) { - lv_obj_set_style_border_color(panel, colorOrange, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(panel, colorOrange, LV_PART_MAIN); highlight = true; } } if (lv_obj_has_state(objects.nodes_hl_position_switch, LV_STATE_CHECKED)) { if (lv_label_get_text(panel->LV_OBJ_IDX(node_pos1_idx))[0] != '\0') { - lv_obj_set_style_border_color(panel, colorBlueGreen, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(panel, colorBlueGreen, LV_PART_MAIN); highlight = true; } } if (lv_obj_has_state(objects.nodes_hl_telemetry_switch, LV_STATE_CHECKED)) { if (lv_label_get_text(panel->LV_OBJ_IDX(node_tm1_idx))[0] != '\0') { - lv_obj_set_style_border_color(panel, colorBlue, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(panel, 2, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(panel, colorBlue, LV_PART_MAIN); + lv_obj_set_style_border_width(panel, 2, LV_PART_MAIN); highlight = true; } } @@ -5579,11 +5563,11 @@ bool TFTView_320x240::applyNodesFilter(uint32_t nodeNum, bool reset) fg = lv_color_hex(0xffffffff); bg = lv_color_hex(0x001d1414); } - lv_obj_set_style_text_color(panel->LV_OBJ_IDX(node_tm2_idx), fg, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(panel->LV_OBJ_IDX(node_tm2_idx), bg, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_opa(panel->LV_OBJ_IDX(node_tm2_idx), 255, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_color(panel, bg, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(panel, 2, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(panel->LV_OBJ_IDX(node_tm2_idx), fg, LV_PART_MAIN); + lv_obj_set_style_bg_color(panel->LV_OBJ_IDX(node_tm2_idx), bg, LV_PART_MAIN); + lv_obj_set_style_bg_opa(panel->LV_OBJ_IDX(node_tm2_idx), 255, LV_PART_MAIN); + lv_obj_set_style_border_color(panel, bg, LV_PART_MAIN); + lv_obj_set_style_border_width(panel, 2, LV_PART_MAIN); highlight = true; } } @@ -5591,14 +5575,14 @@ bool TFTView_320x240::applyNodesFilter(uint32_t nodeNum, bool reset) if (name[0] != '\0') { if (strcasestr(lv_label_get_text(panel->LV_OBJ_IDX(node_lbl_idx)), name) || strcasestr(lv_label_get_text(panel->LV_OBJ_IDX(node_lbs_idx)), name)) { - lv_obj_set_style_border_color(panel, colorMesh, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(panel, colorMesh, LV_PART_MAIN); highlight = true; } } } if (!highlight) { - lv_obj_set_style_border_color(panel, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(panel, 1, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(panel, colorMidGray, LV_PART_MAIN); + lv_obj_set_style_border_width(panel, 1, LV_PART_MAIN); } return hide; // TODO || filter.active; } @@ -5640,11 +5624,7 @@ void TFTView_320x240::handleTextMessageResponse(uint32_t channelOrNode, const ui if (requestId == id) { // now give the textlabel border another color lv_obj_t *textLabel = panel->spec_attr->children[0]; - lv_obj_set_style_border_color(textLabel, - err ? colorRed - : ack ? colorBlueGreen - : colorYellow, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(textLabel, err ? colorRed : ack ? colorBlueGreen : colorYellow, LV_PART_MAIN); // store message break; @@ -5781,7 +5761,7 @@ void TFTView_320x240::updateChannelConfig(const meshtastic_Channel &ch) setChannelName(ch); lv_obj_set_width(btn[ch.index], lv_pct(70)); - lv_obj_set_style_pad_left(btn[ch.index], 8, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_left(btn[ch.index], 8, LV_PART_MAIN); lv_obj_t *lockImage = NULL; if (lv_obj_get_child_cnt(btn[ch.index]) == 1) @@ -5806,8 +5786,8 @@ void TFTView_320x240::updateChannelConfig(const meshtastic_Channel &ch) lv_obj_set_align(lockImage, LV_ALIGN_LEFT_MID); lv_obj_add_flag(lockImage, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(lockImage, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_img_recolor(lockImage, lv_color_hex(recolor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_img_recolor_opa(lockImage, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_img_recolor(lockImage, lv_color_hex(recolor), LV_PART_MAIN); + lv_obj_set_style_img_recolor_opa(lockImage, 255, LV_PART_MAIN); lv_obj_t *bellImage = NULL; if (lv_obj_get_child_cnt(btn[ch.index]) < 3) @@ -5819,7 +5799,7 @@ void TFTView_320x240::updateChannelConfig(const meshtastic_Channel &ch) lv_obj_set_align(bellImage, LV_ALIGN_RIGHT_MID); lv_obj_add_flag(bellImage, LV_OBJ_FLAG_ADV_HITTEST); /// Flags lv_obj_clear_flag(bellImage, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_img_recolor_opa(bellImage, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_img_recolor_opa(bellImage, 255, LV_PART_MAIN); updateGroupChannel(ch.index); } else { // display smaller button with just the channel number @@ -5843,7 +5823,7 @@ void TFTView_320x240::updateGroupChannel(uint8_t chId) lv_obj_t *bellImage = lv_obj_get_child(btn[chId], 2); if (db.channel[chId].settings.module_settings.is_muted) { - lv_obj_set_style_img_recolor(bellImage, lv_color_hex(0xffab0000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_img_recolor(bellImage, lv_color_hex(0xffab0000), LV_PART_MAIN); lv_image_set_src(bellImage, &img_groups_bell_slash_image); } else { Themes::recolorImage(bellImage, true); @@ -6289,12 +6269,12 @@ lv_obj_t *TFTView_320x240::newMessageContainer(uint32_t from, uint32_t to, uint8 LV_OBJ_FLAG_SNAPPABLE | LV_OBJ_FLAG_SCROLL_ELASTIC)); /// Flags lv_obj_set_scrollbar_mode(container, LV_SCROLLBAR_MODE_ACTIVE); lv_obj_set_scroll_dir(container, LV_DIR_VER); - lv_obj_set_style_pad_left(container, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(container, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(container, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(container, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_left(container, 6, LV_PART_MAIN); + lv_obj_set_style_pad_right(container, 6, LV_PART_MAIN); + lv_obj_set_style_pad_top(container, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(container, 0, LV_PART_MAIN); + lv_obj_set_style_pad_row(container, 6, LV_PART_MAIN); + lv_obj_set_style_pad_column(container, 0, LV_PART_MAIN); // store new message container if (to == UINT32_MAX || from == 0) { @@ -6388,16 +6368,17 @@ void TFTView_320x240::newMessage(uint32_t nodeNum, lv_obj_t *container, uint8_t lv_obj_set_height(hiddenPanel, LV_SIZE_CONTENT); /// 50 lv_obj_set_align(hiddenPanel, LV_ALIGN_CENTER); lv_obj_clear_flag(hiddenPanel, LV_OBJ_FLAG_SCROLLABLE); /// Flags - lv_obj_set_style_radius(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(hiddenPanel, 0, LV_PART_MAIN); add_style_panel_style(hiddenPanel); - lv_obj_set_style_pad_left(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(hiddenPanel, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_left(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_right(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_top(hiddenPanel, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(hiddenPanel, 0, LV_PART_MAIN); lv_obj_t *msgLabel = lv_label_create(hiddenPanel); // calculate expected size of text bubble, to make it look nicer - lv_coord_t width = lv_txt_get_width(msg, strlen(msg), &ui_font_montserrat_14, 0); + lv_text_attributes_t text{}; + lv_coord_t width = lv_txt_get_width(msg, strlen(msg), &ui_font_montserrat_14, &text); lv_obj_set_width(msgLabel, std::max(std::min((int32_t)(width), 160) + 10, 40)); lv_obj_set_height(msgLabel, LV_SIZE_CONTENT); lv_obj_set_align(msgLabel, LV_ALIGN_LEFT_MID); @@ -6503,18 +6484,18 @@ void TFTView_320x240::addChat(uint32_t from, uint32_t to, uint8_t ch) lv_obj_add_flag(chatBtn, LV_OBJ_FLAG_SCROLL_ON_FOCUS); lv_obj_clear_flag(chatBtn, LV_OBJ_FLAG_SCROLLABLE); add_style_home_button_style(chatBtn); - lv_obj_set_style_align(chatBtn, LV_ALIGN_TOP_MID, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_color(chatBtn, colorMidGray, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_width(chatBtn, 1, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_shadow_ofs_x(chatBtn, 1, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_shadow_ofs_y(chatBtn, 2, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_radius(chatBtn, 6, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(chatBtn, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_right(chatBtn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_top(chatBtn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(chatBtn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(chatBtn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(chatBtn, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(chatBtn, LV_ALIGN_TOP_MID, LV_PART_MAIN); + lv_obj_set_style_border_color(chatBtn, colorMidGray, LV_PART_MAIN); + lv_obj_set_style_border_width(chatBtn, 1, LV_PART_MAIN); + lv_obj_set_style_shadow_ofs_x(chatBtn, 1, LV_PART_MAIN); + lv_obj_set_style_shadow_ofs_y(chatBtn, 2, LV_PART_MAIN); + lv_obj_set_style_radius(chatBtn, 6, LV_PART_MAIN); + lv_obj_set_style_pad_left(chatBtn, 3, LV_PART_MAIN); + lv_obj_set_style_pad_right(chatBtn, 0, LV_PART_MAIN); + lv_obj_set_style_pad_top(chatBtn, 0, LV_PART_MAIN); + lv_obj_set_style_pad_bottom(chatBtn, 0, LV_PART_MAIN); + lv_obj_set_style_pad_row(chatBtn, 0, LV_PART_MAIN); + lv_obj_set_style_pad_column(chatBtn, 0, LV_PART_MAIN); char buf[64]; if (to == UINT32_MAX || from == 0) { @@ -6539,8 +6520,8 @@ void TFTView_320x240::addChat(uint32_t from, uint32_t to, uint8_t ch) lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT); lv_label_set_long_mode(obj, LV_LABEL_LONG_DOT); lv_label_set_text(obj, buf); - lv_obj_set_style_align(obj, LV_ALIGN_LEFT_MID, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(obj, LV_ALIGN_LEFT_MID, LV_PART_MAIN); + lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN); } { // ChatDelButton @@ -6549,8 +6530,8 @@ void TFTView_320x240::addChat(uint32_t from, uint32_t to, uint8_t ch) lv_obj_set_pos(obj, -3, -1); lv_obj_set_size(obj, 40, 23); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_style_align(obj, LV_ALIGN_RIGHT_MID, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(obj, colorDarkRed, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(obj, LV_ALIGN_RIGHT_MID, LV_PART_MAIN); + lv_obj_set_style_bg_color(obj, colorDarkRed, LV_PART_MAIN); lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN); { lv_obj_t *parent_obj = obj; @@ -6560,7 +6541,7 @@ void TFTView_320x240::addChat(uint32_t from, uint32_t to, uint8_t ch) lv_obj_set_pos(chatDelBtn, 0, 0); lv_obj_set_size(chatDelBtn, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_label_set_text(chatDelBtn, _("DEL")); - lv_obj_set_style_align(chatDelBtn, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_align(chatDelBtn, LV_ALIGN_CENTER, LV_PART_MAIN); } } } @@ -6583,7 +6564,7 @@ void TFTView_320x240::highlightChat(uint32_t from, uint32_t to, uint8_t ch) auto it = chats.find(index); if (it != chats.end()) { // mark chat in color - lv_obj_set_style_border_color(it->second, colorOrange, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(it->second, colorOrange, LV_PART_MAIN); } } @@ -6688,16 +6669,13 @@ void TFTView_320x240::showMessages(uint32_t nodeNum) ui_set_active(objects.messages_button, objects.messages_panel, objects.top_messages_panel); switch ((unsigned long)p->LV_OBJ_IDX(node_bat_idx)->user_data) { case 0: - lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_channel_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_channel_image, LV_PART_MAIN); break; case 1: - lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_secure_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_secure_image, LV_PART_MAIN); break; default: - lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_slash_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.top_messages_node_image, &img_lock_slash_image, LV_PART_MAIN); break; } unreadMessages = 0; // TODO: not all messages may be actually read @@ -6921,10 +6899,10 @@ void TFTView_320x240::setNodeImage(uint32_t nodeNum, eRole role, bool unmessagab std::tie(bgColor, fgColor) = nodeColor(nodeNum); if (unmessagable) { lv_image_set_src(img, &img_unmessagable_image); - lv_obj_set_style_border_color(img, lv_color_hex(bgColor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(img, lv_color_hex(0x202020), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_img_recolor(img, lv_color_hex(0xFF5555), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_img_recolor_opa(img, 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(img, lv_color_hex(bgColor), LV_PART_MAIN); + lv_obj_set_style_bg_color(img, lv_color_hex(0x202020), LV_PART_MAIN); + lv_obj_set_style_img_recolor(img, lv_color_hex(0xFF5555), LV_PART_MAIN); + lv_obj_set_style_img_recolor_opa(img, 255, LV_PART_MAIN); return; } else { switch (role) { @@ -6961,9 +6939,9 @@ void TFTView_320x240::setNodeImage(uint32_t nodeNum, eRole role, bool unmessagab break; } } - lv_obj_set_style_bg_color(img, lv_color_hex(bgColor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_border_color(img, lv_color_hex(bgColor), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_img_recolor_opa(img, fgColor ? 0 : 255, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(img, lv_color_hex(bgColor), LV_PART_MAIN); + lv_obj_set_style_border_color(img, lv_color_hex(bgColor), LV_PART_MAIN); + lv_obj_set_style_img_recolor_opa(img, fgColor ? 0 : 255, LV_PART_MAIN); } void TFTView_320x240::updateNodesStatus(void) @@ -7069,11 +7047,10 @@ void TFTView_320x240::updateUnreadMessages(void) char buf[64]; if (unreadMessages > 0) { sprintf(buf, unreadMessages == 1 ? _("%d new message") : _("%d new messages"), unreadMessages); - lv_obj_set_style_bg_img_src(objects.home_mail_button, &img_home_mail_unread_button_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_src(objects.home_mail_button, &img_home_mail_unread_button_image, LV_PART_MAIN); } else { strcpy(buf, _("no new messages")); - lv_obj_set_style_bg_img_src(objects.home_mail_button, &img_home_mail_button_image, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_img_src(objects.home_mail_button, &img_home_mail_button_image, LV_PART_MAIN); } lv_label_set_text(objects.home_mail_label, buf); } @@ -7283,8 +7260,7 @@ void TFTView_320x240::task_handler(void) if (startTime) { if (curtime - startTime > 30) { lv_label_set_text(objects.trace_route_start_label, _("Start")); - lv_obj_set_style_outline_color(objects.trace_route_start_button, colorMesh, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_outline_color(objects.trace_route_start_button, colorMesh, LV_PART_MAIN); removeSpinner(); } else { char buf[16]; @@ -7311,8 +7287,7 @@ void TFTView_320x240::task_handler(void) // if we didn't hear any node for 1h assume we have no signal if (curtime - lastHeard > secs_until_offline) { - lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_no_signal_image, - LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_image_src(objects.home_signal_button, &img_home_no_signal_image, LV_PART_MAIN); lv_label_set_text(objects.home_signal_label, _("no signal")); lv_label_set_text(objects.home_signal_pct_label, ""); } diff --git a/source/graphics/driver/DisplayDriverFactory.cpp b/source/graphics/driver/DisplayDriverFactory.cpp index 41f749c5..a3f65e7d 100644 --- a/source/graphics/driver/DisplayDriverFactory.cpp +++ b/source/graphics/driver/DisplayDriverFactory.cpp @@ -16,6 +16,9 @@ #if defined(USE_X11) #include "graphics/driver/X11Driver.h" #endif +#if defined(USE_SDL) +#include "graphics/driver/SDLDriver.h" +#endif #ifndef ARCH_PORTDUINO #ifdef LGFX_DRIVER_TEMPLATE @@ -178,14 +181,21 @@ DisplayDriver *DisplayDriverFactory::create(const DisplayDriverConfig &cfg) return new LGFXDriver(cfg.width(), cfg.height()); break; #endif -#elif defined(USE_FRAMEBUFFER) +#endif +#if defined(USE_FRAMEBUFFER) case DisplayDriverConfig::device_t::FB: return &FBDriver::create(cfg.width(), cfg.height()); break; -#elif defined(USE_X11) +#endif +#if defined(USE_X11) case DisplayDriverConfig::device_t::X11: return &X11Driver::create(cfg.width(), cfg.height()); break; +#endif +#if defined(USE_SDL) + case DisplayDriverConfig::device_t::SDL: + return &SDLDriver::create(cfg.width(), cfg.height()); + break; #endif default: ILOG_CRIT("LGFX device_t config not implemented: %d", cfg._device); diff --git a/source/graphics/driver/SDLDriver.cpp b/source/graphics/driver/SDLDriver.cpp new file mode 100644 index 00000000..20475d47 --- /dev/null +++ b/source/graphics/driver/SDLDriver.cpp @@ -0,0 +1,66 @@ +#ifdef USE_SDL +#include "graphics/driver/SDLDriver.h" +#include "util/ILog.h" +#include +#include +#include +#include + +LV_IMG_DECLARE(mouse_cursor_icon); + +SDLDriver *SDLDriver::SDLdriver = nullptr; + +SDLDriver &SDLDriver::create(uint16_t width, uint16_t height) +{ + if (!SDLdriver) + SDLdriver = new SDLDriver(width, height); + return *SDLdriver; +} + +SDLDriver::SDLDriver(uint16_t width, uint16_t height) : DisplayDriver(width, height) {} + +void SDLDriver::init(DeviceGUI *gui) +{ + ILOG_DEBUG("SDLDriver::init..."); + // Initialize LVGL + DisplayDriver::init(gui); + + display = lv_sdl_window_create(screenWidth, screenHeight); + lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565); + char title[25]; + sprintf(title, "Meshtastic (%dx%d)", screenWidth, screenHeight); + lv_sdl_window_set_title(display, title); + lv_indev_t *mouse = lv_sdl_mouse_create(); + lv_indev_t *mouseWheel = lv_sdl_mousewheel_create(); + lv_indev_t *keyboard = lv_sdl_keyboard_create(); +} + +void SDLDriver::task_handler(void) +{ +#if 0 + static Uint32 lastTick = SDL_GetTicks(); + SDL_Delay(5); + Uint32 current = SDL_GetTicks(); + lv_tick_inc(current - lastTick); // Update the tick timer. Tick is new for LVGL 9 + lastTick = current; + lv_timer_handler(); // Update the UI +#elif 0 + const int ms = 10; + auto start = std::chrono::high_resolution_clock::now(); + DisplayDriver::task_handler(); + // lv_timer_handler(); + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(stop - start); + if (duration.count() < ms) { + SDL_Delay(ms - duration.count()); + lv_tick_inc(ms); + } else { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + lv_tick_inc(duration.count() + 1); + } +#else + usleep(lv_timer_handler() * 1000); +#endif +} + +#endif \ No newline at end of file diff --git a/source/graphics/driver/X11Driver.cpp b/source/graphics/driver/X11Driver.cpp index e685e46e..e83c3cdd 100644 --- a/source/graphics/driver/X11Driver.cpp +++ b/source/graphics/driver/X11Driver.cpp @@ -2,6 +2,7 @@ #include "graphics/driver/X11Driver.h" #include "util/ILog.h" #include +#include LV_IMG_DECLARE(mouse_cursor_icon); @@ -28,4 +29,24 @@ void X11Driver::init(DeviceGUI *gui) lv_x11_inputs_create(display, &mouse_cursor_icon); } +/** + * Measure how long it takes to call DisplayDriver::task_handler(). + * Then tell the lvgl library how long it took via lv_tick_inc(). + */ +void X11Driver::task_handler(void) +{ + const int ms = 10; + auto start = std::chrono::high_resolution_clock::now(); + DisplayDriver::task_handler(); + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(stop - start); + if (duration.count() < ms) { + std::this_thread::sleep_for(std::chrono::milliseconds(ms - duration.count())); + lv_tick_inc(ms); + } else { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + lv_tick_inc(duration.count() + 1); + } +} + #endif \ No newline at end of file