From 0b83a82a07e623eda7b63c3bb11793cc351a93da Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 19 Aug 2023 01:42:37 +0200 Subject: [PATCH] feat(multi-instance): collect all the global variables into a struct to allow running multiple instances of LVGL Closes #4358 --- .github/workflows/build_micropython.yml | 2 +- Kconfig | 20 +- .../assets/fonts/font_multilang_large.c | 21 +- .../assets/fonts/font_multilang_small.c | 21 +- demos/stress/lv_demo_stress.c | 2 +- docs/ROADMAP.rst | 3 +- docs/get-started/quick-overview.rst | 4 +- docs/overview/style-props.md | 141 ++ docs/porting/project.rst | 15 + docs/porting/tick.rst | 10 + examples/assets/img_star.c | 58 +- examples/layouts/flex/lv_example_flex_2.py | 2 +- examples/layouts/grid/lv_example_grid_1.py | 2 +- examples/libs/ffmpeg/lv_example_ffmpeg_2.py | 19 +- .../others/imgfont/lv_example_imgfont_1.py | 41 +- examples/others/msg/lv_example_msg_3.py | 2 +- examples/widgets/menu/lv_example_menu_5.py | 4 +- .../widgets/spinner/lv_example_spinner_1.c | 2 +- .../widgets/spinner/lv_example_spinner_1.py | 2 +- examples/widgets/win/lv_example_win_1.c | 2 +- examples/widgets/win/lv_example_win_1.py | 2 +- lv_conf_template.h | 29 +- lvgl.h | 5 +- scripts/style_api_gen.py | 74 + src/core/lv_global.h | 221 +++ src/core/lv_group.c | 11 +- src/core/lv_obj.h | 3 + src/core/lv_obj_pos.c | 28 +- src/core/lv_obj_pos.h | 15 - src/core/lv_obj_style.c | 23 +- src/core/lv_obj_style_gen.c | 124 +- src/core/lv_obj_style_gen.h | 107 ++ src/core/lv_obj_tree.c | 6 +- src/core/lv_refr.c | 8 +- src/dev/sdl/lv_sdl_window.c | 24 +- src/disp/lv_disp.c | 15 +- src/draw/lv_draw.c | 48 +- src/draw/lv_draw.h | 13 + src/draw/lv_img_cache.c | 4 +- src/draw/lv_img_cache_builtin.c | 31 +- src/draw/lv_img_decoder.c | 13 +- src/draw/sw/lv_draw_sw.h | 8 + src/draw/sw/lv_draw_sw_box_shadow.c | 23 +- src/draw/sw/lv_draw_sw_gradient.c | 1 - src/draw/sw/lv_draw_sw_mask.c | 29 +- src/font/lv_font_dejavu_16_persian_hebrew.c | 6 +- src/font/lv_font_fmt_txt.c | 98 +- src/font/lv_font_fmt_txt.h | 24 +- src/font/lv_font_montserrat_10.c | 6 +- src/font/lv_font_montserrat_12.c | 6 +- src/font/lv_font_montserrat_14.c | 6 +- src/font/lv_font_montserrat_16.c | 6 +- src/font/lv_font_montserrat_18.c | 6 +- src/font/lv_font_montserrat_20.c | 6 +- src/font/lv_font_montserrat_22.c | 6 +- src/font/lv_font_montserrat_24.c | 6 +- src/font/lv_font_montserrat_26.c | 6 +- src/font/lv_font_montserrat_28.c | 5 +- src/font/lv_font_montserrat_28_compressed.c | 6 +- src/font/lv_font_montserrat_30.c | 6 +- src/font/lv_font_montserrat_32.c | 6 +- src/font/lv_font_montserrat_34.c | 6 +- src/font/lv_font_montserrat_36.c | 6 +- src/font/lv_font_montserrat_38.c | 6 +- src/font/lv_font_montserrat_40.c | 6 +- src/font/lv_font_montserrat_42.c | 6 +- src/font/lv_font_montserrat_44.c | 6 +- src/font/lv_font_montserrat_46.c | 6 +- src/font/lv_font_montserrat_48.c | 6 +- src/font/lv_font_montserrat_8.c | 6 +- src/font/lv_font_simsun_16_cjk.c | 6 +- src/font/lv_font_unscii_16.c | 6 +- src/font/lv_font_unscii_8.c | 6 +- src/indev/lv_indev.c | 62 +- src/layouts/flex/lv_flex.c | 100 +- src/layouts/flex/lv_flex.h | 80 +- src/layouts/grid/lv_grid.c | 197 +-- src/layouts/grid/lv_grid.h | 156 +-- src/layouts/lv_layout.c | 75 ++ src/layouts/lv_layout.h | 88 ++ src/layouts/lv_layouts.h | 43 - src/libs/freetype/lv_freetype.c | 79 +- src/libs/fsdrv/lv_fs_fatfs.c | 29 +- src/libs/fsdrv/lv_fs_posix.c | 29 +- src/libs/fsdrv/lv_fs_stdio.c | 31 +- src/libs/fsdrv/lv_fs_win32.c | 29 +- src/lv_conf_internal.h | 75 +- src/lv_init.c | 106 +- src/lv_init.h | 5 +- src/misc/lv_anim.c | 58 +- src/misc/lv_anim.h | 9 + src/misc/lv_area.c | 27 +- src/misc/lv_area.h | 5 + src/misc/lv_bidi.c | 48 +- src/misc/lv_event.c | 11 +- src/misc/lv_fs.c | 11 +- src/misc/lv_gc.c | 47 - src/misc/lv_gc.h | 97 -- src/misc/lv_log.c | 10 +- src/misc/lv_math.c | 10 +- src/misc/lv_profiler_builtin.c | 25 +- src/misc/lv_profiler_builtin.h | 22 +- src/misc/lv_style.c | 44 +- src/misc/lv_style.h | 26 +- src/misc/lv_style_gen.c | 150 +++ src/misc/lv_style_gen.h | 104 ++ src/misc/lv_timer.c | 105 +- src/misc/lv_timer.h | 17 + src/others/file_explorer/lv_file_explorer.c | 5 +- src/others/ime/lv_ime_pinyin.c | 36 +- src/others/ime/lv_ime_pinyin.h | 4 +- src/others/msg/lv_msg.c | 24 +- src/others/sysmon/lv_sysmon.c | 20 +- src/others/sysmon/lv_sysmon.h | 5 + src/stdlib/builtin/lv_mem_core_builtin.c | 77 +- src/stdlib/builtin/lv_tlsf.h | 13 + src/stdlib/lv_mem.c | 4 +- src/themes/basic/lv_theme_basic.c | 290 ++-- src/themes/basic/lv_theme_basic.h | 5 + src/themes/default/lv_theme_default.c | 1189 +++++++++-------- src/themes/default/lv_theme_default.h | 5 + src/themes/mono/lv_theme_mono.c | 477 +++---- src/themes/mono/lv_theme_mono.h | 5 + src/tick/lv_tick.c | 37 +- src/tick/lv_tick.h | 19 +- src/widgets/btnmatrix/lv_btnmatrix.c | 5 +- src/widgets/menu/lv_menu.c | 2 +- src/widgets/span/lv_span.c | 29 +- src/widgets/span/lv_span.h | 3 + src/widgets/spinner/lv_spinner.c | 58 +- src/widgets/spinner/lv_spinner.h | 5 +- src/widgets/tileview/lv_tileview.c | 26 +- src/widgets/win/lv_win.c | 7 +- src/widgets/win/lv_win.h | 2 +- tests/ref_imgs/win_01.png | Bin 3172 -> 3173 bytes tests/ref_imgs/win_02.png | Bin 4770 -> 4756 bytes tests/src/lv_test_conf.h | 3 - tests/src/lv_test_init.c | 19 +- .../test_font_montserrat_ascii_1bpp.c | 2 +- .../test_font_montserrat_ascii_2bpp.c | 2 +- .../test_font_montserrat_ascii_4bpp.c | 2 +- ...st_font_montserrat_ascii_4bpp_compressed.c | 2 +- tests/src/test_cases/test_spinner.c | 2 +- tests/src/test_cases/test_style.c | 3 +- tests/src/test_cases/test_win.c | 25 +- 145 files changed, 3230 insertions(+), 2707 deletions(-) create mode 100644 src/core/lv_global.h create mode 100644 src/layouts/lv_layout.c create mode 100644 src/layouts/lv_layout.h delete mode 100644 src/layouts/lv_layouts.h delete mode 100644 src/misc/lv_gc.c delete mode 100644 src/misc/lv_gc.h diff --git a/.github/workflows/build_micropython.yml b/.github/workflows/build_micropython.yml index 7bb6bf32e..d69bfbbb9 100644 --- a/.github/workflows/build_micropython.yml +++ b/.github/workflows/build_micropython.yml @@ -23,7 +23,7 @@ jobs: - name: Clone lv_micropython run: | git clone https://github.com/lvgl/lv_micropython.git . - git checkout feat/parallel-rendering + git checkout feat/multi-instance - name: Initialize lv_bindings submodule run: git submodule update --init --recursive lib/lv_bindings - name: Update ${{ matrix.port }} port submodules diff --git a/Kconfig b/Kconfig index 23234f7c8..95e426d12 100644 --- a/Kconfig +++ b/Kconfig @@ -135,14 +135,6 @@ menu "LVGL configuration" endmenu menu "HAL Settings" - config LV_TICK_CUSTOM - bool "Use a custom tick source" - - config LV_TICK_CUSTOM_INCLUDE - string "Header for the system time function" - default "Arduino.h" - depends on LV_TICK_CUSTOM - config LV_DPI_DEF int "Default Dots Per Inch (in px)." default 130 @@ -524,13 +516,13 @@ menu "LVGL configuration" bool "Enable float in built-in (v)snprintf functions" depends on LV_USE_BUILTIN_SNPRINTF - config LV_ENABLE_GC - bool "Enable garbage collector" + config LV_ENABLE_GLOBAL_CUSTOM + bool "Enable 'lv_global' customization" - config LV_GC_INCLUDE - string "Header to include for the garbage collector related things" - depends on LV_ENABLE_GC - default "gc.h" + config LV_GLOBAL_CUSTOM_INCLUDE + string "Header to include for the custom 'lv_global' function" + depends on LV_ENABLE_GLOBAL_CUSTOM + default "lv_global.h" endmenu menu "Compiler settings" diff --git a/demos/multilang/assets/fonts/font_multilang_large.c b/demos/multilang/assets/fonts/font_multilang_large.c index 906886eef..2b6a3d2b7 100644 --- a/demos/multilang/assets/fonts/font_multilang_large.c +++ b/demos/multilang/assets/fonts/font_multilang_large.c @@ -5,13 +5,13 @@ ******************************************************************************/ #ifdef LV_LVGL_H_INCLUDE_SIMPLE - #include "lvgl.h" +#include "lvgl.h" #else - #include "lvgl/lvgl.h" +#include "lvgl/lvgl.h" #endif #ifndef FONT_MULTILANG_LARGE - #define FONT_MULTILANG_LARGE 1 +#define FONT_MULTILANG_LARGE 1 #endif #if FONT_MULTILANG_LARGE @@ -1445,7 +1445,8 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { /*Collect the unicode lists and glyph_id offsets*/ -static const lv_font_fmt_txt_cmap_t cmaps[] = { +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ { .range_start = 32, .range_length = 95, .glyph_id_start = 1, .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY @@ -1458,7 +1459,8 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = { /*Map glyph_ids to kern left classes*/ -static const uint8_t kern_left_class_mapping[] = { +static const uint8_t kern_left_class_mapping[] = +{ 0, 0, 1, 2, 0, 3, 4, 5, 2, 6, 7, 8, 9, 10, 9, 10, 11, 12, 0, 13, 14, 15, 16, 17, @@ -1474,7 +1476,8 @@ static const uint8_t kern_left_class_mapping[] = { }; /*Map glyph_ids to kern right classes*/ -static const uint8_t kern_right_class_mapping[] = { +static const uint8_t kern_right_class_mapping[] = +{ 0, 0, 1, 2, 0, 3, 4, 5, 2, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 12, @@ -1490,7 +1493,8 @@ static const uint8_t kern_right_class_mapping[] = { }; /*Kern values between classes*/ -static const int8_t kern_class_values[] = { +static const int8_t kern_class_values[] = +{ 0, 1, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 4, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, @@ -1870,7 +1874,8 @@ static const int8_t kern_class_values[] = { /*Collect the kern class' data in one place*/ -static const lv_font_fmt_txt_kern_classes_t kern_classes = { +static const lv_font_fmt_txt_kern_classes_t kern_classes = +{ .class_pair_values = kern_class_values, .left_class_mapping = kern_left_class_mapping, .right_class_mapping = kern_right_class_mapping, diff --git a/demos/multilang/assets/fonts/font_multilang_small.c b/demos/multilang/assets/fonts/font_multilang_small.c index 7f9074ffa..89ddeab01 100644 --- a/demos/multilang/assets/fonts/font_multilang_small.c +++ b/demos/multilang/assets/fonts/font_multilang_small.c @@ -5,13 +5,13 @@ ******************************************************************************/ #ifdef LV_LVGL_H_INCLUDE_SIMPLE - #include "lvgl.h" +#include "lvgl.h" #else - #include "lvgl/lvgl.h" +#include "lvgl/lvgl.h" #endif #ifndef FONT_MULTILANG_SMALL - #define FONT_MULTILANG_SMALL 1 +#define FONT_MULTILANG_SMALL 1 #endif #if FONT_MULTILANG_SMALL @@ -5240,7 +5240,8 @@ static const uint16_t unicode_list_6[] = { }; /*Collect the unicode lists and glyph_id offsets*/ -static const lv_font_fmt_txt_cmap_t cmaps[] = { +static const lv_font_fmt_txt_cmap_t cmaps[] = +{ { .range_start = 32, .range_length = 95, .glyph_id_start = 1, .unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY @@ -5277,7 +5278,8 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = { /*Map glyph_ids to kern left classes*/ -static const uint8_t kern_left_class_mapping[] = { +static const uint8_t kern_left_class_mapping[] = +{ 0, 0, 1, 2, 0, 3, 4, 5, 2, 6, 7, 8, 9, 10, 9, 10, 11, 12, 0, 13, 14, 15, 16, 17, @@ -5346,7 +5348,8 @@ static const uint8_t kern_left_class_mapping[] = { }; /*Map glyph_ids to kern right classes*/ -static const uint8_t kern_right_class_mapping[] = { +static const uint8_t kern_right_class_mapping[] = +{ 0, 0, 1, 2, 0, 3, 4, 5, 2, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 12, @@ -5415,7 +5418,8 @@ static const uint8_t kern_right_class_mapping[] = { }; /*Kern values between classes*/ -static const int8_t kern_class_values[] = { +static const int8_t kern_class_values[] = +{ 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, @@ -6290,7 +6294,8 @@ static const int8_t kern_class_values[] = { /*Collect the kern class' data in one place*/ -static const lv_font_fmt_txt_kern_classes_t kern_classes = { +static const lv_font_fmt_txt_kern_classes_t kern_classes = +{ .class_pair_values = kern_class_values, .left_class_mapping = kern_left_class_mapping, .right_class_mapping = kern_right_class_mapping, diff --git a/demos/stress/lv_demo_stress.c b/demos/stress/lv_demo_stress.c index c129829a6..759aa3b67 100644 --- a/demos/stress/lv_demo_stress.c +++ b/demos/stress/lv_demo_stress.c @@ -172,7 +172,7 @@ static void obj_test_task_cb(lv_timer_t * tmr) break; case 8: - obj = lv_win_create(lv_scr_act(), 50); + obj = lv_win_create(lv_scr_act()); lv_obj_set_size(obj, LV_HOR_RES / 2, LV_VER_RES / 2); lv_obj_align(obj, LV_ALIGN_BOTTOM_RIGHT, 0, 0); lv_win_add_title(obj, "Window title"); diff --git a/docs/ROADMAP.rst b/docs/ROADMAP.rst index df89be1c7..3c8d34275 100644 --- a/docs/ROADMAP.rst +++ b/docs/ROADMAP.rst @@ -50,8 +50,7 @@ Architecture - |check| More color formats: 24 bit, ARGB1555, ARGB4444 etc - |uncheck| Add more feature to key presses (long press, release, etc). (see `here `__) -- |uncheck| Variable binding. I.e create properties which can be bound to - objects and those objects are notified on value change. Maybe based on `lv_msg`? +- |uncheck| Variable binding. I.e create properties which can be bound to objects and those objects are notified on value change. Maybe based on `lv_msg`? - |uncheck| Add GPU abstraction for display rotation - |uncheck| Replace the `read_line_cb` of the image decoders with `get_area_cb` - |uncheck| Limit the image caching size in bytes instead of image count diff --git a/docs/get-started/quick-overview.rst b/docs/get-started/quick-overview.rst index 786f38997..b4d29b0c0 100644 --- a/docs/get-started/quick-overview.rst +++ b/docs/get-started/quick-overview.rst @@ -34,8 +34,8 @@ If you would rather try LVGL on your own project follow these steps: - Include ``lvgl/lvgl.h`` in files where you need to use LVGL related functions. - Call :cpp:expr:`lv_tick_inc(x)` every ``x`` milliseconds in a Timer or Task (``x`` should be between 1 and 10). It is required for the internal - timing of LVGL. Alternatively, configure :c:macro:`LV_TICK_CUSTOM` (see - ``lv_conf.h``) so that LVGL can retrieve the current time directly. + timing of LVGL. Alternatively, register a ``tick_get_cb`` with + :cpp:func:`lv_tick_set_cb` so that LVGL can retrieve the current time directly. - Call :cpp:func:`lv_init` - Create a draw buffer: LVGL will render the graphics here first, and send the rendered image to the display. The buffer size can be set diff --git a/docs/overview/style-props.md b/docs/overview/style-props.md index 7f1275c65..9801f4024 100644 --- a/docs/overview/style-props.md +++ b/docs/overview/style-props.md @@ -836,3 +836,144 @@ Set the base direction of the object. The possible values are `LV_BIDI_DIR_LTR/R
  • Layout Yes
  • Ext. draw No
  • + +## Flex +Flex layout properties. + +### flex_flow +Defines in which direct the flex layout should arrange the children + + +### flex_main_place +Defines how to align the children in the direction of flex flow + + +### flex_cross_place +Defines how to align the children perpendicular to the direction of flex flow + + +### flex_track_place +Defines how to align the tracks of the flow + + +### flex_grow +Defines how mayn space to take proprtionally the free space of the object's trach + + +## Grid +Grid layout properties. + +### grid_column_dsc_array +An array to describe the columns of the grid. Should be LV_GRID_TEMPLATE_LAST terminated + + +### grid_column_align +Defines how to ditribute the columns + + +### grid_row_dsc_array +An array to describe the rows of the grid. Should be LV_GRID_TEMPLATE_LAST terminated + + +### grid_row_align +Defines how to ditribute the rows. + + +### grid_cell_column_pos +Set the column in which the object should be placed + + +### grid_cell_x_align +Set how to align the object horizontally. + + +### grid_cell_column_span +Set how many columns the object should span. Needs to be >= 1 + + +### grid_cell_row_pos +Set the row in which the object should be placed + + +### grid_cell_y_align +Set how to align the object vertically. + + +### grid_cell_row_span +Set how many rows the object should span. Needs to be >= 1 + diff --git a/docs/porting/project.rst b/docs/porting/project.rst index 04edd6743..5d2d1c7c5 100644 --- a/docs/porting/project.rst +++ b/docs/porting/project.rst @@ -104,6 +104,21 @@ from ``lv_conf.h`` or build settings (``-D...``) overwrite the values set in Kconfig. To ignore the configs from ``lv_conf.h`` simply remove its content, or define :c:macro:`LV_CONF_SKIP`. +To enable multi-instance feature, set :c:macro:`LV_GLOBAL_CUSTOM` in +``lv_conf.h`` and provide a custom function to +:cpp:func:`lv_global_default` using ``__thread`` or ``pthread_key_t``. + +For example: + +.. code:: c + + lv_global_t * lv_global_default(void) + { + static __thread lv_global_t lv_global; + return &lv_global; + } + + Initialization -------------- diff --git a/docs/porting/tick.rst b/docs/porting/tick.rst index a8e63ce75..5dada36ef 100644 --- a/docs/porting/tick.rst +++ b/docs/porting/tick.rst @@ -7,6 +7,16 @@ Tick interface LVGL needs a system tick to know elapsed time for animations and other tasks. +If you want to use a custom function to :cpp:func:`lv_tick_get`, you can +register a "tick_get_cb" with :cpp:func:`lv_tick_set_cb`. + +For example: + +.. code:: c + + lv_tick_set_cb(SDL_GetTicks); + + You need to call the :cpp:expr:`lv_tick_inc(tick_period)` function periodically and provide the call period in milliseconds. For example, :cpp:expr:`lv_tick_inc(1)` when calling every millisecond. diff --git a/examples/assets/img_star.c b/examples/assets/img_star.c index 74ee925dc..b42b2a8d3 100644 --- a/examples/assets/img_star.c +++ b/examples/assets/img_star.c @@ -12,35 +12,35 @@ const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_IMG_STAR uint8_t img_star_map[] = { /*Pixel format: Blue: 8 bit, Green: 8 bit, Red: 8 bit, Alpha: 8 bit*/ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd2, 0xff, 0x54, 0x43, 0xd9, 0xff, 0x23, 0x00, 0x00, 0x00, 0x00, 0x4d, 0xdb, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xce, 0xff, 0xc7, 0x4c, 0xdb, 0xff, 0xac, 0x31, 0xd6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0xff, 0x50, 0x08, 0xce, 0xff, 0xec, 0x4f, 0xdc, 0xff, 0xff, 0x50, 0xdb, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x4d, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0xaf, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x54, 0xdc, 0xff, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x4b, 0x00, 0xcc, 0xff, 0xe8, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x51, 0xdb, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00, 0x4e, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x08, 0x00, 0xcc, 0xff, 0x9c, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x3f, 0x00, 0xcc, 0xff, 0xe8, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xf0, 0x51, 0xdd, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x4f, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x0b, 0x00, 0xcc, 0xff, 0x8f, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0xff, 0x2c, 0x00, 0xcc, 0xff, 0xef, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xe4, 0x51, 0xdd, 0xff, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x07, 0x80, 0xe6, 0xff, 0x2f, 0x7b, 0xe5, 0xff, 0x5b, 0x36, 0xd7, 0xff, 0xb0, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xff, 0x5e, 0xdf, 0xff, 0xc4, 0x87, 0xe8, 0xff, 0x5b, 0x80, 0xe6, 0xff, 0x34, 0x80, 0xe6, 0xff, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x00, - 0x33, 0xd7, 0xff, 0x08, 0x6c, 0xe2, 0xff, 0x18, 0x81, 0xe6, 0xff, 0x3f, 0x81, 0xe6, 0xff, 0x68, 0x80, 0xe6, 0xff, 0x93, 0x80, 0xe6, 0xff, 0xbc, 0x80, 0xe6, 0xff, 0xe7, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x71, 0xe3, 0xff, 0xff, 0x1e, 0xd2, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x5b, 0xde, 0xff, 0xff, 0x78, 0xe5, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xeb, 0x80, 0xe6, 0xff, 0xc3, 0x80, 0xe6, 0xff, 0x98, 0x81, 0xe6, 0xff, 0x6f, 0x81, 0xe6, 0xff, 0x44, 0x71, 0xe3, 0xff, 0x1c, 0x35, 0xd7, 0xff, 0x07, - 0x31, 0xd6, 0xff, 0x87, 0x50, 0xdc, 0xff, 0xff, 0x6e, 0xe3, 0xff, 0xff, 0x77, 0xe4, 0xff, 0xff, 0x7e, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x5e, 0xdf, 0xff, 0xff, 0x0a, 0xce, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x6e, 0xe2, 0xff, 0xff, 0x83, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x7f, 0xe6, 0xff, 0xff, 0x78, 0xe4, 0xff, 0xff, 0x6e, 0xe2, 0xff, 0xff, 0x52, 0xdd, 0xff, 0xff, 0x38, 0xd8, 0xff, 0x83, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0xff, 0x93, 0x01, 0xcc, 0xff, 0xfb, 0x24, 0xd4, 0xff, 0xff, 0x4b, 0xdc, 0xff, 0xff, 0x65, 0xe1, 0xff, 0xff, 0x72, 0xe3, 0xff, 0xff, 0x7f, 0xe6, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x82, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x43, 0xda, 0xff, 0xff, 0x01, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x66, 0xe1, 0xff, 0xff, 0x82, 0xe7, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x74, 0xe4, 0xff, 0xff, 0x67, 0xe1, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x27, 0xd4, 0xff, 0xff, 0x04, 0xcd, 0xff, 0xfb, 0x00, 0xc9, 0xff, 0x8f, 0x00, 0xc1, 0xff, 0x0c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0x8b, 0x00, 0xcb, 0xff, 0xfb, 0x00, 0xcb, 0xff, 0xff, 0x06, 0xcd, 0xff, 0xff, 0x25, 0xd3, 0xff, 0xff, 0x45, 0xda, 0xff, 0xff, 0x5d, 0xdf, 0xff, 0xff, 0x70, 0xe3, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x87, 0xe7, 0xff, 0xff, 0x7a, 0xe5, 0xff, 0xff, 0x27, 0xd4, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x5e, 0xdf, 0xff, 0xff, 0x80, 0xe7, 0xff, 0xff, 0x84, 0xe7, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x75, 0xe4, 0xff, 0xff, 0x61, 0xe0, 0xff, 0xff, 0x4a, 0xdb, 0xff, 0xff, 0x2a, 0xd5, 0xff, 0xff, 0x09, 0xce, 0xff, 0xff, 0x00, 0xca, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xfc, 0x00, 0xcc, 0xff, 0x8c, 0x02, 0xcd, 0xff, 0x0b, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x08, 0x00, 0xcc, 0xff, 0x87, 0x00, 0xcc, 0xff, 0xf8, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xca, 0xff, 0xff, 0x08, 0xce, 0xff, 0xff, 0x22, 0xd3, 0xff, 0xff, 0x3c, 0xd8, 0xff, 0xff, 0x55, 0xde, 0xff, 0xff, 0x75, 0xe4, 0xff, 0xff, 0x6b, 0xe2, 0xff, 0xff, 0x1c, 0xd2, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x78, 0xe4, 0xff, 0xff, 0x5d, 0xdf, 0xff, 0xff, 0x42, 0xda, 0xff, 0xff, 0x28, 0xd4, 0xff, 0xff, 0x0c, 0xcf, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x88, 0x00, 0xcc, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, - 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x0b, 0x00, 0xcc, 0xff, 0x84, 0x00, 0xcc, 0xff, 0xfb, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x09, 0xce, 0xff, 0xff, 0x1b, 0xd2, 0xff, 0xff, 0x34, 0xd7, 0xff, 0xff, 0x2e, 0xd5, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x37, 0xd7, 0xff, 0xff, 0x1f, 0xd2, 0xff, 0xff, 0x0e, 0xcf, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x7f, 0x00, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x07, 0x00, 0xcc, 0xff, 0x84, 0x00, 0xcc, 0xff, 0xfc, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x02, 0xcd, 0xff, 0xff, 0x0d, 0xcf, 0xff, 0xff, 0x19, 0xd1, 0xff, 0xff, 0x39, 0xd8, 0xff, 0xff, 0x34, 0xd6, 0xff, 0xff, 0x3c, 0xd9, 0xff, 0xff, 0x1d, 0xd2, 0xff, 0xff, 0x07, 0xce, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x73, 0x00, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0x83, 0x00, 0xcc, 0xff, 0xff, 0x02, 0xcc, 0xff, 0xff, 0x10, 0xd0, 0xff, 0xff, 0x1d, 0xd2, 0xff, 0xff, 0x26, 0xd3, 0xff, 0xff, 0x26, 0xd3, 0xff, 0xff, 0x38, 0xd6, 0xff, 0xff, 0x4a, 0xdb, 0xff, 0xff, 0x08, 0xcd, 0xff, 0xff, 0x46, 0xda, 0xff, 0xff, 0x52, 0xdc, 0xff, 0xff, 0x4b, 0xdb, 0xff, 0xff, 0x3d, 0xd8, 0xff, 0xff, 0x20, 0xd3, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x6c, 0x00, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd1, 0xff, 0xb4, 0x28, 0xd4, 0xff, 0xff, 0x29, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x29, 0xd4, 0xff, 0xff, 0x2f, 0xd5, 0xff, 0xff, 0x4c, 0xdb, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x0c, 0xcf, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x39, 0xd8, 0xff, 0x8b, 0x1c, 0xd2, 0xff, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xc8, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x42, 0xd9, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x1e, 0xd2, 0xff, 0xff, 0x59, 0xde, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0x97, 0x55, 0xdd, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xef, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x39, 0xd7, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x02, 0xcc, 0xff, 0xff, 0x35, 0xd6, 0xff, 0xff, 0x57, 0xde, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xc0, 0x55, 0xdd, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x20, 0x2a, 0xd4, 0xff, 0xf4, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x31, 0xd6, 0xff, 0xff, 0x4d, 0xdc, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x0a, 0xcf, 0xff, 0xff, 0x46, 0xda, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xe8, 0x55, 0xdd, 0xff, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x4b, 0x2a, 0xd4, 0xff, 0xf7, 0x2a, 0xd4, 0xff, 0xff, 0x2c, 0xd5, 0xff, 0xff, 0x45, 0xda, 0xff, 0xff, 0x58, 0xde, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x19, 0xd1, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdd, 0xff, 0x1f, 0x4a, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x77, 0x2a, 0xd4, 0xff, 0xfb, 0x29, 0xd4, 0xff, 0xff, 0x3d, 0xd8, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xef, 0x05, 0xcd, 0xff, 0xf8, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x01, 0xcc, 0xff, 0xff, 0x2c, 0xd5, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdd, 0xff, 0x47, 0x52, 0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xa3, 0x29, 0xd4, 0xff, 0xfc, 0x34, 0xd6, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xfc, 0x55, 0xdd, 0xff, 0xb3, 0x53, 0xdd, 0xff, 0x58, 0x04, 0xcd, 0xff, 0x5c, 0x00, 0xcc, 0xff, 0xb0, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x08, 0xce, 0xff, 0xff, 0x3e, 0xd8, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x54, 0xdd, 0xff, 0x74, 0x54, 0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xcb, 0x2d, 0xd5, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdc, 0xff, 0xc0, 0x53, 0xdd, 0xff, 0x5b, 0x53, 0xdd, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x1b, 0x00, 0xcc, 0xff, 0x58, 0x00, 0xcc, 0xff, 0xbf, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x12, 0xd0, 0xff, 0xff, 0x4d, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xa4, 0x54, 0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd3, 0xff, 0x0b, 0x27, 0xd4, 0xff, 0xdc, 0x47, 0xda, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x51, 0xdc, 0xff, 0xdb, 0x4e, 0xdc, 0xff, 0x5c, 0x52, 0xdc, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0xd4, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x1b, 0x00, 0xcc, 0xff, 0x5c, 0x00, 0xcc, 0xff, 0xd7, 0x00, 0xcc, 0xff, 0xff, 0x24, 0xd3, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xd3, 0x5d, 0xdf, 0xff, 0x00, 0x39, 0xd7, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xd1, 0xff, 0x30, 0x41, 0xd9, 0xff, 0xef, 0x4f, 0xdc, 0xff, 0xf0, 0x48, 0xdb, 0xff, 0x6b, 0x4a, 0xdb, 0xff, 0x10, 0x3f, 0xda, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0x14, 0x00, 0xcc, 0xff, 0x6f, 0x00, 0xcc, 0xff, 0xef, 0x37, 0xd7, 0xff, 0xff, 0x49, 0xda, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xd7, 0xff, 0x4b, 0x40, 0xd9, 0xff, 0x70, 0x3a, 0xd8, 0xff, 0x10, 0x43, 0xda, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0xdb, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xcc, 0xff, 0x00, 0x00, 0xca, 0xff, 0x10, 0x0c, 0xce, 0xff, 0x90, 0x20, 0xd3, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd2, 0xff, 0x54, 0x43, 0xd9, 0xff, 0x23, 0x00, 0x00, 0x00, 0x00, 0x4d, 0xdb, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xce, 0xff, 0xc7, 0x4c, 0xdb, 0xff, 0xac, 0x31, 0xd6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcb, 0xff, 0x50, 0x08, 0xce, 0xff, 0xec, 0x4f, 0xdc, 0xff, 0xff, 0x50, 0xdb, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x4d, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0xaf, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x54, 0xdc, 0xff, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x4b, 0x00, 0xcc, 0xff, 0xe8, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x51, 0xdb, 0xff, 0x34, 0x00, 0x00, 0x00, 0x00, 0x4e, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x08, 0x00, 0xcc, 0xff, 0x9c, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x3f, 0x00, 0xcc, 0xff, 0xe8, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xf0, 0x51, 0xdd, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x4f, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x0b, 0x00, 0xcc, 0xff, 0x8f, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0xff, 0x2c, 0x00, 0xcc, 0xff, 0xef, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xe4, 0x51, 0xdd, 0xff, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x07, 0x80, 0xe6, 0xff, 0x2f, 0x7b, 0xe5, 0xff, 0x5b, 0x36, 0xd7, 0xff, 0xb0, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xff, 0x5e, 0xdf, 0xff, 0xc4, 0x87, 0xe8, 0xff, 0x5b, 0x80, 0xe6, 0xff, 0x34, 0x80, 0xe6, 0xff, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe6, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x33, 0xd7, 0xff, 0x08, 0x6c, 0xe2, 0xff, 0x18, 0x81, 0xe6, 0xff, 0x3f, 0x81, 0xe6, 0xff, 0x68, 0x80, 0xe6, 0xff, 0x93, 0x80, 0xe6, 0xff, 0xbc, 0x80, 0xe6, 0xff, 0xe7, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x71, 0xe3, 0xff, 0xff, 0x1e, 0xd2, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x5b, 0xde, 0xff, 0xff, 0x78, 0xe5, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xeb, 0x80, 0xe6, 0xff, 0xc3, 0x80, 0xe6, 0xff, 0x98, 0x81, 0xe6, 0xff, 0x6f, 0x81, 0xe6, 0xff, 0x44, 0x71, 0xe3, 0xff, 0x1c, 0x35, 0xd7, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x31, 0xd6, 0xff, 0x87, 0x50, 0xdc, 0xff, 0xff, 0x6e, 0xe3, 0xff, 0xff, 0x77, 0xe4, 0xff, 0xff, 0x7e, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x5e, 0xdf, 0xff, 0xff, 0x0a, 0xce, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x6e, 0xe2, 0xff, 0xff, 0x83, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x7f, 0xe6, 0xff, 0xff, 0x78, 0xe4, 0xff, 0xff, 0x6e, 0xe2, 0xff, 0xff, 0x52, 0xdd, 0xff, 0xff, 0x38, 0xd8, 0xff, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xca, 0xff, 0x93, 0x01, 0xcc, 0xff, 0xfb, 0x24, 0xd4, 0xff, 0xff, 0x4b, 0xdc, 0xff, 0xff, 0x65, 0xe1, 0xff, 0xff, 0x72, 0xe3, 0xff, 0xff, 0x7f, 0xe6, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x82, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x43, 0xda, 0xff, 0xff, 0x01, 0xcc, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x66, 0xe1, 0xff, 0xff, 0x82, 0xe7, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x74, 0xe4, 0xff, 0xff, 0x67, 0xe1, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x27, 0xd4, 0xff, 0xff, 0x04, 0xcd, 0xff, 0xfb, 0x00, 0xc9, 0xff, 0x8f, 0x00, 0xc1, 0xff, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0x8b, 0x00, 0xcb, 0xff, 0xfb, 0x00, 0xcb, 0xff, 0xff, 0x06, 0xcd, 0xff, 0xff, 0x25, 0xd3, 0xff, 0xff, 0x45, 0xda, 0xff, 0xff, 0x5d, 0xdf, 0xff, 0xff, 0x70, 0xe3, 0xff, 0xff, 0x81, 0xe6, 0xff, 0xff, 0x87, 0xe7, 0xff, 0xff, 0x7a, 0xe5, 0xff, 0xff, 0x27, 0xd4, 0xff, 0xff, 0x07, 0xcd, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x5e, 0xdf, 0xff, 0xff, 0x80, 0xe7, 0xff, 0xff, 0x84, 0xe7, 0xff, 0xff, 0x83, 0xe7, 0xff, 0xff, 0x75, 0xe4, 0xff, 0xff, 0x61, 0xe0, 0xff, 0xff, 0x4a, 0xdb, 0xff, 0xff, 0x2a, 0xd5, 0xff, 0xff, 0x09, 0xce, 0xff, 0xff, 0x00, 0xca, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xfc, 0x00, 0xcc, 0xff, 0x8c, 0x02, 0xcd, 0xff, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x08, 0x00, 0xcc, 0xff, 0x87, 0x00, 0xcc, 0xff, 0xf8, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xca, 0xff, 0xff, 0x08, 0xce, 0xff, 0xff, 0x22, 0xd3, 0xff, 0xff, 0x3c, 0xd8, 0xff, 0xff, 0x55, 0xde, 0xff, 0xff, 0x75, 0xe4, 0xff, 0xff, 0x6b, 0xe2, 0xff, 0xff, 0x1c, 0xd2, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x80, 0xe6, 0xff, 0xff, 0x78, 0xe4, 0xff, 0xff, 0x5d, 0xdf, 0xff, 0xff, 0x42, 0xda, 0xff, 0xff, 0x28, 0xd4, 0xff, 0xff, 0x0c, 0xcf, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x88, 0x00, 0xcc, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x0b, 0x00, 0xcc, 0xff, 0x84, 0x00, 0xcc, 0xff, 0xfb, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x09, 0xce, 0xff, 0xff, 0x1b, 0xd2, 0xff, 0xff, 0x34, 0xd7, 0xff, 0xff, 0x2e, 0xd5, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x37, 0xd7, 0xff, 0xff, 0x1f, 0xd2, 0xff, 0xff, 0x0e, 0xcf, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x7f, 0x00, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x07, 0x00, 0xcc, 0xff, 0x84, 0x00, 0xcc, 0xff, 0xfc, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x02, 0xcd, 0xff, 0xff, 0x0d, 0xcf, 0xff, 0xff, 0x19, 0xd1, 0xff, 0xff, 0x39, 0xd8, 0xff, 0xff, 0x34, 0xd6, 0xff, 0xff, 0x3c, 0xd9, 0xff, 0xff, 0x1d, 0xd2, 0xff, 0xff, 0x07, 0xce, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcb, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x73, 0x00, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0x83, 0x00, 0xcc, 0xff, 0xff, 0x02, 0xcc, 0xff, 0xff, 0x10, 0xd0, 0xff, 0xff, 0x1d, 0xd2, 0xff, 0xff, 0x26, 0xd3, 0xff, 0xff, 0x26, 0xd3, 0xff, 0xff, 0x38, 0xd6, 0xff, 0xff, 0x4a, 0xdb, 0xff, 0xff, 0x08, 0xcd, 0xff, 0xff, 0x46, 0xda, 0xff, 0xff, 0x52, 0xdc, 0xff, 0xff, 0x4b, 0xdb, 0xff, 0xff, 0x3d, 0xd8, 0xff, 0xff, 0x20, 0xd3, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0x6c, 0x00, 0xcc, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd1, 0xff, 0xb4, 0x28, 0xd4, 0xff, 0xff, 0x29, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x29, 0xd4, 0xff, 0xff, 0x2f, 0xd5, 0xff, 0xff, 0x4c, 0xdb, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x0c, 0xcf, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x39, 0xd8, 0xff, 0x8b, 0x1c, 0xd2, 0xff, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xc8, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x42, 0xd9, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x4f, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x1e, 0xd2, 0xff, 0xff, 0x59, 0xde, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0x97, 0x55, 0xdd, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xef, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x39, 0xd7, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x02, 0xcc, 0xff, 0xff, 0x35, 0xd6, 0xff, 0xff, 0x57, 0xde, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xc0, 0x55, 0xdd, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x20, 0x2a, 0xd4, 0xff, 0xf4, 0x2a, 0xd4, 0xff, 0xff, 0x2a, 0xd4, 0xff, 0xff, 0x31, 0xd6, 0xff, 0xff, 0x4d, 0xdc, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x0a, 0xcf, 0xff, 0xff, 0x46, 0xda, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xe8, 0x55, 0xdd, 0xff, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x4b, 0x2a, 0xd4, 0xff, 0xf7, 0x2a, 0xd4, 0xff, 0xff, 0x2c, 0xd5, 0xff, 0xff, 0x45, 0xda, 0xff, 0xff, 0x58, 0xde, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x05, 0xcd, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x19, 0xd1, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdd, 0xff, 0x1f, 0x4a, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x77, 0x2a, 0xd4, 0xff, 0xfb, 0x29, 0xd4, 0xff, 0xff, 0x3d, 0xd8, 0xff, 0xff, 0x57, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x50, 0xdc, 0xff, 0xef, 0x05, 0xcd, 0xff, 0xf8, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x01, 0xcc, 0xff, 0xff, 0x2c, 0xd5, 0xff, 0xff, 0x54, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdd, 0xff, 0x47, 0x52, 0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xa3, 0x29, 0xd4, 0xff, 0xfc, 0x34, 0xd6, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xfc, 0x55, 0xdd, 0xff, 0xb3, 0x53, 0xdd, 0xff, 0x58, 0x04, 0xcd, 0xff, 0x5c, 0x00, 0xcc, 0xff, 0xb0, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x08, 0xce, 0xff, 0xff, 0x3e, 0xd8, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x54, 0xdd, 0xff, 0x74, 0x54, 0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd4, 0xff, 0xcb, 0x2d, 0xd5, 0xff, 0xff, 0x4e, 0xdc, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xff, 0x53, 0xdc, 0xff, 0xc0, 0x53, 0xdd, 0xff, 0x5b, 0x53, 0xdd, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x1b, 0x00, 0xcc, 0xff, 0x58, 0x00, 0xcc, 0xff, 0xbf, 0x00, 0xcc, 0xff, 0xff, 0x00, 0xcc, 0xff, 0xff, 0x12, 0xd0, 0xff, 0xff, 0x4d, 0xdc, 0xff, 0xff, 0x55, 0xdd, 0xff, 0xa4, 0x54, 0xdd, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xd3, 0xff, 0x0b, 0x27, 0xd4, 0xff, 0xdc, 0x47, 0xda, 0xff, 0xff, 0x56, 0xdd, 0xff, 0xff, 0x51, 0xdc, 0xff, 0xdb, 0x4e, 0xdc, 0xff, 0x5c, 0x52, 0xdc, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0xd4, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x1b, 0x00, 0xcc, 0xff, 0x5c, 0x00, 0xcc, 0xff, 0xd7, 0x00, 0xcc, 0xff, 0xff, 0x24, 0xd3, 0xff, 0xff, 0x53, 0xdd, 0xff, 0xd3, 0x5d, 0xdf, 0xff, 0x00, 0x39, 0xd7, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xd1, 0xff, 0x30, 0x41, 0xd9, 0xff, 0xef, 0x4f, 0xdc, 0xff, 0xf0, 0x48, 0xdb, 0xff, 0x6b, 0x4a, 0xdb, 0xff, 0x10, 0x3f, 0xda, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0xdc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x03, 0x00, 0xcc, 0xff, 0x14, 0x00, 0xcc, 0xff, 0x6f, 0x00, 0xcc, 0xff, 0xef, 0x37, 0xd7, 0xff, 0xff, 0x49, 0xda, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0xd7, 0xff, 0x4b, 0x40, 0xd9, 0xff, 0x70, 0x3a, 0xd8, 0xff, 0x10, 0x43, 0xda, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0xdb, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0xcc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xcc, 0xff, 0x00, 0x00, 0xca, 0xff, 0x10, 0x0c, 0xce, 0xff, 0x90, 0x20, 0xd3, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; const lv_img_dsc_t img_star = { diff --git a/examples/layouts/flex/lv_example_flex_2.py b/examples/layouts/flex/lv_example_flex_2.py index 07003c43e..9946ccd2d 100644 --- a/examples/layouts/flex/lv_example_flex_2.py +++ b/examples/layouts/flex/lv_example_flex_2.py @@ -5,7 +5,7 @@ style = lv.style_t() style.init() style.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP) style.set_flex_main_place(lv.FLEX_ALIGN.SPACE_EVENLY) -style.set_layout(lv.LAYOUT_FLEX.value) +style.set_layout(lv.LAYOUT.FLEX) cont = lv.obj(lv.scr_act()) cont.set_size(300, 220) diff --git a/examples/layouts/grid/lv_example_grid_1.py b/examples/layouts/grid/lv_example_grid_1.py index a5006ca04..55a5b5bc7 100644 --- a/examples/layouts/grid/lv_example_grid_1.py +++ b/examples/layouts/grid/lv_example_grid_1.py @@ -11,7 +11,7 @@ cont.set_style_grid_column_dsc_array(col_dsc, 0) cont.set_style_grid_row_dsc_array(row_dsc, 0) cont.set_size(300, 220) cont.center() -cont.set_layout(lv.LAYOUT_GRID.value) +cont.set_layout(lv.LAYOUT.GRID) for i in range(9): col = i % 3 diff --git a/examples/libs/ffmpeg/lv_example_ffmpeg_2.py b/examples/libs/ffmpeg/lv_example_ffmpeg_2.py index 4fbbcde71..b9ca590a5 100644 --- a/examples/libs/ffmpeg/lv_example_ffmpeg_2.py +++ b/examples/libs/ffmpeg/lv_example_ffmpeg_2.py @@ -1,17 +1,2 @@ -#!/opt/bin/lv_micropython-ffmpeg -i -import sys -import lvgl as lv -import display_driver - -# -# Open a video from a file -# - -# birds.mp4 is downloaded from http://www.videezy.com (Free Stock Footage by Videezy!) -# https://www.videezy.com/abstract/44864-silhouettes-of-birds-over-the-sunset -player = lv.ffmpeg_player(lv.scr_act()) -player.player_set_src("birds.mp4") -player.player_set_auto_restart(True) -player.player_set_cmd(lv.ffmpeg_player.PLAYER_CMD.START) -# player.player_set_cmd(0) -player.center() +#TODO +pass diff --git a/examples/others/imgfont/lv_example_imgfont_1.py b/examples/others/imgfont/lv_example_imgfont_1.py index 9cad63fe7..e8f6d6ef6 100644 --- a/examples/others/imgfont/lv_example_imgfont_1.py +++ b/examples/others/imgfont/lv_example_imgfont_1.py @@ -1,40 +1,3 @@ -import fs_driver -import sys +#TODO +pass -# set LV_USE_FFMPEG to True if it is enabled in lv_conf.h -LV_USE_FFMPEG = True -LV_FONT_DEFAULT = lv.font_montserrat_14 - -fs_drv = lv.fs_drv_t() -fs_driver.fs_register(fs_drv, 'A') - -# get the directory in which the script is running -try: - script_path = __file__[:__file__.rfind('/')] if __file__.find('/') >= 0 else '.' -except NameError: - script_path = '' - -def get_imgfont_path(font, unicode, unicode_next, offset_y, user_data) : - if unicode < 0xf000: None - if unicode == 0xF600: - if LV_USE_FFMPEG: - return bytes(script_path + "/../../assets/emoji/{:04X}.png".format(unicode) + "\0","ascii") - else: - return bytes("A:"+ script_path + "/../../assets/emoji/{:04X}.png".format(unicode) + "\0","ascii") - - return None - -# -# draw img in label or span obj -# -imgfont = lv.imgfont_create(80, get_imgfont_path, None) -if imgfont == None: - print("imgfont init error") - sys.exit(1) - -imgfont.fallback = LV_FONT_DEFAULT - -label1 = lv.label(lv.scr_act()) -label1.set_text("12\uF600\uF617AB") -label1.set_style_text_font(imgfont, lv.PART.MAIN) -label1.center() diff --git a/examples/others/msg/lv_example_msg_3.py b/examples/others/msg/lv_example_msg_3.py index 088019352..436316547 100644 --- a/examples/others/msg/lv_example_msg_3.py +++ b/examples/others/msg/lv_example_msg_3.py @@ -54,7 +54,7 @@ class LV_Example_Msg_2: # Slider slider = lv.slider(panel) slider.set_flex_grow(1) - slider.add_flag(lv.OBJ_FLAG_FLEX_IN_NEW_TRACK) + slider.add_flag(lv.obj.FLAG.FLEX_IN_NEW_TRACK) slider.add_event(self.slider_event_cb, lv.EVENT.ALL, None) lv.msg_subscribe_obj(MSG_UPDATE, slider, None) diff --git a/examples/widgets/menu/lv_example_menu_5.py b/examples/widgets/menu/lv_example_menu_5.py index d37634e61..05026ca77 100644 --- a/examples/widgets/menu/lv_example_menu_5.py +++ b/examples/widgets/menu/lv_example_menu_5.py @@ -18,7 +18,7 @@ def create_text(parent, icon, txt, builder_variant): label.set_flex_grow(1) if builder_variant == LV_MENU_ITEM_BUILDER_VARIANT_2 and icon and txt : - img.add_flag(lv.OBJ_FLAG_FLEX_IN_NEW_TRACK) + img.add_flag(lv.obj.FLAG.FLEX_IN_NEW_TRACK) img.swap(label) return obj @@ -34,7 +34,7 @@ def create_slider(parent, icon, txt, min, max, val) : slider.set_value(val, lv.ANIM.OFF) if icon == None : - slider.add_flag(lv.obj.FLAG_FLEX.IN_NEW_TRACK) + slider.add_flag(lv.obj.FLAG.FLEX_IN_NEW_TRACK) return obj diff --git a/examples/widgets/spinner/lv_example_spinner_1.c b/examples/widgets/spinner/lv_example_spinner_1.c index ac3cd8665..fa07ffe24 100644 --- a/examples/widgets/spinner/lv_example_spinner_1.c +++ b/examples/widgets/spinner/lv_example_spinner_1.c @@ -4,7 +4,7 @@ void lv_example_spinner_1(void) { /*Create a spinner*/ - lv_obj_t * spinner = lv_spinner_create(lv_scr_act(), 1000, 200); + lv_obj_t * spinner = lv_spinner_create(lv_scr_act()); lv_obj_set_size(spinner, 100, 100); lv_obj_center(spinner); } diff --git a/examples/widgets/spinner/lv_example_spinner_1.py b/examples/widgets/spinner/lv_example_spinner_1.py index 8c342f358..fd22ce2f1 100644 --- a/examples/widgets/spinner/lv_example_spinner_1.py +++ b/examples/widgets/spinner/lv_example_spinner_1.py @@ -1,5 +1,5 @@ # Create a spinner -spinner = lv.spinner(lv.scr_act(), 1000, 60) +spinner = lv.spinner(lv.scr_act()) spinner.set_size(100, 100) spinner.center() diff --git a/examples/widgets/win/lv_example_win_1.c b/examples/widgets/win/lv_example_win_1.c index 202fda99a..e5f427f7d 100644 --- a/examples/widgets/win/lv_example_win_1.c +++ b/examples/widgets/win/lv_example_win_1.c @@ -11,7 +11,7 @@ static void event_handler(lv_event_t * e) void lv_example_win_1(void) { - lv_obj_t * win = lv_win_create(lv_scr_act(), 40); + lv_obj_t * win = lv_win_create(lv_scr_act()); lv_obj_t * btn; btn = lv_win_add_btn(win, LV_SYMBOL_LEFT, 40); lv_obj_add_event(btn, event_handler, LV_EVENT_CLICKED, NULL); diff --git a/examples/widgets/win/lv_example_win_1.py b/examples/widgets/win/lv_example_win_1.py index 03984699d..56b8a2157 100644 --- a/examples/widgets/win/lv_example_win_1.py +++ b/examples/widgets/win/lv_example_win_1.py @@ -5,7 +5,7 @@ def event_handler(e): print("Button {:d} clicked".format(obj.get_child_id())) -win = lv.win(lv.scr_act(), 60) +win = lv.win(lv.scr_act()) btn1 = win.add_btn(lv.SYMBOL.LEFT, 40) btn1.add_event(event_handler, lv.EVENT.ALL, None) win.add_title("A title") diff --git a/lv_conf_template.h b/lv_conf_template.h index c864ecc20..56bbf72dc 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -68,17 +68,6 @@ /*Default display refresh, input device read and animation step period.*/ #define LV_DEF_REFR_PERIOD 33 /*[ms]*/ -/*Use a custom tick source that tells the elapsed time in milliseconds. - *It removes the need to manually update the tick with `lv_tick_inc()`)*/ -#define LV_TICK_CUSTOM 0 -#if LV_TICK_CUSTOM - #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ - #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ - /*If using lvgl as ESP32 component*/ - // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" - // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) -#endif /*LV_TICK_CUSTOM*/ - /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. *(Not so important, you can adjust it to modify default sizes and spaces)*/ #define LV_DPI_DEF 130 /*[px/inch]*/ @@ -99,6 +88,12 @@ #define LV_DRAW_BUF_ALIGN 4 #endif +/*Align the stride of all layers and images to this bytes*/ +#define LV_DRAW_BUF_STRIDE_ALIGN 1 + +/*Align the start address of draw_buf addresses to this bytes*/ +#define LV_DRAW_BUF_ALIGN 4 + /* Max. memory to be used for layers */ #define LV_LAYER_MAX_MEMORY_USAGE 150 /*[kB]*/ @@ -150,7 +145,6 @@ #define LV_OS_CUSTOM_INCLUDE #endif - /*======================= * FEATURE CONFIGURATION *=======================*/ @@ -254,12 +248,11 @@ *Only used if software rotation is enabled in the display driver.*/ #define LV_DISP_ROT_MAX_BUF (10*1024) -/*Garbage Collector settings - *Used if lvgl is bound to higher level language and the memory is managed by that language*/ -#define LV_ENABLE_GC 0 -#if LV_ENABLE_GC != 0 - #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ -#endif /*LV_ENABLE_GC*/ +#define LV_ENABLE_GLOBAL_CUSTOM 0 +#if LV_ENABLE_GLOBAL_CUSTOM + /*Header to include for the custom 'lv_global' function"*/ + #define LV_GLOBAL_CUSTOM_INCLUDE +#endif /*Default image cache size. Image caching keeps some images opened. *If only the built-in image formats are used there is no real advantage of caching. diff --git a/lvgl.h b/lvgl.h index b0751b7a3..42a8433df 100644 --- a/lvgl.h +++ b/lvgl.h @@ -100,7 +100,7 @@ extern "C" { #include "src/libs/ffmpeg/lv_ffmpeg.h" #include "src/libs/tiny_ttf/lv_tiny_ttf.h" -#include "src/layouts/lv_layouts.h" +#include "src/layouts/lv_layout.h" #include "src/draw/lv_draw.h" @@ -119,6 +119,7 @@ extern "C" { #include "src/dev/input/touchscreen/lv_nuttx_touchscreen.h" +#include "src/core/lv_global.h" /********************* * DEFINES *********************/ @@ -180,7 +181,7 @@ static inline int lv_version_patch(void) return LVGL_VERSION_PATCH; } -static inline const char *lv_version_info(void) +static inline const char * lv_version_info(void) { return LVGL_VERSION_INFO; } diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index 398ced0d6..239f6dafe 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -372,6 +372,80 @@ props = [ {'name': 'BASE_DIR', 'style_type': 'num', 'var_type': 'lv_base_dir_t', 'default':'`LV_BASE_DIR_AUTO`', 'inherited': 1, 'layout': 1, 'ext_draw': 0, 'dsc': "Set the base direction of the object. The possible values are `LV_BIDI_DIR_LTR/RTL/AUTO`."}, + + + +{'section': 'Flex', 'dsc':'Flex layout properties.' }, + + +{'name': 'FLEX_FLOW', + 'style_type': 'num', 'var_type': 'lv_flex_flow_t', 'default':'`LV_FLEX_FLOW_NONE`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines in which direct the flex layout should arrange the children"}, + + +{'name': 'FLEX_MAIN_PLACE', + 'style_type': 'num', 'var_type': 'lv_flex_align_t', 'default':'`LV_FLEX_ALIGN_NONE`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines how to align the children in the direction of flex flow"}, + + +{'name': 'FLEX_CROSS_PLACE', + 'style_type': 'num', 'var_type': 'lv_flex_align_t', 'default':'`LV_FLEX_ALIGN_NONE`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines how to align the children perpendicular to the direction of flex flow"}, + + +{'name': 'FLEX_TRACK_PLACE', + 'style_type': 'num', 'var_type': 'lv_flex_align_t', 'default':'`LV_FLEX_ALIGN_NONE`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines how to align the tracks of the flow"}, + +{'name': 'FLEX_GROW', + 'style_type': 'num', 'var_type': 'uint8_t', 'default':'`LV_FLEX_ALIGN_ROW`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines how mayn space to take proprtionally the free space of the object's trach"}, + + + +{'section': 'Grid', 'dsc':'Grid layout properties.' }, + + +{'name': 'GRID_COLUMN_DSC_ARRAY', + 'style_type': 'ptr', 'var_type': 'const lv_coord_t *', 'default':'`NULL`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "An array to describe the columns of the grid. Should be LV_GRID_TEMPLATE_LAST terminated"}, + +{'name': 'GRID_COLUMN_ALIGN', + 'style_type': 'num', 'var_type': 'lv_grid_align_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines how to ditribute the columns"}, + + +{'name': 'GRID_ROW_DSC_ARRAY', + 'style_type': 'ptr', 'var_type': 'const lv_coord_t *', 'default':'`NULL`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "An array to describe the rows of the grid. Should be LV_GRID_TEMPLATE_LAST terminated"}, + +{'name': 'GRID_ROW_ALIGN', + 'style_type': 'num', 'var_type': 'lv_grid_align_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Defines how to ditribute the rows."}, + +{'name': 'GRID_CELL_COLUMN_POS', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Set the column in which the object should be placed"}, + +{'name': 'GRID_CELL_X_ALIGN', + 'style_type': 'num', 'var_type': 'lv_grid_align_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Set how to align the object horizontally."}, + +{'name': 'GRID_CELL_COLUMN_SPAN', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Set how many columns the object should span. Needs to be >= 1"}, + +{'name': 'GRID_CELL_ROW_POS', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Set the row in which the object should be placed"}, + +{'name': 'GRID_CELL_Y_ALIGN', + 'style_type': 'num', 'var_type': 'lv_grid_align_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Set how to align the object vertically."}, + +{'name': 'GRID_CELL_ROW_SPAN', + 'style_type': 'num', 'var_type': 'lv_coord_t', 'default':'`LV_GRID_ALIGN_START`', 'inherited': 0, 'layout': 1, 'ext_draw': 0, + 'dsc': "Set how many rows the object should span. Needs to be >= 1"}, ] diff --git a/src/core/lv_global.h b/src/core/lv_global.h new file mode 100644 index 000000000..75c1150d0 --- /dev/null +++ b/src/core/lv_global.h @@ -0,0 +1,221 @@ +/** + * @file lv_global.h + * + */ + +#ifndef LV_GLOBAL_H +#define LV_GLOBAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_conf_internal.h" + +#include + +#include "../draw/lv_img_cache.h" +#include "../draw/lv_draw.h" +#if LV_USE_DRAW_SW +#include "../draw/sw/lv_draw_sw.h" +#endif +#include "../misc/lv_anim.h" +#include "../misc/lv_area.h" +#include "../misc/lv_color_op.h" +#include "../misc/lv_ll.h" +#include "../misc/lv_log.h" +#include "../misc/lv_profiler_builtin.h" +#include "../misc/lv_style.h" +#include "../misc/lv_timer.h" +#include "../stdlib/builtin/lv_tlsf.h" + +#if LV_USE_FONT_COMPRESSED +#include "../font/lv_font_fmt_txt.h" +#endif + +#include "../tick/lv_tick.h" +#include "../layouts/lv_layout.h" + +/********************* + * DEFINES + *********************/ +#define ZERO_MEM_SENTINEL 0xa1b2c3d4 + +/********************** + * TYPEDEFS + **********************/ + +struct _lv_disp_t; +struct _lv_group_t; +struct _my_theme_t; +struct _lv_indev_t; +struct _lv_event_t; +struct _lv_obj_t; + +#if LV_USE_SPAN != 0 +struct _snippet_stack; +#endif + +#if LV_USE_FREETYPE +struct _lv_freetype_context_t; +#endif + +typedef struct _lv_global_t { + bool inited; + + lv_ll_t disp_ll; + struct _lv_disp_t * disp_refresh; + struct _lv_disp_t * disp_default; + + lv_ll_t style_trans_ll; + bool style_refresh; + uint32_t style_custom_table_size; + uint16_t style_last_custom_prop_id; + uint8_t * style_custom_prop_flag_lookup_table; + + lv_ll_t group_ll; + struct _lv_group_t * group_default; + + lv_ll_t indev_ll; + struct _lv_indev_t * indev_active; + struct _lv_obj_t * indev_obj_active; + + uint32_t layout_count; + lv_layout_dsc_t * layout_list; + bool layout_update_mutex; + + uint32_t memory_zero; + uint32_t math_rand_seed; + lv_area_transform_cache_t area_trans_cache; + + struct _lv_event_t * event_header; + uint32_t event_last_register_id; + + lv_timer_state_t timer_state; + lv_anim_state_t anim_state; + lv_tick_state_t tick_state; + + lv_ll_t img_decoder_ll; + lv_img_cache_manager_t img_cache_mgr; +#if LV_IMG_CACHE_DEF_SIZE + uint16_t img_cache_entry_cnt; + _lv_img_cache_entry_t * img_cache_array; +#else + _lv_img_cache_entry_t img_cache_single; +#endif + + lv_draw_cache_t draw_cache; +#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0 + lv_draw_sw_shadow_cache_t sw_shadow_cache; +#endif +#if LV_DRAW_SW_COMPLEX + _lv_draw_sw_mask_radius_circle_dsc_arr_t sw_circle_cache; +#endif + + lv_log_print_g_cb_t custom_log_print_cb; +#if LV_LOG_USE_TIMESTAMP + uint32_t log_last_log_time; +#endif + +#if LV_USE_THEME_BASIC + struct _my_theme_t * theme_basic; +#endif + +#if LV_USE_THEME_DEFAULT + struct _my_theme_t * theme_default; +#endif + +#if LV_USE_THEME_MONO + struct _my_theme_t * theme_mono; +#endif + +#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN + lv_tlsf_state_t tlsf_state; +#endif + + lv_ll_t fsdrv_ll; +#if LV_USE_FS_STDIO != '\0' + lv_fs_drv_t stdio_fs_drv; +#endif +#if LV_USE_FS_POSIX + lv_fs_drv_t posix_fs_drv; +#endif + +#if LV_USE_FS_FATFS + lv_fs_drv_t fatfs_fs_drv; +#endif + +#if LV_USE_FS_WIN32 != '\0' + lv_fs_drv_t win32_fs_drv; +#endif + +#if LV_USE_FREETYPE + struct _lv_freetype_context_t * ft_context; +#endif + +#if LV_USE_FONT_COMPRESSED + lv_font_fmt_rle_t font_fmt_rle; +#endif + +#if LV_USE_SPAN != 0 + struct _snippet_stack * span_snippet_stack; +#endif + +#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN + lv_profiler_builtin_ctx_t profiler_context; +#endif + +#if LV_USE_MSG + bool msg_restart_notify; + unsigned int msg_recursion_counter; + lv_ll_t msg_subs_ll; +#endif + +#if LV_USE_FILE_EXPLORER != 0 + lv_style_t fe_list_btn_style; +#endif + +#if LV_USE_SYSMON && LV_USE_PERF_MONITOR + void * sysmon_perf_info; +#endif + +#if LV_USE_IME_PINYIN != 0 + uint16_t ime_cand_len; +#endif +} lv_global_t; + + +/********************** + * MACROS + **********************/ + +#if LV_ENABLE_GLOBAL_CUSTOM +#include LV_GLOBAL_CUSTOM_INCLUDE + +#ifndef LV_GLOBAL_CUSTOM +#define LV_GLOBAL_CUSTOM() lv_global_default() +#endif +#define LV_GLOBAL_DEFAULT() LV_GLOBAL_CUSTOM() +#else +extern lv_global_t lv_global; +#define LV_GLOBAL_DEFAULT() (&lv_global) +#endif + +/********************** + * GLOBAL PROTOTYPES + **********************/ +#if LV_ENABLE_GLOBAL_CUSTOM +/** + * Get the default global object for current thread + * @return pointer to the default global object + */ +lv_global_t * lv_global_default(void); +#endif +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_GLOBAL_H*/ diff --git a/src/core/lv_group.c b/src/core/lv_group.c index 592154a93..0b541bc48 100644 --- a/src/core/lv_group.c +++ b/src/core/lv_group.c @@ -9,13 +9,15 @@ #include #include "lv_group.h" -#include "../misc/lv_gc.h" #include "../core/lv_obj.h" +#include "../core/lv_global.h" #include "../indev/lv_indev.h" /********************* * DEFINES *********************/ +#define default_group LV_GLOBAL_DEFAULT()->group_default +#define group_ll_p &(LV_GLOBAL_DEFAULT()->group_ll) /********************** * TYPEDEFS @@ -32,7 +34,6 @@ static lv_indev_t * get_indev(const lv_group_t * g); /********************** * STATIC VARIABLES **********************/ -static lv_group_t * default_group; /********************** * MACROS @@ -44,12 +45,12 @@ static lv_group_t * default_group; void _lv_group_init(void) { - _lv_ll_init(&LV_GC_ROOT(_lv_group_ll), sizeof(lv_group_t)); + _lv_ll_init(group_ll_p, sizeof(lv_group_t)); } lv_group_t * lv_group_create(void) { - lv_group_t * group = _lv_ll_ins_head(&LV_GC_ROOT(_lv_group_ll)); + lv_group_t * group = _lv_ll_ins_head(group_ll_p); LV_ASSERT_MALLOC(group); if(group == NULL) return NULL; _lv_ll_init(&group->obj_ll, sizeof(lv_obj_t *)); @@ -93,7 +94,7 @@ void lv_group_del(lv_group_t * group) if(group == lv_group_get_default()) lv_group_set_default(NULL); _lv_ll_clear(&(group->obj_ll)); - _lv_ll_remove(&LV_GC_ROOT(_lv_group_ll), group); + _lv_ll_remove(group_ll_p, group); lv_free(group); } diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index 3a63d1fb7..ce06e0a4a 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -116,6 +116,9 @@ typedef enum { LV_OBJ_FLAG_IGNORE_LAYOUT = (1L << 17), /**< Make the object position-able by the layouts*/ LV_OBJ_FLAG_FLOATING = (1L << 18), /**< Do not scroll the object when the parent scrolls and ignore layout*/ LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS = (1L << 19), /**< Send `LV_EVENT_DRAW_TASK_ADDED` events*/ +#if LV_USE_FLEX + LV_OBJ_FLAG_FLEX_IN_NEW_TRACK = (1L << 20), /**< Start a new flex track on this item*/ +#endif LV_OBJ_FLAG_LAYOUT_1 = (1L << 23), /**< Custom flag, free to use by layouts*/ LV_OBJ_FLAG_LAYOUT_2 = (1L << 24), /**< Custom flag, free to use by layouts*/ diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index abef80f29..09c4f6254 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -10,12 +10,13 @@ #include "../disp/lv_disp.h" #include "../disp/lv_disp_private.h" #include "lv_refr.h" -#include "../misc/lv_gc.h" +#include "../core/lv_global.h" /********************* * DEFINES *********************/ #define MY_CLASS &lv_obj_class +#define update_layout_mutex LV_GLOBAL_DEFAULT()->layout_update_mutex /********************** * TYPEDEFS @@ -32,7 +33,6 @@ static void transform_point(const lv_obj_t * obj, lv_point_t * p, bool inv); /********************** * STATIC VARIABLES **********************/ -static uint32_t layout_cnt; /********************** * MACROS @@ -288,12 +288,11 @@ void lv_obj_mark_layout_as_dirty(lv_obj_t * obj) void lv_obj_update_layout(const lv_obj_t * obj) { - static bool mutex = false; - if(mutex) { + if(update_layout_mutex) { LV_LOG_TRACE("Already running, returning"); return; } - mutex = true; + update_layout_mutex = true; lv_obj_t * scr = lv_obj_get_screen(obj); /*Repeat until there are no more layout invalidations*/ @@ -304,18 +303,7 @@ void lv_obj_update_layout(const lv_obj_t * obj) LV_LOG_TRACE("Layout update end"); } - mutex = false; -} - -uint32_t lv_layout_register(lv_layout_update_cb_t cb, void * user_data) -{ - layout_cnt++; - LV_GC_ROOT(_lv_layout_list) = lv_realloc(LV_GC_ROOT(_lv_layout_list), layout_cnt * sizeof(lv_layout_dsc_t)); - LV_ASSERT_MALLOC(LV_GC_ROOT(_lv_layout_list)); - - LV_GC_ROOT(_lv_layout_list)[layout_cnt - 1].cb = cb; - LV_GC_ROOT(_lv_layout_list)[layout_cnt - 1].user_data = user_data; - return layout_cnt; /*No -1 to skip 0th index*/ + update_layout_mutex = false; } void lv_obj_set_align(lv_obj_t * obj, lv_align_t align) @@ -1120,11 +1108,7 @@ static void layout_update_core(lv_obj_t * obj) lv_obj_refr_pos(obj); if(child_cnt > 0) { - uint32_t layout_id = lv_obj_get_style_layout(obj, LV_PART_MAIN); - if(layout_id > 0 && layout_id <= layout_cnt) { - void * user_data = LV_GC_ROOT(_lv_layout_list)[layout_id - 1].user_data; - LV_GC_ROOT(_lv_layout_list)[layout_id - 1].cb(obj, user_data); - } + _lv_layout_apply(obj); } } diff --git a/src/core/lv_obj_pos.h b/src/core/lv_obj_pos.h index d20ee9656..a7aac531d 100644 --- a/src/core/lv_obj_pos.h +++ b/src/core/lv_obj_pos.h @@ -22,13 +22,6 @@ extern "C" { /********************** * TYPEDEFS **********************/ -struct _lv_obj_t; - -typedef void (*lv_layout_update_cb_t)(struct _lv_obj_t *, void * user_data); -typedef struct { - lv_layout_update_cb_t cb; - void * user_data; -} lv_layout_dsc_t; /********************** * GLOBAL PROTOTYPES @@ -152,14 +145,6 @@ void lv_obj_mark_layout_as_dirty(struct _lv_obj_t * obj); */ void lv_obj_update_layout(const struct _lv_obj_t * obj); -/** - * Register a new layout - * @param cb the layout update callback - * @param user_data custom data that will be passed to `cb` - * @return the ID of the new layout - */ -uint32_t lv_layout_register(lv_layout_update_cb_t cb, void * user_data); - /** * Change the alignment of an object. * @param obj pointer to an object to align diff --git a/src/core/lv_obj_style.c b/src/core/lv_obj_style.c index ee8e212c0..22b0076a2 100644 --- a/src/core/lv_obj_style.c +++ b/src/core/lv_obj_style.c @@ -9,14 +9,16 @@ #include "lv_obj.h" #include "../disp/lv_disp.h" #include "../disp/lv_disp_private.h" -#include "../misc/lv_gc.h" #include "../misc/lv_color.h" #include "../stdlib/lv_string.h" - +#include "../core/lv_global.h" /********************* * DEFINES *********************/ #define MY_CLASS &lv_obj_class +#define style_refr LV_GLOBAL_DEFAULT()->style_refresh +#define style_trans_ll_p &(LV_GLOBAL_DEFAULT()->style_trans_ll) +#define style_custom_prop_flag_lookup_table LV_GLOBAL_DEFAULT()->style_custom_prop_flag_lookup_table /********************** * TYPEDEFS @@ -63,7 +65,6 @@ static bool style_has_flag(const lv_style_t * style, uint32_t flag); /********************** * STATIC VARIABLES **********************/ -static bool style_refr = true; /********************** * MACROS @@ -75,7 +76,7 @@ static bool style_refr = true; void _lv_obj_style_init(void) { - _lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(trans_t)); + _lv_ll_init(style_trans_ll_p, sizeof(trans_t)); } void lv_obj_add_style(lv_obj_t * obj, const lv_style_t * style, lv_style_selector_t selector) @@ -398,7 +399,7 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_ inheritable = _lv_style_builtin_prop_flag_lookup_table[prop] & LV_STYLE_PROP_FLAG_INHERITABLE; } else { - inheritable = LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table)[prop - _LV_STYLE_NUM_BUILT_IN_PROPS] & + inheritable = style_custom_prop_flag_lookup_table[prop - _LV_STYLE_NUM_BUILT_IN_PROPS] & LV_STYLE_PROP_FLAG_INHERITABLE; } @@ -535,7 +536,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t } } - tr = _lv_ll_ins_head(&LV_GC_ROOT(_lv_obj_style_trans_ll)); + tr = _lv_ll_ins_head(style_trans_ll_p); LV_ASSERT_MALLOC(tr); if(tr == NULL) return; tr->start_value = v1; @@ -885,12 +886,12 @@ static bool trans_del(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, tran trans_t * tr; trans_t * tr_prev; bool removed = false; - tr = _lv_ll_get_tail(&LV_GC_ROOT(_lv_obj_style_trans_ll)); + tr = _lv_ll_get_tail(style_trans_ll_p); while(tr != NULL) { if(tr == tr_limit) break; /*'tr' might be deleted, so get the next object while 'tr' is valid*/ - tr_prev = _lv_ll_get_prev(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + tr_prev = _lv_ll_get_prev(style_trans_ll_p, tr); if(tr->obj == obj && (part == tr->selector || part == LV_PART_ANY) && (prop == tr->prop || prop == LV_STYLE_PROP_ANY)) { /*Remove any transitioned properties from the trans. style @@ -904,7 +905,7 @@ static bool trans_del(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, tran /*Free the transition descriptor too*/ lv_anim_del(tr, NULL); - _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + _lv_ll_remove(style_trans_ll_p, tr); lv_free(tr); removed = true; @@ -1011,7 +1012,7 @@ static void trans_anim_ready_cb(lv_anim_t * a) *It allows changing it by normal styles*/ bool running = false; trans_t * tr_i; - _LV_LL_READ(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr_i) { + _LV_LL_READ(style_trans_ll_p, tr_i) { if(tr_i != tr && tr_i->obj == tr->obj && tr_i->selector == tr->selector && tr_i->prop == tr->prop) { running = true; break; @@ -1022,7 +1023,7 @@ static void trans_anim_ready_cb(lv_anim_t * a) uint32_t i; for(i = 0; i < obj->style_cnt; i++) { if(obj->styles[i].is_trans && obj->styles[i].selector == tr->selector) { - _lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr); + _lv_ll_remove(style_trans_ll_p, tr); lv_free(tr); _lv_obj_style_t * obj_style = &obj->styles[i]; diff --git a/src/core/lv_obj_style_gen.c b/src/core/lv_obj_style_gen.c index 17e1e0c8f..50c0c203b 100644 --- a/src/core/lv_obj_style_gen.c +++ b/src/core/lv_obj_style_gen.c @@ -690,7 +690,8 @@ void lv_obj_set_style_anim_speed(struct _lv_obj_t * obj, uint32_t value, lv_styl lv_obj_set_local_style_prop(obj, LV_STYLE_ANIM_SPEED, v, selector); } -void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, lv_style_selector_t selector) +void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transition_dsc_t * value, + lv_style_selector_t selector) { lv_style_value_t v = { .ptr = value @@ -721,3 +722,124 @@ void lv_obj_set_style_base_dir(struct _lv_obj_t * obj, lv_base_dir_t value, lv_s }; lv_obj_set_local_style_prop(obj, LV_STYLE_BASE_DIR, v, selector); } + +void lv_obj_set_style_flex_flow(struct _lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_FLOW, v, selector); +} + +void lv_obj_set_style_flex_main_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_MAIN_PLACE, v, selector); +} + +void lv_obj_set_style_flex_cross_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_CROSS_PLACE, v, selector); +} + +void lv_obj_set_style_flex_track_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_TRACK_PLACE, v, selector); +} + +void lv_obj_set_style_flex_grow(struct _lv_obj_t * obj, uint8_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_GROW, v, selector); +} + +void lv_obj_set_style_grid_column_dsc_array(struct _lv_obj_t * obj, const lv_coord_t * value, + lv_style_selector_t selector) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v, selector); +} + +void lv_obj_set_style_grid_column_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_ALIGN, v, selector); +} + +void lv_obj_set_style_grid_row_dsc_array(struct _lv_obj_t * obj, const lv_coord_t * value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_DSC_ARRAY, v, selector); +} + +void lv_obj_set_style_grid_row_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_ALIGN, v, selector); +} + +void lv_obj_set_style_grid_cell_column_pos(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_POS, v, selector); +} + +void lv_obj_set_style_grid_cell_x_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_X_ALIGN, v, selector); +} + +void lv_obj_set_style_grid_cell_column_span(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_SPAN, v, selector); +} + +void lv_obj_set_style_grid_cell_row_pos(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_POS, v, selector); +} + +void lv_obj_set_style_grid_cell_y_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_Y_ALIGN, v, selector); +} + +void lv_obj_set_style_grid_cell_row_span(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_SPAN, v, selector); +} diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index aeab1ff50..023768aa8 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -615,6 +615,96 @@ static inline lv_base_dir_t lv_obj_get_style_base_dir(const struct _lv_obj_t * o return (lv_base_dir_t)v.num; } +static inline lv_flex_flow_t lv_obj_get_style_flex_flow(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_FLOW); + return (lv_flex_flow_t)v.num; +} + +static inline lv_flex_align_t lv_obj_get_style_flex_main_place(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_MAIN_PLACE); + return (lv_flex_align_t)v.num; +} + +static inline lv_flex_align_t lv_obj_get_style_flex_cross_place(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_CROSS_PLACE); + return (lv_flex_align_t)v.num; +} + +static inline lv_flex_align_t lv_obj_get_style_flex_track_place(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_TRACK_PLACE); + return (lv_flex_align_t)v.num; +} + +static inline uint8_t lv_obj_get_style_flex_grow(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_GROW); + return (uint8_t)v.num; +} + +static inline const lv_coord_t * lv_obj_get_style_grid_column_dsc_array(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_DSC_ARRAY); + return (const lv_coord_t *)v.ptr; +} + +static inline lv_grid_align_t lv_obj_get_style_grid_column_align(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_ALIGN); + return (lv_grid_align_t)v.num; +} + +static inline const lv_coord_t * lv_obj_get_style_grid_row_dsc_array(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_DSC_ARRAY); + return (const lv_coord_t *)v.ptr; +} + +static inline lv_grid_align_t lv_obj_get_style_grid_row_align(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_ALIGN); + return (lv_grid_align_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_grid_cell_column_pos(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_COLUMN_POS); + return (lv_coord_t)v.num; +} + +static inline lv_grid_align_t lv_obj_get_style_grid_cell_x_align(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_X_ALIGN); + return (lv_grid_align_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_grid_cell_column_span(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_COLUMN_SPAN); + return (lv_coord_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_grid_cell_row_pos(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_ROW_POS); + return (lv_coord_t)v.num; +} + +static inline lv_grid_align_t lv_obj_get_style_grid_cell_y_align(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_Y_ALIGN); + return (lv_grid_align_t)v.num; +} + +static inline lv_coord_t lv_obj_get_style_grid_cell_row_span(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_ROW_SPAN); + return (lv_coord_t)v.num; +} + void lv_obj_set_style_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); void lv_obj_set_style_min_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); void lv_obj_set_style_max_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); @@ -708,5 +798,22 @@ void lv_obj_set_style_transition(struct _lv_obj_t * obj, const lv_style_transiti void lv_obj_set_style_blend_mode(struct _lv_obj_t * obj, lv_blend_mode_t value, lv_style_selector_t selector); void lv_obj_set_style_layout(struct _lv_obj_t * obj, uint16_t value, lv_style_selector_t selector); void lv_obj_set_style_base_dir(struct _lv_obj_t * obj, lv_base_dir_t value, lv_style_selector_t selector); +void lv_obj_set_style_flex_flow(struct _lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector); +void lv_obj_set_style_flex_main_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_flex_cross_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_flex_track_place(struct _lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_flex_grow(struct _lv_obj_t * obj, uint8_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_column_dsc_array(struct _lv_obj_t * obj, const lv_coord_t * value, + lv_style_selector_t selector); +void lv_obj_set_style_grid_column_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_row_dsc_array(struct _lv_obj_t * obj, const lv_coord_t * value, + lv_style_selector_t selector); +void lv_obj_set_style_grid_row_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_cell_column_pos(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_cell_x_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_cell_column_span(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_cell_row_pos(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_cell_y_align(struct _lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); +void lv_obj_set_style_grid_cell_row_span(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); #endif /* LV_OBJ_STYLE_GEN_H */ diff --git a/src/core/lv_obj_tree.c b/src/core/lv_obj_tree.c index c97b939e2..59af7f458 100644 --- a/src/core/lv_obj_tree.c +++ b/src/core/lv_obj_tree.c @@ -14,13 +14,14 @@ #include "../disp/lv_disp.h" #include "../disp/lv_disp_private.h" #include "../misc/lv_anim.h" -#include "../misc/lv_gc.h" #include "../misc/lv_async.h" +#include "../core/lv_global.h" /********************* * DEFINES *********************/ #define MY_CLASS &lv_obj_class +#define disp_ll_p &(LV_GLOBAL_DEFAULT()->disp_ll) /********************** * TYPEDEFS @@ -288,7 +289,8 @@ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj) else scr = lv_obj_get_screen(obj); /*get the screen of `obj`*/ lv_disp_t * d; - _LV_LL_READ(&LV_GC_ROOT(_lv_disp_ll), d) { + lv_ll_t * disp_head = disp_ll_p; + _LV_LL_READ(disp_head, d) { uint32_t i; for(i = 0; i < d->screen_cnt; i++) { if(d->screens[i] == scr) return d; diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index 9c67e12c0..745fff9b9 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -13,15 +13,19 @@ #include "../tick/lv_tick.h" #include "../misc/lv_timer.h" #include "../misc/lv_math.h" -#include "../misc/lv_gc.h" #include "../misc/lv_profiler.h" #include "../draw/lv_draw.h" #include "../font/lv_font_fmt_txt.h" +#include "../stdlib/lv_string.h" +#include "lv_global.h" /********************* * DEFINES *********************/ +/*Display being refreshed*/ +#define disp_refr LV_GLOBAL_DEFAULT()->disp_refresh + /********************** * TYPEDEFS **********************/ @@ -44,8 +48,6 @@ static void call_flush_cb(lv_disp_t * disp, const lv_area_t * area, uint8_t * px * STATIC VARIABLES **********************/ -static lv_disp_t * disp_refr; /*Display being refreshed*/ - /********************** * MACROS **********************/ diff --git a/src/dev/sdl/lv_sdl_window.c b/src/dev/sdl/lv_sdl_window.c index 2a4d2a595..8c4864403 100644 --- a/src/dev/sdl/lv_sdl_window.c +++ b/src/dev/sdl/lv_sdl_window.c @@ -53,9 +53,6 @@ void _lv_sdl_mousewheel_handler(SDL_Event * event); void _lv_sdl_keyboard_handler(SDL_Event * event); static void res_chg_event_cb(lv_event_t * e); -#if !LV_TICK_CUSTOM - static int tick_thread(void * ptr); -#endif static bool inited = false; /********************** @@ -77,9 +74,7 @@ lv_disp_t * lv_sdl_window_create(lv_coord_t hor_res, lv_coord_t ver_res) SDL_Init(SDL_INIT_VIDEO); SDL_StartTextInput(); event_handler_timer = lv_timer_create(sdl_event_handler, 5, NULL); -#if !LV_TICK_CUSTOM - SDL_CreateThread(tick_thread, "LVGL thread", NULL); -#endif + lv_tick_set_cb(SDL_GetTicks); inited = true; } @@ -352,23 +347,6 @@ static void res_chg_event_cb(lv_event_t * e) texture_resize(disp); } -#if !LV_TICK_CUSTOM -static int tick_thread(void * ptr) -{ - LV_UNUSED(ptr); - static uint32_t tick_prev = 0; - - while(1) { - uint32_t tick_now = SDL_GetTicks(); - lv_tick_inc(tick_now - tick_prev); - tick_prev = tick_now; - SDL_Delay(5); - } - - return 0; -} -#endif - static void release_disp_cb(lv_event_t * e) { lv_disp_t * disp = (lv_disp_t *) lv_event_get_user_data(e); diff --git a/src/disp/lv_disp.c b/src/disp/lv_disp.c index 40796b3c7..10f9c3df7 100644 --- a/src/disp/lv_disp.c +++ b/src/disp/lv_disp.c @@ -10,9 +10,9 @@ #include "../misc/lv_math.h" #include "../core/lv_refr.h" #include "../disp/lv_disp_private.h" -#include "../misc/lv_gc.h" #include "../stdlib/lv_string.h" #include "../themes/lv_theme.h" +#include "../core/lv_global.h" #if LV_USE_DRAW_SW #include "../draw/sw/lv_draw_sw.h" @@ -22,6 +22,8 @@ /********************* * DEFINES *********************/ +#define disp_def LV_GLOBAL_DEFAULT()->disp_default +#define disp_ll_p &(LV_GLOBAL_DEFAULT()->disp_ll) /********************** * TYPEDEFS @@ -44,7 +46,6 @@ static void disp_event_cb(lv_event_t * e); /********************** * STATIC VARIABLES **********************/ -static lv_disp_t * disp_def; /********************** * MACROS @@ -56,7 +57,7 @@ static lv_disp_t * disp_def; lv_disp_t * lv_disp_create(lv_coord_t hor_res, lv_coord_t ver_res) { - lv_disp_t * disp = _lv_ll_ins_head(&LV_GC_ROOT(_lv_disp_ll)); + lv_disp_t * disp = _lv_ll_ins_head(disp_ll_p); LV_ASSERT_MALLOC(disp); if(!disp) return NULL; @@ -167,11 +168,11 @@ void lv_disp_remove(lv_disp_t * disp) lv_obj_del(disp->screens[0]); } - _lv_ll_remove(&LV_GC_ROOT(_lv_disp_ll), disp); + _lv_ll_remove(disp_ll_p, disp); if(disp->refr_timer) lv_timer_del(disp->refr_timer); lv_free(disp); - if(was_default) lv_disp_set_default(_lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll))); + if(was_default) lv_disp_set_default(_lv_ll_get_head(disp_ll_p)); } void lv_disp_set_default(lv_disp_t * disp) @@ -187,9 +188,9 @@ lv_disp_t * lv_disp_get_default(void) lv_disp_t * lv_disp_get_next(lv_disp_t * disp) { if(disp == NULL) - return _lv_ll_get_head(&LV_GC_ROOT(_lv_disp_ll)); + return _lv_ll_get_head(disp_ll_p); else - return _lv_ll_get_next(&LV_GC_ROOT(_lv_disp_ll), disp); + return _lv_ll_get_next(disp_ll_p, disp); } /*--------------------- diff --git a/src/draw/lv_draw.c b/src/draw/lv_draw.c index 04aa925da..28ce733fa 100644 --- a/src/draw/lv_draw.c +++ b/src/draw/lv_draw.c @@ -9,13 +9,14 @@ #include "lv_draw.h" #include "sw/lv_draw_sw.h" #include "../disp/lv_disp_private.h" +#include "../core/lv_global.h" #include "../core/lv_refr.h" #include "../stdlib/lv_string.h" -#include "../misc/lv_gc.h" /********************* * DEFINES *********************/ +#define _draw_cache LV_GLOBAL_DEFAULT()->draw_cache /********************** * TYPEDEFS @@ -29,13 +30,6 @@ static bool is_independent(lv_layer_t * layer, lv_draw_task_t * t_check); /********************** * STATIC VARIABLES **********************/ -#if LV_USE_OS - static lv_thread_sync_t sync; -#else - static int dispatch_req = 0; -#endif - -static uint32_t used_memory_for_layers_kb = 0; /********************** * STATIC VARIABLES @@ -52,7 +46,7 @@ static uint32_t used_memory_for_layers_kb = 0; void lv_draw_init(void) { #if LV_USE_OS - lv_thread_sync_init(&sync); + lv_thread_sync_init(&_draw_cache.sync); #endif } @@ -61,8 +55,8 @@ void * lv_draw_create_unit(size_t size) lv_draw_unit_t * new_unit = lv_malloc(size); lv_memzero(new_unit, size); - new_unit->next = LV_GC_ROOT(_lv_draw_unit_head); - LV_GC_ROOT(_lv_draw_unit_head) = new_unit; + new_unit->next = _draw_cache.unit_head; + _draw_cache.unit_head = new_unit; return new_unit; } @@ -102,14 +96,15 @@ void lv_draw_finalize_task_creation(lv_layer_t * layer, lv_draw_task_t * t) *and not on the draw tasks added in the event. *Sending LV_EVENT_DRAW_TASK_ADDED events might cause recursive event sends *Dispatching might remove the "main" draw task while it's still being used in the event*/ - static bool running = false; - if(running == false) { - running = true; + lv_draw_cache_t * cache = &_draw_cache; + + if(cache->task_running == false) { + cache->task_running = true; if(base_dsc->obj && lv_obj_has_flag(base_dsc->obj, LV_OBJ_FLAG_SEND_DRAW_TASK_EVENTS)) { lv_obj_send_event(base_dsc->obj, LV_EVENT_DRAW_TASK_ADDED, t); } lv_draw_dispatch(); - running = false; + cache->task_running = false; } } @@ -154,8 +149,8 @@ bool lv_draw_dispatch_layer(struct _lv_disp_t * disp, lv_layer_t * layer) uint32_t layer_size_byte = layer_drawn->draw_buf.height * lv_draw_buf_width_to_stride(layer_drawn->draw_buf.width, layer_drawn->draw_buf.color_format); - used_memory_for_layers_kb -= layer_size_byte < 1024 ? 1 : layer_size_byte >> 10; - LV_LOG_INFO("Layer memory used: %d kB\n", used_memory_for_layers_kb); + _draw_cache.used_memory_for_layers_kb -= layer_size_byte < 1024 ? 1 : layer_size_byte >> 10; + LV_LOG_INFO("Layer memory used: %d kB\n", _draw_cache.used_memory_for_layers_kb); lv_draw_buf_free(&layer_drawn->draw_buf); } @@ -216,7 +211,7 @@ bool lv_draw_dispatch_layer(struct _lv_disp_t * disp, lv_layer_t * layer) uint32_t layer_size_byte = layer->draw_buf.height * lv_draw_buf_width_to_stride(layer->draw_buf.width, layer->draw_buf.color_format); uint32_t kb = layer_size_byte < 1024 ? 1 : layer_size_byte >> 10; - if(used_memory_for_layers_kb + kb > LV_LAYER_MAX_MEMORY_USAGE) { + if(_draw_cache.used_memory_for_layers_kb + kb > LV_LAYER_MAX_MEMORY_USAGE) { layer_ok = false; } } @@ -224,7 +219,7 @@ bool lv_draw_dispatch_layer(struct _lv_disp_t * disp, lv_layer_t * layer) if(layer_ok) { /*Find a draw unit which is not busy and can take at least one task*/ /*Let all draw units to pick draw tasks*/ - lv_draw_unit_t * u = LV_GC_ROOT(_lv_draw_unit_head); + lv_draw_unit_t * u = _draw_cache.unit_head; while(u) { int32_t taken_cnt = u->dispatch(u, layer); if(taken_cnt < 0) { @@ -243,19 +238,19 @@ bool lv_draw_dispatch_layer(struct _lv_disp_t * disp, lv_layer_t * layer) void lv_draw_dispatch_wait_for_request(void) { #if LV_USE_OS - lv_thread_sync_wait(&sync); + lv_thread_sync_wait(&_draw_cache.sync); #else - while(!dispatch_req); - dispatch_req = 0; + while(!_draw_cache.dispatch_req); + _draw_cache.dispatch_req = 0; #endif } void lv_draw_dispatch_request(void) { #if LV_USE_OS - lv_thread_sync_signal(&sync); + lv_thread_sync_signal(&_draw_cache.sync); #else - dispatch_req = 1; + _draw_cache.dispatch_req = 1; #endif } @@ -326,12 +321,11 @@ void lv_draw_layer_get_area(lv_layer_t * layer, lv_area_t * area) void lv_draw_add_used_layer_size(uint32_t kb) { - used_memory_for_layers_kb += kb; - LV_LOG_INFO("Layer memory used: %d kB\n", used_memory_for_layers_kb); + _draw_cache.used_memory_for_layers_kb += kb; + LV_LOG_INFO("Layer memory used: %d kB\n", _draw_cache.used_memory_for_layers_kb); } - /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/draw/lv_draw.h b/src/draw/lv_draw.h index b8c94924f..cd25d5ba0 100644 --- a/src/draw/lv_draw.h +++ b/src/draw/lv_draw.h @@ -20,6 +20,7 @@ extern "C" { #include "../misc/lv_profiler.h" #include "lv_img_decoder.h" #include "lv_img_cache.h" +#include "../osal/lv_os.h" #include "draw_buf/lv_draw_buf.h" /********************* @@ -141,6 +142,18 @@ typedef struct { lv_layer_t * layer; } lv_draw_dsc_base_t; +typedef struct { + lv_draw_unit_t * unit_head; + uint32_t used_memory_for_layers_kb; +#if LV_USE_OS + lv_thread_sync_t sync; + lv_mutex_t circle_cache_mutex; +#else + int dispatch_req; +#endif + bool task_running; +} lv_draw_cache_t; + /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/src/draw/lv_img_cache.c b/src/draw/lv_img_cache.c index c835cbd29..985d68620 100644 --- a/src/draw/lv_img_cache.c +++ b/src/draw/lv_img_cache.c @@ -8,10 +8,12 @@ *********************/ #include "lv_img_cache.h" #include "../stdlib/lv_string.h" +#include "../core/lv_global.h" /********************* * DEFINES *********************/ +#define img_cache_manager LV_GLOBAL_DEFAULT()->img_cache_mgr /********************** * TYPEDEFS @@ -25,8 +27,6 @@ * STATIC VARIABLES **********************/ -static lv_img_cache_manager_t img_cache_manager = { 0 }; - /********************** * MACROS **********************/ diff --git a/src/draw/lv_img_cache_builtin.c b/src/draw/lv_img_cache_builtin.c index 03aa52bc0..8a7cdfa93 100644 --- a/src/draw/lv_img_cache_builtin.c +++ b/src/draw/lv_img_cache_builtin.c @@ -12,11 +12,19 @@ #include "lv_draw_img.h" #include "../tick/lv_tick.h" #include "../misc/lv_assert.h" -#include "../misc/lv_gc.h" +#include "../core/lv_global.h" +#include "../stdlib/lv_string.h" /********************* * DEFINES *********************/ +#if LV_IMG_CACHE_DEF_SIZE + #define entry_cnt LV_GLOBAL_DEFAULT()->img_cache_entry_cnt + #define _img_cache_array LV_GLOBAL_DEFAULT()->img_cache_array +#else + #define _img_cache_single LV_GLOBAL_DEFAULT()->img_cache_single +#endif + /** Count the cache entries's life. Add `time_to_open` to `life` when the entry is used. * Decrement all lifes by one every in every ::lv_img_cache_open. @@ -53,9 +61,6 @@ static void lv_img_cache_invalidate_src_builtin(const void * src); /********************** * STATIC VARIABLES **********************/ -#if LV_IMG_CACHE_DEF_SIZE - static uint16_t entry_cnt; -#endif /********************** * MACROS @@ -102,7 +107,7 @@ static _lv_img_cache_entry_t * _lv_img_cache_open_builtin(const void * src, lv_c return NULL; } - _lv_img_cache_entry_t * cache = LV_GC_ROOT(_lv_img_cache_array); + _lv_img_cache_entry_t * cache = _img_cache_array; /*Decrement all lifes. Make the entries older*/ uint16_t i; @@ -149,7 +154,7 @@ static _lv_img_cache_entry_t * _lv_img_cache_open_builtin(const void * src, lv_c LV_LOG_INFO("image draw: cache miss, cached to an empty entry"); } #else - cached_src = &LV_GC_ROOT(_lv_img_cache_single); + cached_src = &(_img_cache_single); #endif /*Open the image and measure the time to open*/ uint32_t t_start = lv_tick_get(); @@ -185,23 +190,23 @@ static void lv_img_cache_set_size_builtin(uint16_t new_entry_cnt) LV_UNUSED(new_entry_cnt); LV_LOG_WARN("Can't change cache size because it's disabled by LV_IMG_CACHE_DEF_SIZE = 0"); #else - if(LV_GC_ROOT(_lv_img_cache_array) != NULL) { + if(_img_cache_array != NULL) { /*Clean the cache before free it*/ lv_img_cache_invalidate_src_builtin(NULL); - lv_free(LV_GC_ROOT(_lv_img_cache_array)); + lv_free(_img_cache_array); } /*Reallocate the cache*/ - LV_GC_ROOT(_lv_img_cache_array) = lv_malloc(sizeof(_lv_img_cache_entry_t) * new_entry_cnt); - LV_ASSERT_MALLOC(LV_GC_ROOT(_lv_img_cache_array)); - if(LV_GC_ROOT(_lv_img_cache_array) == NULL) { + _img_cache_array = lv_malloc(sizeof(_lv_img_cache_entry_t) * new_entry_cnt); + LV_ASSERT_MALLOC(_img_cache_array); + if(_img_cache_array == NULL) { entry_cnt = 0; return; } entry_cnt = new_entry_cnt; /*Clean the cache*/ - lv_memzero(LV_GC_ROOT(_lv_img_cache_array), entry_cnt * sizeof(_lv_img_cache_entry_t)); + lv_memzero(_img_cache_array, entry_cnt * sizeof(_lv_img_cache_entry_t)); #endif } @@ -214,7 +219,7 @@ static void lv_img_cache_invalidate_src_builtin(const void * src) { LV_UNUSED(src); #if LV_IMG_CACHE_DEF_SIZE - _lv_img_cache_entry_t * cache = LV_GC_ROOT(_lv_img_cache_array); + _lv_img_cache_entry_t * cache = _img_cache_array; uint16_t i; for(i = 0; i < entry_cnt; i++) { diff --git a/src/draw/lv_img_decoder.c b/src/draw/lv_img_decoder.c index 8abe556c4..28d33caee 100644 --- a/src/draw/lv_img_decoder.c +++ b/src/draw/lv_img_decoder.c @@ -10,12 +10,13 @@ #include "../misc/lv_assert.h" #include "../draw/lv_draw_img.h" #include "../misc/lv_ll.h" -#include "../misc/lv_gc.h" #include "../stdlib/lv_string.h" +#include "../core/lv_global.h" /********************* * DEFINES *********************/ +#define img_decoder_ll_p &(LV_GLOBAL_DEFAULT()->img_decoder_ll) /********************** * TYPEDEFS @@ -50,7 +51,7 @@ static lv_res_t decode_indexed_line(lv_color_format_t color_format, const lv_col */ void _lv_img_decoder_init(void) { - _lv_ll_init(&LV_GC_ROOT(_lv_img_decoder_ll), sizeof(lv_img_decoder_t)); + _lv_ll_init(img_decoder_ll_p, sizeof(lv_img_decoder_t)); lv_img_decoder_t * decoder; @@ -88,7 +89,7 @@ lv_res_t lv_img_decoder_get_info(const void * src, lv_img_header_t * header) lv_res_t res = LV_RES_INV; lv_img_decoder_t * d; - _LV_LL_READ(&LV_GC_ROOT(_lv_img_decoder_ll), d) { + _LV_LL_READ(img_decoder_ll_p, d) { if(d->info_cb) { res = d->info_cb(d, src, header); if(res == LV_RES_OK) break; @@ -130,7 +131,7 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co lv_res_t res = LV_RES_INV; lv_img_decoder_t * decoder; - _LV_LL_READ(&LV_GC_ROOT(_lv_img_decoder_ll), decoder) { + _LV_LL_READ(img_decoder_ll_p, decoder) { /*Info and Open callbacks are required*/ if(decoder->info_cb == NULL || decoder->open_cb == NULL) continue; @@ -198,7 +199,7 @@ void lv_img_decoder_close(lv_img_decoder_dsc_t * dsc) lv_img_decoder_t * lv_img_decoder_create(void) { lv_img_decoder_t * decoder; - decoder = _lv_ll_ins_head(&LV_GC_ROOT(_lv_img_decoder_ll)); + decoder = _lv_ll_ins_head(img_decoder_ll_p); LV_ASSERT_MALLOC(decoder); if(decoder == NULL) return NULL; @@ -213,7 +214,7 @@ lv_img_decoder_t * lv_img_decoder_create(void) */ void lv_img_decoder_delete(lv_img_decoder_t * decoder) { - _lv_ll_remove(&LV_GC_ROOT(_lv_img_decoder_ll), decoder); + _lv_ll_remove(img_decoder_ll_p, decoder); lv_free(decoder); } diff --git a/src/draw/sw/lv_draw_sw.h b/src/draw/sw/lv_draw_sw.h index fefdadbb2..64c9ad222 100644 --- a/src/draw/sw/lv_draw_sw.h +++ b/src/draw/sw/lv_draw_sw.h @@ -39,6 +39,14 @@ typedef struct { uint32_t idx; } lv_draw_sw_unit_t; +#if LV_DRAW_SW_SHADOW_CACHE_SIZE +typedef struct { + uint8_t cache[LV_DRAW_SW_SHADOW_CACHE_SIZE * LV_DRAW_SW_SHADOW_CACHE_SIZE]; + int32_t cache_size; + int32_t cache_r; +} lv_draw_sw_shadow_cache_t; +#endif + /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/src/draw/sw/lv_draw_sw_box_shadow.c b/src/draw/sw/lv_draw_sw_box_shadow.c index 40ce6d53f..e1b906d84 100644 --- a/src/draw/sw/lv_draw_sw_box_shadow.c +++ b/src/draw/sw/lv_draw_sw_box_shadow.c @@ -10,6 +10,7 @@ #if LV_USE_DRAW_SW #include "blend/lv_draw_sw_blend.h" +#include "../../core/lv_global.h" #include "../../misc/lv_math.h" #include "../../core/lv_refr.h" #include "../../misc/lv_assert.h" @@ -22,6 +23,10 @@ #define SHADOW_UPSCALE_SHIFT 6 #define SHADOW_ENHANCE 1 +#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0 + #define shadow_cache LV_GLOBAL_DEFAULT()->sw_shadow_cache +#endif + /********************** * TYPEDEFS **********************/ @@ -39,11 +44,6 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t /********************** * STATIC VARIABLES **********************/ -#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0 - static uint8_t sh_cache[LV_DRAW_SW_SHADOW_CACHE_SIZE * LV_DRAW_SW_SHADOW_CACHE_SIZE]; - static int32_t sh_cache_size = -1; - static int32_t sh_cache_r = -1; -#endif /********************** * MACROS @@ -99,10 +99,11 @@ void lv_draw_sw_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_ lv_opa_t * sh_buf; #if LV_DRAW_SW_SHADOW_CACHE_SIZE - if(sh_cache_size == corner_size && sh_cache_r == r_sh) { + lv_draw_sw_shadow_cache_t * cache = &shadow_cache; + if(cache->cache_size == corner_size && cache->cache_r == r_sh) { /*Use the cache if available*/ sh_buf = lv_malloc(corner_size * corner_size); - lv_memcpy(sh_buf, sh_cache, corner_size * corner_size); + lv_memcpy(sh_buf, cache->cache, corner_size * corner_size); } else { /*A larger buffer is required for calculation*/ @@ -110,10 +111,10 @@ void lv_draw_sw_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_ shadow_draw_corner_buf(&core_area, (uint16_t *)sh_buf, dsc->width, r_sh); /*Cache the corner if it fits into the cache size*/ - if((uint32_t)corner_size * corner_size < sizeof(sh_cache)) { - lv_memcpy(sh_cache, sh_buf, corner_size * corner_size); - sh_cache_size = corner_size; - sh_cache_r = r_sh; + if((uint32_t)corner_size * corner_size < sizeof(cache->cache)) { + lv_memcpy(cache->cache, sh_buf, corner_size * corner_size); + cache->cache_size = corner_size; + cache->cache_r = r_sh; } } #else diff --git a/src/draw/sw/lv_draw_sw_gradient.c b/src/draw/sw/lv_draw_sw_gradient.c index 8dfd68f00..7ca528079 100644 --- a/src/draw/sw/lv_draw_sw_gradient.c +++ b/src/draw/sw/lv_draw_sw_gradient.c @@ -9,7 +9,6 @@ #include "lv_draw_sw_gradient.h" #if LV_USE_DRAW_SW -#include "../../misc/lv_gc.h" #include "../../misc/lv_types.h" #include "../../osal/lv_os.h" diff --git a/src/draw/sw/lv_draw_sw_mask.c b/src/draw/sw/lv_draw_sw_mask.c index 6c4154224..c8fe2f4a8 100644 --- a/src/draw/sw/lv_draw_sw_mask.c +++ b/src/draw/sw/lv_draw_sw_mask.c @@ -10,10 +10,10 @@ #if LV_DRAW_SW_COMPLEX #include "lv_draw_sw_mask.h" +#include "../../core/lv_global.h" #include "../../misc/lv_math.h" #include "../../misc/lv_log.h" #include "../../misc/lv_assert.h" -#include "../../misc/lv_gc.h" #include "../../osal/lv_os.h" #include "../../stdlib/lv_string.h" @@ -22,6 +22,10 @@ *********************/ #define CIRCLE_CACHE_LIFE_MAX 1000 #define CIRCLE_CACHE_AGING(life, r) life = LV_MIN(life + (r < 16 ? 1 : (r >> 4)), 1000) +#if LV_USE_OS + #define circle_cache_mutex LV_GLOBAL_DEFAULT()->draw_cache.circle_cache_mutex +#endif +#define _circle_cache LV_GLOBAL_DEFAULT()->sw_circle_cache /********************** * TYPEDEFS @@ -66,9 +70,6 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_ /********************** * STATIC VARIABLES **********************/ -#if LV_USE_OS - static lv_mutex_t circle_cache_mutex; -#endif /********************** * MACROS @@ -141,10 +142,10 @@ void _lv_draw_sw_mask_cleanup(void) { uint8_t i; for(i = 0; i < LV_DRAW_SW_CIRCLE_CACHE_SIZE; i++) { - if(LV_GC_ROOT(_lv_circle_cache[i]).buf) { - lv_free(LV_GC_ROOT(_lv_circle_cache[i]).buf); + if(_circle_cache[i].buf) { + lv_free(_circle_cache[i].buf); } - lv_memzero(&LV_GC_ROOT(_lv_circle_cache[i]), sizeof(LV_GC_ROOT(_lv_circle_cache[i]))); + lv_memzero(&(_circle_cache[i]), sizeof(_circle_cache[i])); } } @@ -369,10 +370,10 @@ void lv_draw_sw_mask_radius_init(lv_draw_sw_mask_radius_param_t * param, const l /*Try to reuse a circle cache entry*/ for(i = 0; i < LV_DRAW_SW_CIRCLE_CACHE_SIZE; i++) { - if(LV_GC_ROOT(_lv_circle_cache[i]).radius == radius) { - LV_GC_ROOT(_lv_circle_cache[i]).used_cnt++; - CIRCLE_CACHE_AGING(LV_GC_ROOT(_lv_circle_cache[i]).life, radius); - param->circle = &LV_GC_ROOT(_lv_circle_cache[i]); + if(_circle_cache[i].radius == radius) { + _circle_cache[i].used_cnt++; + CIRCLE_CACHE_AGING(_circle_cache[i].life, radius); + param->circle = &(_circle_cache[i]); #if LV_USE_OS lv_mutex_unlock(&circle_cache_mutex); #endif @@ -383,9 +384,9 @@ void lv_draw_sw_mask_radius_init(lv_draw_sw_mask_radius_param_t * param, const l /*If not cached use the free entry with lowest life*/ _lv_draw_sw_mask_radius_circle_dsc_t * entry = NULL; for(i = 0; i < LV_DRAW_SW_CIRCLE_CACHE_SIZE; i++) { - if(LV_GC_ROOT(_lv_circle_cache[i]).used_cnt == 0) { - if(!entry) entry = &LV_GC_ROOT(_lv_circle_cache[i]); - else if(LV_GC_ROOT(_lv_circle_cache[i]).life < entry->life) entry = &LV_GC_ROOT(_lv_circle_cache[i]); + if(_circle_cache[i].used_cnt == 0) { + if(!entry) entry = &(_circle_cache[i]); + else if(_circle_cache[i].life < entry->life) entry = &(_circle_cache[i]); } } diff --git a/src/font/lv_font_dejavu_16_persian_hebrew.c b/src/font/lv_font_dejavu_16_persian_hebrew.c index a35168764..3f692adab 100644 --- a/src/font/lv_font_dejavu_16_persian_hebrew.c +++ b/src/font/lv_font_dejavu_16_persian_hebrew.c @@ -6564,7 +6564,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -6578,9 +6578,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 0, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_fmt_txt.c b/src/font/lv_font_fmt_txt.c index bc463e6da..8b43bf65c 100644 --- a/src/font/lv_font_fmt_txt.c +++ b/src/font/lv_font_fmt_txt.c @@ -8,9 +8,9 @@ *********************/ #include "lv_font.h" #include "lv_font_fmt_txt.h" +#include "../core/lv_global.h" #include "../misc/lv_assert.h" #include "../misc/lv_types.h" -#include "../misc/lv_gc.h" #include "../misc/lv_log.h" #include "../misc/lv_utils.h" #include "../stdlib/lv_mem.h" @@ -18,15 +18,13 @@ /********************* * DEFINES *********************/ +#if LV_USE_FONT_COMPRESSED + #define font_rle LV_GLOBAL_DEFAULT()->font_fmt_rle +#endif /*LV_USE_FONT_COMPRESSED*/ /********************** * TYPEDEFS **********************/ -typedef enum { - RLE_STATE_SINGLE = 0, - RLE_STATE_REPEATE, - RLE_STATE_COUNTER, -} rle_state_t; /********************** * STATIC PROTOTYPES @@ -48,14 +46,6 @@ static int32_t kern_pair_16_compare(const void * ref, const void * element); /********************** * STATIC VARIABLES **********************/ -#if LV_USE_FONT_COMPRESSED - static uint32_t rle_rdp; - static const uint8_t * rle_in; - static uint8_t rle_bpp; - static uint8_t rle_prev_v; - static uint8_t rle_cnt; - static rle_state_t rle_state; -#endif /*LV_USE_FONT_COMPRESSED*/ static const uint8_t opa4_table[16] = {0, 17, 34, 51, 68, 85, 102, 119, @@ -480,65 +470,67 @@ static inline uint8_t get_bits(const uint8_t * in, uint32_t bit_pos, uint8_t len static inline void rle_init(const uint8_t * in, uint8_t bpp) { - rle_in = in; - rle_bpp = bpp; - rle_state = RLE_STATE_SINGLE; - rle_rdp = 0; - rle_prev_v = 0; - rle_cnt = 0; + lv_font_fmt_rle_t * rle = &font_rle; + rle->in = in; + rle->bpp = bpp; + rle->state = RLE_STATE_SINGLE; + rle->rdp = 0; + rle->prev_v = 0; + rle->count = 0; } static inline uint8_t rle_next(void) { uint8_t v = 0; uint8_t ret = 0; + lv_font_fmt_rle_t * rle = &font_rle; - if(rle_state == RLE_STATE_SINGLE) { - ret = get_bits(rle_in, rle_rdp, rle_bpp); - if(rle_rdp != 0 && rle_prev_v == ret) { - rle_cnt = 0; - rle_state = RLE_STATE_REPEATE; + if(rle->state == RLE_STATE_SINGLE) { + ret = get_bits(rle->in, rle->rdp, rle->bpp); + if(rle->rdp != 0 && rle->prev_v == ret) { + rle->count = 0; + rle->state = RLE_STATE_REPEATE; } - rle_prev_v = ret; - rle_rdp += rle_bpp; + rle->prev_v = ret; + rle->rdp += rle->bpp; } - else if(rle_state == RLE_STATE_REPEATE) { - v = get_bits(rle_in, rle_rdp, 1); - rle_cnt++; - rle_rdp += 1; + else if(rle->state == RLE_STATE_REPEATE) { + v = get_bits(rle->in, rle->rdp, 1); + rle->count++; + rle->rdp += 1; if(v == 1) { - ret = rle_prev_v; - if(rle_cnt == 11) { - rle_cnt = get_bits(rle_in, rle_rdp, 6); - rle_rdp += 6; - if(rle_cnt != 0) { - rle_state = RLE_STATE_COUNTER; + ret = rle->prev_v; + if(rle->count == 11) { + rle->count = get_bits(rle->in, rle->rdp, 6); + rle->rdp += 6; + if(rle->count != 0) { + rle->state = RLE_STATE_COUNTER; } else { - ret = get_bits(rle_in, rle_rdp, rle_bpp); - rle_prev_v = ret; - rle_rdp += rle_bpp; - rle_state = RLE_STATE_SINGLE; + ret = get_bits(rle->in, rle->rdp, rle->bpp); + rle->prev_v = ret; + rle->rdp += rle->bpp; + rle->state = RLE_STATE_SINGLE; } } } else { - ret = get_bits(rle_in, rle_rdp, rle_bpp); - rle_prev_v = ret; - rle_rdp += rle_bpp; - rle_state = RLE_STATE_SINGLE; + ret = get_bits(rle->in, rle->rdp, rle->bpp); + rle->prev_v = ret; + rle->rdp += rle->bpp; + rle->state = RLE_STATE_SINGLE; } } - else if(rle_state == RLE_STATE_COUNTER) { - ret = rle_prev_v; - rle_cnt--; - if(rle_cnt == 0) { - ret = get_bits(rle_in, rle_rdp, rle_bpp); - rle_prev_v = ret; - rle_rdp += rle_bpp; - rle_state = RLE_STATE_SINGLE; + else if(rle->state == RLE_STATE_COUNTER) { + ret = rle->prev_v; + rle->count--; + if(rle->count == 0) { + ret = get_bits(rle->in, rle->rdp, rle->bpp); + rle->prev_v = ret; + rle->rdp += rle->bpp; + rle->state = RLE_STATE_SINGLE; } } diff --git a/src/font/lv_font_fmt_txt.h b/src/font/lv_font_fmt_txt.h index 672c4358c..b7c92e089 100644 --- a/src/font/lv_font_fmt_txt.h +++ b/src/font/lv_font_fmt_txt.h @@ -156,11 +156,6 @@ typedef enum { LV_FONT_FMT_TXT_COMPRESSED_NO_PREFILTER = 1, } lv_font_fmt_txt_bitmap_format_t; -typedef struct { - uint32_t last_letter; - uint32_t last_glyph_id; -} lv_font_fmt_txt_glyph_cache_t; - /*Describe store additional data for fonts*/ typedef struct { /*The bitmaps of all glyphs*/ @@ -197,10 +192,25 @@ typedef struct { * from `lv_font_fmt_txt_bitmap_format_t` */ uint16_t bitmap_format : 2; - - lv_font_fmt_txt_glyph_cache_t * cache; } lv_font_fmt_txt_dsc_t; +#if LV_USE_FONT_COMPRESSED +typedef enum { + RLE_STATE_SINGLE = 0, + RLE_STATE_REPEATE, + RLE_STATE_COUNTER, +} lv_font_fmt_rle_state_t; + +typedef struct { + uint32_t rdp; + const uint8_t * in; + uint8_t bpp; + uint8_t prev_v; + uint8_t count; + lv_font_fmt_rle_state_t state; +} lv_font_fmt_rle_t; +#endif + /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/src/font/lv_font_montserrat_10.c b/src/font/lv_font_montserrat_10.c index 4612d561e..415c0fcf2 100644 --- a/src/font/lv_font_montserrat_10.c +++ b/src/font/lv_font_montserrat_10.c @@ -1613,7 +1613,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -1627,9 +1627,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_12.c b/src/font/lv_font_montserrat_12.c index ce7ded3ca..f18f69ffe 100644 --- a/src/font/lv_font_montserrat_12.c +++ b/src/font/lv_font_montserrat_12.c @@ -1874,7 +1874,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -1888,9 +1888,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_14.c b/src/font/lv_font_montserrat_14.c index 7289a3c41..e65410be9 100644 --- a/src/font/lv_font_montserrat_14.c +++ b/src/font/lv_font_montserrat_14.c @@ -2150,7 +2150,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -2164,9 +2164,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_16.c b/src/font/lv_font_montserrat_16.c index 0358d5ca8..86663821d 100644 --- a/src/font/lv_font_montserrat_16.c +++ b/src/font/lv_font_montserrat_16.c @@ -2419,7 +2419,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -2433,9 +2433,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_18.c b/src/font/lv_font_montserrat_18.c index 4e777bed0..9bcbe79e8 100644 --- a/src/font/lv_font_montserrat_18.c +++ b/src/font/lv_font_montserrat_18.c @@ -2819,7 +2819,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -2833,9 +2833,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_20.c b/src/font/lv_font_montserrat_20.c index bdd0731d6..0672e100f 100644 --- a/src/font/lv_font_montserrat_20.c +++ b/src/font/lv_font_montserrat_20.c @@ -3176,7 +3176,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -3190,9 +3190,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_22.c b/src/font/lv_font_montserrat_22.c index 275927561..2a89b094f 100644 --- a/src/font/lv_font_montserrat_22.c +++ b/src/font/lv_font_montserrat_22.c @@ -3605,7 +3605,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -3619,9 +3619,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_24.c b/src/font/lv_font_montserrat_24.c index 926785513..9d44e559b 100644 --- a/src/font/lv_font_montserrat_24.c +++ b/src/font/lv_font_montserrat_24.c @@ -4016,7 +4016,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -4030,9 +4030,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_26.c b/src/font/lv_font_montserrat_26.c index 2c5e000b4..a62e57d3b 100644 --- a/src/font/lv_font_montserrat_26.c +++ b/src/font/lv_font_montserrat_26.c @@ -4551,7 +4551,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -4565,9 +4565,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_28.c b/src/font/lv_font_montserrat_28.c index fc855bf60..5cedabc15 100644 --- a/src/font/lv_font_montserrat_28.c +++ b/src/font/lv_font_montserrat_28.c @@ -5100,7 +5100,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -5114,9 +5114,6 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif }; diff --git a/src/font/lv_font_montserrat_28_compressed.c b/src/font/lv_font_montserrat_28_compressed.c index ecd3997ba..6dbebb81d 100644 --- a/src/font/lv_font_montserrat_28_compressed.c +++ b/src/font/lv_font_montserrat_28_compressed.c @@ -3230,7 +3230,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -3244,9 +3244,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 1, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_30.c b/src/font/lv_font_montserrat_30.c index d92fa66d8..d0aa70ed1 100644 --- a/src/font/lv_font_montserrat_30.c +++ b/src/font/lv_font_montserrat_30.c @@ -5682,7 +5682,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -5696,9 +5696,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_32.c b/src/font/lv_font_montserrat_32.c index 997022b9e..71dfe9a42 100644 --- a/src/font/lv_font_montserrat_32.c +++ b/src/font/lv_font_montserrat_32.c @@ -6171,7 +6171,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -6185,9 +6185,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_34.c b/src/font/lv_font_montserrat_34.c index ffb52247c..3e6f0c77f 100644 --- a/src/font/lv_font_montserrat_34.c +++ b/src/font/lv_font_montserrat_34.c @@ -6970,7 +6970,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -6984,9 +6984,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_36.c b/src/font/lv_font_montserrat_36.c index 48c0baaca..65fb10479 100644 --- a/src/font/lv_font_montserrat_36.c +++ b/src/font/lv_font_montserrat_36.c @@ -7614,7 +7614,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -7628,9 +7628,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_38.c b/src/font/lv_font_montserrat_38.c index 63b2764a7..e93c79f1e 100644 --- a/src/font/lv_font_montserrat_38.c +++ b/src/font/lv_font_montserrat_38.c @@ -8359,7 +8359,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -8373,9 +8373,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_40.c b/src/font/lv_font_montserrat_40.c index 35d8c0570..b55c01e59 100644 --- a/src/font/lv_font_montserrat_40.c +++ b/src/font/lv_font_montserrat_40.c @@ -9207,7 +9207,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -9221,9 +9221,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_42.c b/src/font/lv_font_montserrat_42.c index 401c521c1..a5284221f 100644 --- a/src/font/lv_font_montserrat_42.c +++ b/src/font/lv_font_montserrat_42.c @@ -10049,7 +10049,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -10063,9 +10063,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_44.c b/src/font/lv_font_montserrat_44.c index 46ff35faf..bfbe70fbe 100644 --- a/src/font/lv_font_montserrat_44.c +++ b/src/font/lv_font_montserrat_44.c @@ -10875,7 +10875,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -10889,9 +10889,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_46.c b/src/font/lv_font_montserrat_46.c index c49895024..65b7655dc 100644 --- a/src/font/lv_font_montserrat_46.c +++ b/src/font/lv_font_montserrat_46.c @@ -11827,7 +11827,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -11841,9 +11841,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_48.c b/src/font/lv_font_montserrat_48.c index 5c48d41ae..8841d1c8d 100644 --- a/src/font/lv_font_montserrat_48.c +++ b/src/font/lv_font_montserrat_48.c @@ -12528,7 +12528,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -12542,9 +12542,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_montserrat_8.c b/src/font/lv_font_montserrat_8.c index 7c3b967cb..a8ce73695 100644 --- a/src/font/lv_font_montserrat_8.c +++ b/src/font/lv_font_montserrat_8.c @@ -1399,7 +1399,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -1413,9 +1413,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 1, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_simsun_16_cjk.c b/src/font/lv_font_simsun_16_cjk.c index 0c0b14d23..53496c3c2 100644 --- a/src/font/lv_font_simsun_16_cjk.c +++ b/src/font/lv_font_simsun_16_cjk.c @@ -23731,7 +23731,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -23745,9 +23745,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 4, .kern_classes = 0, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_unscii_16.c b/src/font/lv_font_unscii_16.c index 578bccacc..078e3310c 100644 --- a/src/font/lv_font_unscii_16.c +++ b/src/font/lv_font_unscii_16.c @@ -602,7 +602,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -616,9 +616,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 1, .kern_classes = 0, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/font/lv_font_unscii_8.c b/src/font/lv_font_unscii_8.c index 1fc1ffd67..b6878faf1 100644 --- a/src/font/lv_font_unscii_8.c +++ b/src/font/lv_font_unscii_8.c @@ -438,7 +438,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = { #if LVGL_VERSION_MAJOR >= 8 /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { @@ -452,9 +452,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { .bpp = 1, .kern_classes = 0, .bitmap_format = 0, -#if LVGL_VERSION_MAJOR >= 8 - .cache = &cache -#endif + }; diff --git a/src/indev/lv_indev.c b/src/indev/lv_indev.c index a2ba81290..036b2ffb8 100644 --- a/src/indev/lv_indev.c +++ b/src/indev/lv_indev.c @@ -9,6 +9,7 @@ #include "lv_indev_private.h" #include "lv_indev_scroll.h" #include "../disp/lv_disp_private.h" +#include "../core/lv_global.h" #include "../core/lv_obj.h" #include "../core/lv_group.h" #include "../core/lv_refr.h" @@ -16,8 +17,8 @@ #include "../tick/lv_tick.h" #include "../misc/lv_timer.h" #include "../misc/lv_math.h" -#include "../misc/lv_gc.h" #include "../misc/lv_profiler.h" +#include "../stdlib/lv_string.h" /********************* * DEFINES @@ -47,6 +48,10 @@ #warning "LV_INDEV_DRAG_THROW must be greater than 0" #endif +#define indev_act LV_GLOBAL_DEFAULT()->indev_active +#define indev_obj_act LV_GLOBAL_DEFAULT()->indev_obj_active +#define indev_ll_head &(LV_GLOBAL_DEFAULT()->indev_ll) + /********************** * TYPEDEFS **********************/ @@ -69,8 +74,6 @@ static bool indev_reset_check(lv_indev_t * indev); /********************** * STATIC VARIABLES **********************/ -static lv_indev_t * indev_act; -static lv_obj_t * indev_obj_act = NULL; /********************** * MACROS @@ -92,7 +95,7 @@ lv_indev_t * lv_indev_create(void) LV_LOG_WARN("no display was created so far"); } - lv_indev_t * indev = _lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll)); + lv_indev_t * indev = _lv_ll_ins_head(indev_ll_head); LV_ASSERT_MALLOC(indev); if(!indev) { return NULL; @@ -120,7 +123,7 @@ void lv_indev_delete(lv_indev_t * indev) /*Clean up the read timer first*/ lv_timer_del(indev->read_timer); /*Remove the input device from the list*/ - _lv_ll_remove(&LV_GC_ROOT(_lv_indev_ll), indev); + _lv_ll_remove(indev_ll_head, indev); /*Free the memory of the input device*/ lv_free(indev); } @@ -128,9 +131,9 @@ void lv_indev_delete(lv_indev_t * indev) lv_indev_t * lv_indev_get_next(lv_indev_t * indev) { if(indev == NULL) - return _lv_ll_get_head(&LV_GC_ROOT(_lv_indev_ll)); + return _lv_ll_get_head(indev_ll_head); else - return _lv_ll_get_next(&LV_GC_ROOT(_lv_indev_ll), indev); + return _lv_ll_get_next(indev_ll_head, indev); } void _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) @@ -169,53 +172,53 @@ void lv_indev_read_timer_cb(lv_timer_t * timer) lv_indev_data_t data; - indev_act = timer->user_data; + lv_indev_t * indev_p = indev_act = timer->user_data; /*Read and process all indevs*/ - if(indev_act->disp == NULL) return; /*Not assigned to any displays*/ + if(indev_p->disp == NULL) return; /*Not assigned to any displays*/ /*Handle reset query before processing the point*/ - indev_proc_reset_query_handler(indev_act); + indev_proc_reset_query_handler(indev_p); - if(indev_act->disabled || - indev_act->disp->prev_scr != NULL) return; /*Input disabled or screen animation active*/ + if(indev_p->disabled || + indev_p->disp->prev_scr != NULL) return; /*Input disabled or screen animation active*/ LV_PROFILER_BEGIN; bool continue_reading; do { /*Read the data*/ - _lv_indev_read(indev_act, &data); + _lv_indev_read(indev_p, &data); continue_reading = data.continue_reading; /*The active object might be deleted even in the read function*/ - indev_proc_reset_query_handler(indev_act); + indev_proc_reset_query_handler(indev_p); indev_obj_act = NULL; - indev_act->state = data.state; + indev_p->state = data.state; /*Save the last activity time*/ - if(indev_act->state == LV_INDEV_STATE_PRESSED) { - indev_act->disp->last_activity_time = lv_tick_get(); + if(indev_p->state == LV_INDEV_STATE_PRESSED) { + indev_p->disp->last_activity_time = lv_tick_get(); } - else if(indev_act->type == LV_INDEV_TYPE_ENCODER && data.enc_diff) { - indev_act->disp->last_activity_time = lv_tick_get(); + else if(indev_p->type == LV_INDEV_TYPE_ENCODER && data.enc_diff) { + indev_p->disp->last_activity_time = lv_tick_get(); } - if(indev_act->type == LV_INDEV_TYPE_POINTER) { - indev_pointer_proc(indev_act, &data); + if(indev_p->type == LV_INDEV_TYPE_POINTER) { + indev_pointer_proc(indev_p, &data); } - else if(indev_act->type == LV_INDEV_TYPE_KEYPAD) { - indev_keypad_proc(indev_act, &data); + else if(indev_p->type == LV_INDEV_TYPE_KEYPAD) { + indev_keypad_proc(indev_p, &data); } - else if(indev_act->type == LV_INDEV_TYPE_ENCODER) { - indev_encoder_proc(indev_act, &data); + else if(indev_p->type == LV_INDEV_TYPE_ENCODER) { + indev_encoder_proc(indev_p, &data); } - else if(indev_act->type == LV_INDEV_TYPE_BUTTON) { - indev_button_proc(indev_act, &data); + else if(indev_p->type == LV_INDEV_TYPE_BUTTON) { + indev_button_proc(indev_p, &data); } /*Handle reset query if it happened in during processing*/ - indev_proc_reset_query_handler(indev_act); + indev_proc_reset_query_handler(indev_p); } while(continue_reading); /*End of indev processing, so no act indev*/ @@ -951,8 +954,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) lv_coord_t x = i->btn_points[data->btn_id].x; lv_coord_t y = i->btn_points[data->btn_id].y; - static lv_indev_state_t prev_state = LV_INDEV_STATE_RELEASED; - if(prev_state != data->state) { + if(LV_INDEV_STATE_RELEASED != data->state) { if(data->state == LV_INDEV_STATE_PRESSED) { LV_LOG_INFO("button %" LV_PRIu32 " is pressed (x:%d y:%d)", data->btn_id, (int)x, (int)y); } diff --git a/src/layouts/flex/lv_flex.c b/src/layouts/flex/lv_flex.c index 187c09746..58af0afee 100644 --- a/src/layouts/flex/lv_flex.c +++ b/src/layouts/flex/lv_flex.c @@ -7,12 +7,16 @@ * INCLUDES *********************/ #include "lv_flex.h" +#include "../lv_layout.h" +#include "../../core/lv_obj.h" #if LV_USE_FLEX +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ +#define layout_list_def LV_GLOBAL_DEFAULT()->layout_list /********************** * TYPEDEFS @@ -67,12 +71,6 @@ static lv_coord_t lv_obj_get_height_with_margin(const lv_obj_t * obj); /********************** * GLOBAL VARIABLES **********************/ -uint16_t LV_LAYOUT_FLEX; -lv_style_prop_t LV_STYLE_FLEX_FLOW; -lv_style_prop_t LV_STYLE_FLEX_MAIN_PLACE; -lv_style_prop_t LV_STYLE_FLEX_CROSS_PLACE; -lv_style_prop_t LV_STYLE_FLEX_TRACK_PLACE; -lv_style_prop_t LV_STYLE_FLEX_GROW; /********************** * STATIC VARIABLES @@ -97,13 +95,9 @@ lv_style_prop_t LV_STYLE_FLEX_GROW; void lv_flex_init(void) { - LV_LAYOUT_FLEX = lv_layout_register(flex_update, NULL); + layout_list_def[LV_LAYOUT_FLEX].cb = flex_update; + layout_list_def[LV_LAYOUT_FLEX].user_data = NULL; - LV_STYLE_FLEX_FLOW = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_FLEX_MAIN_PLACE = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_FLEX_CROSS_PLACE = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_FLEX_TRACK_PLACE = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_FLEX_GROW = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); } void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow) @@ -127,88 +121,6 @@ void lv_obj_set_flex_grow(lv_obj_t * obj, uint8_t grow) lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj)); } - -void lv_style_set_flex_flow(lv_style_t * style, lv_flex_flow_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_FLEX_FLOW, v); -} - -void lv_style_set_flex_main_place(lv_style_t * style, lv_flex_align_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_FLEX_MAIN_PLACE, v); -} - -void lv_style_set_flex_cross_place(lv_style_t * style, lv_flex_align_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_FLEX_CROSS_PLACE, v); -} - -void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_FLEX_TRACK_PLACE, v); -} - -void lv_style_set_flex_grow(lv_style_t * style, uint8_t value) -{ - lv_style_value_t v = { - .num = (int32_t)value - }; - lv_style_set_prop(style, LV_STYLE_FLEX_GROW, v); -} - - -void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_FLOW, v, selector); -} - -void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_MAIN_PLACE, v, selector); -} - -void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_CROSS_PLACE, v, selector); -} - -void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_TRACK_PLACE, v, selector); -} - -void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_GROW, v, selector); -} - /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/layouts/flex/lv_flex.h b/src/layouts/flex/lv_flex.h index f9279e115..d7fc5b030 100644 --- a/src/layouts/flex/lv_flex.h +++ b/src/layouts/flex/lv_flex.h @@ -13,16 +13,15 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../../core/lv_obj.h" +#include "../../lv_conf_internal.h" +#include "../../misc/lv_area.h" + #if LV_USE_FLEX /********************* * DEFINES *********************/ -#define LV_OBJ_FLAG_FLEX_IN_NEW_TRACK LV_OBJ_FLAG_LAYOUT_1 -LV_EXPORT_CONST_INT(LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); - #define _LV_FLEX_COLUMN (1 << 0) #define _LV_FLEX_WRAP (1 << 2) #define _LV_FLEX_REVERSE (1 << 3) @@ -57,12 +56,6 @@ typedef enum { /********************** * GLOBAL VARIABLES **********************/ -extern uint16_t LV_LAYOUT_FLEX; -extern lv_style_prop_t LV_STYLE_FLEX_FLOW; -extern lv_style_prop_t LV_STYLE_FLEX_MAIN_PLACE; -extern lv_style_prop_t LV_STYLE_FLEX_CROSS_PLACE; -extern lv_style_prop_t LV_STYLE_FLEX_TRACK_PLACE; -extern lv_style_prop_t LV_STYLE_FLEX_GROW; /********************** * GLOBAL PROTOTYPES @@ -79,7 +72,7 @@ void lv_flex_init(void); * @param obj pointer to an object. The parent must have flex layout else nothing will happen. * @param flow an element of `lv_flex_flow_t`. */ -void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow); +void lv_obj_set_flex_flow(struct _lv_obj_t * obj, lv_flex_flow_t flow); /** * Set how to place (where to align) the items and tracks @@ -88,7 +81,7 @@ void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow); * @param cross_place where to place the item in their track on the cross axis. `LV_FLEX_ALIGN_START/END/CENTER` * @param track_cross_place where to place the tracks in the cross direction. Any value of `lv_flex_align_t`. */ -void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place, +void lv_obj_set_flex_align(struct _lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place, lv_flex_align_t track_cross_place); /** @@ -96,73 +89,12 @@ void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_a * @param obj pointer to an object. The parent must have flex layout else nothing will happen. * @param grow a value to set how much free space to take proportionally to other growing items. */ -void lv_obj_set_flex_grow(lv_obj_t * obj, uint8_t grow); - -void lv_style_set_flex_flow(lv_style_t * style, lv_flex_flow_t value); -void lv_style_set_flex_main_place(lv_style_t * style, lv_flex_align_t value); -void lv_style_set_flex_cross_place(lv_style_t * style, lv_flex_align_t value); -void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value); -void lv_style_set_flex_grow(lv_style_t * style, uint8_t value); -void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector); -void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); -void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); -void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_flex_align_t value, lv_style_selector_t selector); -void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector_t selector); - -static inline lv_flex_flow_t lv_obj_get_style_flex_flow(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_FLOW); - return (lv_flex_flow_t)v.num; -} - -static inline lv_flex_align_t lv_obj_get_style_flex_main_place(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_MAIN_PLACE); - return (lv_flex_align_t)v.num; -} - -static inline lv_flex_align_t lv_obj_get_style_flex_cross_place(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_CROSS_PLACE); - return (lv_flex_align_t)v.num; -} - -static inline lv_flex_align_t lv_obj_get_style_flex_track_place(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_TRACK_PLACE); - return (lv_flex_align_t)v.num; -} - -static inline uint8_t lv_obj_get_style_flex_grow(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_FLEX_GROW); - return (uint8_t)v.num; -} +void lv_obj_set_flex_grow(struct _lv_obj_t * obj, uint8_t grow); /********************** * MACROS **********************/ -#define LV_STYLE_CONST_FLEX_FLOW(val) \ - { \ - .prop_ptr = &LV_STYLE_FLEX_FLOW, .value = { .num = (lv_flex_flow_t)val } \ - } - -#define LV_STYLE_CONST_FLEX_MAIN_PLACE(val) \ - { \ - .prop_ptr = &LV_STYLE_FLEX_MAIN_PLACE, .value = { .num = (lv_flex_flow_t)val } \ - } - -#define LV_STYLE_CONST_FLEX_TRACK_PLACE(val) \ - { \ - .prop_ptr = &LV_STYLE_FLEX_TRACK_PLACE, .value = { .num = (lv_flex_flow_t)val } \ - } - -#define LV_STYLE_CONST_FLEX_CROSS_PLACE(val) \ - { \ - .prop_ptr = &LV_STYLE_FLEX_CROSS_PLACE, .value = { .num = (lv_flex_flow_t)val } \ - } - #endif /*LV_USE_FLEX*/ diff --git a/src/layouts/grid/lv_grid.c b/src/layouts/grid/lv_grid.c index 21e1384e5..3c87e1548 100644 --- a/src/layouts/grid/lv_grid.c +++ b/src/layouts/grid/lv_grid.c @@ -11,10 +11,14 @@ #if LV_USE_GRID #include "../../stdlib/lv_string.h" - +#include "../lv_layout.h" +#include "../../core/lv_obj.h" +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ +#define layout_list_def LV_GLOBAL_DEFAULT()->layout_list + /** * Some helper defines */ @@ -114,17 +118,6 @@ static inline lv_coord_t get_margin_ver(lv_obj_t * obj) /********************** * GLOBAL VARIABLES **********************/ -uint16_t LV_LAYOUT_GRID; -lv_style_prop_t LV_STYLE_GRID_COLUMN_DSC_ARRAY; -lv_style_prop_t LV_STYLE_GRID_COLUMN_ALIGN; -lv_style_prop_t LV_STYLE_GRID_ROW_DSC_ARRAY; -lv_style_prop_t LV_STYLE_GRID_ROW_ALIGN; -lv_style_prop_t LV_STYLE_GRID_CELL_COLUMN_POS; -lv_style_prop_t LV_STYLE_GRID_CELL_COLUMN_SPAN; -lv_style_prop_t LV_STYLE_GRID_CELL_X_ALIGN; -lv_style_prop_t LV_STYLE_GRID_CELL_ROW_POS; -lv_style_prop_t LV_STYLE_GRID_CELL_ROW_SPAN; -lv_style_prop_t LV_STYLE_GRID_CELL_Y_ALIGN; /********************** * STATIC VARIABLES @@ -146,19 +139,8 @@ lv_style_prop_t LV_STYLE_GRID_CELL_Y_ALIGN; void lv_grid_init(void) { - LV_LAYOUT_GRID = lv_layout_register(grid_update, NULL); - - LV_STYLE_GRID_COLUMN_DSC_ARRAY = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_ROW_DSC_ARRAY = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_COLUMN_ALIGN = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_ROW_ALIGN = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - - LV_STYLE_GRID_CELL_ROW_SPAN = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_CELL_ROW_POS = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_CELL_COLUMN_SPAN = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_CELL_COLUMN_POS = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_CELL_X_ALIGN = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); - LV_STYLE_GRID_CELL_Y_ALIGN = lv_style_register_prop(LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); + layout_list_def[LV_LAYOUT_GRID].cb = grid_update; + layout_list_def[LV_LAYOUT_GRID].user_data = NULL; } void lv_obj_set_grid_dsc_array(lv_obj_t * obj, const lv_coord_t col_dsc[], const lv_coord_t row_dsc[]) @@ -189,171 +171,6 @@ void lv_obj_set_grid_cell(lv_obj_t * obj, lv_grid_align_t x_align, lv_coord_t co lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj)); } - -void lv_style_set_grid_row_dsc_array(lv_style_t * style, const lv_coord_t value[]) -{ - lv_style_value_t v = { - .ptr = (const void *)value - }; - lv_style_set_prop(style, LV_STYLE_GRID_ROW_DSC_ARRAY, v); -} - -void lv_style_set_grid_column_dsc_array(lv_style_t * style, const lv_coord_t value[]) -{ - lv_style_value_t v = { - .ptr = (const void *)value - }; - lv_style_set_prop(style, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v); -} - -void lv_style_set_grid_row_align(lv_style_t * style, lv_grid_align_t value) -{ - lv_style_value_t v = { - .num = (lv_grid_align_t)value - }; - lv_style_set_prop(style, LV_STYLE_GRID_ROW_ALIGN, v); -} - -void lv_style_set_grid_column_align(lv_style_t * style, lv_grid_align_t value) -{ - lv_style_value_t v = { - .num = (lv_grid_align_t)value - }; - lv_style_set_prop(style, LV_STYLE_GRID_COLUMN_ALIGN, v); -} - - -void lv_style_set_grid_cell_column_pos(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = value - }; - lv_style_set_prop(style, LV_STYLE_GRID_CELL_COLUMN_POS, v); -} - -void lv_style_set_grid_cell_column_span(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = value - }; - lv_style_set_prop(style, LV_STYLE_GRID_CELL_COLUMN_SPAN, v); -} - -void lv_style_set_grid_cell_row_pos(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = value - }; - lv_style_set_prop(style, LV_STYLE_GRID_CELL_ROW_POS, v); -} - -void lv_style_set_grid_cell_row_span(lv_style_t * style, lv_coord_t value) -{ - lv_style_value_t v = { - .num = value - }; - lv_style_set_prop(style, LV_STYLE_GRID_CELL_ROW_SPAN, v); -} - -void lv_style_set_grid_cell_x_align(lv_style_t * style, lv_grid_align_t value) -{ - lv_style_value_t v = { - .num = value - }; - lv_style_set_prop(style, LV_STYLE_GRID_CELL_X_ALIGN, v); -} - -void lv_style_set_grid_cell_y_align(lv_style_t * style, lv_grid_align_t value) -{ - lv_style_value_t v = { - .num = value - }; - lv_style_set_prop(style, LV_STYLE_GRID_CELL_Y_ALIGN, v); -} - -void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector) -{ - lv_style_value_t v = { - .ptr = (const void *)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_DSC_ARRAY, v, selector); -} - -void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector) -{ - lv_style_value_t v = { - .ptr = (const void *)value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v, selector); -} - - -void lv_obj_set_style_grid_row_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_ALIGN, v, selector); -} - -void lv_obj_set_style_grid_column_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = (int32_t) value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_COLUMN_ALIGN, v, selector); -} - - -void lv_obj_set_style_grid_cell_column_pos(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_POS, v, selector); -} - -void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_SPAN, v, selector); -} - -void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_POS, v, selector); -} - -void lv_obj_set_style_grid_cell_row_span(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_SPAN, v, selector); -} - -void lv_obj_set_style_grid_cell_x_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_X_ALIGN, v, selector); -} - -void lv_obj_set_style_grid_cell_y_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector) -{ - lv_style_value_t v = { - .num = value - }; - lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_Y_ALIGN, v, selector); -} - - /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/layouts/grid/lv_grid.h b/src/layouts/grid/lv_grid.h index ebb4ace7d..7ee4fab03 100644 --- a/src/layouts/grid/lv_grid.h +++ b/src/layouts/grid/lv_grid.h @@ -13,7 +13,9 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../../core/lv_obj.h" +#include "../../lv_conf_internal.h" +#include "../../misc/lv_area.h" + #if LV_USE_GRID /********************* @@ -53,27 +55,15 @@ typedef enum { * GLOBAL VARIABLES **********************/ -extern uint16_t LV_LAYOUT_GRID; -extern lv_style_prop_t LV_STYLE_GRID_COLUMN_DSC_ARRAY; -extern lv_style_prop_t LV_STYLE_GRID_COLUMN_ALIGN; -extern lv_style_prop_t LV_STYLE_GRID_ROW_DSC_ARRAY; -extern lv_style_prop_t LV_STYLE_GRID_ROW_ALIGN; -extern lv_style_prop_t LV_STYLE_GRID_CELL_COLUMN_POS; -extern lv_style_prop_t LV_STYLE_GRID_CELL_COLUMN_SPAN; -extern lv_style_prop_t LV_STYLE_GRID_CELL_X_ALIGN; -extern lv_style_prop_t LV_STYLE_GRID_CELL_ROW_POS; -extern lv_style_prop_t LV_STYLE_GRID_CELL_ROW_SPAN; -extern lv_style_prop_t LV_STYLE_GRID_CELL_Y_ALIGN; - /********************** * GLOBAL PROTOTYPES **********************/ void lv_grid_init(void); -void lv_obj_set_grid_dsc_array(lv_obj_t * obj, const lv_coord_t col_dsc[], const lv_coord_t row_dsc[]); +void lv_obj_set_grid_dsc_array(struct _lv_obj_t * obj, const lv_coord_t col_dsc[], const lv_coord_t row_dsc[]); -void lv_obj_set_grid_align(lv_obj_t * obj, lv_grid_align_t column_align, lv_grid_align_t row_align); +void lv_obj_set_grid_align(struct _lv_obj_t * obj, lv_grid_align_t column_align, lv_grid_align_t row_align); /** * Set the cell of an object. The object's parent needs to have grid layout, else nothing will happen @@ -85,7 +75,7 @@ void lv_obj_set_grid_align(lv_obj_t * obj, lv_grid_align_t column_align, lv_grid * @param row_pos row ID * @param row_span number of rows to take (>= 1) */ -void lv_obj_set_grid_cell(lv_obj_t * obj, lv_grid_align_t column_align, lv_coord_t col_pos, lv_coord_t col_span, +void lv_obj_set_grid_cell(struct _lv_obj_t * obj, lv_grid_align_t column_align, lv_coord_t col_pos, lv_coord_t col_span, lv_grid_align_t row_align, lv_coord_t row_pos, lv_coord_t row_span); /** @@ -96,88 +86,6 @@ static inline lv_coord_t lv_grid_fr(uint8_t x) return LV_GRID_FR(x); } -void lv_style_set_grid_row_dsc_array(lv_style_t * style, const lv_coord_t value[]); -void lv_style_set_grid_column_dsc_array(lv_style_t * style, const lv_coord_t value[]); -void lv_style_set_grid_row_align(lv_style_t * style, lv_grid_align_t value); -void lv_style_set_grid_column_align(lv_style_t * style, lv_grid_align_t value); -void lv_style_set_grid_cell_column_pos(lv_style_t * style, lv_coord_t value); -void lv_style_set_grid_cell_column_span(lv_style_t * style, lv_coord_t value); -void lv_style_set_grid_cell_row_pos(lv_style_t * style, lv_coord_t value); -void lv_style_set_grid_cell_row_span(lv_style_t * style, lv_coord_t value); -void lv_style_set_grid_cell_x_align(lv_style_t * style, lv_grid_align_t value); -void lv_style_set_grid_cell_y_align(lv_style_t * style, lv_grid_align_t value); - -void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector); -void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector); -void lv_obj_set_style_grid_row_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_column_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_cell_column_pos(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_cell_row_span(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_cell_x_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); -void lv_obj_set_style_grid_cell_y_align(lv_obj_t * obj, lv_grid_align_t value, lv_style_selector_t selector); - -static inline const lv_coord_t * lv_obj_get_style_grid_row_dsc_array(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_DSC_ARRAY); - return (const lv_coord_t *)v.ptr; -} - -static inline const lv_coord_t * lv_obj_get_style_grid_column_dsc_array(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_DSC_ARRAY); - return (const lv_coord_t *)v.ptr; -} - -static inline lv_grid_align_t lv_obj_get_style_grid_row_align(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_ROW_ALIGN); - return (lv_grid_align_t)v.num; -} - -static inline lv_grid_align_t lv_obj_get_style_grid_column_align(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_COLUMN_ALIGN); - return (lv_grid_align_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_grid_cell_column_pos(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_COLUMN_POS); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_grid_cell_column_span(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_COLUMN_SPAN); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_grid_cell_row_pos(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_ROW_POS); - return (lv_coord_t)v.num; -} - -static inline lv_coord_t lv_obj_get_style_grid_cell_row_span(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_ROW_SPAN); - return (lv_coord_t)v.num; -} - -static inline lv_grid_align_t lv_obj_get_style_grid_cell_x_align(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_X_ALIGN); - return (lv_grid_align_t)v.num; -} - -static inline lv_grid_align_t lv_obj_get_style_grid_cell_y_align(const lv_obj_t * obj, uint32_t part) -{ - lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_GRID_CELL_Y_ALIGN); - return (lv_grid_align_t)v.num; -} - /********************** * GLOBAL VARIABLES **********************/ @@ -186,58 +94,6 @@ static inline lv_grid_align_t lv_obj_get_style_grid_cell_y_align(const lv_obj_t * MACROS **********************/ - - -#define LV_STYLE_CONST_GRID_COLUMN_DSC_ARRAY(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_COLUMN_DSC_ARRAY, .value = { .ptr = (void*)val } \ - } - -#define LV_STYLE_CONST_GRID_COLUMN_ALIGN(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_COLUMN_ALIGN, .value = { .num = (lv_grid_align_t)val } \ - } - -#define LV_STYLE_CONST_GRID_ROW_DSC_ARRAY(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_ROW_DSC_ARRAY, .value = { .ptr = (void*)val } \ - } - -#define LV_STYLE_CONST_GRID_ROW_ALIGN(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_ROW_ALIGN, .value = { .num = (lv_grid_align_t)val } \ - } - -#define LV_STYLE_CONST_GRID_CELL_COLUMN_POS(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_CELL_COLUMN_POS, .value = { .num = (lv_coord_t)val } \ - } - -#define LV_STYLE_CONST_GRID_CELL_COLUMN_SPAN(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_CELL_COLUMN_SPAN, .value = { .num = (lv_coord_t)val } \ - } - -#define LV_STYLE_CONST_GRID_X_ALIGN(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_X_ALIGN, .value = { .num = (lv_grid_align_t)val } \ - } - -#define LV_STYLE_CONST_GRID_CELL_ROW_POS(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_CELL_ROW_POS, .value = { .num = (lv_coord_t)val } \ - } - -#define LV_STYLE_CONST_GRID_CELL_ROW_SPAN(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_CELL_ROWSPAN, .value = { .num = (lv_coord_t)val } \ - } - -#define LV_STYLE_CONST_GRID_Y_ALIGN(val) \ - { \ - .prop_ptr = &LV_STYLE_GRID_Y_ALIGN, .value = { .num = (lv_grid_align_t)val } \ - } - #endif /*LV_USE_GRID*/ #ifdef __cplusplus diff --git a/src/layouts/lv_layout.c b/src/layouts/lv_layout.c new file mode 100644 index 000000000..a62985758 --- /dev/null +++ b/src/layouts/lv_layout.c @@ -0,0 +1,75 @@ +/** + * @file lv_layout.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_layout.h" +#include "../core/lv_global.h" +#include "../core/lv_obj.h" + +/********************* + * DEFINES + *********************/ +#define layout_cnt LV_GLOBAL_DEFAULT()->layout_count +#define layout_list_def LV_GLOBAL_DEFAULT()->layout_list + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +void _lv_layout_init(void) +{ + /*Malloc a list for the built in layouts*/ + layout_list_def = lv_malloc(layout_cnt * sizeof(lv_layout_dsc_t)); + +#if LV_USE_FLEX + lv_flex_init(); +#endif + +#if LV_USE_GRID + lv_grid_init(); +#endif +} + +uint32_t lv_layout_register(lv_layout_update_cb_t cb, void * user_data) +{ + layout_cnt++; + layout_list_def = lv_realloc(layout_list_def, layout_cnt * sizeof(lv_layout_dsc_t)); + LV_ASSERT_MALLOC(layout_list_def); + + layout_list_def[layout_cnt - 1].cb = cb; + layout_list_def[layout_cnt - 1].user_data = user_data; + return layout_cnt; /*No -1 to skip 0th index*/ +} + +void _lv_layout_apply(lv_obj_t * obj) +{ + lv_layout_t layout_id = lv_obj_get_style_layout(obj, LV_PART_MAIN); + if(layout_id > 0 && layout_id <= layout_cnt) { + void * user_data = layout_list_def[layout_id].user_data; + layout_list_def[layout_id].cb(obj, user_data); + } +} + +/********************** + * STATIC FUNCTIONS + **********************/ diff --git a/src/layouts/lv_layout.h b/src/layouts/lv_layout.h new file mode 100644 index 000000000..b72a5831d --- /dev/null +++ b/src/layouts/lv_layout.h @@ -0,0 +1,88 @@ +/** + * @file lv_layouts.h + * + */ + +#ifndef LV_LAYOUTS_H +#define LV_LAYOUTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../lv_conf_internal.h" + + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +struct _lv_obj_t; + +typedef void (*lv_layout_update_cb_t)(struct _lv_obj_t *, void * user_data); +typedef struct { + lv_layout_update_cb_t cb; + void * user_data; +} lv_layout_dsc_t; + + +typedef enum { + LV_LAYOUT_NONE = 0, + +#if LV_USE_FLEX + LV_LAYOUT_FLEX, +#endif + +#if LV_USE_GRID + LV_LAYOUT_GRID, +#endif + + _LV_LAYOUT_LAST +} lv_layout_t; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +void _lv_layout_init(void); + +/** + * Register a new layout + * @param cb the layout update callback + * @param user_data custom data that will be passed to `cb` + * @return the ID of the new layout + */ +uint32_t lv_layout_register(lv_layout_update_cb_t cb, void * user_data); + + +/** + * Update the layout of a widget + * @param obj pointer to a widget + */ +void _lv_layout_apply(struct _lv_obj_t * obj); + +/********************** + * MACROS + **********************/ + +#if LV_USE_FLEX +#include "flex/lv_flex.h" +#endif /* LV_USE_FLEX */ + +#if LV_USE_GRID +#include "grid/lv_grid.h" +#endif /* LV_USE_GRID */ + + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_LAYOUTS_H*/ diff --git a/src/layouts/lv_layouts.h b/src/layouts/lv_layouts.h deleted file mode 100644 index 77a4c7770..000000000 --- a/src/layouts/lv_layouts.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file lv_layouts.h - * - */ - -#ifndef LV_LAYOUTS_H -#define LV_LAYOUTS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#if LV_USE_FLEX -#include "flex/lv_flex.h" -#endif /* LV_USE_FLEX */ -#if LV_USE_GRID -#include "grid/lv_grid.h" -#endif /* LV_USE_GRID */ - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_LAYOUTS_H*/ diff --git a/src/libs/freetype/lv_freetype.c b/src/libs/freetype/lv_freetype.c index 0005f641a..ce6e2d440 100644 --- a/src/libs/freetype/lv_freetype.c +++ b/src/libs/freetype/lv_freetype.c @@ -17,6 +17,7 @@ #include FT_IMAGE_H #include FT_OUTLINE_H +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ @@ -32,6 +33,8 @@ #error "LV_FREETYPE_CACHE_SIZE must > 0" #endif +#define ft_ctx LV_GLOBAL_DEFAULT()->ft_context + /********************** * TYPEDEFS **********************/ @@ -80,8 +83,6 @@ static const uint8_t * freetype_get_glyph_bitmap_cb(const lv_font_t * font, * STATIC VARIABLES **********************/ -static lv_freetype_context_t ft_ctx; - /********************** * MACROS **********************/ @@ -93,40 +94,46 @@ static lv_freetype_context_t ft_ctx; lv_res_t lv_freetype_init(uint16_t max_faces, uint16_t max_sizes, uint32_t max_bytes) { FT_Error error; + lv_freetype_context_t * context = ft_ctx = lv_malloc(sizeof(lv_freetype_context_t)); + LV_ASSERT_MALLOC(context); + if(!context) { + LV_LOG_ERROR("malloc failed for lv_freetype_context_t"); + return LV_RES_INV; + } - error = FT_Init_FreeType(&ft_ctx.library); + error = FT_Init_FreeType(&context->library); if(error) { FT_ERROR_MSG("FT_Init_FreeType", error); return LV_RES_INV; } - error = FTC_Manager_New(ft_ctx.library, + error = FTC_Manager_New(context->library, max_faces, max_sizes, max_bytes, freetpye_face_requester, NULL, - &ft_ctx.cache_manager); + &context->cache_manager); if(error) { - FT_Done_FreeType(ft_ctx.library); + FT_Done_FreeType(context->library); FT_ERROR_MSG("FTC_Manager_New", error); return LV_RES_INV; } - error = FTC_CMapCache_New(ft_ctx.cache_manager, &ft_ctx.cmap_cache); + error = FTC_CMapCache_New(context->cache_manager, &context->cmap_cache); if(error) { FT_ERROR_MSG("FTC_CMapCache_New", error); goto failed; } #if LV_FREETYPE_SBIT_CACHE - error = FTC_SBitCache_New(ft_ctx.cache_manager, &ft_ctx.sbit_cache); + error = FTC_SBitCache_New(context->cache_manager, &context->sbit_cache); if(error) { FT_ERROR_MSG("FTC_SBitCache_New", error); goto failed; } #else - error = FTC_ImageCache_New(ft_ctx.cache_manager, &ft_ctx.image_cache); + error = FTC_ImageCache_New(context->cache_manager, &context->image_cache); if(error) { FT_ERROR_MSG("FTC_ImageCache_New", error); goto failed; @@ -135,15 +142,22 @@ lv_res_t lv_freetype_init(uint16_t max_faces, uint16_t max_sizes, uint32_t max_b return LV_RES_OK; failed: - FTC_Manager_Done(ft_ctx.cache_manager); - FT_Done_FreeType(ft_ctx.library); + FTC_Manager_Done(context->cache_manager); + FT_Done_FreeType(context->library); return LV_RES_INV; } void lv_freetype_uninit(void) { - FTC_Manager_Done(ft_ctx.cache_manager); - FT_Done_FreeType(ft_ctx.library); + lv_freetype_context_t * context = ft_ctx; + if(!context) { + return; + } + + FTC_Manager_Done(context->cache_manager); + FT_Done_FreeType(context->library); + lv_free(context); + ft_ctx = NULL; } lv_font_t * lv_freetype_font_create(const char * pathname, uint16_t size, uint16_t style) @@ -187,7 +201,7 @@ lv_font_t * lv_freetype_font_create(const char * pathname, uint16_t size, uint16 scaler.width = size; scaler.height = size; scaler.pixel = 1; - FT_Error error = FTC_Manager_LookupSize(ft_ctx.cache_manager, + FT_Error error = FTC_Manager_LookupSize(ft_ctx->cache_manager, &scaler, &face_size); if(error) { @@ -218,7 +232,7 @@ void lv_freetype_font_del(lv_font_t * font) LV_ASSERT_NULL(font); lv_freetype_font_dsc_t * dsc = (lv_freetype_font_dsc_t *)(font->dsc); LV_ASSERT_NULL(dsc); - FTC_Manager_RemoveFaceID(ft_ctx.cache_manager, (FTC_FaceID)dsc); + FTC_Manager_RemoveFaceID(ft_ctx->cache_manager, (FTC_FaceID)dsc); lv_free(dsc->pathname); lv_free(dsc); } @@ -238,7 +252,7 @@ static FT_Error freetpye_face_requester(FTC_FaceID face_id, lv_freetype_font_dsc_t * dsc = (lv_freetype_font_dsc_t *)face_id; FT_Error error; - error = FT_New_Face(ft_ctx.library, dsc->pathname, 0, aface); + error = FT_New_Face(ft_ctx->library, dsc->pathname, 0, aface); if(error) { FT_ERROR_MSG("FT_New_Face", error); } @@ -301,6 +315,7 @@ static bool freetype_get_glyph_dsc_cb(const lv_font_t * font, return true; } + lv_freetype_context_t * context = ft_ctx; lv_freetype_font_dsc_t * dsc = (lv_freetype_font_dsc_t *)(font->dsc); FTC_FaceID face_id = (FTC_FaceID)dsc; @@ -311,7 +326,7 @@ static bool freetype_get_glyph_dsc_cb(const lv_font_t * font, scaler.width = dsc->size; scaler.height = dsc->size; scaler.pixel = 1; - error = FTC_Manager_LookupSize(ft_ctx.cache_manager, &scaler, &face_size); + error = FTC_Manager_LookupSize(context->cache_manager, &scaler, &face_size); if(error) { FT_ERROR_MSG("FTC_Manager_LookupSize", error); return false; @@ -319,7 +334,7 @@ static bool freetype_get_glyph_dsc_cb(const lv_font_t * font, FT_Face face = face_size->face; FT_UInt charmap_index = FT_Get_Charmap_Index(face->charmap); - FT_UInt glyph_index = FTC_CMapCache_Lookup(ft_ctx.cmap_cache, face_id, charmap_index, unicode_letter); + FT_UInt glyph_index = FTC_CMapCache_Lookup(context->cmap_cache, face_id, charmap_index, unicode_letter); dsc_out->is_placeholder = glyph_index == 0; if(dsc->style & LV_FREETYPE_FONT_STYLE_ITALIC) { @@ -332,10 +347,10 @@ static bool freetype_get_glyph_dsc_cb(const lv_font_t * font, } if(dsc->style & LV_FREETYPE_FONT_STYLE_BOLD) { - ft_ctx.current_face = face; + context->current_face = face; error = freetype_get_bold_glyph(font, face, glyph_index, dsc_out); if(error) { - ft_ctx.current_face = NULL; + context->current_face = NULL; return false; } goto end; @@ -348,17 +363,17 @@ static bool freetype_get_glyph_dsc_cb(const lv_font_t * font, desc_type.width = dsc->size; #if LV_FREETYPE_SBIT_CACHE - error = FTC_SBitCache_Lookup(ft_ctx.sbit_cache, + error = FTC_SBitCache_Lookup(context->sbit_cache, &desc_type, glyph_index, - &ft_ctx.sbit, + &context->sbit, NULL); if(error) { FT_ERROR_MSG("FTC_SBitCache_Lookup", error); return false; } - FTC_SBit sbit = ft_ctx.sbit; + FTC_SBit sbit = context->sbit; dsc_out->adv_w = sbit->xadvance; dsc_out->box_h = sbit->height; /*Height of the bitmap in [px]*/ dsc_out->box_w = sbit->width; /*Width of the bitmap in [px]*/ @@ -366,21 +381,21 @@ static bool freetype_get_glyph_dsc_cb(const lv_font_t * font, dsc_out->ofs_y = sbit->top - sbit->height; /*Y offset of the bitmap measured from the as line*/ dsc_out->bpp = 8; /*Bit per pixel: 1/2/4/8*/ #else - error = FTC_ImageCache_Lookup(ft_ctx.image_cache, + error = FTC_ImageCache_Lookup(context->image_cache, &desc_type, glyph_index, - &ft_ctx.image_glyph, + &context->image_glyph, NULL); if(error) { FT_ERROR_MSG("ImageCache_Lookup", error); return false; } - if(ft_ctx.image_glyph->format != FT_GLYPH_FORMAT_BITMAP) { + if(context->image_glyph->format != FT_GLYPH_FORMAT_BITMAP) { LV_LOG_ERROR("image_glyph->format != FT_GLYPH_FORMAT_BITMAP"); return false; } - FT_BitmapGlyph glyph_bitmap = (FT_BitmapGlyph)ft_ctx.image_glyph; + FT_BitmapGlyph glyph_bitmap = (FT_BitmapGlyph)context->image_glyph; dsc_out->adv_w = (glyph_bitmap->root.advance.x >> 16); dsc_out->box_h = glyph_bitmap->bitmap.rows; /*Height of the bitmap in [px]*/ dsc_out->box_w = glyph_bitmap->bitmap.width; /*Width of the bitmap in [px]*/ @@ -404,17 +419,19 @@ static const uint8_t * freetype_get_glyph_bitmap_cb(const lv_font_t * font, uint LV_UNUSED(buf_out); lv_freetype_font_dsc_t * dsc = (lv_freetype_font_dsc_t *)font->dsc; + lv_freetype_context_t * context = ft_ctx; + if(dsc->style & LV_FREETYPE_FONT_STYLE_BOLD) { - if(ft_ctx.current_face && ft_ctx.current_face->glyph->format == FT_GLYPH_FORMAT_BITMAP) { - return (const uint8_t *)(ft_ctx.current_face->glyph->bitmap.buffer); + if(context->current_face && context->current_face->glyph->format == FT_GLYPH_FORMAT_BITMAP) { + return (const uint8_t *)(context->current_face->glyph->bitmap.buffer); } return NULL; } #if LV_FREETYPE_SBIT_CACHE - return (const uint8_t *)ft_ctx.sbit->buffer; + return (const uint8_t *)context->sbit->buffer; #else - FT_BitmapGlyph glyph_bitmap = (FT_BitmapGlyph)ft_ctx.image_glyph; + FT_BitmapGlyph glyph_bitmap = (FT_BitmapGlyph)context->image_glyph; return (const uint8_t *)glyph_bitmap->bitmap.buffer; #endif } diff --git a/src/libs/fsdrv/lv_fs_fatfs.c b/src/libs/fsdrv/lv_fs_fatfs.c index 00c85d9e6..654abdfda 100644 --- a/src/libs/fsdrv/lv_fs_fatfs.c +++ b/src/libs/fsdrv/lv_fs_fatfs.c @@ -11,6 +11,7 @@ #if LV_USE_FS_FATFS #include "ff.h" +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ @@ -62,25 +63,25 @@ void lv_fs_fatfs_init(void) *--------------------------------------------------*/ /*Add a simple drive to open images*/ - static lv_fs_drv_t fs_drv; /*A driver descriptor*/ - lv_fs_drv_init(&fs_drv); + lv_fs_drv_t * fs_drv_p = &(LV_GLOBAL_DEFAULT()->fatfs_fs_drv); + lv_fs_drv_init(fs_drv_p); /*Set up fields...*/ - fs_drv.letter = LV_FS_FATFS_LETTER; - fs_drv.cache_size = LV_FS_FATFS_CACHE_SIZE; + fs_drv_p->letter = LV_FS_FATFS_LETTER; + fs_drv_p->cache_size = LV_FS_FATFS_CACHE_SIZE; - fs_drv.open_cb = fs_open; - fs_drv.close_cb = fs_close; - fs_drv.read_cb = fs_read; - fs_drv.write_cb = fs_write; - fs_drv.seek_cb = fs_seek; - fs_drv.tell_cb = fs_tell; + fs_drv_p->open_cb = fs_open; + fs_drv_p->close_cb = fs_close; + fs_drv_p->read_cb = fs_read; + fs_drv_p->write_cb = fs_write; + fs_drv_p->seek_cb = fs_seek; + fs_drv_p->tell_cb = fs_tell; - fs_drv.dir_close_cb = fs_dir_close; - fs_drv.dir_open_cb = fs_dir_open; - fs_drv.dir_read_cb = fs_dir_read; + fs_drv_p->dir_close_cb = fs_dir_close; + fs_drv_p->dir_open_cb = fs_dir_open; + fs_drv_p->dir_read_cb = fs_dir_read; - lv_fs_drv_register(&fs_drv); + lv_fs_drv_register(fs_drv_p); } /********************** diff --git a/src/libs/fsdrv/lv_fs_posix.c b/src/libs/fsdrv/lv_fs_posix.c index 6e5f6a005..f1ec7d63a 100644 --- a/src/libs/fsdrv/lv_fs_posix.c +++ b/src/libs/fsdrv/lv_fs_posix.c @@ -21,6 +21,7 @@ #include #endif +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ @@ -68,25 +69,25 @@ void lv_fs_posix_init(void) *--------------------------------------------------*/ /*Add a simple drive to open images*/ - static lv_fs_drv_t fs_drv; /*A driver descriptor*/ - lv_fs_drv_init(&fs_drv); + lv_fs_drv_t * fs_drv_p = &(LV_GLOBAL_DEFAULT()->posix_fs_drv); + lv_fs_drv_init(fs_drv_p); /*Set up fields...*/ - fs_drv.letter = LV_FS_POSIX_LETTER; - fs_drv.cache_size = LV_FS_POSIX_CACHE_SIZE; + fs_drv_p->letter = LV_FS_POSIX_LETTER; + fs_drv_p->cache_size = LV_FS_POSIX_CACHE_SIZE; - fs_drv.open_cb = fs_open; - fs_drv.close_cb = fs_close; - fs_drv.read_cb = fs_read; - fs_drv.write_cb = fs_write; - fs_drv.seek_cb = fs_seek; - fs_drv.tell_cb = fs_tell; + fs_drv_p->open_cb = fs_open; + fs_drv_p->close_cb = fs_close; + fs_drv_p->read_cb = fs_read; + fs_drv_p->write_cb = fs_write; + fs_drv_p->seek_cb = fs_seek; + fs_drv_p->tell_cb = fs_tell; - fs_drv.dir_close_cb = fs_dir_close; - fs_drv.dir_open_cb = fs_dir_open; - fs_drv.dir_read_cb = fs_dir_read; + fs_drv_p->dir_close_cb = fs_dir_close; + fs_drv_p->dir_open_cb = fs_dir_open; + fs_drv_p->dir_read_cb = fs_dir_read; - lv_fs_drv_register(&fs_drv); + lv_fs_drv_register(fs_drv_p); } /********************** diff --git a/src/libs/fsdrv/lv_fs_stdio.c b/src/libs/fsdrv/lv_fs_stdio.c index a46e21dd2..e22658b8f 100644 --- a/src/libs/fsdrv/lv_fs_stdio.c +++ b/src/libs/fsdrv/lv_fs_stdio.c @@ -18,6 +18,7 @@ #include #endif +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ @@ -70,25 +71,25 @@ void lv_fs_stdio_init(void) *--------------------------------------------------*/ /*Add a simple drive to open images*/ - static lv_fs_drv_t fs_drv; /*A driver descriptor*/ - lv_fs_drv_init(&fs_drv); + lv_fs_drv_t * fs_drv_p = &(LV_GLOBAL_DEFAULT()->stdio_fs_drv); + lv_fs_drv_init(fs_drv_p); /*Set up fields...*/ - fs_drv.letter = LV_FS_STDIO_LETTER; - fs_drv.cache_size = LV_FS_STDIO_CACHE_SIZE; + fs_drv_p->letter = LV_FS_STDIO_LETTER; + fs_drv_p->cache_size = LV_FS_STDIO_CACHE_SIZE; - fs_drv.open_cb = fs_open; - fs_drv.close_cb = fs_close; - fs_drv.read_cb = fs_read; - fs_drv.write_cb = fs_write; - fs_drv.seek_cb = fs_seek; - fs_drv.tell_cb = fs_tell; + fs_drv_p->open_cb = fs_open; + fs_drv_p->close_cb = fs_close; + fs_drv_p->read_cb = fs_read; + fs_drv_p->write_cb = fs_write; + fs_drv_p->seek_cb = fs_seek; + fs_drv_p->tell_cb = fs_tell; - fs_drv.dir_close_cb = fs_dir_close; - fs_drv.dir_open_cb = fs_dir_open; - fs_drv.dir_read_cb = fs_dir_read; + fs_drv_p->dir_close_cb = fs_dir_close; + fs_drv_p->dir_open_cb = fs_dir_open; + fs_drv_p->dir_read_cb = fs_dir_read; - lv_fs_drv_register(&fs_drv); + lv_fs_drv_register(fs_drv_p); } /********************** @@ -282,7 +283,7 @@ static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn) do { entry = readdir(handle->dir_p); if(entry) { - if(entry->d_type == DT_DIR) sprintf(fn, "/%s", entry->d_name); + if(entry->d_type == DT_DIR) snprintf(fn, strlen(entry->d_name), "/%s", entry->d_name); else lv_strcpy(fn, entry->d_name); } else { diff --git a/src/libs/fsdrv/lv_fs_win32.c b/src/libs/fsdrv/lv_fs_win32.c index cff9a1c4c..3c0402fa2 100644 --- a/src/libs/fsdrv/lv_fs_win32.c +++ b/src/libs/fsdrv/lv_fs_win32.c @@ -14,6 +14,7 @@ #include #include +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ @@ -66,25 +67,25 @@ void lv_fs_win32_init(void) *--------------------------------------------------*/ /*Add a simple driver to open images*/ - static lv_fs_drv_t fs_drv; /*A driver descriptor*/ - lv_fs_drv_init(&fs_drv); + lv_fs_drv_t * fs_drv_p = &(LV_GLOBAL_DEFAULT()->win32_fs_drv); + lv_fs_drv_init(fs_drv_p); /*Set up fields...*/ - fs_drv.letter = LV_FS_WIN32_LETTER; - fs_drv.cache_size = LV_FS_WIN32_CACHE_SIZE; + fs_drv_p->letter = LV_FS_WIN32_LETTER; + fs_drv_p->cache_size = LV_FS_WIN32_CACHE_SIZE; - fs_drv.open_cb = fs_open; - fs_drv.close_cb = fs_close; - fs_drv.read_cb = fs_read; - fs_drv.write_cb = fs_write; - fs_drv.seek_cb = fs_seek; - fs_drv.tell_cb = fs_tell; + fs_drv_p->open_cb = fs_open; + fs_drv_p->close_cb = fs_close; + fs_drv_p->read_cb = fs_read; + fs_drv_p->write_cb = fs_write; + fs_drv_p->seek_cb = fs_seek; + fs_drv_p->tell_cb = fs_tell; - fs_drv.dir_close_cb = fs_dir_close; - fs_drv.dir_open_cb = fs_dir_open; - fs_drv.dir_read_cb = fs_dir_read; + fs_drv_p->dir_close_cb = fs_dir_close; + fs_drv_p->dir_open_cb = fs_dir_open; + fs_drv_p->dir_read_cb = fs_dir_read; - lv_fs_drv_register(&fs_drv); + lv_fs_drv_register(fs_drv_p); } /********************** diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index c8369923b..b8c903d57 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -172,35 +172,6 @@ #endif #endif -/*Use a custom tick source that tells the elapsed time in milliseconds. - *It removes the need to manually update the tick with `lv_tick_inc()`)*/ -#ifndef LV_TICK_CUSTOM - #ifdef CONFIG_LV_TICK_CUSTOM - #define LV_TICK_CUSTOM CONFIG_LV_TICK_CUSTOM - #else - #define LV_TICK_CUSTOM 0 - #endif -#endif -#if LV_TICK_CUSTOM - #ifndef LV_TICK_CUSTOM_INCLUDE - #ifdef CONFIG_LV_TICK_CUSTOM_INCLUDE - #define LV_TICK_CUSTOM_INCLUDE CONFIG_LV_TICK_CUSTOM_INCLUDE - #else - #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ - #endif - #endif - #ifndef LV_TICK_CUSTOM_SYS_TIME_EXPR - #ifdef CONFIG_LV_TICK_CUSTOM_SYS_TIME_EXPR - #define LV_TICK_CUSTOM_SYS_TIME_EXPR CONFIG_LV_TICK_CUSTOM_SYS_TIME_EXPR - #else - #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ - #endif - #endif - /*If using lvgl as ESP32 component*/ - // #define LV_TICK_CUSTOM_INCLUDE "esp_timer.h" - // #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((esp_timer_get_time() / 1000LL)) -#endif /*LV_TICK_CUSTOM*/ - /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. *(Not so important, you can adjust it to modify default sizes and spaces)*/ #ifndef LV_DPI_DEF @@ -249,6 +220,28 @@ #endif #endif +/*Align the stride of all layers and images to this bytes*/ +#ifndef LV_DRAW_BUF_STRIDE_ALIGN + #ifdef _LV_KCONFIG_PRESENT + #ifdef CONFIG_LV_DRAW_BUF_STRIDE_ALIGN + #define LV_DRAW_BUF_STRIDE_ALIGN CONFIG_LV_DRAW_BUF_STRIDE_ALIGN + #else + #define LV_DRAW_BUF_STRIDE_ALIGN 0 + #endif + #else + #define LV_DRAW_BUF_STRIDE_ALIGN 1 + #endif +#endif + +/*Align the start address of draw_buf addresses to this bytes*/ +#ifndef LV_DRAW_BUF_ALIGN + #ifdef CONFIG_LV_DRAW_BUF_ALIGN + #define LV_DRAW_BUF_ALIGN CONFIG_LV_DRAW_BUF_ALIGN + #else + #define LV_DRAW_BUF_ALIGN 4 + #endif +#endif + /* Max. memory to be used for layers */ #ifndef LV_LAYER_MAX_MEMORY_USAGE #ifdef CONFIG_LV_LAYER_MAX_MEMORY_USAGE @@ -366,7 +359,6 @@ #endif #endif - /*======================= * FEATURE CONFIGURATION *=======================*/ @@ -692,24 +684,23 @@ #endif #endif -/*Garbage Collector settings - *Used if lvgl is bound to higher level language and the memory is managed by that language*/ -#ifndef LV_ENABLE_GC - #ifdef CONFIG_LV_ENABLE_GC - #define LV_ENABLE_GC CONFIG_LV_ENABLE_GC +#ifndef LV_ENABLE_GLOBAL_CUSTOM + #ifdef CONFIG_LV_ENABLE_GLOBAL_CUSTOM + #define LV_ENABLE_GLOBAL_CUSTOM CONFIG_LV_ENABLE_GLOBAL_CUSTOM #else - #define LV_ENABLE_GC 0 + #define LV_ENABLE_GLOBAL_CUSTOM 0 #endif #endif -#if LV_ENABLE_GC != 0 - #ifndef LV_GC_INCLUDE - #ifdef CONFIG_LV_GC_INCLUDE - #define LV_GC_INCLUDE CONFIG_LV_GC_INCLUDE +#if LV_ENABLE_GLOBAL_CUSTOM + /*Header to include for the custom 'lv_global' function"*/ + #ifndef LV_GLOBAL_CUSTOM_INCLUDE + #ifdef CONFIG_LV_GLOBAL_CUSTOM_INCLUDE + #define LV_GLOBAL_CUSTOM_INCLUDE CONFIG_LV_GLOBAL_CUSTOM_INCLUDE #else - #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ + #define LV_GLOBAL_CUSTOM_INCLUDE #endif #endif -#endif /*LV_ENABLE_GC*/ +#endif /*Default image cache size. Image caching keeps some images opened. *If only the built-in image formats are used there is no real advantage of caching. diff --git a/src/lv_init.c b/src/lv_init.c index 4ee331184..0eac57746 100644 --- a/src/lv_init.c +++ b/src/lv_init.c @@ -6,10 +6,11 @@ /********************* * INCLUDES *********************/ +#include "core/lv_global.h" #include "core/lv_obj.h" #include "disp/lv_disp_private.h" #include "indev/lv_indev_private.h" -#include "layouts/lv_layouts.h" +#include "layouts/lv_layout.h" #include "libs/bmp/lv_bmp.h" #include "libs/ffmpeg/lv_ffmpeg.h" #include "libs/freetype/lv_freetype.h" @@ -19,18 +20,13 @@ #include "libs/sjpg/lv_sjpg.h" #include "draw/lv_draw.h" #include "draw/lv_img_cache_builtin.h" -#include "misc/lv_anim.h" -#include "misc/lv_timer.h" #include "misc/lv_async.h" #include "misc/lv_fs.h" -#include "misc/lv_gc.h" -#if LV_USE_DRAW_SW - #include "draw/sw/lv_draw_sw.h" -#endif /********************* * DEFINES *********************/ +#define lv_initialized LV_GLOBAL_DEFAULT()->inited /********************** * TYPEDEFS @@ -43,7 +39,9 @@ /********************** * STATIC VARIABLES **********************/ -static bool lv_initialized = false; +#if LV_ENABLE_GLOBAL_CUSTOM == 0 + lv_global_t lv_global; +#endif /********************** * MACROS @@ -52,6 +50,33 @@ static bool lv_initialized = false; /********************** * GLOBAL FUNCTIONS **********************/ +static inline void lv_global_init(lv_global_t * global) +{ + LV_ASSERT_NULL(global); + + if(global == NULL) { + LV_LOG_ERROR("lv_global cannot be null"); + return; + } + + lv_memset(global, 0, sizeof(lv_global_t)); + + _lv_ll_init(&(global->disp_ll), sizeof(lv_disp_t)); + _lv_ll_init(&(global->indev_ll), sizeof(lv_indev_t)); + + global->memory_zero = ZERO_MEM_SENTINEL; + global->style_refresh = true; + global->layout_count = _LV_LAYOUT_LAST; + global->style_last_custom_prop_id = (uint16_t)_LV_STYLE_LAST_BUILT_IN_PROP; + global->area_trans_cache.angle_prev = INT32_MIN; + global->event_last_register_id = _LV_EVENT_LAST; + global->math_rand_seed = 0x1234ABCD; + +#if defined(LV_DRAW_SW_SHADOW_CACHE_SIZE) && LV_DRAW_SW_SHADOW_CACHE_SIZE > 0 + global->sw_shadow_cache.cache_size = -1; + global->sw_shadow_cache.cache_r = -1; +#endif +} bool lv_is_initialized(void) { @@ -60,21 +85,28 @@ bool lv_is_initialized(void) void lv_init(void) { - /*Do nothing if already initialized*/ - if(lv_initialized) { - LV_LOG_WARN("lv_init: already inited"); - return; - } - - LV_LOG_INFO("begin"); - /*First initialize Garbage Collection if needed*/ #ifdef LV_GC_INIT LV_GC_INIT(); #endif + /*Do nothing if already initialized*/ + if(lv_initialized) { + LV_LOG_WARN("lv_init: already initialized"); + return; + } + + LV_LOG_INFO("begin"); + + /*Initialize members of static variable lv_global */ + lv_global_init(LV_GLOBAL_DEFAULT()); + lv_mem_init(); +#if LV_USE_SPAN != 0 + lv_span_stack_init(); +#endif + #if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN lv_profiler_builtin_config_t profiler_config; lv_profiler_builtin_config_init(&profiler_config); @@ -85,6 +117,8 @@ void lv_init(void) _lv_fs_init(); + _lv_layout_init(); + _lv_anim_core_init(); _lv_group_init(); @@ -96,8 +130,6 @@ void lv_init(void) #endif _lv_obj_style_init(); - _lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t)); - _lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t)); /*Initialize the screen refresh system*/ _lv_refr_init(); @@ -147,15 +179,6 @@ void lv_init(void) LV_LOG_WARN("Log level is set to 'Trace' which makes LVGL much slower"); #endif - -#if LV_USE_FLEX - lv_flex_init(); -#endif - -#if LV_USE_GRID - lv_grid_init(); -#endif - #if LV_USE_MSG lv_msg_init(); #endif @@ -208,15 +231,38 @@ void lv_init(void) LV_LOG_TRACE("finished"); } -#if LV_ENABLE_GC || LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN +#if LV_ENABLE_GLOBAL_CUSTOM || LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN void lv_deinit(void) { - _lv_gc_clear_roots(); +#if LV_USE_SYSMON + _lv_sysmon_builtin_deinit(); +#endif lv_disp_set_default(NULL); +#if LV_USE_SPAN != 0 + lv_span_stack_deinit(); +#endif + +#if LV_USE_FREETYPE + lv_freetype_uninit(); +#endif + +#if LV_USE_THEME_DEFAULT + lv_theme_default_deinit(); +#endif + +#if LV_USE_THEME_BASIC + lv_theme_basic_deinit(); +#endif + +#if LV_USE_THEME_MONO + lv_theme_mono_deinit(); +#endif + lv_mem_deinit(); + lv_initialized = false; LV_LOG_INFO("lv_deinit done"); @@ -227,8 +273,6 @@ void lv_deinit(void) } #endif - - /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/lv_init.h b/src/lv_init.h index de8a0d584..7359e989c 100644 --- a/src/lv_init.h +++ b/src/lv_init.h @@ -35,11 +35,12 @@ extern "C" { void lv_init(void); -#if LV_ENABLE_GC || LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN +#if LV_ENABLE_GLOBAL_CUSTOM || LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN /** * Deinit the 'lv' library - * Currently only implemented when not using custom allocators, or GC is enabled. + * Currently only implemented when not using custom allocators, + * or using custom 'lv_global'. */ void lv_deinit(void); diff --git a/src/misc/lv_anim.c b/src/misc/lv_anim.c index ab75610a5..61e05aa3d 100644 --- a/src/misc/lv_anim.c +++ b/src/misc/lv_anim.c @@ -8,19 +8,21 @@ *********************/ #include "lv_anim.h" +#include "../core/lv_global.h" #include "../tick/lv_tick.h" #include "lv_assert.h" #include "lv_timer.h" #include "lv_math.h" #include "../stdlib/lv_mem.h" #include "../stdlib/lv_string.h" -#include "lv_gc.h" /********************* * DEFINES *********************/ #define LV_ANIM_RESOLUTION 1024 #define LV_ANIM_RES_SHIFT 10 +#define state LV_GLOBAL_DEFAULT()->anim_state +#define anim_ll_p &(state.anim_ll) /********************** * TYPEDEFS @@ -38,9 +40,6 @@ static int32_t lv_anim_path_cubic_bezier(const lv_anim_t * a, int32_t x1, /********************** * STATIC VARIABLES **********************/ -static bool anim_list_changed; -static bool anim_run_round; -static lv_timer_t * _lv_anim_tmr; /********************** * MACROS @@ -58,10 +57,11 @@ static lv_timer_t * _lv_anim_tmr; void _lv_anim_core_init(void) { - _lv_ll_init(&LV_GC_ROOT(_lv_anim_ll), sizeof(lv_anim_t)); - _lv_anim_tmr = lv_timer_create(anim_timer, LV_DEF_REFR_PERIOD, NULL); + _lv_ll_init(anim_ll_p, sizeof(lv_anim_t)); + state.timer = lv_timer_create(anim_timer, LV_DEF_REFR_PERIOD, NULL); anim_mark_list_change(); /*Turn off the animation timer*/ - anim_list_changed = false; + state.anim_list_changed = false; + state.anim_run_round = false; } void lv_anim_init(lv_anim_t * a) @@ -83,14 +83,14 @@ lv_anim_t * lv_anim_start(const lv_anim_t * a) if(a->exec_cb != NULL) lv_anim_del(a->var, a->exec_cb); /*exec_cb == NULL would delete all animations of var*/ /*Add the new animation to the animation linked list*/ - lv_anim_t * new_anim = _lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll)); + lv_anim_t * new_anim = _lv_ll_ins_head(anim_ll_p); LV_ASSERT_MALLOC(new_anim); if(new_anim == NULL) return NULL; /*Initialize the animation descriptor*/ lv_memcpy(new_anim, a, sizeof(lv_anim_t)); if(a->var == a) new_anim->var = new_anim; - new_anim->run_round = anim_run_round; + new_anim->run_round = state.anim_run_round; new_anim->last_timer_run = lv_tick_get(); /*Set the start value*/ @@ -138,13 +138,13 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb) lv_anim_t * a; lv_anim_t * a_next; bool del = false; - a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)); + a = _lv_ll_get_head(anim_ll_p); while(a != NULL) { /*'a' might be deleted, so get the next object while 'a' is valid*/ - a_next = _lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a); + a_next = _lv_ll_get_next(anim_ll_p, a); if((a->var == var || var == NULL) && (a->exec_cb == exec_cb || exec_cb == NULL)) { - _lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a); + _lv_ll_remove(anim_ll_p, a); if(a->deleted_cb != NULL) a->deleted_cb(a); lv_free(a); anim_mark_list_change(); /*Read by `anim_timer`. It need to know if a delete occurred in @@ -160,14 +160,14 @@ bool lv_anim_del(void * var, lv_anim_exec_xcb_t exec_cb) void lv_anim_del_all(void) { - _lv_ll_clear(&LV_GC_ROOT(_lv_anim_ll)); + _lv_ll_clear(anim_ll_p); anim_mark_list_change(); } lv_anim_t * lv_anim_get(void * var, lv_anim_exec_xcb_t exec_cb) { lv_anim_t * a; - _LV_LL_READ(&LV_GC_ROOT(_lv_anim_ll), a) { + _LV_LL_READ(anim_ll_p, a) { if(a->var == var && (a->exec_cb == exec_cb || exec_cb == NULL)) { return a; } @@ -178,14 +178,14 @@ lv_anim_t * lv_anim_get(void * var, lv_anim_exec_xcb_t exec_cb) struct _lv_timer_t * lv_anim_get_timer(void) { - return _lv_anim_tmr; + return state.timer; } uint16_t lv_anim_count_running(void) { uint16_t cnt = 0; lv_anim_t * a; - _LV_LL_READ(&LV_GC_ROOT(_lv_anim_ll), a) cnt++; + _LV_LL_READ(anim_ll_p, a) cnt++; return cnt; } @@ -324,9 +324,9 @@ static void anim_timer(lv_timer_t * param) /*Flip the run round*/ - anim_run_round = anim_run_round ? false : true; + state.anim_run_round = state.anim_run_round ? false : true; - lv_anim_t * a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)); + lv_anim_t * a = _lv_ll_get_head(anim_ll_p); while(a != NULL) { uint32_t elaps = lv_tick_elaps(a->last_timer_run); @@ -335,10 +335,10 @@ static void anim_timer(lv_timer_t * param) * happened in `anim_ready_handler` which could make this linked list reading corrupt * because the list is changed meanwhile */ - anim_list_changed = false; + state.anim_list_changed = false; - if(a->run_round != anim_run_round) { - a->run_round = anim_run_round; /*The list readying might be reset so need to know which anim has run already*/ + if(a->run_round != state.anim_run_round) { + a->run_round = state.anim_run_round; /*The list readying might be reset so need to know which anim has run already*/ /*The animation will run now for the first time. Call `start_cb`*/ int32_t new_act_time = a->act_time + elaps; @@ -373,10 +373,10 @@ static void anim_timer(lv_timer_t * param) /*If the linked list changed due to anim. delete then it's not safe to continue *the reading of the list from here -> start from the head*/ - if(anim_list_changed) - a = _lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)); + if(state.anim_list_changed) + a = _lv_ll_get_head(anim_ll_p); else - a = _lv_ll_get_next(&LV_GC_ROOT(_lv_anim_ll), a); + a = _lv_ll_get_next(anim_ll_p, a); } } @@ -400,7 +400,7 @@ static void anim_ready_handler(lv_anim_t * a) /*Delete the animation from the list. * This way the `ready_cb` will see the animations like it's animation is ready deleted*/ - _lv_ll_remove(&LV_GC_ROOT(_lv_anim_ll), a); + _lv_ll_remove(anim_ll_p, a); /*Flag that the list has changed*/ anim_mark_list_change(); @@ -433,11 +433,11 @@ static void anim_ready_handler(lv_anim_t * a) static void anim_mark_list_change(void) { - anim_list_changed = true; - if(_lv_ll_get_head(&LV_GC_ROOT(_lv_anim_ll)) == NULL) - lv_timer_pause(_lv_anim_tmr); + state.anim_list_changed = true; + if(_lv_ll_get_head(anim_ll_p) == NULL) + lv_timer_pause(state.timer); else - lv_timer_resume(_lv_anim_tmr); + lv_timer_resume(state.timer); } static int32_t lv_anim_path_cubic_bezier(const lv_anim_t * a, int32_t x1, int32_t y1, int32_t x2, int32_t y2) diff --git a/src/misc/lv_anim.h b/src/misc/lv_anim.h index e213c4f87..80c86f2b2 100644 --- a/src/misc/lv_anim.h +++ b/src/misc/lv_anim.h @@ -15,6 +15,8 @@ extern "C" { *********************/ #include "../lv_conf_internal.h" #include "lv_math.h" +#include "lv_timer.h" +#include "lv_ll.h" #include #include @@ -89,6 +91,13 @@ typedef enum { struct _lv_anim_t; struct _lv_timer_t; +typedef struct { + bool anim_list_changed; + bool anim_run_round; + struct _lv_timer_t * timer; + lv_ll_t anim_ll; +} lv_anim_state_t; + /** Get the current value during an animation*/ typedef int32_t (*lv_anim_path_cb_t)(const struct _lv_anim_t *); diff --git a/src/misc/lv_area.c b/src/misc/lv_area.c index c20ef2063..d0380a41d 100644 --- a/src/misc/lv_area.c +++ b/src/misc/lv_area.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "../lv_conf_internal.h" +#include "../core/lv_global.h" #include "lv_area.h" #include "lv_math.h" @@ -14,6 +15,7 @@ /********************* * DEFINES *********************/ +#define trans_cache LV_GLOBAL_DEFAULT()->area_trans_cache /********************** * TYPEDEFS @@ -471,11 +473,8 @@ void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom, const lv_po p->y = (((int32_t)(p->y) * zoom) >> 8) + pivot->y; return; } - - static int32_t angle_prev = INT32_MIN; - static int32_t sinma; - static int32_t cosma; - if(angle_prev != angle) { + lv_area_transform_cache_t * cache = &trans_cache; + if(cache->angle_prev != angle) { int32_t angle_limited = angle; if(angle_limited > 3600) angle_limited -= 3600; if(angle_limited < 0) angle_limited += 3600; @@ -490,21 +489,21 @@ void lv_point_transform(lv_point_t * p, int32_t angle, int32_t zoom, const lv_po int32_t c1 = lv_trigo_sin(angle_low + 90); int32_t c2 = lv_trigo_sin(angle_high + 90); - sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; - cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; - sinma = sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); - cosma = cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); - angle_prev = angle; + cache->sinma = (s1 * (10 - angle_rem) + s2 * angle_rem) / 10; + cache->cosma = (c1 * (10 - angle_rem) + c2 * angle_rem) / 10; + cache->sinma = cache->sinma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + cache->cosma = cache->cosma >> (LV_TRIGO_SHIFT - _LV_TRANSFORM_TRIGO_SHIFT); + cache->angle_prev = angle; } int32_t x = p->x; int32_t y = p->y; if(zoom == 256) { - p->x = ((cosma * x - sinma * y) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; - p->y = ((sinma * x + cosma * y) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; + p->x = ((cache->cosma * x - cache->sinma * y) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->x; + p->y = ((cache->sinma * x + cache->cosma * y) >> _LV_TRANSFORM_TRIGO_SHIFT) + pivot->y; } else { - p->x = (((cosma * x - sinma * y) * zoom) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->x; - p->y = (((sinma * x + cosma * y) * zoom) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->y; + p->x = (((cache->cosma * x - cache->sinma * y) * zoom) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->x; + p->y = (((cache->sinma * x + cache->cosma * y) * zoom) >> (_LV_TRANSFORM_TRIGO_SHIFT + 8)) + pivot->y; } } diff --git a/src/misc/lv_area.h b/src/misc/lv_area.h index ebf60fb65..bad5c7a75 100644 --- a/src/misc/lv_area.h +++ b/src/misc/lv_area.h @@ -99,6 +99,11 @@ typedef _lv_dir_t lv_dir_t; typedef uint8_t lv_dir_t; #endif /*DOXYGEN*/ +typedef struct { + int32_t angle_prev; + int32_t sinma; + int32_t cosma; +} lv_area_transform_cache_t; /********************** * GLOBAL PROTOTYPES diff --git a/src/misc/lv_bidi.c b/src/misc/lv_bidi.c index 9eb408390..23d579c02 100644 --- a/src/misc/lv_bidi.c +++ b/src/misc/lv_bidi.c @@ -32,6 +32,11 @@ typedef struct { lv_base_dir_t dir; } bracket_stack_t; +typedef struct { + bracket_stack_t br_stack[LV_BIDI_BRACKLET_DEPTH]; + uint8_t br_stack_p; +} lv_bidi_ctx_t; + /********************** * STATIC PROTOTYPES **********************/ @@ -42,12 +47,14 @@ static bool lv_bidi_letter_is_weak(uint32_t letter); static bool lv_bidi_letter_is_rtl(uint32_t letter); static bool lv_bidi_letter_is_neutral(uint32_t letter); -static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint32_t max_len, uint32_t * len, +static lv_base_dir_t get_next_run(lv_bidi_ctx_t * ctx, const char * txt, lv_base_dir_t base_dir, uint32_t max_len, + uint32_t * len, uint16_t * pos_conv_len); static void rtl_reverse(char * dest, const char * src, uint32_t len, uint16_t * pos_conv_out, uint16_t pos_conv_rd_base, uint16_t pos_conv_len); static uint32_t char_change_to_pair(uint32_t letter); -static lv_base_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, +static lv_base_dir_t bracket_process(lv_bidi_ctx_t * ctx, const char * txt, uint32_t next_pos, uint32_t len, + uint32_t letter, lv_base_dir_t base_dir); static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index); static uint32_t get_txt_len(const char * txt, uint32_t max_len); @@ -57,8 +64,6 @@ static uint32_t get_txt_len(const char * txt, uint32_t max_len); **********************/ static const uint8_t bracket_left[] = {"<({["}; static const uint8_t bracket_right[] = {">)}]"}; -static bracket_stack_t br_stack[LV_BIDI_BRACKLET_DEPTH]; -static uint8_t br_stack_p; /********************** * MACROS @@ -240,14 +245,15 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le lv_base_dir_t dir = base_dir; /*Empty the bracket stack*/ - br_stack_p = 0; + lv_bidi_ctx_t ctx; + lv_memzero(&ctx, sizeof(ctx)); /*Process neutral chars in the beginning*/ while(rd < len) { uint32_t letter = _lv_txt_encoded_next(str_in, &rd); pos_conv_rd++; dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(str_in, rd, len, letter, base_dir); + if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(&ctx, str_in, rd, len, letter, base_dir); else if(dir != LV_BASE_DIR_WEAK) break; } @@ -278,7 +284,7 @@ void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t le /*Get and process the runs*/ while(rd < len && str_in[rd]) { - run_dir = get_next_run(&str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); + run_dir = get_next_run(&ctx, &str_in[rd], base_dir, len - rd, &run_len, &pos_conv_run_len); if(base_dir == LV_BASE_DIR_LTR) { if(run_dir == LV_BASE_DIR_LTR) { @@ -429,7 +435,8 @@ static void fill_pos_conv(uint16_t * out, uint16_t len, uint16_t index) } } -static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint32_t max_len, uint32_t * len, +static lv_base_dir_t get_next_run(lv_bidi_ctx_t * ctx, const char * txt, lv_base_dir_t base_dir, uint32_t max_len, + uint32_t * len, uint16_t * pos_conv_len) { uint32_t i = 0; @@ -439,7 +446,7 @@ static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint letter = _lv_txt_encoded_next(txt, NULL); lv_base_dir_t dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(txt, 0, max_len, letter, base_dir); + if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(ctx, txt, 0, max_len, letter, base_dir); /*Find the first strong char. Skip the neutrals*/ while(dir == LV_BASE_DIR_NEUTRAL || dir == LV_BASE_DIR_WEAK) { @@ -447,7 +454,7 @@ static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint pos_conv_i++; dir = lv_bidi_get_letter_dir(letter); - if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(txt, i, max_len, letter, base_dir); + if(dir == LV_BASE_DIR_NEUTRAL) dir = bracket_process(ctx, txt, i, max_len, letter, base_dir); if(dir == LV_BASE_DIR_LTR || dir == LV_BASE_DIR_RTL) break; @@ -471,7 +478,7 @@ static lv_base_dir_t get_next_run(const char * txt, lv_base_dir_t base_dir, uint letter = _lv_txt_encoded_next(txt, &i); pos_conv_i++; next_dir = lv_bidi_get_letter_dir(letter); - if(next_dir == LV_BASE_DIR_NEUTRAL) next_dir = bracket_process(txt, i, max_len, letter, base_dir); + if(next_dir == LV_BASE_DIR_NEUTRAL) next_dir = bracket_process(ctx, txt, i, max_len, letter, base_dir); if(next_dir == LV_BASE_DIR_WEAK) { if(run_dir == LV_BASE_DIR_RTL) { @@ -605,7 +612,8 @@ static uint32_t char_change_to_pair(uint32_t letter) return letter; } -static lv_base_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32_t len, uint32_t letter, +static lv_base_dir_t bracket_process(lv_bidi_ctx_t * ctx, const char * txt, uint32_t next_pos, uint32_t len, + uint32_t letter, lv_base_dir_t base_dir) { lv_base_dir_t bracket_dir = LV_BASE_DIR_NEUTRAL; @@ -663,19 +671,19 @@ static lv_base_dir_t bracket_process(const char * txt, uint32_t next_pos, uint32 /*The letter was an opening bracket*/ if(bracket_left[i] != '\0') { - if(bracket_dir == LV_BASE_DIR_NEUTRAL || br_stack_p == LV_BIDI_BRACKLET_DEPTH) return LV_BASE_DIR_NEUTRAL; + if(bracket_dir == LV_BASE_DIR_NEUTRAL || ctx->br_stack_p == LV_BIDI_BRACKLET_DEPTH) return LV_BASE_DIR_NEUTRAL; - br_stack[br_stack_p].bracklet_pos = i; - br_stack[br_stack_p].dir = bracket_dir; + ctx->br_stack[ctx->br_stack_p].bracklet_pos = i; + ctx->br_stack[ctx->br_stack_p].dir = bracket_dir; - br_stack_p++; + ctx->br_stack_p++; return bracket_dir; } - else if(br_stack_p > 0) { + else if(ctx->br_stack_p > 0) { /*Is the letter a closing bracket of the last opening?*/ - if(letter == bracket_right[br_stack[br_stack_p - 1].bracklet_pos]) { - bracket_dir = br_stack[br_stack_p - 1].dir; - br_stack_p--; + if(letter == bracket_right[ctx->br_stack[ctx->br_stack_p - 1].bracklet_pos]) { + bracket_dir = ctx->br_stack[ctx->br_stack_p - 1].dir; + ctx->br_stack_p--; return bracket_dir; } } diff --git a/src/misc/lv_event.c b/src/misc/lv_event.c index 7fc68b664..0509b8269 100644 --- a/src/misc/lv_event.c +++ b/src/misc/lv_event.c @@ -7,6 +7,7 @@ * INCLUDES *********************/ #include "lv_event.h" +#include "../core/lv_global.h" #include "../stdlib/lv_mem.h" #include "lv_assert.h" #include @@ -15,6 +16,9 @@ * DEFINES *********************/ +#define event_head LV_GLOBAL_DEFAULT()->event_header +#define event_last_id LV_GLOBAL_DEFAULT()->event_last_register_id + /********************** * TYPEDEFS **********************/ @@ -26,11 +30,11 @@ /********************** * STATIC VARIABLES **********************/ -static lv_event_t * event_head; /********************** * MACROS **********************/ + #if LV_LOG_TRACE_EVENT #define EVENT_TRACE(...) LV_LOG_TRACE(__VA_ARGS__) #else @@ -173,9 +177,8 @@ void lv_event_stop_processing(lv_event_t * e) uint32_t lv_event_register_id(void) { - static uint32_t last_id = _LV_EVENT_LAST; - last_id ++; - return last_id; + event_last_id ++; + return event_last_id; } void _lv_event_mark_deleted(void * target) diff --git a/src/misc/lv_fs.c b/src/misc/lv_fs.c index c45c81125..71df1e8f8 100644 --- a/src/misc/lv_fs.c +++ b/src/misc/lv_fs.c @@ -12,11 +12,12 @@ #include "../misc/lv_assert.h" #include "../stdlib/lv_string.h" #include "lv_ll.h" -#include "lv_gc.h" +#include "../core/lv_global.h" /********************* * DEFINES *********************/ +#define fsdrv_ll_p &(LV_GLOBAL_DEFAULT()->fsdrv_ll) /********************** * TYPEDEFS @@ -41,7 +42,7 @@ static const char * lv_fs_get_real_path(const char * path); void _lv_fs_init(void) { - _lv_ll_init(&LV_GC_ROOT(_lv_fsdrv_ll), sizeof(lv_fs_drv_t *)); + _lv_ll_init(fsdrv_ll_p, sizeof(lv_fs_drv_t *)); } bool lv_fs_is_ready(char letter) @@ -408,7 +409,7 @@ void lv_fs_drv_register(lv_fs_drv_t * drv_p) { /*Save the new driver*/ lv_fs_drv_t ** new_drv; - new_drv = _lv_ll_ins_head(&LV_GC_ROOT(_lv_fsdrv_ll)); + new_drv = _lv_ll_ins_head(fsdrv_ll_p); LV_ASSERT_MALLOC(new_drv); if(new_drv == NULL) return; @@ -419,7 +420,7 @@ lv_fs_drv_t * lv_fs_get_drv(char letter) { lv_fs_drv_t ** drv; - _LV_LL_READ(&LV_GC_ROOT(_lv_fsdrv_ll), drv) { + _LV_LL_READ(fsdrv_ll_p, drv) { if((*drv)->letter == letter) { return *drv; } @@ -433,7 +434,7 @@ char * lv_fs_get_letters(char * buf) lv_fs_drv_t ** drv; uint8_t i = 0; - _LV_LL_READ(&LV_GC_ROOT(_lv_fsdrv_ll), drv) { + _LV_LL_READ(fsdrv_ll_p, drv) { buf[i] = (*drv)->letter; i++; } diff --git a/src/misc/lv_gc.c b/src/misc/lv_gc.c deleted file mode 100644 index ba34e9b96..000000000 --- a/src/misc/lv_gc.c +++ /dev/null @@ -1,47 +0,0 @@ -/** - * @file lv_gc.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_gc.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -#if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 - LV_ROOTS -#endif /*LV_ENABLE_GC*/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -void _lv_gc_clear_roots(void) -{ -#define LV_CLEAR_ROOT(root_type, root_name) lv_memzero(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name))); - LV_ITERATE_ROOTS(LV_CLEAR_ROOT) -} - -/********************** - * STATIC FUNCTIONS - **********************/ diff --git a/src/misc/lv_gc.h b/src/misc/lv_gc.h deleted file mode 100644 index c000604a9..000000000 --- a/src/misc/lv_gc.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file lv_gc.h - * - */ - -#ifndef LV_GC_H -#define LV_GC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/********************* - * INCLUDES - *********************/ -#include "../lv_conf_internal.h" -#include -#include "../stdlib/lv_mem.h" -#include "../stdlib/lv_string.h" -#include "lv_ll.h" -#include "lv_timer.h" -#include "lv_types.h" -#include "../draw/lv_img_cache.h" -#include "../draw/sw/lv_draw_sw_mask.h" -#include "../core/lv_obj_pos.h" -#include "../disp/lv_disp.h" - -/********************* - * DEFINES - *********************/ -#if LV_IMG_CACHE_DEF_SIZE -# define LV_IMG_CACHE_DEF 1 -#else -# define LV_IMG_CACHE_DEF 0 -#endif - -#define LV_DISPATCH(f, t, n) f(t, n) -#define LV_DISPATCH_COND(f, t, n, m, v) LV_CONCAT3(LV_DISPATCH, m, v)(f, t, n) - -#define LV_DISPATCH00(f, t, n) LV_DISPATCH(f, t, n) -#define LV_DISPATCH01(f, t, n) -#define LV_DISPATCH10(f, t, n) -#define LV_DISPATCH11(f, t, n) LV_DISPATCH(f, t, n) - -#define LV_ITERATE_ROOTS(f) \ - LV_DISPATCH(f, lv_ll_t, _lv_timer_ll) /*Linked list to store the lv_timers*/ \ - LV_DISPATCH(f, lv_ll_t, _lv_disp_ll) /*Linked list of display device*/ \ - LV_DISPATCH(f, lv_ll_t, _lv_indev_ll) /*Linked list of input device*/ \ - LV_DISPATCH(f, lv_ll_t, _lv_fsdrv_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_anim_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_group_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_img_decoder_ll) \ - LV_DISPATCH(f, lv_ll_t, _lv_obj_style_trans_ll) \ - LV_DISPATCH(f, lv_layout_dsc_t *, _lv_layout_list) \ - LV_DISPATCH_COND(f, _lv_img_cache_entry_t*, _lv_img_cache_array, LV_IMG_CACHE_DEF, 1) \ - LV_DISPATCH_COND(f, _lv_img_cache_entry_t, _lv_img_cache_single, LV_IMG_CACHE_DEF, 0) \ - LV_DISPATCH(f, lv_timer_t*, _lv_timer_act) \ - LV_DISPATCH_COND(f, _lv_draw_sw_mask_radius_circle_dsc_arr_t , _lv_circle_cache, LV_DRAW_SW_COMPLEX, 1) \ - LV_DISPATCH(f, void * , _lv_theme_default_styles) \ - LV_DISPATCH(f, void * , _lv_theme_basic_styles) \ - LV_DISPATCH(f, uint8_t * , _lv_style_custom_prop_flag_lookup_table) \ - LV_DISPATCH(f, lv_draw_unit_t *, _lv_draw_unit_head) \ - LV_DISPATCH(f, lv_ll_t, _subs_ll) - -#define LV_DEFINE_ROOT(root_type, root_name) root_type root_name; -#define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT) - -#if LV_ENABLE_GC == 1 -#if LV_USE_BUILTIN_MALLOC -#error "GC requires CUSTOM_MEM" -#endif /*LV_USE_BUILTIN_MALLOC*/ -#include LV_GC_INCLUDE -#else /*LV_ENABLE_GC*/ -#define LV_GC_ROOT(x) x -#define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name; -LV_ITERATE_ROOTS(LV_EXTERN_ROOT) -#endif /*LV_ENABLE_GC*/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * GLOBAL PROTOTYPES - **********************/ - -void _lv_gc_clear_roots(void); - -/********************** - * MACROS - **********************/ - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_GC_H*/ diff --git a/src/misc/lv_log.c b/src/misc/lv_log.c index 9c9740567..583adadea 100644 --- a/src/misc/lv_log.c +++ b/src/misc/lv_log.c @@ -15,6 +15,7 @@ #include "../stdlib/lv_mem.h" #include "../stdlib/lv_string.h" #include "../tick/lv_tick.h" +#include "../core/lv_global.h" #if LV_LOG_PRINTF #include @@ -23,6 +24,10 @@ /********************* * DEFINES *********************/ +#if LV_LOG_USE_TIMESTAMP + #define last_log_time LV_GLOBAL_DEFAULT()->log_last_log_time +#endif +#define custom_print_cb LV_GLOBAL_DEFAULT()->custom_log_print_cb #if LV_LOG_USE_TIMESTAMP #define LOG_TIMESTAMP_FMT "\t(%" LV_PRIu32 ".%03" LV_PRIu32 ", +%" LV_PRIu32 ")\t" @@ -43,7 +48,6 @@ /********************** * STATIC VARIABLES **********************/ -static lv_log_print_g_cb_t custom_print_cb; /********************** * MACROS @@ -77,10 +81,6 @@ void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * { if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/ -#if LV_LOG_USE_TIMESTAMP - static uint32_t last_log_time = 0; -#endif - if(level >= LV_LOG_LEVEL) { va_list args; va_start(args, format); diff --git a/src/misc/lv_math.c b/src/misc/lv_math.c index fb7a2ccf7..eba04f42e 100644 --- a/src/misc/lv_math.c +++ b/src/misc/lv_math.c @@ -7,10 +7,12 @@ * INCLUDES *********************/ #include "lv_math.h" +#include "../core/lv_global.h" /********************* * DEFINES *********************/ +#define rand_seed LV_GLOBAL_DEFAULT()->math_rand_seed /********************** * TYPEDEFS @@ -377,16 +379,14 @@ int32_t lv_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32 uint32_t lv_rand(uint32_t min, uint32_t max) { - static uint32_t a = 0x1234ABCD; /*Seed*/ - /*Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs"*/ - uint32_t x = a; + uint32_t x = rand_seed; x ^= x << 13; x ^= x >> 17; x ^= x << 5; - a = x; + rand_seed = x; - return (a % (max - min + 1)) + min; + return (rand_seed % (max - min + 1)) + min; } /********************** diff --git a/src/misc/lv_profiler_builtin.c b/src/misc/lv_profiler_builtin.c index 904df16d9..46dffc832 100644 --- a/src/misc/lv_profiler_builtin.c +++ b/src/misc/lv_profiler_builtin.c @@ -9,6 +9,7 @@ #include "lv_profiler_builtin.h" #include "../lvgl.h" +#include "../core/lv_global.h" /********************* * DEFINES @@ -16,6 +17,9 @@ #if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN +#define profiler_ctx LV_GLOBAL_DEFAULT()->profiler_context + + #define LV_PROFILER_STR_MAX_LEN 128 #define LV_PROFILER_TICK_PER_SEC_MAX 1000000 @@ -23,25 +27,6 @@ * TYPEDEFS **********************/ -/** - * @brief Structure representing a built-in profiler item in LVGL - */ -typedef struct { - char tag; /**< The tag of the profiler item */ - uint32_t tick; /**< The tick value of the profiler item */ - const char * func; /**< A pointer to the function associated with the profiler item */ -} lv_profiler_builtin_item_t; - -/** - * @brief Structure representing a context for the LVGL built-in profiler - */ -typedef struct { - lv_profiler_builtin_item_t * item_arr; /**< Pointer to an array of profiler items */ - uint32_t item_num; /**< Number of profiler items in the array */ - uint32_t cur_index; /**< Index of the current profiler item */ - lv_profiler_builtin_config_t config; /**< Configuration for the built-in profiler */ -} lv_profiler_builtin_ctx_t; - /********************** * STATIC PROTOTYPES **********************/ @@ -52,8 +37,6 @@ static void default_flush_cb(const char * buf); * STATIC VARIABLES **********************/ -static lv_profiler_builtin_ctx_t profiler_ctx = { 0 }; - /********************** * MACROS **********************/ diff --git a/src/misc/lv_profiler_builtin.h b/src/misc/lv_profiler_builtin.h index cb7432525..66fe3472d 100644 --- a/src/misc/lv_profiler_builtin.h +++ b/src/misc/lv_profiler_builtin.h @@ -1,5 +1,5 @@ /** - * @file lv_profiler_builtin.h.h + * @file lv_profiler_builtin.h * */ @@ -43,6 +43,26 @@ typedef struct { void (*flush_cb)(const char * buf); /**< Callback function to flush the profiling data */ } lv_profiler_builtin_config_t; + +/** + * @brief Structure representing a built-in profiler item in LVGL + */ +typedef struct { + char tag; /**< The tag of the profiler item */ + uint32_t tick; /**< The tick value of the profiler item */ + const char * func; /**< A pointer to the function associated with the profiler item */ +} lv_profiler_builtin_item_t; + +/** + * @brief Structure representing a context for the LVGL built-in profiler + */ +typedef struct { + lv_profiler_builtin_item_t * item_arr; /**< Pointer to an array of profiler items */ + uint32_t item_num; /**< Number of profiler items in the array */ + uint32_t cur_index; /**< Index of the current profiler item */ + lv_profiler_builtin_config_t config; /**< Configuration for the built-in profiler */ +} lv_profiler_builtin_ctx_t; + /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/src/misc/lv_style.c b/src/misc/lv_style.c index ce7df4107..cf608dccf 100644 --- a/src/misc/lv_style.c +++ b/src/misc/lv_style.c @@ -7,14 +7,18 @@ * INCLUDES *********************/ #include "lv_style.h" -#include "lv_gc.h" +#include "../core/lv_global.h" #include "../stdlib/lv_mem.h" +#include "../stdlib/lv_string.h" #include "lv_assert.h" #include "lv_types.h" /********************* * DEFINES *********************/ +#define _lv_style_custom_prop_flag_lookup_table_size LV_GLOBAL_DEFAULT()->style_custom_table_size +#define _lv_style_custom_prop_flag_lookup_table LV_GLOBAL_DEFAULT()->style_custom_prop_flag_lookup_table +#define last_custom_prop_id LV_GLOBAL_DEFAULT()->style_last_custom_prop_id /********************** * TYPEDEFS @@ -128,16 +132,30 @@ const uint8_t _lv_style_builtin_prop_flag_lookup_table[_LV_STYLE_NUM_BUILT_IN_PR [LV_STYLE_BLEND_MODE] = LV_STYLE_PROP_FLAG_LAYER_UPDATE, [LV_STYLE_LAYOUT] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, [LV_STYLE_BASE_DIR] = LV_STYLE_PROP_FLAG_INHERITABLE | LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, -}; -uint32_t _lv_style_custom_prop_flag_lookup_table_size = 0; + [LV_STYLE_FLEX_FLOW] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_FLEX_MAIN_PLACE] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_FLEX_CROSS_PLACE] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_FLEX_TRACK_PLACE] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_FLEX_GROW] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + + [LV_STYLE_GRID_COLUMN_DSC_ARRAY] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_ROW_DSC_ARRAY] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_COLUMN_ALIGN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_ROW_ALIGN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_CELL_ROW_SPAN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_CELL_ROW_POS] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_CELL_COLUMN_SPAN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_CELL_COLUMN_POS] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_CELL_X_ALIGN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + [LV_STYLE_GRID_CELL_Y_ALIGN] = LV_STYLE_PROP_FLAG_LAYOUT_UPDATE, + +}; /********************** * STATIC VARIABLES **********************/ -static uint16_t last_custom_prop_id = (uint16_t)_LV_STYLE_LAST_BUILT_IN_PROP; - /********************** * MACROS **********************/ @@ -173,7 +191,7 @@ void lv_style_reset(lv_style_t * style) lv_style_prop_t lv_style_register_prop(uint8_t flag) { - if(LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table) == NULL) { + if(_lv_style_custom_prop_flag_lookup_table == NULL) { _lv_style_custom_prop_flag_lookup_table_size = 0; last_custom_prop_id = (uint16_t)_LV_STYLE_LAST_BUILT_IN_PROP; } @@ -191,19 +209,19 @@ lv_style_prop_t lv_style_register_prop(uint8_t flag) /* Round required_size up to the nearest 32-byte value */ required_size = (required_size + 31) & ~31; LV_ASSERT_MSG(required_size > 0, "required size has become 0?"); - uint8_t * old_p = LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table); + uint8_t * old_p = _lv_style_custom_prop_flag_lookup_table; uint8_t * new_p = lv_realloc(old_p, required_size * sizeof(uint8_t)); if(new_p == NULL) { LV_LOG_ERROR("Unable to allocate space for custom property lookup table"); return LV_STYLE_PROP_INV; } - LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table) = new_p; + _lv_style_custom_prop_flag_lookup_table = new_p; _lv_style_custom_prop_flag_lookup_table_size = required_size; } last_custom_prop_id++; /* This should never happen - we should bail out above */ - LV_ASSERT_NULL(LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table)); - LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table)[last_custom_prop_id - _LV_STYLE_NUM_BUILT_IN_PROPS] = flag; + LV_ASSERT_NULL(_lv_style_custom_prop_flag_lookup_table); + _lv_style_custom_prop_flag_lookup_table[last_custom_prop_id - _LV_STYLE_NUM_BUILT_IN_PROPS] = flag; return last_custom_prop_id; } @@ -388,16 +406,14 @@ bool lv_style_is_empty(const lv_style_t * style) uint8_t _lv_style_prop_lookup_flags(lv_style_prop_t prop) { - extern const uint8_t _lv_style_builtin_prop_flag_lookup_table[]; - extern uint32_t _lv_style_custom_prop_flag_lookup_table_size; if(prop == LV_STYLE_PROP_ANY) return LV_STYLE_PROP_FLAG_ALL; /*Any prop can have any flags*/ if(prop == LV_STYLE_PROP_INV) return 0; if(prop < _LV_STYLE_NUM_BUILT_IN_PROPS) return _lv_style_builtin_prop_flag_lookup_table[prop]; prop -= _LV_STYLE_NUM_BUILT_IN_PROPS; - if(LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table) != NULL && prop < _lv_style_custom_prop_flag_lookup_table_size) - return LV_GC_ROOT(_lv_style_custom_prop_flag_lookup_table)[prop]; + if(_lv_style_custom_prop_flag_lookup_table != NULL && prop < _lv_style_custom_prop_flag_lookup_table_size) + return _lv_style_custom_prop_flag_lookup_table[prop]; return 0; } diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index 9f3a42c42..9b529f6d6 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -23,6 +23,7 @@ extern "C" { #include "lv_types.h" #include "lv_assert.h" #include "lv_bidi.h" +#include "../layouts/lv_layout.h" /********************* * DEFINES @@ -319,7 +320,30 @@ enum _lv_style_prop_t { LV_STYLE_TRANSFORM_PIVOT_X = 111, LV_STYLE_TRANSFORM_PIVOT_Y = 112, - _LV_STYLE_LAST_BUILT_IN_PROP = 112, +#if LV_USE_FLEX + LV_STYLE_FLEX_FLOW = 113, + LV_STYLE_FLEX_MAIN_PLACE = 114, + LV_STYLE_FLEX_CROSS_PLACE = 115, + LV_STYLE_FLEX_TRACK_PLACE = 116, + LV_STYLE_FLEX_GROW = 117, +#endif + +#if LV_USE_GRID + LV_STYLE_GRID_COLUMN_ALIGN = 118, + LV_STYLE_GRID_ROW_ALIGN = 119, + LV_STYLE_GRID_ROW_DSC_ARRAY = 120, + LV_STYLE_GRID_COLUMN_DSC_ARRAY = 121, + LV_STYLE_GRID_CELL_COLUMN_POS = 122, + LV_STYLE_GRID_CELL_COLUMN_SPAN = 123, + LV_STYLE_GRID_CELL_X_ALIGN = 124, + LV_STYLE_GRID_CELL_ROW_POS = 125, + LV_STYLE_GRID_CELL_ROW_SPAN = 126, + LV_STYLE_GRID_CELL_Y_ALIGN = 127, +#endif + + _LV_STYLE_LAST_BUILT_IN_PROP = 128, + + _LV_STYLE_NUM_BUILT_IN_PROPS = _LV_STYLE_LAST_BUILT_IN_PROP + 1, LV_STYLE_PROP_ANY = 0xFF, diff --git a/src/misc/lv_style_gen.c b/src/misc/lv_style_gen.c index 2a35ae360..0b87a5395 100644 --- a/src/misc/lv_style_gen.c +++ b/src/misc/lv_style_gen.c @@ -899,3 +899,153 @@ void lv_style_set_base_dir(lv_style_t * style, lv_base_dir_t value) } const lv_style_prop_t _lv_style_const_prop_id_BASE_DIR = LV_STYLE_BASE_DIR; + +void lv_style_set_flex_flow(lv_style_t * style, lv_flex_flow_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_FLEX_FLOW, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_FLEX_FLOW = LV_STYLE_FLEX_FLOW; + +void lv_style_set_flex_main_place(lv_style_t * style, lv_flex_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_FLEX_MAIN_PLACE, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_FLEX_MAIN_PLACE = LV_STYLE_FLEX_MAIN_PLACE; + +void lv_style_set_flex_cross_place(lv_style_t * style, lv_flex_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_FLEX_CROSS_PLACE, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_FLEX_CROSS_PLACE = LV_STYLE_FLEX_CROSS_PLACE; + +void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_FLEX_TRACK_PLACE, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_FLEX_TRACK_PLACE = LV_STYLE_FLEX_TRACK_PLACE; + +void lv_style_set_flex_grow(lv_style_t * style, uint8_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_FLEX_GROW, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_FLEX_GROW = LV_STYLE_FLEX_GROW; + +void lv_style_set_grid_column_dsc_array(lv_style_t * style, const lv_coord_t * value) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_style_set_prop(style, LV_STYLE_GRID_COLUMN_DSC_ARRAY, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_COLUMN_DSC_ARRAY = LV_STYLE_GRID_COLUMN_DSC_ARRAY; + +void lv_style_set_grid_column_align(lv_style_t * style, lv_grid_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_COLUMN_ALIGN, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_COLUMN_ALIGN = LV_STYLE_GRID_COLUMN_ALIGN; + +void lv_style_set_grid_row_dsc_array(lv_style_t * style, const lv_coord_t * value) +{ + lv_style_value_t v = { + .ptr = value + }; + lv_style_set_prop(style, LV_STYLE_GRID_ROW_DSC_ARRAY, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_ROW_DSC_ARRAY = LV_STYLE_GRID_ROW_DSC_ARRAY; + +void lv_style_set_grid_row_align(lv_style_t * style, lv_grid_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_ROW_ALIGN, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_ROW_ALIGN = LV_STYLE_GRID_ROW_ALIGN; + +void lv_style_set_grid_cell_column_pos(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_CELL_COLUMN_POS, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_COLUMN_POS = LV_STYLE_GRID_CELL_COLUMN_POS; + +void lv_style_set_grid_cell_x_align(lv_style_t * style, lv_grid_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_CELL_X_ALIGN, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_X_ALIGN = LV_STYLE_GRID_CELL_X_ALIGN; + +void lv_style_set_grid_cell_column_span(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_CELL_COLUMN_SPAN, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_COLUMN_SPAN = LV_STYLE_GRID_CELL_COLUMN_SPAN; + +void lv_style_set_grid_cell_row_pos(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_CELL_ROW_POS, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_ROW_POS = LV_STYLE_GRID_CELL_ROW_POS; + +void lv_style_set_grid_cell_y_align(lv_style_t * style, lv_grid_align_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_CELL_Y_ALIGN, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_Y_ALIGN = LV_STYLE_GRID_CELL_Y_ALIGN; + +void lv_style_set_grid_cell_row_span(lv_style_t * style, lv_coord_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_GRID_CELL_ROW_SPAN, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_ROW_SPAN = LV_STYLE_GRID_CELL_ROW_SPAN; diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h index 19d711023..0697011af 100644 --- a/src/misc/lv_style_gen.h +++ b/src/misc/lv_style_gen.h @@ -188,6 +188,36 @@ void lv_style_set_layout(lv_style_t * style, uint16_t value); extern const lv_style_prop_t _lv_style_const_prop_id_LAYOUT; void lv_style_set_base_dir(lv_style_t * style, lv_base_dir_t value); extern const lv_style_prop_t _lv_style_const_prop_id_BASE_DIR; +void lv_style_set_flex_flow(lv_style_t * style, lv_flex_flow_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_FLEX_FLOW; +void lv_style_set_flex_main_place(lv_style_t * style, lv_flex_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_FLEX_MAIN_PLACE; +void lv_style_set_flex_cross_place(lv_style_t * style, lv_flex_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_FLEX_CROSS_PLACE; +void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_FLEX_TRACK_PLACE; +void lv_style_set_flex_grow(lv_style_t * style, uint8_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_FLEX_GROW; +void lv_style_set_grid_column_dsc_array(lv_style_t * style, const lv_coord_t * value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_COLUMN_DSC_ARRAY; +void lv_style_set_grid_column_align(lv_style_t * style, lv_grid_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_COLUMN_ALIGN; +void lv_style_set_grid_row_dsc_array(lv_style_t * style, const lv_coord_t * value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_ROW_DSC_ARRAY; +void lv_style_set_grid_row_align(lv_style_t * style, lv_grid_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_ROW_ALIGN; +void lv_style_set_grid_cell_column_pos(lv_style_t * style, lv_coord_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_COLUMN_POS; +void lv_style_set_grid_cell_x_align(lv_style_t * style, lv_grid_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_X_ALIGN; +void lv_style_set_grid_cell_column_span(lv_style_t * style, lv_coord_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_COLUMN_SPAN; +void lv_style_set_grid_cell_row_pos(lv_style_t * style, lv_coord_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_ROW_POS; +void lv_style_set_grid_cell_y_align(lv_style_t * style, lv_grid_align_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_Y_ALIGN; +void lv_style_set_grid_cell_row_span(lv_style_t * style, lv_coord_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_GRID_CELL_ROW_SPAN; #define LV_STYLE_CONST_WIDTH(val) \ { \ @@ -634,4 +664,78 @@ extern const lv_style_prop_t _lv_style_const_prop_id_BASE_DIR; .prop_ptr = &_lv_style_const_prop_id_BASE_DIR, .value = { .num = (int32_t)val } \ } +#define LV_STYLE_CONST_FLEX_FLOW(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_FLEX_FLOW, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_FLEX_MAIN_PLACE(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_FLEX_MAIN_PLACE, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_FLEX_CROSS_PLACE(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_FLEX_CROSS_PLACE, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_FLEX_TRACK_PLACE(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_FLEX_TRACK_PLACE, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_FLEX_GROW(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_FLEX_GROW, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_COLUMN_DSC_ARRAY(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_COLUMN_DSC_ARRAY, .value = { .ptr = val } \ + } + +#define LV_STYLE_CONST_GRID_COLUMN_ALIGN(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_COLUMN_ALIGN, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_ROW_DSC_ARRAY(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_ROW_DSC_ARRAY, .value = { .ptr = val } \ + } + +#define LV_STYLE_CONST_GRID_ROW_ALIGN(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_ROW_ALIGN, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_CELL_COLUMN_POS(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_CELL_COLUMN_POS, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_CELL_X_ALIGN(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_CELL_X_ALIGN, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_CELL_COLUMN_SPAN(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_CELL_COLUMN_SPAN, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_CELL_ROW_POS(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_CELL_ROW_POS, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_CELL_Y_ALIGN(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_CELL_Y_ALIGN, .value = { .num = (int32_t)val } \ + } + +#define LV_STYLE_CONST_GRID_CELL_ROW_SPAN(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_GRID_CELL_ROW_SPAN, .value = { .num = (int32_t)val } \ + } #endif /* LV_STYLE_GEN_H */ diff --git a/src/misc/lv_timer.c b/src/misc/lv_timer.c index 9f7077f21..31ca9a26a 100644 --- a/src/misc/lv_timer.c +++ b/src/misc/lv_timer.c @@ -6,20 +6,24 @@ * INCLUDES *********************/ #include "lv_timer.h" +#include "../core/lv_global.h" #include "../tick/lv_tick.h" #include "../stdlib/lv_mem.h" #include "../stdlib/lv_sprintf.h" #include "lv_assert.h" #include "lv_ll.h" -#include "lv_gc.h" #include "lv_profiler.h" /********************* * DEFINES *********************/ + #define IDLE_MEAS_PERIOD 500 /*[ms]*/ #define DEF_PERIOD 500 +#define state LV_GLOBAL_DEFAULT()->timer_state +#define timer_ll_p &(state.timer_ll) + /********************** * TYPEDEFS **********************/ @@ -34,11 +38,6 @@ static void lv_timer_handler_resume(void); /********************** * STATIC VARIABLES **********************/ -static bool lv_timer_run = false; -static uint8_t idle_last = 0; -static bool timer_deleted; -static bool timer_created; -static uint32_t timer_time_until_next; /********************** * MACROS @@ -58,7 +57,7 @@ static uint32_t timer_time_until_next; */ void _lv_timer_core_init(void) { - _lv_ll_init(&LV_GC_ROOT(_lv_timer_ll), sizeof(lv_timer_t)); + _lv_ll_init(timer_ll_p, sizeof(lv_timer_t)); /*Initially enable the lv_timer handling*/ lv_timer_enable(true); @@ -72,59 +71,58 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void) { TIMER_TRACE("begin"); + lv_timer_state_t * state_p = &state; /*Avoid concurrent running of the timer handler*/ - static bool already_running = false; - if(already_running) { + if(state_p->already_running) { TIMER_TRACE("already running, concurrent calls are not allow, returning"); return 1; } - already_running = true; + state_p->already_running = true; - if(lv_timer_run == false) { - already_running = false; /*Release mutex*/ + if(state_p->lv_timer_run == false) { + state_p->already_running = false; /*Release mutex*/ return 1; } LV_PROFILER_BEGIN; - static uint32_t idle_period_start = 0; - static uint32_t busy_time = 0; - uint32_t handler_start = lv_tick_get(); if(handler_start == 0) { - static uint32_t run_cnt = 0; - run_cnt++; - if(run_cnt > 100) { - run_cnt = 0; + state.run_cnt++; + if(state.run_cnt > 100) { + state.run_cnt = 0; LV_LOG_WARN("It seems lv_tick_inc() is not called."); } } /*Run all timer from the list*/ lv_timer_t * next; + lv_timer_t * timer_active; + lv_ll_t * timer_head = timer_ll_p; do { - timer_deleted = false; - timer_created = false; - LV_GC_ROOT(_lv_timer_act) = _lv_ll_get_head(&LV_GC_ROOT(_lv_timer_ll)); - while(LV_GC_ROOT(_lv_timer_act)) { + state_p->timer_deleted = false; + state_p->timer_created = false; + + timer_active = _lv_ll_get_head(timer_head); + while(timer_active) { /*The timer might be deleted if it runs only once ('repeat_count = 1') *So get next element until the current is surely valid*/ - next = _lv_ll_get_next(&LV_GC_ROOT(_lv_timer_ll), LV_GC_ROOT(_lv_timer_act)); + next = _lv_ll_get_next(timer_head, timer_active); - if(lv_timer_exec(LV_GC_ROOT(_lv_timer_act))) { + if(lv_timer_exec(timer_active)) { /*If a timer was created or deleted then this or the next item might be corrupted*/ - if(timer_created || timer_deleted) { + if(state_p->timer_created || state_p->timer_deleted) { TIMER_TRACE("Start from the first timer again because a timer was created or deleted"); break; } } - LV_GC_ROOT(_lv_timer_act) = next; /*Load the next timer*/ + timer_active = next; /*Load the next timer*/ } - } while(LV_GC_ROOT(_lv_timer_act)); + } while(timer_active); uint32_t time_until_next = LV_NO_TIMER_READY; - next = _lv_ll_get_head(&LV_GC_ROOT(_lv_timer_ll)); + next = _lv_ll_get_head(timer_head); while(next) { if(!next->paused) { uint32_t delay = lv_timer_time_remaining(next); @@ -132,20 +130,20 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void) time_until_next = delay; } - next = _lv_ll_get_next(&LV_GC_ROOT(_lv_timer_ll), next); /*Find the next timer*/ + next = _lv_ll_get_next(timer_head, next); /*Find the next timer*/ } - busy_time += lv_tick_elaps(handler_start); - uint32_t idle_period_time = lv_tick_elaps(idle_period_start); + state_p->busy_time += lv_tick_elaps(handler_start); + uint32_t idle_period_time = lv_tick_elaps(state_p->idle_period_start); if(idle_period_time >= IDLE_MEAS_PERIOD) { - idle_last = (busy_time * 100) / idle_period_time; /*Calculate the busy percentage*/ - idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/ - busy_time = 0; - idle_period_start = lv_tick_get(); + state_p->idle_last = (state_p->busy_time * 100) / idle_period_time; /*Calculate the busy percentage*/ + state_p->idle_last = state_p->idle_last > 100 ? 0 : 100 - state_p->idle_last; /*But we need idle time*/ + state_p->busy_time = 0; + state_p->idle_period_start = lv_tick_get(); } - timer_time_until_next = time_until_next; - already_running = false; /*Release the mutex*/ + state_p->timer_time_until_next = time_until_next; + state_p->already_running = false; /*Release the mutex*/ TIMER_TRACE("finished (%" LV_PRIu32 " ms until the next timer call)", time_until_next); LV_PROFILER_END; @@ -154,12 +152,11 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void) LV_ATTRIBUTE_TIMER_HANDLER void lv_timer_periodic_handler(void) { - static uint32_t last_tick = 0; - - if(lv_tick_elaps(last_tick) >= timer_time_until_next) { + lv_timer_state_t * state_p = &state; + if(lv_tick_elaps(state_p->periodic_last_tick) >= state_p->timer_time_until_next) { TIMER_TRACE("calling lv_timer_handler()"); lv_timer_handler(); - last_tick = lv_tick_get(); + state_p->periodic_last_tick = lv_tick_get(); } } @@ -186,7 +183,7 @@ lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * us { lv_timer_t * new_timer = NULL; - new_timer = _lv_ll_ins_head(&LV_GC_ROOT(_lv_timer_ll)); + new_timer = _lv_ll_ins_head(timer_ll_p); LV_ASSERT_MALLOC(new_timer); if(new_timer == NULL) return NULL; @@ -197,7 +194,7 @@ lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * us new_timer->last_run = lv_tick_get(); new_timer->user_data = user_data; - timer_created = true; + state.timer_created = true; lv_timer_handler_resume(); @@ -220,8 +217,8 @@ void lv_timer_set_cb(lv_timer_t * timer, lv_timer_cb_t timer_cb) */ void lv_timer_del(lv_timer_t * timer) { - _lv_ll_remove(&LV_GC_ROOT(_lv_timer_ll), timer); - timer_deleted = true; + _lv_ll_remove(timer_ll_p, timer); + state.timer_deleted = true; lv_free(timer); } @@ -287,7 +284,7 @@ void lv_timer_reset(lv_timer_t * timer) */ void lv_timer_enable(bool en) { - lv_timer_run = en; + state.lv_timer_run = en; if(en) lv_timer_handler_resume(); } @@ -297,7 +294,7 @@ void lv_timer_enable(bool en) */ uint8_t lv_timer_get_idle(void) { - return idle_last; + return state.idle_last; } /** @@ -306,7 +303,7 @@ uint8_t lv_timer_get_idle(void) */ uint32_t lv_timer_get_time_until_next(void) { - return timer_time_until_next; + return state.timer_time_until_next; } /** @@ -316,8 +313,8 @@ uint32_t lv_timer_get_time_until_next(void) */ lv_timer_t * lv_timer_get_next(lv_timer_t * timer) { - if(timer == NULL) return _lv_ll_get_head(&LV_GC_ROOT(_lv_timer_ll)); - else return _lv_ll_get_next(&LV_GC_ROOT(_lv_timer_ll), timer); + if(timer == NULL) return _lv_ll_get_head(timer_ll_p); + else return _lv_ll_get_next(timer_ll_p, timer); } /********************** @@ -345,7 +342,7 @@ static bool lv_timer_exec(lv_timer_t * timer) if(timer->timer_cb && original_repeat_count != 0) timer->timer_cb(timer); - if(!timer_deleted) { + if(!state.timer_deleted) { TIMER_TRACE("timer callback %p finished", *((void **)&timer->timer_cb)); } else { @@ -356,7 +353,7 @@ static bool lv_timer_exec(lv_timer_t * timer) exec = true; } - if(timer_deleted == false) { /*The timer might be deleted by itself as well*/ + if(state.timer_deleted == false) { /*The timer might be deleted by itself as well*/ if(timer->repeat_count == 0) { /*The repeat count is over, delete the timer*/ TIMER_TRACE("deleting timer with %p callback because the repeat count is over", *((void **)&timer->timer_cb)); lv_timer_del(timer); @@ -386,5 +383,5 @@ static uint32_t lv_timer_time_remaining(lv_timer_t * timer) static void lv_timer_handler_resume(void) { /*If there is a timer which is ready to run then resume the timer loop*/ - timer_time_until_next = 0; + state.timer_time_until_next = 0; } diff --git a/src/misc/lv_timer.h b/src/misc/lv_timer.h index 0a62167ba..da086b137 100644 --- a/src/misc/lv_timer.h +++ b/src/misc/lv_timer.h @@ -14,6 +14,7 @@ extern "C" { *********************/ #include "../lv_conf_internal.h" #include "../tick/lv_tick.h" +#include "lv_ll.h" #include #include @@ -50,6 +51,22 @@ typedef struct _lv_timer_t { uint32_t paused : 1; } lv_timer_t; +typedef struct { + lv_ll_t timer_ll; /*Linked list to store the lv_timers*/ + + bool lv_timer_run; + uint8_t idle_last; + bool timer_deleted; + bool timer_created; + uint32_t timer_time_until_next; + + bool already_running; + uint32_t periodic_last_tick; + uint32_t busy_time; + uint32_t idle_period_start; + uint32_t run_cnt; +} lv_timer_state_t; + /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/src/others/file_explorer/lv_file_explorer.c b/src/others/file_explorer/lv_file_explorer.c index 012e78c22..00d93ea49 100644 --- a/src/others/file_explorer/lv_file_explorer.c +++ b/src/others/file_explorer/lv_file_explorer.c @@ -9,6 +9,8 @@ #include "lv_file_explorer.h" #if LV_USE_FILE_EXPLORER != 0 +#include "../../core/lv_global.h" + /********************* * DEFINES *********************/ @@ -17,6 +19,8 @@ #define FILE_EXPLORER_QUICK_ACCESS_AREA_WIDTH (22) #define FILE_EXPLORER_BROWSER_AREA_WIDTH (100 - FILE_EXPLORER_QUICK_ACCESS_AREA_WIDTH) +#define quick_access_list_btn_style (LV_GLOBAL_DEFAULT()->fe_list_btn_style) + /********************** * TYPEDEFS **********************/ @@ -43,7 +47,6 @@ static bool is_end_with(const char * str1, const char * str2); /********************** * STATIC VARIABLES **********************/ -static lv_style_t quick_access_list_btn_style; const lv_obj_class_t lv_file_explorer_class = { .constructor_cb = lv_file_explorer_constructor, diff --git a/src/others/ime/lv_ime_pinyin.c b/src/others/ime/lv_ime_pinyin.c index e5dd3bd70..a51934bf7 100644 --- a/src/others/ime/lv_ime_pinyin.c +++ b/src/others/ime/lv_ime_pinyin.c @@ -10,11 +10,13 @@ #if LV_USE_IME_PINYIN != 0 #include +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ #define MY_CLASS &lv_ime_pinyin_class +#define cand_len LV_GLOBAL_DEFAULT()->ime_cand_len /********************** * TYPEDEFS @@ -29,7 +31,7 @@ static void lv_ime_pinyin_style_change_event(lv_event_t * e); static void lv_ime_pinyin_kb_event(lv_event_t * e); static void lv_ime_pinyin_cand_panel_event(lv_event_t * e); -static void init_pinyin_dict(lv_obj_t * obj, lv_pinyin_dict_t * dict); +static void init_pinyin_dict(lv_obj_t * obj, const lv_pinyin_dict_t * dict); static void pinyin_input_proc(lv_obj_t * obj); static void pinyin_page_proc(lv_obj_t * obj, uint16_t btn); static char * pinyin_search_matching(lv_obj_t * obj, char * py_str, uint16_t * cand_num); @@ -57,12 +59,12 @@ const lv_obj_class_t lv_ime_pinyin_class = { }; #if LV_IME_PINYIN_USE_K9_MODE -static char * lv_btnm_def_pinyin_k9_map[LV_IME_PINYIN_K9_CAND_TEXT_NUM + 21] = {\ - ",\0", "123\0", "abc \0", "def\0", LV_SYMBOL_BACKSPACE"\0", "\n\0", - ".\0", "ghi\0", "jkl\0", "mno\0", LV_SYMBOL_KEYBOARD"\0", "\n\0", - "?\0", "pqrs\0", "tuv\0", "wxyz\0", LV_SYMBOL_NEW_LINE"\0", "\n\0", - LV_SYMBOL_LEFT"\0", "\0" - }; +static const char * lv_btnm_def_pinyin_k9_map[LV_IME_PINYIN_K9_CAND_TEXT_NUM + 21] = {\ + ",\0", "123\0", "abc \0", "def\0", LV_SYMBOL_BACKSPACE"\0", "\n\0", + ".\0", "ghi\0", "jkl\0", "mno\0", LV_SYMBOL_KEYBOARD"\0", "\n\0", + "?\0", "pqrs\0", "tuv\0", "wxyz\0", LV_SYMBOL_NEW_LINE"\0", "\n\0", + LV_SYMBOL_LEFT"\0", "\0" + }; static lv_btnmatrix_ctrl_t default_kb_ctrl_k9_map[LV_IME_PINYIN_K9_CAND_TEXT_NUM + 17] = { 1 }; static char lv_pinyin_k9_cand_str[LV_IME_PINYIN_K9_CAND_TEXT_NUM + 2][LV_IME_PINYIN_K9_MAX_INPUT] = {0}; @@ -72,7 +74,7 @@ static char lv_pinyin_cand_str[LV_IME_PINYIN_CAND_TEXT_NUM][4]; static char * lv_btnm_def_pinyin_sel_map[LV_IME_PINYIN_CAND_TEXT_NUM + 3]; #if LV_IME_PINYIN_USE_DEFAULT_DICT -lv_pinyin_dict_t lv_ime_pinyin_def_dict[] = { +static const lv_pinyin_dict_t lv_ime_pinyin_def_dict[] = { { "a", "啊" }, { "ai", "æ„›" }, { "an", "安暗案" }, @@ -508,12 +510,7 @@ lv_obj_t * lv_ime_pinyin_get_cand_panel(lv_obj_t * obj) return pinyin_ime->cand_panel; } -/** - * Set the dictionary of Pinyin input method. - * @param obj pointer to a Pinyin input method object - * @return pointer to the Pinyin input method dictionary - */ -lv_pinyin_dict_t * lv_ime_pinyin_get_dict(lv_obj_t * obj) +const lv_pinyin_dict_t * lv_ime_pinyin_get_dict(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -884,7 +881,7 @@ static void lv_ime_pinyin_style_change_event(lv_event_t * e) } -static void init_pinyin_dict(lv_obj_t * obj, lv_pinyin_dict_t * dict) +static void init_pinyin_dict(lv_obj_t * obj, const lv_pinyin_dict_t * dict) { lv_ime_pinyin_t * pinyin_ime = (lv_ime_pinyin_t *)obj; @@ -923,7 +920,7 @@ static char * pinyin_search_matching(lv_obj_t * obj, char * py_str, uint16_t * c { lv_ime_pinyin_t * pinyin_ime = (lv_ime_pinyin_t *)obj; - lv_pinyin_dict_t * cpHZ; + const lv_pinyin_dict_t * cpHZ; uint8_t index, len = 0, offset; volatile uint8_t count = 0; @@ -1075,7 +1072,7 @@ static bool pinyin_k9_is_valid_py(lv_obj_t * obj, char * py_str) { lv_ime_pinyin_t * pinyin_ime = (lv_ime_pinyin_t *)obj; - lv_pinyin_dict_t * cpHZ = NULL; + const lv_pinyin_dict_t * cpHZ = NULL; uint8_t index = 0, len = 0, offset = 0; volatile uint8_t count = 0; @@ -1109,7 +1106,6 @@ static bool pinyin_k9_is_valid_py(lv_obj_t * obj, char * py_str) static void pinyin_k9_fill_cand(lv_obj_t * obj) { - static uint16_t len = 0; uint16_t index = 0, tmp_len = 0; ime_pinyin_k9_py_str_t * ll_index = NULL; @@ -1117,11 +1113,11 @@ static void pinyin_k9_fill_cand(lv_obj_t * obj) tmp_len = pinyin_ime->k9_legal_py_count; - if(tmp_len != len) { + if(tmp_len != cand_len) { lv_memzero(lv_pinyin_k9_cand_str, sizeof(lv_pinyin_k9_cand_str)); lv_strcpy(lv_pinyin_k9_cand_str[LV_IME_PINYIN_K9_CAND_TEXT_NUM], LV_SYMBOL_RIGHT"\0"); lv_strcpy(lv_pinyin_k9_cand_str[LV_IME_PINYIN_K9_CAND_TEXT_NUM + 1], "\0"); - len = tmp_len; + cand_len = tmp_len; } ll_index = _lv_ll_get_head(&pinyin_ime->k9_legal_py_ll); diff --git a/src/others/ime/lv_ime_pinyin.h b/src/others/ime/lv_ime_pinyin.h index 8919a7e88..6518898d2 100644 --- a/src/others/ime/lv_ime_pinyin.h +++ b/src/others/ime/lv_ime_pinyin.h @@ -47,7 +47,7 @@ typedef struct { lv_obj_t obj; lv_obj_t * kb; lv_obj_t * cand_panel; - lv_pinyin_dict_t * dict; + const lv_pinyin_dict_t * dict; lv_ll_t k9_legal_py_ll; char * cand_str; /* Candidate string */ char input_char[16]; /* Input box character */ @@ -127,7 +127,7 @@ lv_obj_t * lv_ime_pinyin_get_cand_panel(lv_obj_t * obj); * @param obj pointer to a Pinyin input method object * @return pointer to the Pinyin input method dictionary */ -lv_pinyin_dict_t * lv_ime_pinyin_get_dict(lv_obj_t * obj); +const lv_pinyin_dict_t * lv_ime_pinyin_get_dict(lv_obj_t * obj); /*===================== * Other functions diff --git a/src/others/msg/lv_msg.c b/src/others/msg/lv_msg.c index 6d36ceb54..f8ff58983 100644 --- a/src/others/msg/lv_msg.c +++ b/src/others/msg/lv_msg.c @@ -9,13 +9,17 @@ #include "lv_msg.h" #if LV_USE_MSG +#include "../../core/lv_global.h" #include "../../misc/lv_assert.h" #include "../../misc/lv_ll.h" -#include "../../misc/lv_gc.h" +#include "../../stdlib/lv_string.h" /********************* * DEFINES *********************/ +#define restart_notify LV_GLOBAL_DEFAULT()->msg_restart_notify +#define _recursion_counter LV_GLOBAL_DEFAULT()->msg_recursion_counter +#define _msg_subs_ll_p &(LV_GLOBAL_DEFAULT()->msg_subs_ll) /********************** * TYPEDEFS @@ -40,7 +44,6 @@ static void obj_delete_event_cb(lv_event_t * e); /********************** * STATIC VARIABLES **********************/ -static bool restart_notify; /********************** * GLOBAL VARIABLES @@ -61,12 +64,12 @@ static bool restart_notify; void lv_msg_init(void) { - _lv_ll_init(&LV_GC_ROOT(_subs_ll), sizeof(sub_dsc_t)); + _lv_ll_init(_msg_subs_ll_p, sizeof(sub_dsc_t)); } void * lv_msg_subscribe(lv_msg_id_t msg_id, lv_msg_subscribe_cb_t cb, void * user_data) { - sub_dsc_t * s = _lv_ll_ins_tail(&LV_GC_ROOT(_subs_ll)); + sub_dsc_t * s = _lv_ll_ins_tail(_msg_subs_ll_p); LV_ASSERT_MALLOC(s); if(s == NULL) return NULL; @@ -108,7 +111,7 @@ void * lv_msg_subscribe_obj(lv_msg_id_t msg_id, lv_obj_t * obj, void * user_data void lv_msg_unsubscribe(void * s) { LV_ASSERT_NULL(s); - _lv_ll_remove(&LV_GC_ROOT(_subs_ll), s); + _lv_ll_remove(_msg_subs_ll_p, s); restart_notify = true; lv_free(s); } @@ -159,13 +162,12 @@ lv_msg_t * lv_event_get_msg(lv_event_t * e) static void notify(lv_msg_t * m) { - static unsigned int _recursion_counter = 0; _recursion_counter++; /*First clear all _checked flags*/ sub_dsc_t * s; if(_recursion_counter == 1) { - _LV_LL_READ(&LV_GC_ROOT(_subs_ll), s) { + _LV_LL_READ(_msg_subs_ll_p, s) { s->_checked = 0; } } @@ -173,10 +175,10 @@ static void notify(lv_msg_t * m) /*Run all sub_dsc_t from the list*/ do { restart_notify = false; - s = _lv_ll_get_head(&LV_GC_ROOT(_subs_ll)); + s = _lv_ll_get_head(_msg_subs_ll_p); while(s) { /*get next element while current is surely valid*/ - sub_dsc_t * next = _lv_ll_get_next(&LV_GC_ROOT(_subs_ll), s); + sub_dsc_t * next = _lv_ll_get_next(_msg_subs_ll_p, s); /*Notify only once*/ if(!s->_checked) { @@ -212,11 +214,11 @@ static void obj_delete_event_cb(lv_event_t * e) { lv_obj_t * obj = lv_event_get_target(e); - sub_dsc_t * s = _lv_ll_get_head(&LV_GC_ROOT(_subs_ll)); + sub_dsc_t * s = _lv_ll_get_head(_msg_subs_ll_p); sub_dsc_t * s_next; while(s) { /*On unsubscribe the list changes s becomes invalid so get next item while it's surely valid*/ - s_next = _lv_ll_get_next(&LV_GC_ROOT(_subs_ll), s); + s_next = _lv_ll_get_next(_msg_subs_ll_p, s); if(s->_priv_data == obj) { lv_msg_unsubscribe(s); } diff --git a/src/others/sysmon/lv_sysmon.c b/src/others/sysmon/lv_sysmon.c index d1ff194ae..d8ce0bb08 100644 --- a/src/others/sysmon/lv_sysmon.c +++ b/src/others/sysmon/lv_sysmon.c @@ -11,6 +11,8 @@ #if LV_USE_SYSMON +#include "../../core/lv_global.h" + /********************* * DEFINES *********************/ @@ -18,6 +20,7 @@ #define SYSMON_REFR_PERIOD_DEF 300 /* ms */ +#define perf_info LV_GLOBAL_DEFAULT()->sysmon_perf_info /********************** * TYPEDEFS **********************/ @@ -34,6 +37,7 @@ typedef struct { uint32_t flush_cnt; } perf_info_t; + /********************** * STATIC PROTOTYPES **********************/ @@ -90,6 +94,15 @@ void _lv_sysmon_builtin_init(void) lv_async_call(sysmon_async_cb, NULL); } +void _lv_sysmon_builtin_deinit(void) +{ + lv_async_call_cancel(sysmon_async_cb, NULL); +#if LV_USE_PERF_MONITOR + if(perf_info) { + lv_free(perf_info); + } +#endif +} /********************** * STATIC FUNCTIONS **********************/ @@ -202,13 +215,16 @@ static void perf_monitor_event_cb(lv_event_t * e) static void perf_monitor_init(void) { - static perf_info_t info = { 0 }; lv_disp_t * disp = lv_disp_get_default(); lv_obj_t * sysmon = lv_sysmon_create(lv_layer_sys()); lv_obj_align(sysmon, LV_USE_PERF_MONITOR_POS, 0, 0); lv_obj_set_style_text_align(sysmon, LV_TEXT_ALIGN_RIGHT, 0); - lv_obj_set_user_data(sysmon, &info); + + perf_info_t * info = perf_info = lv_malloc(sizeof(perf_info_t)); + LV_ASSERT_MALLOC(info); + + lv_obj_set_user_data(sysmon, info); lv_obj_add_event(sysmon, perf_monitor_event_cb, LV_EVENT_REFRESH, NULL); lv_disp_add_event(disp, perf_monitor_disp_event_cb, LV_EVENT_ALL, sysmon); diff --git a/src/others/sysmon/lv_sysmon.h b/src/others/sysmon/lv_sysmon.h index b99ef447a..8ba0df79c 100644 --- a/src/others/sysmon/lv_sysmon.h +++ b/src/others/sysmon/lv_sysmon.h @@ -59,6 +59,11 @@ void lv_sysmon_set_refr_period(lv_obj_t * obj, uint32_t period); */ void _lv_sysmon_builtin_init(void); +/** + * DeInitialize built-in system monitor, such as performance and memory monitor. + */ +void _lv_sysmon_builtin_deinit(void); + /********************** * MACROS **********************/ diff --git a/src/stdlib/builtin/lv_mem_core_builtin.c b/src/stdlib/builtin/lv_mem_core_builtin.c index 2af858ddd..8bdcd1b29 100644 --- a/src/stdlib/builtin/lv_mem_core_builtin.c +++ b/src/stdlib/builtin/lv_mem_core_builtin.c @@ -15,6 +15,7 @@ #include "../../misc/lv_ll.h" #include "../../misc/lv_math.h" #include "../../osal/lv_os.h" +#include "../../core/lv_global.h" #ifdef LV_MEM_POOL_INCLUDE #include LV_MEM_POOL_INCLUDE @@ -35,10 +36,8 @@ #define MEM_UNIT uint32_t #define ALIGN_MASK 0x3 #endif +#define state LV_GLOBAL_DEFAULT()->tlsf_state -#if LV_USE_OS - lv_mutex_t mutex; -#endif /********************** * TYPEDEFS @@ -52,10 +51,6 @@ static void lv_mem_walker(void * ptr, size_t size, int used, void * user); /********************** * STATIC VARIABLES **********************/ -static lv_tlsf_t tlsf; -static uint32_t cur_used; -static uint32_t max_used; -static lv_ll_t pool_ll; /********************** * MACROS @@ -78,24 +73,24 @@ void lv_mem_init(void) { #if LV_MEM_ADR == 0 #ifdef LV_MEM_POOL_ALLOC - tlsf = lv_tlsf_create_with_pool((void *)LV_MEM_POOL_ALLOC(LV_MEM_SIZE), LV_MEM_SIZE); + state.tlsf = lv_tlsf_create_with_pool((void *)LV_MEM_POOL_ALLOC(LV_MEM_SIZE), LV_MEM_SIZE); #else /*Allocate a large array to store the dynamically allocated data*/ static LV_ATTRIBUTE_LARGE_RAM_ARRAY MEM_UNIT work_mem_int[LV_MEM_SIZE / sizeof(MEM_UNIT)]; - tlsf = lv_tlsf_create_with_pool((void *)work_mem_int, LV_MEM_SIZE); + state.tlsf = lv_tlsf_create_with_pool((void *)work_mem_int, LV_MEM_SIZE); #endif #else tlsf = lv_tlsf_create_with_pool((void *)LV_MEM_ADR, LV_MEM_SIZE); #endif - _lv_ll_init(&pool_ll, sizeof(lv_pool_t)); + _lv_ll_init(&state.pool_ll, sizeof(lv_pool_t)); /*Record the first pool*/ - lv_pool_t * pool_p = _lv_ll_ins_tail(&pool_ll); + lv_pool_t * pool_p = _lv_ll_ins_tail(&state.pool_ll); LV_ASSERT_MALLOC(pool_p); - *pool_p = lv_tlsf_get_pool(tlsf); + *pool_p = lv_tlsf_get_pool(state.tlsf); #if LV_USE_OS - lv_mutex_init(&mutex); + lv_mutex_init(&state.mutex); #endif #if LV_MEM_ADD_JUNK @@ -105,20 +100,20 @@ void lv_mem_init(void) void lv_mem_deinit(void) { - _lv_ll_clear(&pool_ll); - lv_tlsf_destroy(tlsf); + _lv_ll_clear(&state.pool_ll); + lv_tlsf_destroy(state.tlsf); lv_mem_init(); } lv_mem_pool_t lv_mem_add_pool(void * mem, size_t bytes) { - lv_mem_pool_t new_pool = lv_tlsf_add_pool(tlsf, mem, bytes); + lv_mem_pool_t new_pool = lv_tlsf_add_pool(state.tlsf, mem, bytes); if(!new_pool) { LV_LOG_WARN("failed to add memory pool, address: %p, size: %zu", mem, bytes); return NULL; } - lv_pool_t * pool_p = _lv_ll_ins_tail(&pool_ll); + lv_pool_t * pool_p = _lv_ll_ins_tail(&state.pool_ll); LV_ASSERT_MALLOC(pool_p); *pool_p = new_pool; @@ -128,11 +123,11 @@ lv_mem_pool_t lv_mem_add_pool(void * mem, size_t bytes) void lv_mem_remove_pool(lv_mem_pool_t pool) { lv_pool_t * pool_p; - _LV_LL_READ(&pool_ll, pool_p) { + _LV_LL_READ(&state.pool_ll, pool_p) { if(*pool_p == pool) { - _lv_ll_remove(&pool_ll, pool_p); + _lv_ll_remove(&state.pool_ll, pool_p); lv_free(pool_p); - lv_tlsf_remove_pool(tlsf, pool); + lv_tlsf_remove_pool(state.tlsf, pool); return; } } @@ -143,14 +138,14 @@ void lv_mem_remove_pool(lv_mem_pool_t pool) void * lv_malloc_core(size_t size) { #if LV_USE_OS - lv_mutex_lock(&mutex); + lv_mutex_lock(&state.mutex); #endif - cur_used += size; - max_used = LV_MAX(cur_used, max_used); - void * p = lv_tlsf_malloc(tlsf, size); + state.cur_used += size; + state.max_used = LV_MAX(state.cur_used, state.max_used); + void * p = lv_tlsf_malloc(state.tlsf, size); #if LV_USE_OS - lv_mutex_unlock(&mutex); + lv_mutex_unlock(&state.mutex); #endif return p; } @@ -158,13 +153,13 @@ void * lv_malloc_core(size_t size) void * lv_realloc_core(void * p, size_t new_size) { #if LV_USE_OS - lv_mutex_lock(&mutex); + lv_mutex_lock(&state.mutex); #endif - void * p_new = lv_tlsf_realloc(tlsf, p, new_size); + void * p_new = lv_tlsf_realloc(state.tlsf, p, new_size); #if LV_USE_OS - lv_mutex_unlock(&mutex); + lv_mutex_unlock(&state.mutex); #endif return p_new; @@ -173,18 +168,18 @@ void * lv_realloc_core(void * p, size_t new_size) void lv_free_core(void * p) { #if LV_USE_OS - lv_mutex_lock(&mutex); + lv_mutex_lock(&state.mutex); #endif #if LV_MEM_ADD_JUNK lv_memset(p, 0xbb, lv_tlsf_block_size(data)); #endif - size_t size = lv_tlsf_free(tlsf, p); - if(cur_used > size) cur_used -= size; - else cur_used = 0; + size_t size = lv_tlsf_free(state.tlsf, p); + if(state.cur_used > size) state.cur_used -= size; + else state.cur_used = 0; #if LV_USE_OS - lv_mutex_unlock(&mutex); + lv_mutex_unlock(&state.mutex); #endif } @@ -195,7 +190,7 @@ void lv_mem_monitor_core(lv_mem_monitor_t * mon_p) MEM_TRACE("begin"); lv_pool_t * pool_p; - _LV_LL_READ(&pool_ll, pool_p) { + _LV_LL_READ(&state.pool_ll, pool_p) { lv_tlsf_walk_pool(*pool_p, lv_mem_walker, mon_p); } @@ -208,7 +203,7 @@ void lv_mem_monitor_core(lv_mem_monitor_t * mon_p) mon_p->frag_pct = 0; /*no fragmentation if all the RAM is used*/ } - mon_p->max_used = max_used; + mon_p->max_used = state.max_used; MEM_TRACE("finished"); } @@ -217,22 +212,22 @@ void lv_mem_monitor_core(lv_mem_monitor_t * mon_p) lv_res_t lv_mem_test_core(void) { #if LV_USE_OS - lv_mutex_lock(&mutex); + lv_mutex_lock(&state.mutex); #endif - if(lv_tlsf_check(tlsf)) { + if(lv_tlsf_check(state.tlsf)) { LV_LOG_WARN("failed"); #if LV_USE_OS - lv_mutex_unlock(&mutex); + lv_mutex_unlock(&state.mutex); #endif return LV_RES_INV; } lv_pool_t * pool_p; - _LV_LL_READ(&pool_ll, pool_p) { + _LV_LL_READ(&state.pool_ll, pool_p) { if(lv_tlsf_check_pool(*pool_p)) { LV_LOG_WARN("pool failed"); #if LV_USE_OS - lv_mutex_unlock(&mutex); + lv_mutex_unlock(&state.mutex); #endif return LV_RES_INV; } @@ -240,7 +235,7 @@ lv_res_t lv_mem_test_core(void) MEM_TRACE("passed"); #if LV_USE_OS - lv_mutex_unlock(&mutex); + lv_mutex_unlock(&state.mutex); #endif return LV_RES_OK; } diff --git a/src/stdlib/builtin/lv_tlsf.h b/src/stdlib/builtin/lv_tlsf.h index 2ae4a3e31..066dae45e 100644 --- a/src/stdlib/builtin/lv_tlsf.h +++ b/src/stdlib/builtin/lv_tlsf.h @@ -43,6 +43,9 @@ #include +#include "../../osal/lv_os.h" +#include "../../misc/lv_ll.h" + #if defined(__cplusplus) extern "C" { #endif @@ -52,6 +55,16 @@ extern "C" { typedef void * lv_tlsf_t; typedef void * lv_pool_t; +typedef struct { +#if LV_USE_OS + lv_mutex_t mutex; +#endif + lv_tlsf_t tlsf; + uint32_t cur_used; + uint32_t max_used; + lv_ll_t pool_ll; +} lv_tlsf_state_t; + /* Create/destroy a memory pool. */ lv_tlsf_t lv_tlsf_create(void * mem); lv_tlsf_t lv_tlsf_create_with_pool(void * mem, size_t bytes); diff --git a/src/stdlib/lv_mem.c b/src/stdlib/lv_mem.c index 47fcdc212..3e1927cc9 100644 --- a/src/stdlib/lv_mem.c +++ b/src/stdlib/lv_mem.c @@ -9,6 +9,7 @@ #include "lv_string.h" #include "../misc/lv_assert.h" #include "../misc/lv_log.h" +#include "../core/lv_global.h" #if LV_USE_OS == LV_OS_PTHREAD #include @@ -22,7 +23,7 @@ #define LV_MEM_ADD_JUNK 0 #endif -#define ZERO_MEM_SENTINEL 0xa1b2c3d4 +#define zero_mem LV_GLOBAL_DEFAULT()->memory_zero /********************** * TYPEDEFS @@ -45,7 +46,6 @@ lv_res_t lv_mem_test_core(void); /********************** * STATIC VARIABLES **********************/ -static uint32_t zero_mem = ZERO_MEM_SENTINEL; /*Give the address of this variable if 0 byte should be allocated*/ /********************** * MACROS diff --git a/src/themes/basic/lv_theme_basic.c b/src/themes/basic/lv_theme_basic.c index c1a873022..591e1a6ee 100644 --- a/src/themes/basic/lv_theme_basic.c +++ b/src/themes/basic/lv_theme_basic.c @@ -11,11 +11,13 @@ #if LV_USE_THEME_BASIC #include "lv_theme_basic.h" -#include "../../misc/lv_gc.h" +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ +#define theme_def (LV_GLOBAL_DEFAULT()->theme_basic) + #define COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) #define COLOR_WHITE lv_color_white() #define COLOR_LIGHT lv_palette_lighten(LV_PALETTE_GREY, 2) @@ -44,6 +46,12 @@ typedef struct { } my_theme_styles_t; +typedef struct _my_theme_t { + lv_theme_t base; + my_theme_styles_t styles; + bool inited; +} my_theme_t; + /********************** * STATIC PROTOTYPES **********************/ @@ -53,9 +61,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj); /********************** * STATIC VARIABLES **********************/ -static my_theme_styles_t * styles; -static lv_theme_t theme; -static bool inited; /********************** * MACROS @@ -65,68 +70,68 @@ static bool inited; * STATIC FUNCTIONS **********************/ -static void style_init(void) +static void style_init(struct _my_theme_t * theme) { - style_init_reset(&styles->scrollbar); - lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scrollbar, COLOR_DARK); - lv_style_set_width(&styles->scrollbar, SCROLLBAR_WIDTH); + style_init_reset(&theme->styles.scrollbar); + lv_style_set_bg_opa(&theme->styles.scrollbar, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.scrollbar, COLOR_DARK); + lv_style_set_width(&theme->styles.scrollbar, SCROLLBAR_WIDTH); - style_init_reset(&styles->scr); - lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scr, COLOR_SCR); - lv_style_set_text_color(&styles->scr, COLOR_DIM); + style_init_reset(&theme->styles.scr); + lv_style_set_bg_opa(&theme->styles.scr, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.scr, COLOR_SCR); + lv_style_set_text_color(&theme->styles.scr, COLOR_DIM); - style_init_reset(&styles->transp); - lv_style_set_bg_opa(&styles->transp, LV_OPA_TRANSP); + style_init_reset(&theme->styles.transp); + lv_style_set_bg_opa(&theme->styles.transp, LV_OPA_TRANSP); - style_init_reset(&styles->white); - lv_style_set_bg_opa(&styles->white, LV_OPA_COVER); - lv_style_set_bg_color(&styles->white, COLOR_WHITE); - lv_style_set_line_width(&styles->white, 1); - lv_style_set_line_color(&styles->white, COLOR_WHITE); - lv_style_set_arc_width(&styles->white, 2); - lv_style_set_arc_color(&styles->white, COLOR_WHITE); + style_init_reset(&theme->styles.white); + lv_style_set_bg_opa(&theme->styles.white, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.white, COLOR_WHITE); + lv_style_set_line_width(&theme->styles.white, 1); + lv_style_set_line_color(&theme->styles.white, COLOR_WHITE); + lv_style_set_arc_width(&theme->styles.white, 2); + lv_style_set_arc_color(&theme->styles.white, COLOR_WHITE); - style_init_reset(&styles->light); - lv_style_set_bg_opa(&styles->light, LV_OPA_COVER); - lv_style_set_bg_color(&styles->light, COLOR_LIGHT); - lv_style_set_line_width(&styles->light, 1); - lv_style_set_line_color(&styles->light, COLOR_LIGHT); - lv_style_set_arc_width(&styles->light, 2); - lv_style_set_arc_color(&styles->light, COLOR_LIGHT); + style_init_reset(&theme->styles.light); + lv_style_set_bg_opa(&theme->styles.light, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.light, COLOR_LIGHT); + lv_style_set_line_width(&theme->styles.light, 1); + lv_style_set_line_color(&theme->styles.light, COLOR_LIGHT); + lv_style_set_arc_width(&theme->styles.light, 2); + lv_style_set_arc_color(&theme->styles.light, COLOR_LIGHT); - style_init_reset(&styles->dark); - lv_style_set_bg_opa(&styles->dark, LV_OPA_COVER); - lv_style_set_bg_color(&styles->dark, COLOR_DARK); - lv_style_set_line_width(&styles->dark, 1); - lv_style_set_line_color(&styles->dark, COLOR_DARK); - lv_style_set_arc_width(&styles->dark, 2); - lv_style_set_arc_color(&styles->dark, COLOR_DARK); + style_init_reset(&theme->styles.dark); + lv_style_set_bg_opa(&theme->styles.dark, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.dark, COLOR_DARK); + lv_style_set_line_width(&theme->styles.dark, 1); + lv_style_set_line_color(&theme->styles.dark, COLOR_DARK); + lv_style_set_arc_width(&theme->styles.dark, 2); + lv_style_set_arc_color(&theme->styles.dark, COLOR_DARK); - style_init_reset(&styles->dim); - lv_style_set_bg_opa(&styles->dim, LV_OPA_COVER); - lv_style_set_bg_color(&styles->dim, COLOR_DIM); - lv_style_set_line_width(&styles->dim, 1); - lv_style_set_line_color(&styles->dim, COLOR_DIM); - lv_style_set_arc_width(&styles->dim, 2); - lv_style_set_arc_color(&styles->dim, COLOR_DIM); + style_init_reset(&theme->styles.dim); + lv_style_set_bg_opa(&theme->styles.dim, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.dim, COLOR_DIM); + lv_style_set_line_width(&theme->styles.dim, 1); + lv_style_set_line_color(&theme->styles.dim, COLOR_DIM); + lv_style_set_arc_width(&theme->styles.dim, 2); + lv_style_set_arc_color(&theme->styles.dim, COLOR_DIM); #if LV_USE_ARC - style_init_reset(&styles->arc_line); - lv_style_set_arc_width(&styles->arc_line, 6); - style_init_reset(&styles->arc_knob); - lv_style_set_pad_all(&styles->arc_knob, 5); + style_init_reset(&theme->styles.arc_line); + lv_style_set_arc_width(&theme->styles.arc_line, 6); + style_init_reset(&theme->styles.arc_knob); + lv_style_set_pad_all(&theme->styles.arc_knob, 5); #endif #if LV_USE_TEXTAREA - style_init_reset(&styles->ta_cursor); - lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT); - lv_style_set_border_color(&styles->ta_cursor, COLOR_DIM); - lv_style_set_border_width(&styles->ta_cursor, 2); - lv_style_set_bg_opa(&styles->ta_cursor, LV_OPA_TRANSP); - lv_style_set_anim_time(&styles->ta_cursor, 500); + style_init_reset(&theme->styles.ta_cursor); + lv_style_set_border_side(&theme->styles.ta_cursor, LV_BORDER_SIDE_LEFT); + lv_style_set_border_color(&theme->styles.ta_cursor, COLOR_DIM); + lv_style_set_border_width(&theme->styles.ta_cursor, 2); + lv_style_set_bg_opa(&theme->styles.ta_cursor, LV_OPA_TRANSP); + lv_style_set_anim_time(&theme->styles.ta_cursor, 500); #endif } @@ -137,46 +142,57 @@ static void style_init(void) bool lv_theme_basic_is_inited(void) { - return LV_GC_ROOT(_lv_theme_basic_styles) == NULL ? false : true; + struct _my_theme_t * theme = theme_def; + if(theme == NULL) return false; + return theme->inited; +} + +void lv_theme_basic_deinit(void) +{ + if(theme_def) { + lv_free(theme_def); + theme_def = NULL; + } } lv_theme_t * lv_theme_basic_init(lv_disp_t * disp) { - /*This trick is required only to avoid the garbage collection of *styles' data if LVGL is used in a binding (e.g. Micropython) *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ if(!lv_theme_basic_is_inited()) { - inited = false; - LV_GC_ROOT(_lv_theme_basic_styles) = lv_malloc(sizeof(my_theme_styles_t)); - styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_basic_styles); + theme_def = (my_theme_t *)lv_malloc(sizeof(my_theme_t)); + lv_memzero(theme_def, sizeof(my_theme_t)); } - theme.disp = disp; - theme.font_small = LV_FONT_DEFAULT; - theme.font_normal = LV_FONT_DEFAULT; - theme.font_large = LV_FONT_DEFAULT; - theme.apply_cb = theme_apply; + struct _my_theme_t * theme = theme_def; - style_init(); + theme->base.disp = disp; + theme->base.font_small = LV_FONT_DEFAULT; + theme->base.font_normal = LV_FONT_DEFAULT; + theme->base.font_large = LV_FONT_DEFAULT; + theme->base.apply_cb = theme_apply; - if(disp == NULL || lv_disp_get_theme(disp) == &theme) { + style_init(theme); + + if(disp == NULL || lv_disp_get_theme(disp) == (lv_theme_t *)theme) { lv_obj_report_style_change(NULL); } - inited = true; + theme->inited = true; - return (lv_theme_t *)&theme; + return (lv_theme_t *)theme_def; } - static void theme_apply(lv_theme_t * th, lv_obj_t * obj) { LV_UNUSED(th); + struct _my_theme_t * theme = theme_def; + if(lv_obj_get_parent(obj) == NULL) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } @@ -185,13 +201,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_t * parent = lv_obj_get_parent(obj); /*Tabview content area*/ if(lv_obj_check_type(parent, &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &theme->styles.scr, 0); return; } /*Tabview pages*/ else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } #endif @@ -199,22 +215,22 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_WIN /*Header*/ if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->light, 0); + lv_obj_add_style(obj, &theme->styles.light, 0); return; } /*Content*/ else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } #endif - lv_obj_add_style(obj, &styles->white, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.white, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); } #if LV_USE_BTN else if(lv_obj_check_type(obj, &lv_btn_class)) { - lv_obj_add_style(obj, &styles->dark, 0); + lv_obj_add_style(obj, &theme->styles.dark, 0); } #endif @@ -222,174 +238,174 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { #if LV_USE_MSGBOX if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS); return; } #endif #if LV_USE_TABVIEW if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS); return; } #endif - lv_obj_add_style(obj, &styles->white, 0); - lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.white, 0); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS); } #endif #if LV_USE_BAR else if(lv_obj_check_type(obj, &lv_bar_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR); } #endif #if LV_USE_SLIDER else if(lv_obj_check_type(obj, &lv_slider_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->dim, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.dim, LV_PART_KNOB); } #endif #if LV_USE_TABLE else if(lv_obj_check_type(obj, &lv_table_class)) { - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS); } #endif #if LV_USE_CHECKBOX else if(lv_obj_check_type(obj, &lv_checkbox_class)) { - lv_obj_add_style(obj, &styles->light, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR | LV_STATE_CHECKED); } #endif #if LV_USE_SWITCH else if(lv_obj_check_type(obj, &lv_switch_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->dim, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.dim, LV_PART_KNOB); } #endif #if LV_USE_CHART else if(lv_obj_check_type(obj, &lv_chart_class)) { - lv_obj_add_style(obj, &styles->white, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->dark, LV_PART_TICKS); - lv_obj_add_style(obj, &styles->dark, LV_PART_CURSOR); + lv_obj_add_style(obj, &theme->styles.white, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_TICKS); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_CURSOR); } #endif #if LV_USE_ROLLER else if(lv_obj_check_type(obj, &lv_roller_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->dark, LV_PART_SELECTED); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_SELECTED); } #endif #if LV_USE_DROPDOWN else if(lv_obj_check_type(obj, &lv_dropdown_class)) { - lv_obj_add_style(obj, &styles->white, 0); + lv_obj_add_style(obj, &theme->styles.white, 0); } else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) { - lv_obj_add_style(obj, &styles->white, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->light, LV_PART_SELECTED); - lv_obj_add_style(obj, &styles->dark, LV_PART_SELECTED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.white, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_SELECTED); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_SELECTED | LV_STATE_CHECKED); } #endif #if LV_USE_ARC else if(lv_obj_check_type(obj, &lv_arc_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->transp, 0); - lv_obj_add_style(obj, &styles->arc_line, 0); - lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->arc_line, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->dim, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->arc_knob, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.transp, 0); + lv_obj_add_style(obj, &theme->styles.arc_line, 0); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.arc_line, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.dim, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.arc_knob, LV_PART_KNOB); } #endif #if LV_USE_SPINNER else if(lv_obj_check_type(obj, &lv_spinner_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->transp, 0); - lv_obj_add_style(obj, &styles->arc_line, 0); - lv_obj_add_style(obj, &styles->dark, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->arc_line, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.transp, 0); + lv_obj_add_style(obj, &theme->styles.arc_line, 0); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.arc_line, LV_PART_INDICATOR); } #endif //#if LV_USE_METER // else if(lv_obj_check_type(obj, &lv_meter_class)) { - // lv_obj_add_style(obj, &styles->light, 0); + // lv_obj_add_style(obj, &theme->styles.light, 0); // } //#endif #if LV_USE_TEXTAREA else if(lv_obj_check_type(obj, &lv_textarea_class)) { - lv_obj_add_style(obj, &styles->white, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); + lv_obj_add_style(obj, &theme->styles.white, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); } #endif #if LV_USE_CALENDAR else if(lv_obj_check_type(obj, &lv_calendar_class)) { - lv_obj_add_style(obj, &styles->light, 0); + lv_obj_add_style(obj, &theme->styles.light, 0); } #endif #if LV_USE_KEYBOARD else if(lv_obj_check_type(obj, &lv_keyboard_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->white, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.white, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.light, LV_PART_ITEMS | LV_STATE_CHECKED); } #endif #if LV_USE_LIST else if(lv_obj_check_type(obj, &lv_list_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } else if(lv_obj_check_type(obj, &lv_list_text_class)) { } else if(lv_obj_check_type(obj, &lv_list_btn_class)) { - lv_obj_add_style(obj, &styles->dark, 0); + lv_obj_add_style(obj, &theme->styles.dark, 0); } #endif #if LV_USE_MSGBOX else if(lv_obj_check_type(obj, &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->light, 0); + lv_obj_add_style(obj, &theme->styles.light, 0); return; } #endif #if LV_USE_SPINBOX else if(lv_obj_check_type(obj, &lv_spinbox_class)) { - lv_obj_add_style(obj, &styles->light, 0); - lv_obj_add_style(obj, &styles->dark, LV_PART_CURSOR); + lv_obj_add_style(obj, &theme->styles.light, 0); + lv_obj_add_style(obj, &theme->styles.dark, LV_PART_CURSOR); } #endif #if LV_USE_TILEVIEW else if(lv_obj_check_type(obj, &lv_tileview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); } else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) { - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); } #endif #if LV_USE_LED else if(lv_obj_check_type(obj, &lv_led_class)) { - lv_obj_add_style(obj, &styles->light, 0); + lv_obj_add_style(obj, &theme->styles.light, 0); } #endif } @@ -400,7 +416,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(inited) { + if(lv_theme_basic_is_inited()) { lv_style_reset(style); } else { diff --git a/src/themes/basic/lv_theme_basic.h b/src/themes/basic/lv_theme_basic.h index 7835656f9..01b095a48 100644 --- a/src/themes/basic/lv_theme_basic.h +++ b/src/themes/basic/lv_theme_basic.h @@ -43,6 +43,11 @@ lv_theme_t * lv_theme_basic_init(lv_disp_t * disp); */ bool lv_theme_basic_is_inited(void); +/** + * Deinitialize the basic theme + */ +void lv_theme_basic_deinit(void); + /********************** * MACROS **********************/ diff --git a/src/themes/default/lv_theme_default.c b/src/themes/default/lv_theme_default.c index f956bc238..6dfae9d49 100644 --- a/src/themes/default/lv_theme_default.c +++ b/src/themes/default/lv_theme_default.c @@ -11,14 +11,16 @@ #if LV_USE_THEME_DEFAULT #include "../lv_theme.h" -#include "../../misc/lv_gc.h" #include "../../misc/lv_color.h" +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ +#define theme_def (LV_GLOBAL_DEFAULT()->theme_default) + #define MODE_DARK 1 -#define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)) +#define RADIUS_DEFAULT (theme->disp_size == DISP_LARGE ? lv_disp_dpx(theme->base.disp, 12) : lv_disp_dpx(theme->base.disp, 8)) /*SCREEN*/ #define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) @@ -31,12 +33,12 @@ #define DARK_COLOR_GREY lv_color_hex(0x2f3237) #define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITION_TIME -#define BORDER_WIDTH lv_disp_dpx(theme.disp, 2) -#define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3) +#define BORDER_WIDTH lv_disp_dpx(theme->base.disp, 2) +#define OUTLINE_WIDTH lv_disp_dpx(theme->base.disp, 3) -#define PAD_DEF (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 20) : lv_disp_dpx(theme.disp, 16)) -#define PAD_SMALL (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 10)) -#define PAD_TINY (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 6) : lv_disp_dpx(theme.disp, 2)) +#define PAD_DEF (theme->disp_size == DISP_LARGE ? lv_disp_dpx(theme->base.disp, 24) : theme->disp_size == DISP_MEDIUM ? lv_disp_dpx(theme->base.disp, 20) : lv_disp_dpx(theme->base.disp, 16)) +#define PAD_SMALL (theme->disp_size == DISP_LARGE ? lv_disp_dpx(theme->base.disp, 14) : theme->disp_size == DISP_MEDIUM ? lv_disp_dpx(theme->base.disp, 12) : lv_disp_dpx(theme->base.disp, 10)) +#define PAD_TINY (theme->disp_size == DISP_LARGE ? lv_disp_dpx(theme->base.disp, 8) : theme->disp_size == DISP_MEDIUM ? lv_disp_dpx(theme->base.disp, 6) : lv_disp_dpx(theme->base.disp, 2)) /********************** * TYPEDEFS @@ -147,17 +149,32 @@ typedef struct { #endif } my_theme_styles_t; -typedef struct { - lv_theme_t base; - uint8_t light : 1; -} my_theme_t; - typedef enum { DISP_SMALL = 3, DISP_MEDIUM = 2, DISP_LARGE = 1, } disp_size_t; +typedef struct _my_theme_t { + lv_theme_t base; + disp_size_t disp_size; + lv_color_t color_scr; + lv_color_t color_text; + lv_color_t color_card; + lv_color_t color_grey; + bool inited; + my_theme_styles_t styles; + + lv_color_filter_dsc_t dark_filter; + lv_color_filter_dsc_t grey_filter; + +#if LV_THEME_DEFAULT_TRANSITION_TIME + lv_style_transition_dsc_t trans_delayed; + lv_style_transition_dsc_t trans_normal; +#endif +} my_theme_t; + + /********************** * STATIC PROTOTYPES **********************/ @@ -167,15 +184,6 @@ static void style_init_reset(lv_style_t * style); /********************** * STATIC VARIABLES **********************/ -static my_theme_styles_t * styles; -static lv_theme_t theme; -static disp_size_t disp_size; -static lv_color_t color_scr; -static lv_color_t color_text; -static lv_color_t color_card; -static lv_color_t color_grey; -static bool inited = false; - /********************** * MACROS @@ -195,11 +203,11 @@ static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa) { LV_UNUSED(f); - if(theme.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa); + if(theme_def->base.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa); else return lv_color_mix(lv_palette_lighten(LV_PALETTE_GREY, 2), color, opa); } -static void style_init(void) +static void style_init(struct _my_theme_t * theme) { #if TRANSITION_TIME static const lv_style_prop_t trans_props[] = { @@ -212,427 +220,424 @@ static void style_init(void) }; #endif - color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; - color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; - color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD; - color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY; + theme->color_scr = theme->base.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; + theme->color_text = theme->base.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; + theme->color_card = theme->base.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD; + theme->color_grey = theme->base.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY; - style_init_reset(&styles->transition_delayed); - style_init_reset(&styles->transition_normal); + style_init_reset(&theme->styles.transition_delayed); + style_init_reset(&theme->styles.transition_normal); #if TRANSITION_TIME - static lv_style_transition_dsc_t trans_delayed; - lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL); + lv_style_transition_dsc_init(&theme->trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL); + lv_style_transition_dsc_init(&theme->trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL); - static lv_style_transition_dsc_t trans_normal; - lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL); + lv_style_set_transition(&theme->styles.transition_delayed, + &theme->trans_delayed); /*Go back to default state with delay*/ - lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/ - - lv_style_set_transition(&styles->transition_normal, &trans_normal); /*Go back to default state with delay*/ + lv_style_set_transition(&theme->styles.transition_normal, &theme->trans_normal); /*Go back to default state with delay*/ #endif - style_init_reset(&styles->scrollbar); - lv_color_t sb_color = (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, - 2) : lv_palette_main(LV_PALETTE_GREY); - lv_style_set_bg_color(&styles->scrollbar, sb_color); + style_init_reset(&theme->styles.scrollbar); + lv_color_t sb_color = (theme->base.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, + 2) : lv_palette_main(LV_PALETTE_GREY); + lv_style_set_bg_color(&theme->styles.scrollbar, sb_color); - lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE); - lv_style_set_pad_all(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); - lv_style_set_width(&styles->scrollbar, lv_disp_dpx(theme.disp, 5)); - lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40); + lv_style_set_radius(&theme->styles.scrollbar, LV_RADIUS_CIRCLE); + lv_style_set_pad_all(&theme->styles.scrollbar, lv_disp_dpx(theme->base.disp, 7)); + lv_style_set_width(&theme->styles.scrollbar, lv_disp_dpx(theme->base.disp, 5)); + lv_style_set_bg_opa(&theme->styles.scrollbar, LV_OPA_40); #if TRANSITION_TIME - lv_style_set_transition(&styles->scrollbar, &trans_normal); + lv_style_set_transition(&theme->styles.scrollbar, &theme->trans_normal); #endif - style_init_reset(&styles->scrollbar_scrolled); - lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER); + style_init_reset(&theme->styles.scrollbar_scrolled); + lv_style_set_bg_opa(&theme->styles.scrollbar_scrolled, LV_OPA_COVER); - style_init_reset(&styles->scr); - lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scr, color_scr); - lv_style_set_text_color(&styles->scr, color_text); - lv_style_set_text_font(&styles->scr, theme.font_normal); - lv_style_set_pad_row(&styles->scr, PAD_SMALL); - lv_style_set_pad_column(&styles->scr, PAD_SMALL); + style_init_reset(&theme->styles.scr); + lv_style_set_bg_opa(&theme->styles.scr, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.scr, theme->color_scr); + lv_style_set_text_color(&theme->styles.scr, theme->color_text); + lv_style_set_text_font(&theme->styles.scr, theme->base.font_normal); + lv_style_set_pad_row(&theme->styles.scr, PAD_SMALL); + lv_style_set_pad_column(&theme->styles.scr, PAD_SMALL); - style_init_reset(&styles->card); - lv_style_set_radius(&styles->card, RADIUS_DEFAULT); - lv_style_set_bg_opa(&styles->card, LV_OPA_COVER); - lv_style_set_bg_color(&styles->card, color_card); - lv_style_set_border_color(&styles->card, color_grey); - lv_style_set_border_width(&styles->card, BORDER_WIDTH); - lv_style_set_border_post(&styles->card, true); - lv_style_set_text_color(&styles->card, color_text); - lv_style_set_pad_all(&styles->card, PAD_DEF); - lv_style_set_pad_row(&styles->card, PAD_SMALL); - lv_style_set_pad_column(&styles->card, PAD_SMALL); - lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_line_width(&styles->card, lv_disp_dpx(theme.disp, 1)); + style_init_reset(&theme->styles.card); + lv_style_set_radius(&theme->styles.card, RADIUS_DEFAULT); + lv_style_set_bg_opa(&theme->styles.card, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.card, theme->color_card); + lv_style_set_border_color(&theme->styles.card, theme->color_grey); + lv_style_set_border_width(&theme->styles.card, BORDER_WIDTH); + lv_style_set_border_post(&theme->styles.card, true); + lv_style_set_text_color(&theme->styles.card, theme->color_text); + lv_style_set_pad_all(&theme->styles.card, PAD_DEF); + lv_style_set_pad_row(&theme->styles.card, PAD_SMALL); + lv_style_set_pad_column(&theme->styles.card, PAD_SMALL); + lv_style_set_line_color(&theme->styles.card, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_line_width(&theme->styles.card, lv_disp_dpx(theme->base.disp, 1)); - style_init_reset(&styles->outline_primary); - lv_style_set_outline_color(&styles->outline_primary, theme.color_primary); - lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH); - lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH); - lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50); + style_init_reset(&theme->styles.outline_primary); + lv_style_set_outline_color(&theme->styles.outline_primary, theme->base.color_primary); + lv_style_set_outline_width(&theme->styles.outline_primary, OUTLINE_WIDTH); + lv_style_set_outline_pad(&theme->styles.outline_primary, OUTLINE_WIDTH); + lv_style_set_outline_opa(&theme->styles.outline_primary, LV_OPA_50); - style_init_reset(&styles->outline_secondary); - lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary); - lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH); - lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50); + style_init_reset(&theme->styles.outline_secondary); + lv_style_set_outline_color(&theme->styles.outline_secondary, theme->base.color_secondary); + lv_style_set_outline_width(&theme->styles.outline_secondary, OUTLINE_WIDTH); + lv_style_set_outline_opa(&theme->styles.outline_secondary, LV_OPA_50); - style_init_reset(&styles->btn); - lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, - 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8))); - lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER); - lv_style_set_bg_color(&styles->btn, color_grey); - if(!(theme.flags & MODE_DARK)) { - lv_style_set_shadow_color(&styles->btn, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_shadow_width(&styles->btn, LV_DPX(3)); - lv_style_set_shadow_opa(&styles->btn, LV_OPA_50); - lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, LV_DPX(4))); + style_init_reset(&theme->styles.btn); + lv_style_set_radius(&theme->styles.btn, (theme->disp_size == DISP_LARGE ? lv_disp_dpx(theme->base.disp, + 16) : theme->disp_size == DISP_MEDIUM ? lv_disp_dpx(theme->base.disp, 12) : lv_disp_dpx(theme->base.disp, 8))); + lv_style_set_bg_opa(&theme->styles.btn, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.btn, theme->color_grey); + if(!(theme->base.flags & MODE_DARK)) { + lv_style_set_shadow_color(&theme->styles.btn, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_shadow_width(&theme->styles.btn, LV_DPX(3)); + lv_style_set_shadow_opa(&theme->styles.btn, LV_OPA_50); + lv_style_set_shadow_ofs_y(&theme->styles.btn, lv_disp_dpx(theme->base.disp, LV_DPX(4))); } - lv_style_set_text_color(&styles->btn, color_text); - lv_style_set_pad_hor(&styles->btn, PAD_DEF); - lv_style_set_pad_ver(&styles->btn, PAD_SMALL); - lv_style_set_pad_column(&styles->btn, lv_disp_dpx(theme.disp, 5)); - lv_style_set_pad_row(&styles->btn, lv_disp_dpx(theme.disp, 5)); + lv_style_set_text_color(&theme->styles.btn, theme->color_text); + lv_style_set_pad_hor(&theme->styles.btn, PAD_DEF); + lv_style_set_pad_ver(&theme->styles.btn, PAD_SMALL); + lv_style_set_pad_column(&theme->styles.btn, lv_disp_dpx(theme->base.disp, 5)); + lv_style_set_pad_row(&theme->styles.btn, lv_disp_dpx(theme->base.disp, 5)); - static lv_color_filter_dsc_t dark_filter; - lv_color_filter_dsc_init(&dark_filter, dark_color_filter_cb); + lv_color_filter_dsc_init(&theme->dark_filter, dark_color_filter_cb); + lv_color_filter_dsc_init(&theme->grey_filter, grey_filter_cb); - static lv_color_filter_dsc_t grey_filter; - lv_color_filter_dsc_init(&grey_filter, grey_filter_cb); + style_init_reset(&theme->styles.pressed); + lv_style_set_color_filter_dsc(&theme->styles.pressed, &theme->dark_filter); + lv_style_set_color_filter_opa(&theme->styles.pressed, 35); - style_init_reset(&styles->pressed); - lv_style_set_color_filter_dsc(&styles->pressed, &dark_filter); - lv_style_set_color_filter_opa(&styles->pressed, 35); + style_init_reset(&theme->styles.disabled); + lv_style_set_color_filter_dsc(&theme->styles.disabled, &theme->grey_filter); + lv_style_set_color_filter_opa(&theme->styles.disabled, LV_OPA_50); - style_init_reset(&styles->disabled); - lv_style_set_color_filter_dsc(&styles->disabled, &grey_filter); - lv_style_set_color_filter_opa(&styles->disabled, LV_OPA_50); + style_init_reset(&theme->styles.clip_corner); + lv_style_set_clip_corner(&theme->styles.clip_corner, true); + lv_style_set_border_post(&theme->styles.clip_corner, true); - style_init_reset(&styles->clip_corner); - lv_style_set_clip_corner(&styles->clip_corner, true); - lv_style_set_border_post(&styles->clip_corner, true); + style_init_reset(&theme->styles.pad_normal); + lv_style_set_pad_all(&theme->styles.pad_normal, PAD_DEF); + lv_style_set_pad_row(&theme->styles.pad_normal, PAD_DEF); + lv_style_set_pad_column(&theme->styles.pad_normal, PAD_DEF); - style_init_reset(&styles->pad_normal); - lv_style_set_pad_all(&styles->pad_normal, PAD_DEF); - lv_style_set_pad_row(&styles->pad_normal, PAD_DEF); - lv_style_set_pad_column(&styles->pad_normal, PAD_DEF); + style_init_reset(&theme->styles.pad_small); + lv_style_set_pad_all(&theme->styles.pad_small, PAD_SMALL); + lv_style_set_pad_gap(&theme->styles.pad_small, PAD_SMALL); - style_init_reset(&styles->pad_small); - lv_style_set_pad_all(&styles->pad_small, PAD_SMALL); - lv_style_set_pad_gap(&styles->pad_small, PAD_SMALL); + style_init_reset(&theme->styles.pad_gap); + lv_style_set_pad_row(&theme->styles.pad_gap, lv_disp_dpx(theme->base.disp, 10)); + lv_style_set_pad_column(&theme->styles.pad_gap, lv_disp_dpx(theme->base.disp, 10)); - style_init_reset(&styles->pad_gap); - lv_style_set_pad_row(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); - lv_style_set_pad_column(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); + style_init_reset(&theme->styles.line_space_large); + lv_style_set_text_line_space(&theme->styles.line_space_large, lv_disp_dpx(theme->base.disp, 20)); - style_init_reset(&styles->line_space_large); - lv_style_set_text_line_space(&styles->line_space_large, lv_disp_dpx(theme.disp, 20)); + style_init_reset(&theme->styles.text_align_center); + lv_style_set_text_align(&theme->styles.text_align_center, LV_TEXT_ALIGN_CENTER); - style_init_reset(&styles->text_align_center); - lv_style_set_text_align(&styles->text_align_center, LV_TEXT_ALIGN_CENTER); + style_init_reset(&theme->styles.pad_zero); + lv_style_set_pad_all(&theme->styles.pad_zero, 0); + lv_style_set_pad_row(&theme->styles.pad_zero, 0); + lv_style_set_pad_column(&theme->styles.pad_zero, 0); - style_init_reset(&styles->pad_zero); - lv_style_set_pad_all(&styles->pad_zero, 0); - lv_style_set_pad_row(&styles->pad_zero, 0); - lv_style_set_pad_column(&styles->pad_zero, 0); + style_init_reset(&theme->styles.pad_tiny); + lv_style_set_pad_all(&theme->styles.pad_tiny, PAD_TINY); + lv_style_set_pad_row(&theme->styles.pad_tiny, PAD_TINY); + lv_style_set_pad_column(&theme->styles.pad_tiny, PAD_TINY); - style_init_reset(&styles->pad_tiny); - lv_style_set_pad_all(&styles->pad_tiny, PAD_TINY); - lv_style_set_pad_row(&styles->pad_tiny, PAD_TINY); - lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY); + style_init_reset(&theme->styles.bg_color_primary); + lv_style_set_bg_color(&theme->styles.bg_color_primary, theme->base.color_primary); + lv_style_set_text_color(&theme->styles.bg_color_primary, lv_color_white()); + lv_style_set_bg_opa(&theme->styles.bg_color_primary, LV_OPA_COVER); - style_init_reset(&styles->bg_color_primary); - lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary); - lv_style_set_text_color(&styles->bg_color_primary, lv_color_white()); - lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); + style_init_reset(&theme->styles.bg_color_primary_muted); + lv_style_set_bg_color(&theme->styles.bg_color_primary_muted, theme->base.color_primary); + lv_style_set_text_color(&theme->styles.bg_color_primary_muted, theme->base.color_primary); + lv_style_set_bg_opa(&theme->styles.bg_color_primary_muted, LV_OPA_20); - style_init_reset(&styles->bg_color_primary_muted); - lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary); - lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary); - lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20); + style_init_reset(&theme->styles.bg_color_secondary); + lv_style_set_bg_color(&theme->styles.bg_color_secondary, theme->base.color_secondary); + lv_style_set_text_color(&theme->styles.bg_color_secondary, lv_color_white()); + lv_style_set_bg_opa(&theme->styles.bg_color_secondary, LV_OPA_COVER); - style_init_reset(&styles->bg_color_secondary); - lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); - lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); - lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER); + style_init_reset(&theme->styles.bg_color_secondary_muted); + lv_style_set_bg_color(&theme->styles.bg_color_secondary_muted, theme->base.color_secondary); + lv_style_set_text_color(&theme->styles.bg_color_secondary_muted, theme->base.color_secondary); + lv_style_set_bg_opa(&theme->styles.bg_color_secondary_muted, LV_OPA_20); - style_init_reset(&styles->bg_color_secondary_muted); - lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary); - lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary); - lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20); + style_init_reset(&theme->styles.bg_color_grey); + lv_style_set_bg_color(&theme->styles.bg_color_grey, theme->color_grey); + lv_style_set_bg_opa(&theme->styles.bg_color_grey, LV_OPA_COVER); + lv_style_set_text_color(&theme->styles.bg_color_grey, theme->color_text); - style_init_reset(&styles->bg_color_grey); - lv_style_set_bg_color(&styles->bg_color_grey, color_grey); - lv_style_set_bg_opa(&styles->bg_color_grey, LV_OPA_COVER); - lv_style_set_text_color(&styles->bg_color_grey, color_text); + style_init_reset(&theme->styles.bg_color_white); + lv_style_set_bg_color(&theme->styles.bg_color_white, theme->color_card); + lv_style_set_bg_opa(&theme->styles.bg_color_white, LV_OPA_COVER); + lv_style_set_text_color(&theme->styles.bg_color_white, theme->color_text); - style_init_reset(&styles->bg_color_white); - lv_style_set_bg_color(&styles->bg_color_white, color_card); - lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER); - lv_style_set_text_color(&styles->bg_color_white, color_text); + style_init_reset(&theme->styles.circle); + lv_style_set_radius(&theme->styles.circle, LV_RADIUS_CIRCLE); - style_init_reset(&styles->circle); - lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE); - - style_init_reset(&styles->no_radius); - lv_style_set_radius(&styles->no_radius, 0); + style_init_reset(&theme->styles.no_radius); + lv_style_set_radius(&theme->styles.no_radius, 0); #if LV_THEME_DEFAULT_GROW - style_init_reset(&styles->grow); - lv_style_set_transform_width(&styles->grow, lv_disp_dpx(theme.disp, 3)); - lv_style_set_transform_height(&styles->grow, lv_disp_dpx(theme.disp, 3)); + style_init_reset(&theme->styles.grow); + lv_style_set_transform_width(&theme->styles.grow, lv_disp_dpx(theme->base.disp, 3)); + lv_style_set_transform_height(&theme->styles.grow, lv_disp_dpx(theme->base.disp, 3)); #endif - style_init_reset(&styles->knob); - lv_style_set_bg_color(&styles->knob, theme.color_primary); - lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER); - lv_style_set_pad_all(&styles->knob, lv_disp_dpx(theme.disp, 6)); - lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE); + style_init_reset(&theme->styles.knob); + lv_style_set_bg_color(&theme->styles.knob, theme->base.color_primary); + lv_style_set_bg_opa(&theme->styles.knob, LV_OPA_COVER); + lv_style_set_pad_all(&theme->styles.knob, lv_disp_dpx(theme->base.disp, 6)); + lv_style_set_radius(&theme->styles.knob, LV_RADIUS_CIRCLE); - style_init_reset(&styles->anim); - lv_style_set_anim_time(&styles->anim, 200); + style_init_reset(&theme->styles.anim); + lv_style_set_anim_time(&theme->styles.anim, 200); - style_init_reset(&styles->anim_fast); - lv_style_set_anim_time(&styles->anim_fast, 120); + style_init_reset(&theme->styles.anim_fast); + lv_style_set_anim_time(&theme->styles.anim_fast, 120); #if LV_USE_ARC - style_init_reset(&styles->arc_indic); - lv_style_set_arc_color(&styles->arc_indic, color_grey); - lv_style_set_arc_width(&styles->arc_indic, lv_disp_dpx(theme.disp, 15)); - lv_style_set_arc_rounded(&styles->arc_indic, true); + style_init_reset(&theme->styles.arc_indic); + lv_style_set_arc_color(&theme->styles.arc_indic, theme->color_grey); + lv_style_set_arc_width(&theme->styles.arc_indic, lv_disp_dpx(theme->base.disp, 15)); + lv_style_set_arc_rounded(&theme->styles.arc_indic, true); - style_init_reset(&styles->arc_indic_primary); - lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary); + style_init_reset(&theme->styles.arc_indic_primary); + lv_style_set_arc_color(&theme->styles.arc_indic_primary, theme->base.color_primary); #endif #if LV_USE_DROPDOWN - style_init_reset(&styles->dropdown_list); - lv_style_set_max_height(&styles->dropdown_list, LV_DPI_DEF * 2); + style_init_reset(&theme->styles.dropdown_list); + lv_style_set_max_height(&theme->styles.dropdown_list, LV_DPI_DEF * 2); #endif #if LV_USE_CHECKBOX - style_init_reset(&styles->cb_marker); - lv_style_set_pad_all(&styles->cb_marker, lv_disp_dpx(theme.disp, 3)); - lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH); - lv_style_set_border_color(&styles->cb_marker, theme.color_primary); - lv_style_set_bg_color(&styles->cb_marker, color_card); - lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER); - lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); + style_init_reset(&theme->styles.cb_marker); + lv_style_set_pad_all(&theme->styles.cb_marker, lv_disp_dpx(theme->base.disp, 3)); + lv_style_set_border_width(&theme->styles.cb_marker, BORDER_WIDTH); + lv_style_set_border_color(&theme->styles.cb_marker, theme->base.color_primary); + lv_style_set_bg_color(&theme->styles.cb_marker, theme->color_card); + lv_style_set_bg_opa(&theme->styles.cb_marker, LV_OPA_COVER); + lv_style_set_radius(&theme->styles.cb_marker, RADIUS_DEFAULT / 2); - style_init_reset(&styles->cb_marker_checked); - lv_style_set_bg_img_src(&styles->cb_marker_checked, LV_SYMBOL_OK); - lv_style_set_text_color(&styles->cb_marker_checked, lv_color_white()); - lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small); + style_init_reset(&theme->styles.cb_marker_checked); + lv_style_set_bg_img_src(&theme->styles.cb_marker_checked, LV_SYMBOL_OK); + lv_style_set_text_color(&theme->styles.cb_marker_checked, lv_color_white()); + lv_style_set_text_font(&theme->styles.cb_marker_checked, theme->base.font_small); #endif #if LV_USE_SWITCH - style_init_reset(&styles->switch_knob); - lv_style_set_pad_all(&styles->switch_knob, - lv_disp_dpx(theme.disp, 4)); - lv_style_set_bg_color(&styles->switch_knob, lv_color_white()); + style_init_reset(&theme->styles.switch_knob); + lv_style_set_pad_all(&theme->styles.switch_knob, - lv_disp_dpx(theme->base.disp, 4)); + lv_style_set_bg_color(&theme->styles.switch_knob, lv_color_white()); #endif #if LV_USE_LINE - style_init_reset(&styles->line); - lv_style_set_line_width(&styles->line, 1); - lv_style_set_line_color(&styles->line, color_text); + style_init_reset(&theme->styles.line); + lv_style_set_line_width(&theme->styles.line, 1); + lv_style_set_line_color(&theme->styles.line, theme->color_text); #endif #if LV_USE_CHART - style_init_reset(&styles->chart_bg); - lv_style_set_border_post(&styles->chart_bg, false); - lv_style_set_pad_column(&styles->chart_bg, lv_disp_dpx(theme.disp, 10)); - lv_style_set_line_color(&styles->chart_bg, color_grey); + style_init_reset(&theme->styles.chart_bg); + lv_style_set_border_post(&theme->styles.chart_bg, false); + lv_style_set_pad_column(&theme->styles.chart_bg, lv_disp_dpx(theme->base.disp, 10)); + lv_style_set_line_color(&theme->styles.chart_bg, theme->color_grey); - style_init_reset(&styles->chart_series); - lv_style_set_line_width(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); - lv_style_set_radius(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); - lv_style_set_size(&styles->chart_series, lv_disp_dpx(theme.disp, 8), lv_disp_dpx(theme.disp, 8)); - lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2)); + style_init_reset(&theme->styles.chart_series); + lv_style_set_line_width(&theme->styles.chart_series, lv_disp_dpx(theme->base.disp, 3)); + lv_style_set_radius(&theme->styles.chart_series, lv_disp_dpx(theme->base.disp, 3)); + lv_style_set_size(&theme->styles.chart_series, lv_disp_dpx(theme->base.disp, 8), lv_disp_dpx(theme->base.disp, 8)); + lv_style_set_pad_column(&theme->styles.chart_series, lv_disp_dpx(theme->base.disp, 2)); - style_init_reset(&styles->chart_indic); - lv_style_set_radius(&styles->chart_indic, LV_RADIUS_CIRCLE); - lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8), lv_disp_dpx(theme.disp, 8)); - lv_style_set_bg_color(&styles->chart_indic, theme.color_primary); - lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER); + style_init_reset(&theme->styles.chart_indic); + lv_style_set_radius(&theme->styles.chart_indic, LV_RADIUS_CIRCLE); + lv_style_set_size(&theme->styles.chart_indic, lv_disp_dpx(theme->base.disp, 8), lv_disp_dpx(theme->base.disp, 8)); + lv_style_set_bg_color(&theme->styles.chart_indic, theme->base.color_primary); + lv_style_set_bg_opa(&theme->styles.chart_indic, LV_OPA_COVER); - style_init_reset(&styles->chart_ticks); - lv_style_set_line_width(&styles->chart_ticks, lv_disp_dpx(theme.disp, 1)); - lv_style_set_line_color(&styles->chart_ticks, color_text); - lv_style_set_pad_all(&styles->chart_ticks, lv_disp_dpx(theme.disp, 2)); - lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY)); + style_init_reset(&theme->styles.chart_ticks); + lv_style_set_line_width(&theme->styles.chart_ticks, lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_line_color(&theme->styles.chart_ticks, theme->color_text); + lv_style_set_pad_all(&theme->styles.chart_ticks, lv_disp_dpx(theme->base.disp, 2)); + lv_style_set_text_color(&theme->styles.chart_ticks, lv_palette_main(LV_PALETTE_GREY)); #endif #if LV_USE_MENU - style_init_reset(&styles->menu_bg); - lv_style_set_pad_all(&styles->menu_bg, 0); - lv_style_set_pad_gap(&styles->menu_bg, 0); - lv_style_set_radius(&styles->menu_bg, 0); - lv_style_set_clip_corner(&styles->menu_bg, true); - lv_style_set_border_side(&styles->menu_bg, LV_BORDER_SIDE_NONE); + style_init_reset(&theme->styles.menu_bg); + lv_style_set_pad_all(&theme->styles.menu_bg, 0); + lv_style_set_pad_gap(&theme->styles.menu_bg, 0); + lv_style_set_radius(&theme->styles.menu_bg, 0); + lv_style_set_clip_corner(&theme->styles.menu_bg, true); + lv_style_set_border_side(&theme->styles.menu_bg, LV_BORDER_SIDE_NONE); - style_init_reset(&styles->menu_section); - lv_style_set_radius(&styles->menu_section, RADIUS_DEFAULT); - lv_style_set_clip_corner(&styles->menu_section, true); - lv_style_set_bg_opa(&styles->menu_section, LV_OPA_COVER); - lv_style_set_bg_color(&styles->menu_section, color_card); - lv_style_set_text_color(&styles->menu_section, color_text); + style_init_reset(&theme->styles.menu_section); + lv_style_set_radius(&theme->styles.menu_section, RADIUS_DEFAULT); + lv_style_set_clip_corner(&theme->styles.menu_section, true); + lv_style_set_bg_opa(&theme->styles.menu_section, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.menu_section, theme->color_card); + lv_style_set_text_color(&theme->styles.menu_section, theme->color_text); - style_init_reset(&styles->menu_cont); - lv_style_set_pad_hor(&styles->menu_cont, PAD_SMALL); - lv_style_set_pad_ver(&styles->menu_cont, PAD_SMALL); - lv_style_set_pad_gap(&styles->menu_cont, PAD_SMALL); - lv_style_set_border_width(&styles->menu_cont, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_opa(&styles->menu_cont, LV_OPA_10); - lv_style_set_border_color(&styles->menu_cont, color_text); - lv_style_set_border_side(&styles->menu_cont, LV_BORDER_SIDE_NONE); + style_init_reset(&theme->styles.menu_cont); + lv_style_set_pad_hor(&theme->styles.menu_cont, PAD_SMALL); + lv_style_set_pad_ver(&theme->styles.menu_cont, PAD_SMALL); + lv_style_set_pad_gap(&theme->styles.menu_cont, PAD_SMALL); + lv_style_set_border_width(&theme->styles.menu_cont, lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_border_opa(&theme->styles.menu_cont, LV_OPA_10); + lv_style_set_border_color(&theme->styles.menu_cont, theme->color_text); + lv_style_set_border_side(&theme->styles.menu_cont, LV_BORDER_SIDE_NONE); - style_init_reset(&styles->menu_sidebar_cont); - lv_style_set_pad_all(&styles->menu_sidebar_cont, 0); - lv_style_set_pad_gap(&styles->menu_sidebar_cont, 0); - lv_style_set_border_width(&styles->menu_sidebar_cont, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_opa(&styles->menu_sidebar_cont, LV_OPA_10); - lv_style_set_border_color(&styles->menu_sidebar_cont, color_text); - lv_style_set_border_side(&styles->menu_sidebar_cont, LV_BORDER_SIDE_RIGHT); + style_init_reset(&theme->styles.menu_sidebar_cont); + lv_style_set_pad_all(&theme->styles.menu_sidebar_cont, 0); + lv_style_set_pad_gap(&theme->styles.menu_sidebar_cont, 0); + lv_style_set_border_width(&theme->styles.menu_sidebar_cont, lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_border_opa(&theme->styles.menu_sidebar_cont, LV_OPA_10); + lv_style_set_border_color(&theme->styles.menu_sidebar_cont, theme->color_text); + lv_style_set_border_side(&theme->styles.menu_sidebar_cont, LV_BORDER_SIDE_RIGHT); - style_init_reset(&styles->menu_main_cont); - lv_style_set_pad_all(&styles->menu_main_cont, 0); - lv_style_set_pad_gap(&styles->menu_main_cont, 0); + style_init_reset(&theme->styles.menu_main_cont); + lv_style_set_pad_all(&theme->styles.menu_main_cont, 0); + lv_style_set_pad_gap(&theme->styles.menu_main_cont, 0); - style_init_reset(&styles->menu_header_cont); - lv_style_set_pad_hor(&styles->menu_header_cont, PAD_SMALL); - lv_style_set_pad_ver(&styles->menu_header_cont, PAD_TINY); - lv_style_set_pad_gap(&styles->menu_header_cont, PAD_SMALL); + style_init_reset(&theme->styles.menu_header_cont); + lv_style_set_pad_hor(&theme->styles.menu_header_cont, PAD_SMALL); + lv_style_set_pad_ver(&theme->styles.menu_header_cont, PAD_TINY); + lv_style_set_pad_gap(&theme->styles.menu_header_cont, PAD_SMALL); - style_init_reset(&styles->menu_header_btn); - lv_style_set_pad_hor(&styles->menu_header_btn, PAD_TINY); - lv_style_set_pad_ver(&styles->menu_header_btn, PAD_TINY); - lv_style_set_shadow_opa(&styles->menu_header_btn, LV_OPA_TRANSP); - lv_style_set_bg_opa(&styles->menu_header_btn, LV_OPA_TRANSP); - lv_style_set_text_color(&styles->menu_header_btn, color_text); + style_init_reset(&theme->styles.menu_header_btn); + lv_style_set_pad_hor(&theme->styles.menu_header_btn, PAD_TINY); + lv_style_set_pad_ver(&theme->styles.menu_header_btn, PAD_TINY); + lv_style_set_shadow_opa(&theme->styles.menu_header_btn, LV_OPA_TRANSP); + lv_style_set_bg_opa(&theme->styles.menu_header_btn, LV_OPA_TRANSP); + lv_style_set_text_color(&theme->styles.menu_header_btn, theme->color_text); - style_init_reset(&styles->menu_page); - lv_style_set_pad_hor(&styles->menu_page, 0); - lv_style_set_pad_gap(&styles->menu_page, 0); + style_init_reset(&theme->styles.menu_page); + lv_style_set_pad_hor(&theme->styles.menu_page, 0); + lv_style_set_pad_gap(&theme->styles.menu_page, 0); - style_init_reset(&styles->menu_pressed); - lv_style_set_bg_opa(&styles->menu_pressed, LV_OPA_20); - lv_style_set_bg_color(&styles->menu_pressed, lv_palette_main(LV_PALETTE_GREY)); + style_init_reset(&theme->styles.menu_pressed); + lv_style_set_bg_opa(&theme->styles.menu_pressed, LV_OPA_20); + lv_style_set_bg_color(&theme->styles.menu_pressed, lv_palette_main(LV_PALETTE_GREY)); - style_init_reset(&styles->menu_separator); - lv_style_set_bg_opa(&styles->menu_separator, LV_OPA_TRANSP); - lv_style_set_pad_ver(&styles->menu_separator, PAD_TINY); + style_init_reset(&theme->styles.menu_separator); + lv_style_set_bg_opa(&theme->styles.menu_separator, LV_OPA_TRANSP); + lv_style_set_pad_ver(&theme->styles.menu_separator, PAD_TINY); #endif #if LV_USE_METER - style_init_reset(&styles->meter_marker); - lv_style_set_line_width(&styles->meter_marker, lv_disp_dpx(theme.disp, 5)); - lv_style_set_line_color(&styles->meter_marker, color_text); - lv_style_set_size(&styles->meter_marker, lv_disp_dpx(theme.disp, 20), lv_disp_dpx(theme.disp, 20)); - lv_style_set_pad_left(&styles->meter_marker, lv_disp_dpx(theme.disp, 15)); + style_init_reset(&theme->styles.meter_marker); + lv_style_set_line_width(&theme->styles.meter_marker, lv_disp_dpx(theme->base.disp, 5)); + lv_style_set_line_color(&theme->styles.meter_marker, theme->color_text); + lv_style_set_size(&theme->styles.meter_marker, lv_disp_dpx(theme->base.disp, 20), lv_disp_dpx(theme->base.disp, 20)); + lv_style_set_pad_left(&theme->styles.meter_marker, lv_disp_dpx(theme->base.disp, 15)); - style_init_reset(&styles->meter_indic); - lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE); - lv_style_set_bg_color(&styles->meter_indic, color_text); - lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER); - lv_style_set_size(&styles->meter_indic, lv_disp_dpx(theme.disp, 15), lv_disp_dpx(theme.disp, 15)); + style_init_reset(&theme->styles.meter_indic); + lv_style_set_radius(&theme->styles.meter_indic, LV_RADIUS_CIRCLE); + lv_style_set_bg_color(&theme->styles.meter_indic, theme->color_text); + lv_style_set_bg_opa(&theme->styles.meter_indic, LV_OPA_COVER); + lv_style_set_size(&theme->styles.meter_indic, lv_disp_dpx(theme->base.disp, 15), lv_disp_dpx(theme->base.disp, 15)); #endif #if LV_USE_TABLE - style_init_reset(&styles->table_cell); - lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_color(&styles->table_cell, color_grey); - lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); + style_init_reset(&theme->styles.table_cell); + lv_style_set_border_width(&theme->styles.table_cell, lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_border_color(&theme->styles.table_cell, theme->color_grey); + lv_style_set_border_side(&theme->styles.table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM); #endif #if LV_USE_TEXTAREA - style_init_reset(&styles->ta_cursor); - lv_style_set_border_color(&styles->ta_cursor, color_text); - lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2)); - lv_style_set_pad_left(&styles->ta_cursor, - lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT); - lv_style_set_anim_time(&styles->ta_cursor, 400); + style_init_reset(&theme->styles.ta_cursor); + lv_style_set_border_color(&theme->styles.ta_cursor, theme->color_text); + lv_style_set_border_width(&theme->styles.ta_cursor, lv_disp_dpx(theme->base.disp, 2)); + lv_style_set_pad_left(&theme->styles.ta_cursor, - lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_border_side(&theme->styles.ta_cursor, LV_BORDER_SIDE_LEFT); + lv_style_set_anim_time(&theme->styles.ta_cursor, 400); - style_init_reset(&styles->ta_placeholder); - lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, - 2) : lv_palette_lighten(LV_PALETTE_GREY, 1)); + style_init_reset(&theme->styles.ta_placeholder); + lv_style_set_text_color(&theme->styles.ta_placeholder, + (theme->base.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, + 2) : lv_palette_lighten(LV_PALETTE_GREY, 1)); #endif #if LV_USE_CALENDAR - style_init_reset(&styles->calendar_btnm_bg); - lv_style_set_pad_all(&styles->calendar_btnm_bg, PAD_SMALL); - lv_style_set_pad_gap(&styles->calendar_btnm_bg, PAD_SMALL / 2); + style_init_reset(&theme->styles.calendar_btnm_bg); + lv_style_set_pad_all(&theme->styles.calendar_btnm_bg, PAD_SMALL); + lv_style_set_pad_gap(&theme->styles.calendar_btnm_bg, PAD_SMALL / 2); - style_init_reset(&styles->calendar_btnm_day); - lv_style_set_border_width(&styles->calendar_btnm_day, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_color(&styles->calendar_btnm_day, color_grey); - lv_style_set_bg_color(&styles->calendar_btnm_day, color_card); - lv_style_set_bg_opa(&styles->calendar_btnm_day, LV_OPA_20); + style_init_reset(&theme->styles.calendar_btnm_day); + lv_style_set_border_width(&theme->styles.calendar_btnm_day, lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_border_color(&theme->styles.calendar_btnm_day, theme->color_grey); + lv_style_set_bg_color(&theme->styles.calendar_btnm_day, theme->color_card); + lv_style_set_bg_opa(&theme->styles.calendar_btnm_day, LV_OPA_20); - style_init_reset(&styles->calendar_header); - lv_style_set_pad_hor(&styles->calendar_header, PAD_SMALL); - lv_style_set_pad_top(&styles->calendar_header, PAD_SMALL); - lv_style_set_pad_bottom(&styles->calendar_header, PAD_TINY); - lv_style_set_pad_gap(&styles->calendar_header, PAD_SMALL); + style_init_reset(&theme->styles.calendar_header); + lv_style_set_pad_hor(&theme->styles.calendar_header, PAD_SMALL); + lv_style_set_pad_top(&theme->styles.calendar_header, PAD_SMALL); + lv_style_set_pad_bottom(&theme->styles.calendar_header, PAD_TINY); + lv_style_set_pad_gap(&theme->styles.calendar_header, PAD_SMALL); #endif #if LV_USE_MSGBOX /*To add space for for the button shadow*/ - style_init_reset(&styles->msgbox_btn_bg); - lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_disp_dpx(theme.disp, 4)); + style_init_reset(&theme->styles.msgbox_btn_bg); + lv_style_set_pad_all(&theme->styles.msgbox_btn_bg, lv_disp_dpx(theme->base.disp, 4)); - style_init_reset(&styles->msgbox_bg); - lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100)); + style_init_reset(&theme->styles.msgbox_bg); + lv_style_set_max_width(&theme->styles.msgbox_bg, lv_pct(100)); - style_init_reset(&styles->msgbox_backdrop_bg); - lv_style_set_bg_color(&styles->msgbox_backdrop_bg, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_bg_opa(&styles->msgbox_backdrop_bg, LV_OPA_100); + style_init_reset(&theme->styles.msgbox_backdrop_bg); + lv_style_set_bg_color(&theme->styles.msgbox_backdrop_bg, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_bg_opa(&theme->styles.msgbox_backdrop_bg, LV_OPA_100); #endif #if LV_USE_KEYBOARD - style_init_reset(&styles->keyboard_btn_bg); - lv_style_set_shadow_width(&styles->keyboard_btn_bg, 0); - lv_style_set_radius(&styles->keyboard_btn_bg, disp_size == DISP_SMALL ? RADIUS_DEFAULT / 2 : RADIUS_DEFAULT); + style_init_reset(&theme->styles.keyboard_btn_bg); + lv_style_set_shadow_width(&theme->styles.keyboard_btn_bg, 0); + lv_style_set_radius(&theme->styles.keyboard_btn_bg, + theme->disp_size == DISP_SMALL ? RADIUS_DEFAULT / 2 : RADIUS_DEFAULT); #endif #if LV_USE_TABVIEW - style_init_reset(&styles->tab_btn); - lv_style_set_border_color(&styles->tab_btn, theme.color_primary); - lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2); - lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM); + style_init_reset(&theme->styles.tab_btn); + lv_style_set_border_color(&theme->styles.tab_btn, theme->base.color_primary); + lv_style_set_border_width(&theme->styles.tab_btn, BORDER_WIDTH * 2); + lv_style_set_border_side(&theme->styles.tab_btn, LV_BORDER_SIDE_BOTTOM); - style_init_reset(&styles->tab_bg_focus); - lv_style_set_outline_pad(&styles->tab_bg_focus, -BORDER_WIDTH); + style_init_reset(&theme->styles.tab_bg_focus); + lv_style_set_outline_pad(&theme->styles.tab_bg_focus, -BORDER_WIDTH); #endif #if LV_USE_LIST - style_init_reset(&styles->list_bg); - lv_style_set_pad_hor(&styles->list_bg, PAD_DEF); - lv_style_set_pad_ver(&styles->list_bg, 0); - lv_style_set_pad_gap(&styles->list_bg, 0); - lv_style_set_clip_corner(&styles->list_bg, true); + style_init_reset(&theme->styles.list_bg); + lv_style_set_pad_hor(&theme->styles.list_bg, PAD_DEF); + lv_style_set_pad_ver(&theme->styles.list_bg, 0); + lv_style_set_pad_gap(&theme->styles.list_bg, 0); + lv_style_set_clip_corner(&theme->styles.list_bg, true); - style_init_reset(&styles->list_btn); - lv_style_set_border_width(&styles->list_btn, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_color(&styles->list_btn, color_grey); - lv_style_set_border_side(&styles->list_btn, LV_BORDER_SIDE_BOTTOM); - lv_style_set_pad_all(&styles->list_btn, PAD_SMALL); - lv_style_set_pad_column(&styles->list_btn, PAD_SMALL); + style_init_reset(&theme->styles.list_btn); + lv_style_set_border_width(&theme->styles.list_btn, lv_disp_dpx(theme->base.disp, 1)); + lv_style_set_border_color(&theme->styles.list_btn, theme->color_grey); + lv_style_set_border_side(&theme->styles.list_btn, LV_BORDER_SIDE_BOTTOM); + lv_style_set_pad_all(&theme->styles.list_btn, PAD_SMALL); + lv_style_set_pad_column(&theme->styles.list_btn, PAD_SMALL); - style_init_reset(&styles->list_item_grow); - lv_style_set_transform_width(&styles->list_item_grow, PAD_DEF); + style_init_reset(&theme->styles.list_item_grow); + lv_style_set_transform_width(&theme->styles.list_item_grow, PAD_DEF); #endif #if LV_USE_LED - style_init_reset(&styles->led); - lv_style_set_bg_opa(&styles->led, LV_OPA_COVER); - lv_style_set_bg_color(&styles->led, lv_color_white()); - lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE); - lv_style_set_shadow_width(&styles->led, lv_disp_dpx(theme.disp, 15)); - lv_style_set_shadow_color(&styles->led, lv_color_white()); - lv_style_set_shadow_spread(&styles->led, lv_disp_dpx(theme.disp, 5)); + style_init_reset(&theme->styles.led); + lv_style_set_bg_opa(&theme->styles.led, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.led, lv_color_white()); + lv_style_set_bg_grad_color(&theme->styles.led, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_radius(&theme->styles.led, LV_RADIUS_CIRCLE); + lv_style_set_shadow_width(&theme->styles.led, lv_disp_dpx(theme->base.disp, 15)); + lv_style_set_shadow_color(&theme->styles.led, lv_color_white()); + lv_style_set_shadow_spread(&theme->styles.led, lv_disp_dpx(theme->base.disp, 5)); #endif } @@ -643,36 +648,44 @@ static void style_init(void) lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) { - /*This trick is required only to avoid the garbage collection of *styles' data if LVGL is used in a binding (e.g. Micropython) - *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ + *In a general case styles could be in a simple `static lv_style_t my_style...` variables*/ + if(!lv_theme_default_is_inited()) { - inited = false; - LV_GC_ROOT(_lv_theme_default_styles) = lv_malloc(sizeof(my_theme_styles_t)); - styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); + theme_def = (my_theme_t *)lv_malloc(sizeof(my_theme_t)); + lv_memzero(theme_def, sizeof(my_theme_t)); } - if(LV_HOR_RES <= 320) disp_size = DISP_SMALL; - else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM; - else disp_size = DISP_LARGE; + struct _my_theme_t * theme = theme_def; + if(LV_HOR_RES <= 320) theme->disp_size = DISP_SMALL; + else if(LV_HOR_RES < 720) theme->disp_size = DISP_MEDIUM; + else theme->disp_size = DISP_LARGE; - theme.disp = disp; - theme.color_primary = color_primary; - theme.color_secondary = color_secondary; - theme.font_small = font; - theme.font_normal = font; - theme.font_large = font; - theme.apply_cb = theme_apply; - theme.flags = dark ? MODE_DARK : 0; + theme->base.disp = disp; + theme->base.color_primary = color_primary; + theme->base.color_secondary = color_secondary; + theme->base.font_small = font; + theme->base.font_normal = font; + theme->base.font_large = font; + theme->base.apply_cb = theme_apply; + theme->base.flags = dark ? MODE_DARK : 0; - style_init(); + style_init(theme); - if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); + if(disp == NULL || lv_disp_get_theme(disp) == (lv_theme_t *)theme) lv_obj_report_style_change(NULL); - inited = true; + theme->inited = true; - return (lv_theme_t *)&theme; + return (lv_theme_t *) theme; +} + +void lv_theme_default_deinit(void) +{ + if(theme_def) { + lv_free(theme_def); + theme_def = NULL; + } } lv_theme_t * lv_theme_default_get(void) @@ -681,12 +694,14 @@ lv_theme_t * lv_theme_default_get(void) return NULL; } - return (lv_theme_t *)&theme; + return (lv_theme_t *)theme_def; } bool lv_theme_default_is_inited(void) { - return LV_GC_ROOT(_lv_theme_default_styles) == NULL ? false : true; + struct _my_theme_t * theme = theme_def; + if(theme == NULL) return false; + return theme->inited; } @@ -694,10 +709,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) { LV_UNUSED(th); + struct _my_theme_t * theme = theme_def; + if(lv_obj_get_parent(obj) == NULL) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); return; } @@ -710,9 +727,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) } /*Tabview pages*/ else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->pad_normal, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.pad_normal, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); return; } #endif @@ -720,16 +737,16 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_WIN /*Header*/ if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->bg_color_grey, 0); - lv_obj_add_style(obj, &styles->pad_tiny, 0); + lv_obj_add_style(obj, &theme->styles.bg_color_grey, 0); + lv_obj_add_style(obj, &theme->styles.pad_tiny, 0); return; } /*Content*/ else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->pad_normal, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.pad_normal, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); return; } #endif @@ -742,29 +759,29 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) } #endif - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); } #if LV_USE_BTN else if(lv_obj_check_type(obj, &lv_btn_class)) { - lv_obj_add_style(obj, &styles->btn, 0); - lv_obj_add_style(obj, &styles->bg_color_primary, 0); - lv_obj_add_style(obj, &styles->transition_delayed, 0); - lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.btn, 0); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, 0); + lv_obj_add_style(obj, &theme->styles.transition_delayed, 0); + lv_obj_add_style(obj, &theme->styles.pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); #if LV_THEME_DEFAULT_GROW - lv_obj_add_style(obj, &styles->grow, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.grow, LV_STATE_PRESSED); #endif - lv_obj_add_style(obj, &styles->bg_color_secondary, LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.bg_color_secondary, LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_STATE_DISABLED); #if LV_USE_MENU if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_menu_sidebar_header_cont_class) || lv_obj_check_type(lv_obj_get_parent(obj), &lv_menu_main_header_cont_class)) { - lv_obj_add_style(obj, &styles->menu_header_btn, 0); - lv_obj_add_style(obj, &styles->menu_pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.menu_header_btn, 0); + lv_obj_add_style(obj, &theme->styles.menu_pressed, LV_STATE_PRESSED); } #endif } @@ -772,7 +789,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_LINE else if(lv_obj_check_type(obj, &lv_line_class)) { - lv_obj_add_style(obj, &styles->line, 0); + lv_obj_add_style(obj, &theme->styles.line, 0); } #endif @@ -780,372 +797,372 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { #if LV_USE_MSGBOX if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->msgbox_btn_bg, 0); - lv_obj_add_style(obj, &styles->pad_gap, 0); - lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.msgbox_btn_bg, 0); + lv_obj_add_style(obj, &theme->styles.pad_gap, 0); + lv_obj_add_style(obj, &theme->styles.btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); return; } #endif #if LV_USE_TABVIEW if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->bg_color_white, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->tab_bg_focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->tab_btn, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->tab_bg_focus, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.bg_color_white, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.tab_bg_focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.tab_btn, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.tab_bg_focus, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); return; } #endif #if LV_USE_CALENDAR if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) { - lv_obj_add_style(obj, &styles->calendar_btnm_bg, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->calendar_btnm_day, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.calendar_btnm_bg, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.calendar_btnm_day, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); return; } #endif - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); } #endif #if LV_USE_BAR else if(lv_obj_check_type(obj, &lv_bar_class)) { - lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, 0); + lv_obj_add_style(obj, &theme->styles.circle, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.circle, LV_PART_INDICATOR); } #endif #if LV_USE_SLIDER else if(lv_obj_check_type(obj, &lv_slider_class)) { - lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, 0); + lv_obj_add_style(obj, &theme->styles.circle, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.knob, LV_PART_KNOB); #if LV_THEME_DEFAULT_GROW - lv_obj_add_style(obj, &styles->grow, LV_PART_KNOB | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.grow, LV_PART_KNOB | LV_STATE_PRESSED); #endif - lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_KNOB | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.transition_delayed, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_PART_KNOB | LV_STATE_PRESSED); } #endif #if LV_USE_TABLE else if(lv_obj_check_type(obj, &lv_table_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); - lv_obj_add_style(obj, &styles->no_radius, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->table_cell, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pad_normal, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_zero, 0); + lv_obj_add_style(obj, &theme->styles.no_radius, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.bg_color_white, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.table_cell, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pad_normal, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.bg_color_secondary, LV_PART_ITEMS | LV_STATE_EDITED); } #endif #if LV_USE_CHECKBOX else if(lv_obj_check_type(obj, &lv_checkbox_class)) { - lv_obj_add_style(obj, &styles->pad_gap, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->cb_marker, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->cb_marker_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->pressed, LV_PART_INDICATOR | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.pad_gap, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.cb_marker, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.cb_marker_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_INDICATOR | LV_STATE_PRESSED); #if LV_THEME_DEFAULT_GROW - lv_obj_add_style(obj, &styles->grow, LV_PART_INDICATOR | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.grow, LV_PART_INDICATOR | LV_STATE_PRESSED); #endif - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_PART_INDICATOR | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.transition_delayed, LV_PART_INDICATOR); } #endif #if LV_USE_SWITCH else if(lv_obj_check_type(obj, &lv_switch_class)) { - lv_obj_add_style(obj, &styles->bg_color_grey, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->anim_fast, 0); - lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->switch_knob, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->disabled, LV_PART_KNOB | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.bg_color_grey, 0); + lv_obj_add_style(obj, &theme->styles.circle, 0); + lv_obj_add_style(obj, &theme->styles.anim_fast, 0); + lv_obj_add_style(obj, &theme->styles.disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.knob, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.bg_color_white, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.switch_knob, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_KNOB | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_PART_INDICATOR); } #endif #if LV_USE_CHART else if(lv_obj_check_type(obj, &lv_chart_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->chart_bg, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->chart_series, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->chart_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->chart_ticks, LV_PART_TICKS); - lv_obj_add_style(obj, &styles->chart_series, LV_PART_CURSOR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_small, 0); + lv_obj_add_style(obj, &theme->styles.chart_bg, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.chart_series, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.chart_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.chart_ticks, LV_PART_TICKS); + lv_obj_add_style(obj, &theme->styles.chart_series, LV_PART_CURSOR); } #endif #if LV_USE_ROLLER else if(lv_obj_check_type(obj, &lv_roller_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->anim, 0); - lv_obj_add_style(obj, &styles->line_space_large, 0); - lv_obj_add_style(obj, &styles->text_align_center, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.anim, 0); + lv_obj_add_style(obj, &theme->styles.line_space_large, 0); + lv_obj_add_style(obj, &theme->styles.text_align_center, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_SELECTED); } #endif #if LV_USE_DROPDOWN else if(lv_obj_check_type(obj, &lv_dropdown_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->transition_delayed, 0); - lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_small, 0); + lv_obj_add_style(obj, &theme->styles.transition_delayed, 0); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.transition_normal, LV_PART_INDICATOR); } else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->clip_corner, 0); - lv_obj_add_style(obj, &styles->line_space_large, 0); - lv_obj_add_style(obj, &styles->dropdown_list, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_SELECTED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->pressed, LV_PART_SELECTED | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.clip_corner, 0); + lv_obj_add_style(obj, &theme->styles.line_space_large, 0); + lv_obj_add_style(obj, &theme->styles.dropdown_list, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.bg_color_white, LV_PART_SELECTED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_SELECTED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_SELECTED | LV_STATE_PRESSED); } #endif #if LV_USE_ARC else if(lv_obj_check_type(obj, &lv_arc_class)) { - lv_obj_add_style(obj, &styles->arc_indic, 0); - lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.arc_indic, 0); + lv_obj_add_style(obj, &theme->styles.arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.arc_indic_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.knob, LV_PART_KNOB); } #endif #if LV_USE_SPINNER else if(lv_obj_check_type(obj, &lv_spinner_class)) { - lv_obj_add_style(obj, &styles->arc_indic, 0); - lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.arc_indic, 0); + lv_obj_add_style(obj, &theme->styles.arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.arc_indic_primary, LV_PART_INDICATOR); } #endif //#if LV_USE_METER // else if(lv_obj_check_type(obj, &lv_meter_class)) { - // lv_obj_add_style(obj, &styles->card, 0); - // lv_obj_add_style(obj, &styles->circle, 0); - // lv_obj_add_style(obj, &styles->meter_indic, LV_PART_INDICATOR); + // lv_obj_add_style(obj, &theme->styles.card, 0); + // lv_obj_add_style(obj, &theme->styles.circle, 0); + // lv_obj_add_style(obj, &theme->styles.meter_indic, LV_PART_INDICATOR); // } //#endif #if LV_USE_TEXTAREA else if(lv_obj_check_type(obj, &lv_textarea_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); - lv_obj_add_style(obj, &styles->ta_placeholder, LV_PART_TEXTAREA_PLACEHOLDER); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_small, 0); + lv_obj_add_style(obj, &theme->styles.disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); + lv_obj_add_style(obj, &theme->styles.ta_placeholder, LV_PART_TEXTAREA_PLACEHOLDER); } #endif #if LV_USE_CALENDAR else if(lv_obj_check_type(obj, &lv_calendar_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_zero, 0); } #if LV_USE_CALENDAR_HEADER_ARROW else if(lv_obj_check_type(obj, &lv_calendar_header_arrow_class)) { - lv_obj_add_style(obj, &styles->calendar_header, 0); + lv_obj_add_style(obj, &theme->styles.calendar_header, 0); } #endif #if LV_USE_CALENDAR_HEADER_DROPDOWN else if(lv_obj_check_type(obj, &lv_calendar_header_dropdown_class)) { - lv_obj_add_style(obj, &styles->calendar_header, 0); + lv_obj_add_style(obj, &theme->styles.calendar_header, 0); } #endif #endif #if LV_USE_KEYBOARD else if(lv_obj_check_type(obj, &lv_keyboard_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, disp_size == DISP_LARGE ? &styles->pad_small : &styles->pad_tiny, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->keyboard_btn_bg, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, theme->disp_size == DISP_LARGE ? &theme->styles.pad_small : &theme->styles.pad_tiny, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.bg_color_white, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.keyboard_btn_bg, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); } #endif #if LV_USE_LIST else if(lv_obj_check_type(obj, &lv_list_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->list_bg, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.list_bg, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); return; } else if(lv_obj_check_type(obj, &lv_list_text_class)) { - lv_obj_add_style(obj, &styles->bg_color_grey, 0); - lv_obj_add_style(obj, &styles->list_item_grow, 0); + lv_obj_add_style(obj, &theme->styles.bg_color_grey, 0); + lv_obj_add_style(obj, &theme->styles.list_item_grow, 0); } else if(lv_obj_check_type(obj, &lv_list_btn_class)) { - lv_obj_add_style(obj, &styles->bg_color_white, 0); - lv_obj_add_style(obj, &styles->list_btn, 0); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.bg_color_white, 0); + lv_obj_add_style(obj, &theme->styles.list_btn, 0); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.list_item_grow, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.list_item_grow, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.pressed, LV_STATE_PRESSED); } #endif #if LV_USE_MENU else if(lv_obj_check_type(obj, &lv_menu_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->menu_bg, 0); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.menu_bg, 0); } else if(lv_obj_check_type(obj, &lv_menu_sidebar_cont_class)) { - lv_obj_add_style(obj, &styles->menu_sidebar_cont, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.menu_sidebar_cont, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); } else if(lv_obj_check_type(obj, &lv_menu_main_cont_class)) { - lv_obj_add_style(obj, &styles->menu_main_cont, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.menu_main_cont, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); } else if(lv_obj_check_type(obj, &lv_menu_cont_class)) { - lv_obj_add_style(obj, &styles->menu_cont, 0); - lv_obj_add_style(obj, &styles->menu_pressed, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_STATE_PRESSED | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.menu_cont, 0); + lv_obj_add_style(obj, &theme->styles.menu_pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, LV_STATE_PRESSED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary_muted, LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_STATE_FOCUS_KEY); } else if(lv_obj_check_type(obj, &lv_menu_sidebar_header_cont_class) || lv_obj_check_type(obj, &lv_menu_main_header_cont_class)) { - lv_obj_add_style(obj, &styles->menu_header_cont, 0); + lv_obj_add_style(obj, &theme->styles.menu_header_cont, 0); } else if(lv_obj_check_type(obj, &lv_menu_page_class)) { - lv_obj_add_style(obj, &styles->menu_page, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.menu_page, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); } else if(lv_obj_check_type(obj, &lv_menu_section_class)) { - lv_obj_add_style(obj, &styles->menu_section, 0); + lv_obj_add_style(obj, &theme->styles.menu_section, 0); } else if(lv_obj_check_type(obj, &lv_menu_separator_class)) { - lv_obj_add_style(obj, &styles->menu_separator, 0); + lv_obj_add_style(obj, &theme->styles.menu_separator, 0); } #endif #if LV_USE_MSGBOX else if(lv_obj_check_type(obj, &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->msgbox_bg, 0); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.msgbox_bg, 0); return; } else if(lv_obj_check_type(obj, &lv_msgbox_backdrop_class)) { - lv_obj_add_style(obj, &styles->msgbox_backdrop_bg, 0); + lv_obj_add_style(obj, &theme->styles.msgbox_backdrop_bg, 0); } #endif #if LV_USE_SPINBOX else if(lv_obj_check_type(obj, &lv_spinbox_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_CURSOR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_small, 0); + lv_obj_add_style(obj, &theme->styles.outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.bg_color_primary, LV_PART_CURSOR); } #endif #if LV_USE_TILEVIEW else if(lv_obj_check_type(obj, &lv_tileview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); } else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) { - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); } #endif #if LV_USE_TABVIEW else if(lv_obj_check_type(obj, &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.pad_zero, 0); } #endif #if LV_USE_WIN else if(lv_obj_check_type(obj, &lv_win_class)) { - lv_obj_add_style(obj, &styles->clip_corner, 0); + lv_obj_add_style(obj, &theme->styles.clip_corner, 0); } #endif #if LV_USE_LED else if(lv_obj_check_type(obj, &lv_led_class)) { - lv_obj_add_style(obj, &styles->led, 0); + lv_obj_add_style(obj, &theme->styles.led, 0); } #endif } @@ -1156,7 +1173,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(inited) { + if(theme_def->inited) { lv_style_reset(style); } else { diff --git a/src/themes/default/lv_theme_default.h b/src/themes/default/lv_theme_default.h index 769f941b5..afec672ae 100644 --- a/src/themes/default/lv_theme_default.h +++ b/src/themes/default/lv_theme_default.h @@ -53,6 +53,11 @@ lv_theme_t * lv_theme_default_get(void); */ bool lv_theme_default_is_inited(void); +/** + * Deinitialize the default theme + */ +void lv_theme_default_deinit(void); + /********************** * MACROS **********************/ diff --git a/src/themes/mono/lv_theme_mono.c b/src/themes/mono/lv_theme_mono.c index 9cee8a6f8..9998c3dc5 100644 --- a/src/themes/mono/lv_theme_mono.c +++ b/src/themes/mono/lv_theme_mono.c @@ -11,11 +11,12 @@ #if LV_USE_THEME_MONO #include "lv_theme_mono.h" -#include "../../misc/lv_gc.h" +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ +#define theme_def (LV_GLOBAL_DEFAULT()->theme_mono) #define COLOR_FG dark_bg ? lv_color_white() : lv_color_black() #define COLOR_BG dark_bg ? lv_color_black() : lv_color_white() @@ -55,6 +56,11 @@ typedef struct { #endif } my_theme_styles_t; +typedef struct _my_theme_t { + lv_theme_t base; + my_theme_styles_t styles; + bool inited; +} my_theme_t; /********************** * STATIC PROTOTYPES @@ -65,9 +71,6 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj); /********************** * STATIC VARIABLES **********************/ -static my_theme_styles_t * styles; -static lv_theme_t theme; -static bool inited; /********************** * MACROS @@ -77,144 +80,154 @@ static bool inited; * STATIC FUNCTIONS **********************/ -static void style_init(bool dark_bg, const lv_font_t * font) +static void style_init(struct _my_theme_t * theme, bool dark_bg, const lv_font_t * font) { - style_init_reset(&styles->scrollbar); - lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scrollbar, COLOR_FG); - lv_style_set_width(&styles->scrollbar, PAD_DEF); + style_init_reset(&theme->styles.scrollbar); + lv_style_set_bg_opa(&theme->styles.scrollbar, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.scrollbar, COLOR_FG); + lv_style_set_width(&theme->styles.scrollbar, PAD_DEF); - style_init_reset(&styles->scr); - lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scr, COLOR_BG); - lv_style_set_text_color(&styles->scr, COLOR_FG); - lv_style_set_pad_row(&styles->scr, PAD_DEF); - lv_style_set_pad_column(&styles->scr, PAD_DEF); - lv_style_set_text_font(&styles->scr, font); + style_init_reset(&theme->styles.scr); + lv_style_set_bg_opa(&theme->styles.scr, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.scr, COLOR_BG); + lv_style_set_text_color(&theme->styles.scr, COLOR_FG); + lv_style_set_pad_row(&theme->styles.scr, PAD_DEF); + lv_style_set_pad_column(&theme->styles.scr, PAD_DEF); + lv_style_set_text_font(&theme->styles.scr, font); - style_init_reset(&styles->card); - lv_style_set_bg_opa(&styles->card, LV_OPA_COVER); - lv_style_set_bg_color(&styles->card, COLOR_BG); - lv_style_set_border_color(&styles->card, COLOR_FG); - lv_style_set_radius(&styles->card, 2); - lv_style_set_border_width(&styles->card, BORDER_W_NORMAL); - lv_style_set_pad_all(&styles->card, PAD_DEF); - lv_style_set_pad_gap(&styles->card, PAD_DEF); - lv_style_set_text_color(&styles->card, COLOR_FG); - lv_style_set_line_width(&styles->card, 2); - lv_style_set_line_color(&styles->card, COLOR_FG); - lv_style_set_arc_width(&styles->card, 2); - lv_style_set_arc_color(&styles->card, COLOR_FG); - lv_style_set_outline_color(&styles->card, COLOR_FG); - lv_style_set_anim_time(&styles->card, 300); + style_init_reset(&theme->styles.card); + lv_style_set_bg_opa(&theme->styles.card, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.card, COLOR_BG); + lv_style_set_border_color(&theme->styles.card, COLOR_FG); + lv_style_set_radius(&theme->styles.card, 2); + lv_style_set_border_width(&theme->styles.card, BORDER_W_NORMAL); + lv_style_set_pad_all(&theme->styles.card, PAD_DEF); + lv_style_set_pad_gap(&theme->styles.card, PAD_DEF); + lv_style_set_text_color(&theme->styles.card, COLOR_FG); + lv_style_set_line_width(&theme->styles.card, 2); + lv_style_set_line_color(&theme->styles.card, COLOR_FG); + lv_style_set_arc_width(&theme->styles.card, 2); + lv_style_set_arc_color(&theme->styles.card, COLOR_FG); + lv_style_set_outline_color(&theme->styles.card, COLOR_FG); + lv_style_set_anim_time(&theme->styles.card, 300); - style_init_reset(&styles->pr); - lv_style_set_border_width(&styles->pr, BORDER_W_PR); + style_init_reset(&theme->styles.pr); + lv_style_set_border_width(&theme->styles.pr, BORDER_W_PR); - style_init_reset(&styles->inv); - lv_style_set_bg_opa(&styles->inv, LV_OPA_COVER); - lv_style_set_bg_color(&styles->inv, COLOR_FG); - lv_style_set_border_color(&styles->inv, COLOR_BG); - lv_style_set_line_color(&styles->inv, COLOR_BG); - lv_style_set_arc_color(&styles->inv, COLOR_BG); - lv_style_set_text_color(&styles->inv, COLOR_BG); - lv_style_set_outline_color(&styles->inv, COLOR_BG); + style_init_reset(&theme->styles.inv); + lv_style_set_bg_opa(&theme->styles.inv, LV_OPA_COVER); + lv_style_set_bg_color(&theme->styles.inv, COLOR_FG); + lv_style_set_border_color(&theme->styles.inv, COLOR_BG); + lv_style_set_line_color(&theme->styles.inv, COLOR_BG); + lv_style_set_arc_color(&theme->styles.inv, COLOR_BG); + lv_style_set_text_color(&theme->styles.inv, COLOR_BG); + lv_style_set_outline_color(&theme->styles.inv, COLOR_BG); - style_init_reset(&styles->disabled); - lv_style_set_border_width(&styles->disabled, BORDER_W_DIS); + style_init_reset(&theme->styles.disabled); + lv_style_set_border_width(&theme->styles.disabled, BORDER_W_DIS); - style_init_reset(&styles->focus); - lv_style_set_outline_width(&styles->focus, 1); - lv_style_set_outline_pad(&styles->focus, BORDER_W_FOCUS); + style_init_reset(&theme->styles.focus); + lv_style_set_outline_width(&theme->styles.focus, 1); + lv_style_set_outline_pad(&theme->styles.focus, BORDER_W_FOCUS); - style_init_reset(&styles->edit); - lv_style_set_outline_width(&styles->edit, BORDER_W_EDIT); + style_init_reset(&theme->styles.edit); + lv_style_set_outline_width(&theme->styles.edit, BORDER_W_EDIT); - style_init_reset(&styles->large_border); - lv_style_set_border_width(&styles->large_border, BORDER_W_EDIT); + style_init_reset(&theme->styles.large_border); + lv_style_set_border_width(&theme->styles.large_border, BORDER_W_EDIT); - style_init_reset(&styles->pad_gap); - lv_style_set_pad_gap(&styles->pad_gap, PAD_DEF); + style_init_reset(&theme->styles.pad_gap); + lv_style_set_pad_gap(&theme->styles.pad_gap, PAD_DEF); - style_init_reset(&styles->pad_zero); - lv_style_set_pad_all(&styles->pad_zero, 0); - lv_style_set_pad_gap(&styles->pad_zero, 0); + style_init_reset(&theme->styles.pad_zero); + lv_style_set_pad_all(&theme->styles.pad_zero, 0); + lv_style_set_pad_gap(&theme->styles.pad_zero, 0); - style_init_reset(&styles->no_radius); - lv_style_set_radius(&styles->no_radius, 0); + style_init_reset(&theme->styles.no_radius); + lv_style_set_radius(&theme->styles.no_radius, 0); - style_init_reset(&styles->radius_circle); - lv_style_set_radius(&styles->radius_circle, LV_RADIUS_CIRCLE); + style_init_reset(&theme->styles.radius_circle); + lv_style_set_radius(&theme->styles.radius_circle, LV_RADIUS_CIRCLE); - style_init_reset(&styles->large_line_space); - lv_style_set_text_line_space(&styles->large_line_space, 6); + style_init_reset(&theme->styles.large_line_space); + lv_style_set_text_line_space(&theme->styles.large_line_space, 6); - style_init_reset(&styles->underline); - lv_style_set_text_decor(&styles->underline, LV_TEXT_DECOR_UNDERLINE); + style_init_reset(&theme->styles.underline); + lv_style_set_text_decor(&theme->styles.underline, LV_TEXT_DECOR_UNDERLINE); #if LV_USE_TEXTAREA - style_init_reset(&styles->ta_cursor); - lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT); - lv_style_set_border_color(&styles->ta_cursor, COLOR_FG); - lv_style_set_border_width(&styles->ta_cursor, 2); - lv_style_set_bg_opa(&styles->ta_cursor, LV_OPA_TRANSP); - lv_style_set_anim_time(&styles->ta_cursor, 500); + style_init_reset(&theme->styles.ta_cursor); + lv_style_set_border_side(&theme->styles.ta_cursor, LV_BORDER_SIDE_LEFT); + lv_style_set_border_color(&theme->styles.ta_cursor, COLOR_FG); + lv_style_set_border_width(&theme->styles.ta_cursor, 2); + lv_style_set_bg_opa(&theme->styles.ta_cursor, LV_OPA_TRANSP); + lv_style_set_anim_time(&theme->styles.ta_cursor, 500); #endif #if LV_USE_CHART - style_init_reset(&styles->chart_indic); - lv_style_set_radius(&styles->chart_indic, LV_RADIUS_CIRCLE); - lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8), lv_disp_dpx(theme.disp, 8)); - lv_style_set_bg_color(&styles->chart_indic, COLOR_FG); - lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER); + style_init_reset(&theme->styles.chart_indic); + lv_style_set_radius(&theme->styles.chart_indic, LV_RADIUS_CIRCLE); + lv_style_set_size(&theme->styles.chart_indic, lv_disp_dpx(theme->base.disp, 8), lv_disp_dpx(theme->base.disp, 8)); + lv_style_set_bg_color(&theme->styles.chart_indic, COLOR_FG); + lv_style_set_bg_opa(&theme->styles.chart_indic, LV_OPA_COVER); #endif } - /********************** * GLOBAL FUNCTIONS **********************/ bool lv_theme_mono_is_inited(void) { - return LV_GC_ROOT(_lv_theme_default_styles) == NULL ? false : true; + struct _my_theme_t * theme = theme_def; + if(theme == NULL) return false; + return theme->inited; +} + +void lv_theme_mono_deinit(void) +{ + if(theme_def) { + lv_free(theme_def); + theme_def = NULL; + } } lv_theme_t * lv_theme_mono_init(lv_disp_t * disp, bool dark_bg, const lv_font_t * font) { - /*This trick is required only to avoid the garbage collection of *styles' data if LVGL is used in a binding (e.g. Micropython) *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ - if(!inited) { - inited = false; - LV_GC_ROOT(_lv_theme_default_styles) = lv_malloc(sizeof(my_theme_styles_t)); - styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); + if(!lv_theme_mono_is_inited()) { + theme_def = (my_theme_t *)lv_malloc(sizeof(my_theme_styles_t)); + lv_memzero(theme_def, sizeof(my_theme_t)); } - theme.disp = disp; - theme.font_small = LV_FONT_DEFAULT; - theme.font_normal = LV_FONT_DEFAULT; - theme.font_large = LV_FONT_DEFAULT; - theme.apply_cb = theme_apply; + struct _my_theme_t * theme = theme_def; - style_init(dark_bg, font); + theme->base.disp = disp; + theme->base.font_small = LV_FONT_DEFAULT; + theme->base.font_normal = LV_FONT_DEFAULT; + theme->base.font_large = LV_FONT_DEFAULT; + theme->base.apply_cb = theme_apply; - if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); + style_init(theme, dark_bg, font); - inited = true; + if(disp == NULL || lv_disp_get_theme(disp) == (lv_theme_t *) theme) lv_obj_report_style_change(NULL); - return (lv_theme_t *)&theme; + theme->inited = true; + + return (lv_theme_t *)theme_def; } - static void theme_apply(lv_theme_t * th, lv_obj_t * obj) { LV_UNUSED(th); + struct _my_theme_t * theme = theme_def; + if(lv_obj_get_parent(obj) == NULL) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } @@ -227,9 +240,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) } /*Tabview pages*/ else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->no_radius, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.no_radius, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } #endif @@ -237,29 +250,29 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_WIN /*Header*/ if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->no_radius, 0); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.no_radius, 0); return; } /*Content*/ else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->no_radius, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.no_radius, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } #endif - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); } #if LV_USE_BTN else if(lv_obj_check_type(obj, &lv_btn_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pr, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->inv, LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.inv, LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif @@ -267,234 +280,234 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { #if LV_USE_MSGBOX if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->pad_gap, 0); - lv_obj_add_style(obj, &styles->card, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pr, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.pad_gap, 0); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); return; } #endif #if LV_USE_TABVIEW if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->pad_gap, 0); - lv_obj_add_style(obj, &styles->card, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pr, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->inv, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.pad_gap, 0); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); return; } #endif - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->card, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pr, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->inv, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); } #endif #if LV_USE_BAR else if(lv_obj_check_type(obj, &lv_bar_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); - lv_obj_add_style(obj, &styles->inv, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_zero, 0); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); } #endif #if LV_USE_SLIDER else if(lv_obj_check_type(obj, &lv_slider_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); - lv_obj_add_style(obj, &styles->inv, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->card, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->radius_circle, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pad_zero, 0); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_TABLE else if(lv_obj_check_type(obj, &lv_table_class)) { - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->card, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->no_radius, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pr, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->inv, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.no_radius, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_CHECKBOX else if(lv_obj_check_type(obj, &lv_checkbox_class)) { - lv_obj_add_style(obj, &styles->pad_gap, LV_PART_MAIN); - lv_obj_add_style(obj, &styles->card, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->inv, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->pr, LV_PART_INDICATOR | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.pad_gap, LV_PART_MAIN); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_INDICATOR | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_SWITCH else if(lv_obj_check_type(obj, &lv_switch_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->radius_circle, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); - lv_obj_add_style(obj, &styles->inv, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->radius_circle, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->card, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->radius_circle, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->pad_zero, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.radius_circle, 0); + lv_obj_add_style(obj, &theme->styles.pad_zero, 0); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.pad_zero, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_CHART else if(lv_obj_check_type(obj, &lv_chart_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->chart_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->card, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->card, LV_PART_TICKS); - lv_obj_add_style(obj, &styles->card, LV_PART_CURSOR); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.chart_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_TICKS); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_CURSOR); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); } #endif #if LV_USE_ROLLER else if(lv_obj_check_type(obj, &lv_roller_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->large_line_space, 0); - lv_obj_add_style(obj, &styles->inv, LV_PART_SELECTED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.large_line_space, 0); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_SELECTED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_DROPDOWN else if(lv_obj_check_type(obj, &lv_dropdown_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pr, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->large_line_space, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->inv, LV_PART_SELECTED | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->pr, LV_PART_SELECTED | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.large_line_space, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_SELECTED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_SELECTED | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_ARC else if(lv_obj_check_type(obj, &lv_arc_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->inv, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->pad_zero, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->card, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->radius_circle, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.pad_zero, LV_PART_INDICATOR); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.radius_circle, LV_PART_KNOB); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif //#if LV_USE_METER // else if(lv_obj_check_type(obj, &lv_meter_class)) { - // lv_obj_add_style(obj, &styles->card, 0); + // lv_obj_add_style(obj, &theme->styles.card, 0); // } //#endif #if LV_USE_TEXTAREA else if(lv_obj_check_type(obj, &lv_textarea_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUSED); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUSED); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_CALENDAR else if(lv_obj_check_type(obj, &lv_calendar_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->no_radius, 0); - lv_obj_add_style(obj, &styles->pr, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.no_radius, 0); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); } #endif #if LV_USE_KEYBOARD else if(lv_obj_check_type(obj, &lv_keyboard_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->card, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pr, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->inv, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.card, LV_PART_ITEMS); + lv_obj_add_style(obj, &theme->styles.pr, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.large_border, LV_PART_ITEMS | LV_STATE_EDITED); } #endif #if LV_USE_LIST else if(lv_obj_check_type(obj, &lv_list_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); return; } else if(lv_obj_check_type(obj, &lv_list_text_class)) { } else if(lv_obj_check_type(obj, &lv_list_btn_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pr, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->large_border, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.pr, LV_STATE_PRESSED); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.large_border, LV_STATE_EDITED); } #endif #if LV_USE_MSGBOX else if(lv_obj_check_type(obj, &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &theme->styles.card, 0); return; } #endif #if LV_USE_SPINBOX else if(lv_obj_check_type(obj, &lv_spinbox_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->inv, LV_PART_CURSOR); - lv_obj_add_style(obj, &styles->focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->edit, LV_STATE_EDITED); + lv_obj_add_style(obj, &theme->styles.card, 0); + lv_obj_add_style(obj, &theme->styles.inv, LV_PART_CURSOR); + lv_obj_add_style(obj, &theme->styles.focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &theme->styles.edit, LV_STATE_EDITED); } #endif #if LV_USE_TILEVIEW else if(lv_obj_check_type(obj, &lv_tileview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); } else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) { - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); } #endif #if LV_USE_LED else if(lv_obj_check_type(obj, &lv_led_class)) { - lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &theme->styles.card, 0); } #endif } @@ -505,7 +518,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(inited) { + if(lv_theme_mono_is_inited()) { lv_style_reset(style); } else { diff --git a/src/themes/mono/lv_theme_mono.h b/src/themes/mono/lv_theme_mono.h index 74a8ae161..642d1ee77 100644 --- a/src/themes/mono/lv_theme_mono.h +++ b/src/themes/mono/lv_theme_mono.h @@ -44,6 +44,11 @@ lv_theme_t * lv_theme_mono_init(lv_disp_t * disp, bool dark_bg, const lv_font_t */ bool lv_theme_mono_is_inited(void); +/** + * Deinitialize the mono theme + */ +void lv_theme_mono_deinit(void); + /********************** * MACROS **********************/ diff --git a/src/tick/lv_tick.c b/src/tick/lv_tick.c index e9fbe6ea1..8f674d994 100644 --- a/src/tick/lv_tick.c +++ b/src/tick/lv_tick.c @@ -8,14 +8,12 @@ *********************/ #include "lv_tick.h" #include - -#if LV_TICK_CUSTOM == 1 - #include LV_TICK_CUSTOM_INCLUDE -#endif +#include "../core/lv_global.h" /********************* * DEFINES *********************/ +#define state LV_GLOBAL_DEFAULT()->tick_state /********************** * TYPEDEFS @@ -28,10 +26,6 @@ /********************** * STATIC VARIABLES **********************/ -#if !LV_TICK_CUSTOM - static uint32_t sys_time = 0; - static volatile uint8_t tick_irq_flag; -#endif /********************** * MACROS @@ -41,17 +35,17 @@ * GLOBAL FUNCTIONS **********************/ -#if !LV_TICK_CUSTOM /** * You have to call this function periodically * @param tick_period the call period of this function in milliseconds */ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) { - tick_irq_flag = 0; - sys_time += tick_period; + lv_tick_state_t * state_p = &state; + + state_p->sys_irq_flag = 0; + state_p->sys_time += tick_period; } -#endif /** * Get the elapsed milliseconds since start up @@ -59,7 +53,10 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) */ uint32_t lv_tick_get(void) { -#if LV_TICK_CUSTOM == 0 + lv_tick_state_t * state_p = &state; + + if(state_p->tick_get_cb) + return state_p->tick_get_cb(); /*If `lv_tick_inc` is called from an interrupt while `sys_time` is read *the result might be corrupted. @@ -68,14 +65,11 @@ uint32_t lv_tick_get(void) *until `tick_irq_flag` remains `1`.*/ uint32_t result; do { - tick_irq_flag = 1; - result = sys_time; - } while(!tick_irq_flag); /*Continue until see a non interrupted cycle*/ + state_p->sys_irq_flag = 1; + result = state_p->sys_time; + } while(!state_p->sys_irq_flag); /*Continue until see a non interrupted cycle*/ return result; -#else - return LV_TICK_CUSTOM_SYS_TIME_EXPR; -#endif } /** @@ -99,6 +93,11 @@ uint32_t lv_tick_elaps(uint32_t prev_tick) return prev_tick; } +void lv_tick_set_cb(lv_tick_get_cb_t cb) +{ + state.tick_get_cb = cb; +} + /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/tick/lv_tick.h b/src/tick/lv_tick.h index 949f56b83..10b468f23 100644 --- a/src/tick/lv_tick.h +++ b/src/tick/lv_tick.h @@ -28,22 +28,23 @@ extern "C" { /********************** * TYPEDEFS **********************/ +typedef uint32_t (*lv_tick_get_cb_t)(void); + +typedef struct { + uint32_t sys_time; + volatile uint8_t sys_irq_flag; + lv_tick_get_cb_t tick_get_cb; +} lv_tick_state_t; /********************** * GLOBAL PROTOTYPES **********************/ -//! @cond Doxygen_Suppress - -#if !LV_TICK_CUSTOM /** * You have to call this function periodically * @param tick_period the call period of this function in milliseconds */ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); -#endif - -//! @endcond /** * Get the elapsed milliseconds since start up @@ -58,6 +59,12 @@ uint32_t lv_tick_get(void); */ uint32_t lv_tick_elaps(uint32_t prev_tick); +/** + * Set the custom callback for 'lv_tick_get' + * @param cb call this callback on 'lv_tick_get' + */ +void lv_tick_set_cb(lv_tick_get_cb_t cb); + /********************** * MACROS **********************/ diff --git a/src/widgets/btnmatrix/lv_btnmatrix.c b/src/widgets/btnmatrix/lv_btnmatrix.c index 773ceeec5..c3669e31d 100644 --- a/src/widgets/btnmatrix/lv_btnmatrix.c +++ b/src/widgets/btnmatrix/lv_btnmatrix.c @@ -545,8 +545,9 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) } } else if(code == LV_EVENT_DEFOCUSED || code == LV_EVENT_LEAVE) { - if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, btnm->btn_id_sel); - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + // TODO + // if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, btnm->btn_id_sel); + // btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; } else if(code == LV_EVENT_KEY) { diff --git a/src/widgets/menu/lv_menu.c b/src/widgets/menu/lv_menu.c index 5c2821102..7106cfc87 100644 --- a/src/widgets/menu/lv_menu.c +++ b/src/widgets/menu/lv_menu.c @@ -16,7 +16,7 @@ #define MY_CLASS &lv_menu_class #include "../../core/lv_obj.h" -#include "../../layouts/flex/lv_flex.h" +#include "../../layouts/lv_layout.h" #include "../../stdlib/lv_string.h" #include "../label/lv_label.h" #include "../btn/lv_btn.h" diff --git a/src/widgets/span/lv_span.c b/src/widgets/span/lv_span.c index f771db80d..61b39bbe2 100644 --- a/src/widgets/span/lv_span.c +++ b/src/widgets/span/lv_span.c @@ -11,11 +11,13 @@ #if LV_USE_SPAN != 0 #include "../../misc/lv_assert.h" +#include "../../core/lv_global.h" /********************* * DEFINES *********************/ #define MY_CLASS &lv_spangroup_class +#define snippet_stack LV_GLOBAL_DEFAULT()->span_snippet_stack /********************** * TYPEDEFS @@ -66,7 +68,6 @@ static lv_coord_t convert_indent_pct(lv_obj_t * spans, lv_coord_t width); /********************** * STATIC VARIABLES **********************/ -static struct _snippet_stack snippet_stack; const lv_obj_class_t lv_spangroup_class = { .base_class = &lv_obj_class, @@ -85,6 +86,19 @@ const lv_obj_class_t lv_spangroup_class = { /********************** * GLOBAL FUNCTIONS **********************/ +void lv_span_stack_init(void) +{ + struct _snippet_stack * stack = snippet_stack = lv_malloc(sizeof(struct _snippet_stack)); + LV_ASSERT_MALLOC(stack); + if(!stack) { + LV_LOG_ERROR("malloc failed for snippet_stack"); + } +} + +void lv_span_stack_deinit(void) +{ + lv_free(snippet_stack); +} lv_obj_t * lv_spangroup_create(lv_obj_t * par) { @@ -637,9 +651,10 @@ static bool lv_txt_get_snippet(const char * txt, const lv_font_t * font, static void lv_snippet_push(lv_snippet_t * item) { - if(snippet_stack.index < LV_SPAN_SNIPPET_STACK_SIZE) { - memcpy(&snippet_stack.stack[snippet_stack.index], item, sizeof(lv_snippet_t)); - snippet_stack.index++; + struct _snippet_stack * stack_p = snippet_stack; + if(stack_p->index < LV_SPAN_SNIPPET_STACK_SIZE) { + memcpy(&stack_p->stack[stack_p->index], item, sizeof(lv_snippet_t)); + stack_p->index++; } else { LV_LOG_ERROR("span draw stack overflow, please set LV_SPAN_SNIPPET_STACK_SIZE too larger"); @@ -648,17 +663,17 @@ static void lv_snippet_push(lv_snippet_t * item) static uint16_t lv_get_snippet_cnt(void) { - return snippet_stack.index; + return snippet_stack->index; } static lv_snippet_t * lv_get_snippet(uint16_t index) { - return &snippet_stack.stack[index]; + return &snippet_stack->stack[index]; } static void lv_snippet_clear(void) { - snippet_stack.index = 0; + snippet_stack->index = 0; } static const lv_font_t * lv_span_get_style_text_font(lv_obj_t * par, lv_span_t * span) diff --git a/src/widgets/span/lv_span.h b/src/widgets/span/lv_span.h index 10f48284e..88ad6c0f4 100644 --- a/src/widgets/span/lv_span.h +++ b/src/widgets/span/lv_span.h @@ -77,6 +77,9 @@ extern const lv_obj_class_t lv_spangroup_class; * GLOBAL PROTOTYPES **********************/ +void lv_span_stack_init(void); +void lv_span_stack_deinit(void); + /** * Create a spangroup object * @param par pointer to an object, it will be the parent of the new spangroup diff --git a/src/widgets/spinner/lv_spinner.c b/src/widgets/spinner/lv_spinner.c index 257c898c0..4d1e1f69d 100644 --- a/src/widgets/spinner/lv_spinner.c +++ b/src/widgets/spinner/lv_spinner.c @@ -12,6 +12,8 @@ /********************* * DEFINES *********************/ +#define DEF_ARC_ANGLE 200 +#define DEF_TIME 1000 /********************** * TYPEDEFS @@ -32,9 +34,6 @@ const lv_obj_class_t lv_spinner_class = { .constructor_cb = lv_spinner_constructor }; -static uint32_t time_param; -static uint32_t arc_length_param; - /********************** * MACROS **********************/ @@ -43,15 +42,8 @@ static uint32_t arc_length_param; * GLOBAL FUNCTIONS **********************/ -/** - * Create a spinner object - * @param parent pointer to an object, it will be the parent of the new spinner - * @return pointer to the created spinner - */ -lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length) +lv_obj_t * lv_spinner_create(lv_obj_t * parent) { - time_param = time; - arc_length_param = arc_length; lv_obj_t * obj = lv_obj_class_create_obj(&lv_spinner_class, parent); lv_obj_class_init_obj(obj); @@ -59,6 +51,31 @@ lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_leng } +void lv_spinner_set_anim_params(lv_obj_t * obj, uint32_t t, uint32_t angle) +{ + /*Delete the current animation*/ + lv_anim_del(obj, NULL); + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, obj); + lv_anim_set_exec_cb(&a, arc_anim_end_angle); + lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); + lv_anim_set_time(&a, t); + lv_anim_set_values(&a, angle, 360 + angle); + lv_anim_start(&a); + + lv_anim_set_path_cb(&a, lv_anim_path_custom_bezier3); + lv_anim_set_bezier3_param(&a, LV_BEZIER_VAL_FLOAT(0.42), LV_BEZIER_VAL_FLOAT(0.58), + LV_BEZIER_VAL_FLOAT(0), LV_BEZIER_VAL_FLOAT(1)); + lv_anim_set_values(&a, 0, 360); + lv_anim_set_exec_cb(&a, arc_anim_start_angle); + lv_anim_start(&a); + + lv_arc_set_bg_angles(obj, 0, 360); + lv_arc_set_rotation(obj, 270); +} + /********************** * STATIC FUNCTIONS **********************/ @@ -71,24 +88,7 @@ static void lv_spinner_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, obj); - lv_anim_set_exec_cb(&a, arc_anim_end_angle); - lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); - lv_anim_set_time(&a, time_param); - lv_anim_set_values(&a, arc_length_param, 360 + arc_length_param); - lv_anim_start(&a); - - lv_anim_set_path_cb(&a, lv_anim_path_custom_bezier3); - lv_anim_set_bezier3_param(&a, LV_BEZIER_VAL_FLOAT(0.42), LV_BEZIER_VAL_FLOAT(0.58), - LV_BEZIER_VAL_FLOAT(0), LV_BEZIER_VAL_FLOAT(1)); - lv_anim_set_values(&a, 0, 360); - lv_anim_set_exec_cb(&a, arc_anim_start_angle); - lv_anim_start(&a); - - lv_arc_set_bg_angles(obj, 0, 360); - lv_arc_set_rotation(obj, 270); + lv_spinner_set_anim_params(obj, DEF_TIME, DEF_ARC_ANGLE); } diff --git a/src/widgets/spinner/lv_spinner.h b/src/widgets/spinner/lv_spinner.h index 2ab36f64d..b9c018103 100644 --- a/src/widgets/spinner/lv_spinner.h +++ b/src/widgets/spinner/lv_spinner.h @@ -35,7 +35,10 @@ extern const lv_obj_class_t lv_spinner_class; * GLOBAL PROTOTYPES **********************/ -lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length); +lv_obj_t * lv_spinner_create(lv_obj_t * parent); + + +void lv_spinner_set_anim_params(lv_obj_t * obj, uint32_t t, uint32_t angle); /********************** * MACROS diff --git a/src/widgets/tileview/lv_tileview.c b/src/widgets/tileview/lv_tileview.c index 2f5da553f..393867753 100644 --- a/src/widgets/tileview/lv_tileview.c +++ b/src/widgets/tileview/lv_tileview.c @@ -40,10 +40,6 @@ const lv_obj_class_t lv_tileview_tile_class = {.constructor_cb = lv_tileview_til .instance_size = sizeof(lv_tileview_tile_t) }; -static lv_dir_t create_dir; -static uint32_t create_col_id; -static uint32_t create_row_id; - /********************** * MACROS **********************/ @@ -67,12 +63,18 @@ lv_obj_t * lv_tileview_create(lv_obj_t * parent) lv_obj_t * lv_tileview_add_tile(lv_obj_t * tv, uint8_t col_id, uint8_t row_id, lv_dir_t dir) { LV_LOG_INFO("begin"); - create_dir = dir; - create_col_id = col_id; - create_row_id = row_id; lv_obj_t * obj = lv_obj_class_create_obj(&lv_tileview_tile_class, tv); lv_obj_class_init_obj(obj); + lv_obj_set_pos(obj, col_id * lv_obj_get_content_width(tv), + row_id * lv_obj_get_content_height(tv)); + + lv_tileview_tile_t * tile = (lv_tileview_tile_t *)obj; + tile->dir = dir; + + if(col_id == 0 && row_id == 0) { + lv_obj_set_scroll_dir(tv, dir); + } return obj; } @@ -138,18 +140,8 @@ static void lv_tileview_tile_constructor(const lv_obj_class_t * class_p, lv_obj_ { LV_UNUSED(class_p); - lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_set_size(obj, LV_PCT(100), LV_PCT(100)); lv_obj_update_layout(obj); /*Be sure the size is correct*/ - lv_obj_set_pos(obj, create_col_id * lv_obj_get_content_width(parent), - create_row_id * lv_obj_get_content_height(parent)); - - lv_tileview_tile_t * tile = (lv_tileview_tile_t *)obj; - tile->dir = create_dir; - - if(create_col_id == 0 && create_row_id == 0) { - lv_obj_set_scroll_dir(parent, create_dir); - } } static void tileview_event_cb(lv_event_t * e) diff --git a/src/widgets/win/lv_win.c b/src/widgets/win/lv_win.c index 92c3b8baa..1c8ab6b2e 100644 --- a/src/widgets/win/lv_win.c +++ b/src/widgets/win/lv_win.c @@ -33,7 +33,6 @@ const lv_obj_class_t lv_win_class = { .base_class = &lv_obj_class, .instance_size = sizeof(lv_win_t) }; -static lv_coord_t create_header_height; /********************** * MACROS **********************/ @@ -42,11 +41,9 @@ static lv_coord_t create_header_height; * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_win_create(lv_obj_t * parent, lv_coord_t header_height) +lv_obj_t * lv_win_create(lv_obj_t * parent) { LV_LOG_INFO("begin"); - create_header_height = header_height; - lv_obj_t * obj = lv_obj_class_create_obj(&lv_win_class, parent); lv_obj_class_init_obj(obj); return obj; @@ -97,7 +94,7 @@ static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN); lv_obj_t * header = lv_obj_create(obj); - lv_obj_set_size(header, LV_PCT(100), create_header_height); + lv_obj_set_size(header, LV_PCT(100), lv_disp_get_dpi(lv_obj_get_disp(obj)) / 2); lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(header, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); diff --git a/src/widgets/win/lv_win.h b/src/widgets/win/lv_win.h index 4342b3104..c67ce8afc 100644 --- a/src/widgets/win/lv_win.h +++ b/src/widgets/win/lv_win.h @@ -32,7 +32,7 @@ extern const lv_obj_class_t lv_win_class; * GLOBAL PROTOTYPES **********************/ -lv_obj_t * lv_win_create(lv_obj_t * parent, lv_coord_t header_height); +lv_obj_t * lv_win_create(lv_obj_t * parent); lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt); diff --git a/tests/ref_imgs/win_01.png b/tests/ref_imgs/win_01.png index ef22e6821ed3f18db7e04874888cc12d85921769..745b176f5a1354952da74eb67d6d0c5c8ddfadec 100644 GIT binary patch literal 3173 zcmeH~|5wsi7{@Q*#-^q%Pmy`bT%I~RrPdhW(UjFJ=S=KmJ7!71T=vC@N(G4Dw}r=J z(sq_MQ~FekT#F$dOGQOUXUpe$c)M6}E* zwDlD8Wp-=I2e}7tCEjpZMZVE|?Z`>5o@<|tZ|vFQcy^nPvfm*(JY`jBz?qMBKXO@p zPw>UNxhJ-N>4m%Jy?4e}f(^@^-2XUSi$k6a+#&E&rbfVhCn)v%!HwplL zP+$-M!}LvJ0KP&xfsLDA>6iw)vY?n^j-k7sK;#FVJ;~8doT-WXB*WNgi-uB@ZN=zE zp6kf2YIi_wyjhj%(rbZcQnk{~Jg3U)RK<4ZCO33%mT}<$%d-ZblYjtEt5zQ>=a**L zzU$O^8gPn?<62CpZ{z~3fL-Q;oXj_B1a2nTStk8JTEi$hS7e>f^D{*}5xIj;E#-5xS2;VZTzI7V~(y;_5;UiMV43(V7f&B?v##l@gko!nzRH@y3rIpCS^-g-8 zAF>amtOD}&BV5hggS5KqBE0Um9RLsr!Qu|#zKGEfZelXunFjZUFUTJveTl>_2#yu zBO@8U2z}X8)fk&y=-@fZ*?205WGl(@z0$8O-`3K@6>MQZHwhRl~27$C~jQ=&vWra zV-)?#!nF%~f9d=;fW;d6awc1ff{XQ+D|kK`bFhWQVgrL50QCr+?b6%T)m7PcoX6{k zWVG7@0s`z)bHxIIfX_z&aR$LzD3M5-o14cx7n9K*ljGx7gKI`jO^rW+P#xs~0A1Nm zVi4K-;koB#j4P!2QQ>$2UgU`;s?9Ryx?!ikc?smWsIo|?p%p4WD&pu>W8`91A8Fw!2 zX9%JkK0G(D8YJhc=+s12U*Dmam>4pdOrgk_y2CYbiYq~tm6d6x>GcJBNnZmneWH5J zAppL47O(!$0StSrgpD0J?|_wVaHrx{VPPSE2!Q116!aSf=1l;WJ^x!dUaif`LM;pR m+H<{(#4-}gNWAs8z>X|c<|e`B%w$sWq{5& zDM}2B2$T^4ML@z9q~Zodgn+CeVt_y*!4N_qOJh4a+E4uf`F8Gm@66me_ni0Ur62Y_ zXkuh#1OO&p-?;w(V6YhgF}4P&TX`OmcOAgk&dYt@k%ViKk(La;9Px0DD{Kr_<|aIj z`7G^7S;P&~wLv!?6b78x(pz|7YICoL(K&lb@ZlA{_?WfV_L8>k?>AlFTKw&*w9xHG zx9n=&>N)FJkMT;IIXn~*kRPlZf(`kdygNDIBiBF4=gL00!X@1P?1;zX+C<#Xi0h%Fm zZ~{k|r8ZA86rO0uj?oER+je6gYl4|)=@k9T@)-v zuywtQAPosBZS9(Jr@pit?_q7GUCguRE4{8KB(? zMW8NEc3dKdpE37Ff<>5)#wLXY7h(_%(QAQ27&i!$`zvuN=|Ou8foR{40{Cmi2Kf3A z5%Dhwzn)w}U0BL)k(BR+=p1GsQIg-Jnar1{)!7@8)OR=D(v4x@5;Cm1Vp9_Ff(1R_ zW!lpY#v+~5IZIqNJ3%=Z7ghe}0%QiUDU?WV4k(O&9rQn!uxx4eR(*e`fGVjw$K zy*Q5HHr+0H%juM`WilSQ<$`>qGO{Pb0K})7#g?$ywhG`U2hXV!QF{IbN|Q4myhljA2jWFJ#PfG2ul>9sC#O$ zFx%EeXq$yv3jNYb@@@lz!DQRqO9~fVHmtOqdGQ>rt6VXd>Yf7twL-dr=-}XhYoJU_ zO{uo_t163%WL(F5KY#zh0ZV`(avLX?$qWb#q-YAw$W^zqvbx-~&(bn7GUDRmur&x6 zJ2oP=RivyobDYhm&PmH`l)-}A#XiSfC}+=WRjnzj(OMGFqQa-=MLoNfa^6i}E(=@7 zW-n#eq`Kv)`ySV**S#S9EOZaW>^v;?8SR(TX5K-iQVLL`+O~qAze*p#jOejN2G? zzOKvS>ZdtQ{C~13lgaRSe3x#Vvp6SwjEp0Tyir~*{sD)I$_aCG2-=wmDSxr0!@jMZaB_lyV_HdE! zlmCg_4XkHDfSd-ELm(ovleQA-91b1iVZqNggtzwrKgaQ;Lk2<$#*#6Jdz9?P|IZ0i z$&)stG!|}&7dA>Sw#BZEOXo@z;(sU27qEuwXd+s!Y)dy(ud3l_YakP$feDk%FgVYb zMicThVem+I6f-M;^QEAU_zKn*D|@=(Y17wE5K}=ki~2}8f1&^K<;%9%RmoS#+ISm2 zBqT&Itf;K6s;0&l?wW?0n!a_!v#%^2#|AXZ>YM$YX13;>CpW!+C8v~z*tG3&2BWy3M8>ToLlYAd4PA=<4uO=4C&2=9 zR8LQjlCtuZ4s|uPjNg9S3GP)MmER(E`G~sHn#B^74+34x=DXAvX#@g`0k&%)0_4NT)Slfe*dHUOe4SG5`IiXN|*m=vx`ffi~2{; zZ3}d4Y-|`97AA=L)RS>Iy=9BsAynd5Z=oBp_)OeAreF1=be`GRne)Zug{@j zLcP7clk%6@&5_b=ek9CO@`6rxLDd6Qx&9MyX@6y2nUT7Lu{p7WV44PQFM;y`Sj+~- zIDI0{D<==5@^dvzN)(V>PW-PNJC(8adCLN zXnt9yE#ULD9q&)SNj>3r|HSS!$t2>MRKi9>jZx&@?agTs7)PXKcyd@4Y_TM1mk+JC zk-}P$AbE_fOa!$o0s{m6JKVJ#=W>3k$p6q5?ywj%vd0yf8^&&Gc=ZY!wQG&?g@96# zgAfbXz?qEmIxTrqQ&XoAR1<+Gu&!r(~L zEdF3AZId zuWj*Wc4Cmoi9`+irvA5zo!-&zs89DWo?36EDRhl-8g7$+<)t?TqTdk#%D<4i zT;ES4kZh>2;(G=zvT%e<_-Lz2b?=(;ULYhS=aSlCa72>89P+?o4-&hx<+3t3brgR0 znavT(iwH#q#OFMvggk%tirfDa2rEq7^^Z66%G90q#3x@%!G|r=A>ZxD$1 zn#bKHj{2E<0kx;>|;iS{U0114E-b*+U{?%cjTUuZm0*fg?Tcm?fQSpU227;Kx!m%Um|=GxfW zhMEC@-{HRm9`Q~t@Lq0OXf)b9|4bM>5+{$I6_J)yeTS&4SXqSBb{N~p-`q6Wc&act zwo3(CKB6S3{0p?fEO{h7H$}EfcEoF?avfXQKr6e-K7BQLL0o>xwyTzVQD>7(jOx?MnqqjL_gq`Lu_)VL-eSKeFS2~LNpL($zM82D)T{n?dP`R^0RU3XGNB#-eDo6b0S8XjYXLylULD|~ y&%ofIM;!_Pnkp|OzMN7e?t6Jwm9C(>EK@K#P6H#fCei@8{p9HKJ;~w5FaHL03)mU} literal 4770 zcmeHLX*iqd8vaVFi>kJxV^Ho#9Yq zFxG4}BxypL7!6e|V~df9s1hQGB@x7OKE1AUU1!cYf6qV9ukZTa_kG^?yYJ_D@B8{5 zUB2X^wFR;T006D?=gwXM0QKDfu&#fT8u+F?Aiod*b_Sn6d**6f?zj+!yb+6S{AA1? z;U=8dC$X&d35%~cS^V(hpAS+^I@_H6EHkU_qd8kHzW=(=Dq8altw5I>>AG3-7$bNK z4YOlY-SIoRv`QE<@l%Gzh1;){-{M?Oe70-- z*`g?WMuk{%(9g5(h**$I)PUq%lP*I5=npi01pvRV{~Gx29~?Dc(^ozKa7#@S*d5wa zyPObR`$?eMn2+q$v@b9}A^;5;5h`cZnzhD_u3 zXhqd(^J;>!YA0i)et1i>2+sWLprN5t_v;$~={odSiI6a+EwimtBH?)8$1fQs=mpfLU@#1phG2gSx9*kr((G z_~3-8t5KLBAo=BY252euXh?iF>>csGVxq_72fvOboI;Ghn8VyEiGx1Z9YEiQQ_{>b#0 z;xJWEEz0S3UmdQHa0o+OQYpiGehV@ZE>@(lfRGi&{1^xxc7GZ=y0pF zt6fj>F0$N|qRK^{*u+m(F*ojdIL?+L!6;JjFsoA@AI-n&W#d+!8M`zzG%%UW1(oVl zSZ|y#OW!VT^4&AzqM{-ck0_B!U#jL`<>%)Q<8fFd64{tx;HkY$ON&aSD&%q<=gLIo zL|a>176KbT&Zia!(L;NVgP}MKbpC`}!8bjG>){m7cvo&;OY*~~;}`3Tvy6N_zMN2p z%iSou5wl{@oL(3w8|zvMzog?FFih#xBZBYj z!RI@2fXQ9O4TnaD?RZnqP!0(SN6B!I5i+}iz-@Y-mRmQ9%)O_0M)Tj1biHwte7%tWvn1EB|bML4Z^aGeQ8jY2xyo4JB(}Tg)JyV4i z(8^0e8sD@1Bqkl{Bsv{LXfiLh@1UXwgNcp~8ZWp_P#S-cr0V+mRvC9bS#paFP1luNkg;23l9)+5DzRJ>wgYNC=3$PT$WUKko zz{8J9B7An*=`dD4n(B-snisdCC@jmR?j+T$@LW!=0}lJf9IPDy4J~-|)qcJ}AWBjS z%UgHF#K!76M@|nmZMYF>@(L&`%oD+u2Ny~T4{Td*e2ZA_I7@A0ylKBS?(9(;J3C4b zyY720(w?{1!fS(r^BlN03nQK>JOIZcxk{ebct%O_FM43N%sG1K47u<78Gd}}&F114 zx1#KluKgA!WRl6`f-eC+ly_%d3Nx^Z=m&AhmicOEXjr2879#I;oF@b+bD^%)%$02@ zRk8i1C_j<=OE;y5ylF4a>Bgl{gC9rL9rkEvX{O*@?2rGZD;dP8u z37@MME6m|#@=t-)w;MAA;p`=_UmtEW2tlF1GGk4kAtmrDOt*RthZ9N<{ssyaFrtR# zE+uAV=0Zxr+;}tN!Zv-Y%S^4alKKZQ7z|^S+vY8c2VC{jO%ueij?mVY^t6tJk%3eUWiZFrNGu^m9EabC4L+w&9V|7nGX8=xj zl6en*Kjcnr`-?QMzqaAO-P}rh;M;1&6BSm zwpd=#%JA(ARd3bzkqR6LgGV(zQjFJq2P>l7^k0tY~X#Sx}9-0A&W4YEt*RvLRUPo{RW|(Q-Y! z4=uE3aBwg-6Kj>gm_Oz1d&u&Z_3Elp)G|terdQMH-T?sc+PV`wkLDM*@B!lE>``4^ z?Fwg9W4YN)O--Jya zreNi5F1ltn;$;5K1t-{5R_SA5)^v_g7XlXj=STy19a@7b2(wei(af?%pS!OV1-I?J+27^&mRaIUdydz@+ zfN%nFG8cn}0ktPei}?JoH~I0?r-;`PxBUGF_*9gpe#E|unMZ;{LvK|2JEKqp+v5Od z@2a1=Ta-!fPyJvH`iIx#>#~#$0O$8jNB-SaKpGkw3HIs$$Bhf#kpE#f{%R#%Z>|G= z*t|Ar4T7~QSZjo}yI}1)TvLSI|5pf>b))~NI#;ddxCi|A1e|xibe8OR^KbtIFJ5F} diff --git a/tests/src/lv_test_conf.h b/tests/src/lv_test_conf.h index f13837646..03632128a 100644 --- a/tests/src/lv_test_conf.h +++ b/tests/src/lv_test_conf.h @@ -55,9 +55,6 @@ extern "C" { void lv_test_assert_fail(void); #define LV_ASSERT_HANDLER lv_test_assert_fail(); -uint32_t custom_tick_get(void); -#define LV_TICK_CUSTOM_SYS_TIME_EXPR custom_tick_get() - typedef void * lv_user_data_t; diff --git a/tests/src/lv_test_init.c b/tests/src/lv_test_init.c index 931fae81e..0b4c968af 100644 --- a/tests/src/lv_test_init.c +++ b/tests/src/lv_test_init.c @@ -46,6 +46,7 @@ static void hal_init(void) lv_test_encoder_indev = lv_indev_create(); lv_indev_set_type(lv_test_encoder_indev, LV_INDEV_TYPE_ENCODER); lv_indev_set_read_cb(lv_test_encoder_indev, lv_test_encoder_read_cb); + } static void dummy_flush_cb(lv_disp_t * disp, const lv_area_t * area, uint8_t * color_p) @@ -56,24 +57,6 @@ static void dummy_flush_cb(lv_disp_t * disp, const lv_area_t * area, uint8_t * c lv_disp_flush_ready(disp); } -uint32_t custom_tick_get(void) -{ - static uint64_t start_ms = 0; - if(start_ms == 0) { - struct timeval tv_start; - gettimeofday(&tv_start, NULL); - start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000; - } - - struct timeval tv_now; - gettimeofday(&tv_now, NULL); - uint64_t now_ms; - now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000; - - uint32_t time_ms = now_ms - start_ms; - return time_ms; -} - void lv_test_assert_fail(void) { // Handle error on test diff --git a/tests/src/test_assets/test_font_montserrat_ascii_1bpp.c b/tests/src/test_assets/test_font_montserrat_ascii_1bpp.c index 76ae837e1..46168d4bf 100644 --- a/tests/src/test_assets/test_font_montserrat_ascii_1bpp.c +++ b/tests/src/test_assets/test_font_montserrat_ascii_1bpp.c @@ -984,7 +984,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LV_VERSION_CHECK(8, 0, 0) /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { diff --git a/tests/src/test_assets/test_font_montserrat_ascii_2bpp.c b/tests/src/test_assets/test_font_montserrat_ascii_2bpp.c index 7b45ad9ca..12d0c32a7 100644 --- a/tests/src/test_assets/test_font_montserrat_ascii_2bpp.c +++ b/tests/src/test_assets/test_font_montserrat_ascii_2bpp.c @@ -1208,7 +1208,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LV_VERSION_CHECK(8, 0, 0) /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { diff --git a/tests/src/test_assets/test_font_montserrat_ascii_4bpp.c b/tests/src/test_assets/test_font_montserrat_ascii_4bpp.c index edaf75293..87cbf0a74 100644 --- a/tests/src/test_assets/test_font_montserrat_ascii_4bpp.c +++ b/tests/src/test_assets/test_font_montserrat_ascii_4bpp.c @@ -1625,7 +1625,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LV_VERSION_CHECK(8, 0, 0) /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { diff --git a/tests/src/test_assets/test_font_montserrat_ascii_4bpp_compressed.c b/tests/src/test_assets/test_font_montserrat_ascii_4bpp_compressed.c index 2e5b55795..0d6cb9549 100644 --- a/tests/src/test_assets/test_font_montserrat_ascii_4bpp_compressed.c +++ b/tests/src/test_assets/test_font_montserrat_ascii_4bpp_compressed.c @@ -1382,7 +1382,7 @@ static const lv_font_fmt_txt_kern_classes_t kern_classes = { #if LV_VERSION_CHECK(8, 0, 0) /*Store all the custom data of the font*/ -static lv_font_fmt_txt_glyph_cache_t cache; + static const lv_font_fmt_txt_dsc_t font_dsc = { #else static lv_font_fmt_txt_dsc_t font_dsc = { diff --git a/tests/src/test_cases/test_spinner.c b/tests/src/test_cases/test_spinner.c index f1a8c8aec..f9a8287eb 100644 --- a/tests/src/test_cases/test_spinner.c +++ b/tests/src/test_cases/test_spinner.c @@ -9,7 +9,7 @@ static lv_obj_t * spinner = NULL; void setUp(void) { active_screen = lv_scr_act(); - spinner = lv_spinner_create(lv_scr_act(), 1000, 200); + spinner = lv_spinner_create(lv_scr_act()); lv_obj_set_size(spinner, 100, 100); lv_obj_center(spinner); } diff --git a/tests/src/test_cases/test_style.c b/tests/src/test_cases/test_style.c index 550d44e09..f54c16c20 100644 --- a/tests/src/test_cases/test_style.c +++ b/tests/src/test_cases/test_style.c @@ -67,8 +67,7 @@ void test_custom_prop_ids(void) * were registered + whatever's built-in. A failure here may just indicate * that LVGL registers more built-in properties now and this needs adjustment. */ - extern uint32_t _lv_style_custom_prop_flag_lookup_table_size; - TEST_ASSERT_EQUAL(_lv_style_custom_prop_flag_lookup_table_size, 96); + TEST_ASSERT_EQUAL(LV_GLOBAL_DEFAULT()->style_custom_table_size, 64); } const lv_style_const_prop_t const_style_props[] = { diff --git a/tests/src/test_cases/test_win.c b/tests/src/test_cases/test_win.c index 5163a28da..8a6d4fff6 100644 --- a/tests/src/test_cases/test_win.c +++ b/tests/src/test_cases/test_win.c @@ -22,11 +22,8 @@ void tearDown(void) void test_win_should_have_valid_documented_defualt_values(void) { - // Header Height must be provided - int win_header_height = 60; - // Create the win object and update layout - win = lv_win_create(active_screen, win_header_height); + win = lv_win_create(active_screen); lv_obj_update_layout(win); // Check that the window has been created @@ -42,7 +39,7 @@ void test_win_should_have_valid_documented_defualt_values(void) TEST_ASSERT_EQUAL(content, lv_obj_get_child(win, 1)); // Check that the header is correctly sized and empty - TEST_ASSERT_EQUAL(win_header_height, lv_obj_get_height(header)); + TEST_ASSERT_EQUAL(lv_disp_get_dpi(lv_obj_get_disp(win)) / 2, lv_obj_get_height(header)); TEST_ASSERT_EQUAL(0, lv_obj_get_child_cnt(header)); // Check that the content is empty @@ -51,11 +48,8 @@ void test_win_should_have_valid_documented_defualt_values(void) void test_win_add_title_single(void) { - // Header Height must be provided - int win_header_height = 60; - // Create the win object, get the header and update layout - win = lv_win_create(active_screen, win_header_height); + win = lv_win_create(active_screen); header = lv_win_get_header(win); lv_obj_update_layout(win); @@ -75,11 +69,8 @@ void test_win_add_title_single(void) void test_win_add_title_multiple(void) { - // Header Height must be provided - int win_header_height = 60; - // Create the win object, get the header and update layout - win = lv_win_create(active_screen, win_header_height); + win = lv_win_create(active_screen); header = lv_win_get_header(win); lv_obj_update_layout(win); @@ -95,12 +86,10 @@ void test_win_add_title_multiple(void) void test_win_add_btn(void) { - // Header Height must be provided - int win_header_height = 60; int win_btn_width = 50; // Create the win object, get the header and update layout - win = lv_win_create(active_screen, win_header_height); + win = lv_win_create(active_screen); header = lv_win_get_header(win); lv_obj_update_layout(win); @@ -127,13 +116,11 @@ void test_win_add_multiple_elements(void) lv_obj_t * btn; lv_obj_t * title; - // Header Height must be provided - int win_header_height = 60; int win_btn_width = 50; int win_btn_close_width = 60; // Create the win object, get the header and update layout - win = lv_win_create(active_screen, win_header_height); + win = lv_win_create(active_screen); lv_win_add_btn(win, LV_SYMBOL_LEFT, win_btn_width); lv_win_add_title(win, dummy_text); lv_win_add_btn(win, LV_SYMBOL_RIGHT, win_btn_width);