├── extras └── img │ └── lvglarduino.jpg ├── src ├── scripts │ ├── built_in_font │ │ ├── FontAwesome.ttf │ │ ├── Roboto-Regular.woff │ │ └── built_in_font_gen.py │ ├── cppcheck_run.sh │ ├── clang-formatter.sh │ └── lv_conf_checker.py ├── src │ ├── lv_hal │ │ ├── lv_hal.mk │ │ ├── lv_hal.h │ │ ├── lv_hal_tick.h │ │ ├── lv_hal_tick.c │ │ └── lv_hal_indev.c │ ├── lv_core │ │ ├── lv_core.mk │ │ ├── lv_refr.h │ │ ├── lv_disp.h │ │ ├── lv_indev.h │ │ └── lv_disp.c │ ├── lv_font │ │ ├── lv_font.mk │ │ ├── lv_font.c │ │ ├── lv_font.h │ │ └── lv_symbol_def.h │ ├── lv_themes │ │ ├── lv_themes.mk │ │ ├── lv_theme_zen.h │ │ ├── lv_theme_mono.h │ │ ├── lv_theme_alien.h │ │ ├── lv_theme_nemo.h │ │ ├── lv_theme_night.h │ │ ├── lv_theme_templ.h │ │ ├── lv_theme_default.h │ │ ├── lv_theme_material.h │ │ └── lv_theme.c │ ├── lv_draw │ │ ├── lv_draw.mk │ │ ├── lv_draw_rect.h │ │ ├── lv_draw_line.h │ │ ├── lv_draw_arc.h │ │ ├── lv_draw_triangle.h │ │ ├── lv_draw_label.h │ │ ├── lv_img_cache.h │ │ ├── lv_draw_basic.h │ │ ├── lv_draw.h │ │ └── lv_draw_img.h │ ├── lv_misc │ │ ├── lv_misc.mk │ │ ├── lv_templ.h │ │ ├── lv_gc.c │ │ ├── lv_templ.c │ │ ├── lv_types.h │ │ ├── lv_async.h │ │ ├── lv_async.c │ │ ├── lv_utils.h │ │ ├── lv_math.h │ │ ├── lv_circ.h │ │ ├── lv_circ.c │ │ ├── lv_log.c │ │ ├── lv_gc.h │ │ ├── lv_utils.c │ │ ├── lv_math.c │ │ ├── lv_color.c │ │ ├── lv_mem.h │ │ ├── lv_ll.h │ │ ├── lv_task.h │ │ └── lv_area.h │ ├── lv_objx │ │ ├── lv_objx.mk │ │ ├── lv_objx_templ.h │ │ ├── lv_arc.h │ │ ├── lv_led.h │ │ ├── lv_sw.h │ │ ├── lv_line.h │ │ ├── lv_lmeter.h │ │ ├── lv_cb.h │ │ ├── lv_tileview.h │ │ ├── lv_img.h │ │ ├── lv_spinbox.h │ │ ├── lv_bar.h │ │ ├── lv_slider.h │ │ └── lv_preload.h │ └── lv_version.h ├── porting │ ├── lv_port_fs_template.h │ ├── lv_port_disp_template.h │ └── lv_port_indev_template.h ├── LICENCE.txt ├── lvgl.h └── docs │ └── CODE_OF_CONDUCT.md ├── library.properties ├── library.json ├── keywords.txt ├── .gitignore ├── .github └── stale.yml ├── LICENSE ├── README.md └── examples ├── SIPEED_MAIX_lvgl └── SIPEED_MAIX_lvgl.ino └── SIPEED_MAIX_touch └── SIPEED_MAIX_touch.ino /extras/img/lvglarduino.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lvgl/lv_port_maixduino/HEAD/extras/img/lvglarduino.jpg -------------------------------------------------------------------------------- /src/scripts/built_in_font/FontAwesome.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lvgl/lv_port_maixduino/HEAD/src/scripts/built_in_font/FontAwesome.ttf -------------------------------------------------------------------------------- /src/scripts/built_in_font/Roboto-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lvgl/lv_port_maixduino/HEAD/src/scripts/built_in_font/Roboto-Regular.woff -------------------------------------------------------------------------------- /src/scripts/cppcheck_run.sh: -------------------------------------------------------------------------------- 1 | cppcheck --template="{severity}\t{file}:{line}\t{id}: {message}" --enable=all ../src/ --output-file=cppcheck_res.txt --suppress=unusedFunction --suppress=preprocessorErrorDirective --force 2 | 3 | -------------------------------------------------------------------------------- /src/src/lv_hal/lv_hal.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_hal_disp.c 2 | CSRCS += lv_hal_indev.c 3 | CSRCS += lv_hal_tick.c 4 | 5 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_hal 6 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_hal 7 | 8 | CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_hal" 9 | -------------------------------------------------------------------------------- /src/src/lv_core/lv_core.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_group.c 2 | CSRCS += lv_indev.c 3 | CSRCS += lv_disp.c 4 | CSRCS += lv_obj.c 5 | CSRCS += lv_refr.c 6 | CSRCS += lv_style.c 7 | 8 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_core 9 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_core 10 | 11 | CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_core" 12 | -------------------------------------------------------------------------------- /src/src/lv_font/lv_font.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font.c 2 | CSRCS += lv_font_fmt_txt.c 3 | CSRCS += lv_font_roboto_12.c 4 | CSRCS += lv_font_roboto_16.c 5 | CSRCS += lv_font_roboto_22.c 6 | CSRCS += lv_font_roboto_28.c 7 | CSRCS += lv_font_unscii_8.c 8 | 9 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_font 10 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_font 11 | 12 | CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_font" 13 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_themes.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_theme_alien.c 2 | CSRCS += lv_theme.c 3 | CSRCS += lv_theme_default.c 4 | CSRCS += lv_theme_night.c 5 | CSRCS += lv_theme_templ.c 6 | CSRCS += lv_theme_zen.c 7 | CSRCS += lv_theme_material.c 8 | CSRCS += lv_theme_nemo.c 9 | CSRCS += lv_theme_mono.c 10 | 11 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_themes 12 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_themes 13 | 14 | CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_themes" 15 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_draw_basic.c 2 | CSRCS += lv_draw.c 3 | CSRCS += lv_draw_rect.c 4 | CSRCS += lv_draw_label.c 5 | CSRCS += lv_draw_line.c 6 | CSRCS += lv_draw_img.c 7 | CSRCS += lv_draw_arc.c 8 | CSRCS += lv_draw_triangle.c 9 | CSRCS += lv_img_decoder.c 10 | CSRCS += lv_img_cache.c 11 | 12 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_draw 13 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_draw 14 | 15 | CFLAGS += "-I$(LVGL_DIR)lvgl/src/lv_draw" 16 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_misc.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_circ.c 2 | CSRCS += lv_area.c 3 | CSRCS += lv_task.c 4 | CSRCS += lv_fs.c 5 | CSRCS += lv_anim.c 6 | CSRCS += lv_mem.c 7 | CSRCS += lv_ll.c 8 | CSRCS += lv_color.c 9 | CSRCS += lv_txt.c 10 | CSRCS += lv_math.c 11 | CSRCS += lv_log.c 12 | CSRCS += lv_gc.c 13 | CSRCS += lv_utils.c 14 | 15 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_misc 16 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_misc 17 | 18 | CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_misc" 19 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=LittlevGL 2 | version=2.0.0 3 | author=Gabor Kiss-Vamosi 4 | maintainer=Pavel Brychta 5 | sentence=Full-featured Graphics Library for embedded systems 6 | paragraph=Littlev Graphics Library provides everything you need to create a Graphical User Interface (GUI) on embedded systems with easy-to-use graphical elements, beautiful visual effects and low memory footprint. 7 | category=Display 8 | url=http://www.gl.littlev.hu 9 | architectures=* 10 | includes=lvgl.h 11 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"LittlevGL", 3 | "description":"Full-featured Graphics Library for embedded systems", 4 | "keywords":"display,gui", 5 | "authors": 6 | { 7 | "name": "Gabor Kiss-Vamosi", 8 | "maintainer": true 9 | }, 10 | "repository": 11 | { 12 | "type": "git", 13 | "url": "https://github.com/littlevgl/arduino" 14 | }, 15 | "version": "2.0.0", 16 | "license": "MIT", 17 | "frameworks": "arduino", 18 | "build": { 19 | "libCompatMode": "strict" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map LowPower 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | ####################################### 14 | # Instances (KEYWORD2) 15 | ####################################### 16 | 17 | ####################################### 18 | # Constants (LITERAL1) 19 | ####################################### 20 | -------------------------------------------------------------------------------- /src/scripts/clang-formatter.sh: -------------------------------------------------------------------------------- 1 | clang-format-7 -style=file ../src/lv_core/*.c -i 2 | clang-format-7 -style=file ../src/lv_draw/*.c -i 3 | clang-format-7 -style=file ../src/lv_hal/*.c -i 4 | clang-format-7 -style=file ../src/lv_misc/*.c -i 5 | clang-format-7 -style=file ../src/lv_objx/*.c -i 6 | clang-format-7 -style=file ../src/lv_themes/*.c -i 7 | 8 | clang-format-7 -style=file ../src/lv_core/*.h -i 9 | clang-format-7 -style=file ../src/lv_draw/*.h -i 10 | clang-format-7 -style=file ../src/lv_hal/*.h -i 11 | clang-format-7 -style=file ../src/lv_misc/*.h -i 12 | clang-format-7 -style=file ../src/lv_objx/*.h -i 13 | clang-format-7 -style=file ../src/lv_themes/*.h -i 14 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEMPL_H 7 | #define LV_TEMPL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | #ifdef __cplusplus 34 | } /* extern "C" */ 35 | #endif 36 | 37 | #endif /*LV_TEMPL_H*/ 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | # vscode 55 | .vscode -------------------------------------------------------------------------------- /src/src/lv_hal/lv_hal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal.h 3 | * 4 | */ 5 | 6 | #ifndef LV_HAL_H 7 | #define LV_HAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_hal_disp.h" 17 | #include "lv_hal_indev.h" 18 | #include "lv_hal_tick.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | #ifdef __cplusplus 37 | } /* extern "C" */ 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 21 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - architecture 8 | - pinned 9 | # Label to use when marking an issue as stale 10 | staleLabel: stale 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue or pull request has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_gc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_gc.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | /********************** 21 | * STATIC PROTOTYPES 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC VARIABLES 26 | **********************/ 27 | #if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 28 | LV_ROOTS 29 | #endif /* LV_ENABLE_GC */ 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | /********************** 39 | * STATIC FUNCTIONS 40 | **********************/ 41 | -------------------------------------------------------------------------------- /src/porting/lv_port_fs_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_port_fs_templ.h 3 | * 4 | */ 5 | 6 | /*Copy this file as "lv_port_fs.h" and set this value to "1" to enable content*/ 7 | #if 0 8 | 9 | #ifndef LV_PORT_FS_TEMPL_H 10 | #define LV_PORT_FS_TEMPL_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /********************* 17 | * INCLUDES 18 | *********************/ 19 | #include "lvgl/lvgl.h" 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | 33 | /********************** 34 | * MACROS 35 | **********************/ 36 | 37 | 38 | #ifdef __cplusplus 39 | } /* extern "C" */ 40 | #endif 41 | 42 | #endif /*LV_PORT_FS_TEMPL_H*/ 43 | 44 | #endif /*Disable/Enable content*/ 45 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_templ.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | /********************* 11 | * DEFINES 12 | *********************/ 13 | 14 | /********************** 15 | * TYPEDEFS 16 | **********************/ 17 | 18 | /* This typedef exists purely to keep -Wpedantic happy when the file is empty. */ 19 | /* It can be removed. */ 20 | typedef int keep_pedantic_happy; 21 | 22 | /********************** 23 | * STATIC PROTOTYPES 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC VARIABLES 28 | **********************/ 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | /********************** 39 | * STATIC FUNCTIONS 40 | **********************/ 41 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_objx.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_arc.c 2 | CSRCS += lv_bar.c 3 | CSRCS += lv_cb.c 4 | CSRCS += lv_ddlist.c 5 | CSRCS += lv_kb.c 6 | CSRCS += lv_line.c 7 | CSRCS += lv_mbox.c 8 | CSRCS += lv_preload.c 9 | CSRCS += lv_roller.c 10 | CSRCS += lv_table.c 11 | CSRCS += lv_tabview.c 12 | CSRCS += lv_tileview.c 13 | CSRCS += lv_btn.c 14 | CSRCS += lv_calendar.c 15 | CSRCS += lv_chart.c 16 | CSRCS += lv_canvas.c 17 | CSRCS += lv_gauge.c 18 | CSRCS += lv_label.c 19 | CSRCS += lv_list.c 20 | CSRCS += lv_slider.c 21 | CSRCS += lv_ta.c 22 | CSRCS += lv_spinbox.c 23 | CSRCS += lv_btnm.c 24 | CSRCS += lv_cont.c 25 | CSRCS += lv_img.c 26 | CSRCS += lv_imgbtn.c 27 | CSRCS += lv_led.c 28 | CSRCS += lv_lmeter.c 29 | CSRCS += lv_page.c 30 | CSRCS += lv_sw.c 31 | CSRCS += lv_win.c 32 | 33 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/src/lv_objx 34 | VPATH += :$(LVGL_DIR)/lvgl/src/lv_objx 35 | 36 | CFLAGS += "-I$(LVGL_DIR)/lvgl/src/lv_objx" 37 | -------------------------------------------------------------------------------- /src/porting/lv_port_disp_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_port_disp_templ.h 3 | * 4 | */ 5 | 6 | /*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/ 7 | #if 0 8 | 9 | #ifndef LV_PORT_DISP_TEMPL_H 10 | #define LV_PORT_DISP_TEMPL_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /********************* 17 | * INCLUDES 18 | *********************/ 19 | #include "lvgl/lvgl.h" 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | 33 | /********************** 34 | * MACROS 35 | **********************/ 36 | 37 | 38 | #ifdef __cplusplus 39 | } /* extern "C" */ 40 | #endif 41 | 42 | #endif /*LV_PORT_DISP_TEMPL_H*/ 43 | 44 | #endif /*Disable/Enable content*/ 45 | -------------------------------------------------------------------------------- /src/porting/lv_port_indev_template.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file lv_port_indev_templ.h 4 | * 5 | */ 6 | 7 | /*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/ 8 | #if 0 9 | 10 | #ifndef LV_PORT_INDEV_TEMPL_H 11 | #define LV_PORT_INDEV_TEMPL_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /********************* 18 | * INCLUDES 19 | *********************/ 20 | #include "lvgl/lvgl.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * GLOBAL PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | 39 | #ifdef __cplusplus 40 | } /* extern "C" */ 41 | #endif 42 | 43 | #endif /*LV_PORT_INDEV_TEMPL_H*/ 44 | 45 | #endif /*Disable/Enable content*/ 46 | -------------------------------------------------------------------------------- /src/LICENCE.txt: -------------------------------------------------------------------------------- 1 | MIT licence 2 | Copyright (c) 2016 Gábor Kiss-Vámosi 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_types.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TYPES_H 7 | #define LV_TYPES_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /** 26 | * LittlevGL error codes. 27 | */ 28 | enum { 29 | LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action 30 | function or an operation was failed*/ 31 | LV_RES_OK, /*The object is valid (no deleted) after the action*/ 32 | }; 33 | typedef uint8_t lv_res_t; 34 | 35 | typedef unsigned long int lv_uintptr_t; 36 | 37 | /********************** 38 | * GLOBAL PROTOTYPES 39 | **********************/ 40 | 41 | /********************** 42 | * MACROS 43 | **********************/ 44 | 45 | #ifdef __cplusplus 46 | } /* extern "C" */ 47 | #endif 48 | 49 | #endif /*LV_TYPES_H*/ 50 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_rect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_rect.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_RECT_H 7 | #define LV_DRAW_RECT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw a rectangle 32 | * @param coords the coordinates of the rectangle 33 | * @param mask the rectangle will be drawn only in this mask 34 | * @param style pointer to a style 35 | * @param opa_scale scale down all opacities by the factor 36 | */ 37 | void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); 38 | 39 | /********************** 40 | * MACROS 41 | **********************/ 42 | 43 | #ifdef __cplusplus 44 | } /* extern "C" */ 45 | #endif 46 | 47 | #endif /*LV_DRAW_RECT_H*/ 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Littlev Graphics Library 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_line.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_line.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LINE_H 7 | #define LV_DRAW_LINE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /** 30 | * Draw a line 31 | * @param point1 first point of the line 32 | * @param point2 second point of the line 33 | * @param mask the line will be drawn only on this area 34 | * @param style pointer to a line's style 35 | * @param opa_scale scale down all opacities by the factor 36 | */ 37 | void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, 38 | const lv_style_t * style, lv_opa_t opa_scale); 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | #ifdef __cplusplus 45 | } /* extern "C" */ 46 | #endif 47 | 48 | #endif /*LV_DRAW_LINE_H*/ 49 | -------------------------------------------------------------------------------- /src/scripts/lv_conf_checker.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values 3 | ''' 4 | 5 | 6 | import re 7 | 8 | fin = open("../lv_conf_template.h", "r") 9 | fout = open("../src/lv_conf_checker.h", "w") 10 | 11 | 12 | fout.write( 13 | '''/** 14 | * GENERATED FILE, DO NOT EDIT IT! 15 | * @file lv_conf_checker.h 16 | * Make sure all the defines of lv_conf.h have a default value 17 | **/ 18 | 19 | #ifndef LV_CONF_CHECKER_H 20 | #define LV_CONF_CHECKER_H 21 | ''' 22 | ) 23 | 24 | started = 0 25 | 26 | for i in fin.read().splitlines(): 27 | if not started: 28 | if '#define LV_CONF_H' in i: 29 | started = 1 30 | continue 31 | else: 32 | continue 33 | 34 | if '/*--END OF LV_CONF_H--*/' in i: break 35 | 36 | r = re.search(r'^ *# *define ([^\s]+).*$', i) 37 | if r: 38 | fout.write( 39 | f'#ifndef {r[1]}\n' 40 | f'{i}\n' 41 | '#endif\n' 42 | ) 43 | elif re.search('^ *typedef .*;.*$', i): 44 | continue #ignore typedefs to avoide redeclaration 45 | else: 46 | fout.write(f'{i}\n') 47 | 48 | 49 | fout.write( 50 | ''' 51 | #endif /*LV_CONF_CHECKER_H*/ 52 | ''' 53 | ) 54 | 55 | fin.close() 56 | fout.close() 57 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_zen.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_zen.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_ZEN_H 7 | #define LV_THEME_ZEN_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_ZEN 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the zen theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_zen(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_ZEN_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_mono.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_mono.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_MONO_H 7 | #define LV_THEME_MONO_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_MONO 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the mono theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_mono(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_MONO_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_alien.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_alien.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_ALIEN_H 7 | #define LV_THEME_ALIEN_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_ALIEN 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the alien theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t * font); 43 | /** 44 | * Get a pointer to the theme 45 | * @return pointer to the theme 46 | */ 47 | lv_theme_t * lv_theme_get_alien(void); 48 | 49 | /********************** 50 | * MACROS 51 | **********************/ 52 | 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | } /* extern "C" */ 57 | #endif 58 | 59 | #endif /*LV_THEME_ALIEN_H*/ 60 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_nemo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_nemo.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_NEMO_H 7 | #define LV_THEME_NEMO_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_NEMO 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the material theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_nemo(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_NEMO_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_night.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_night.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_NIGHT_H 7 | #define LV_THEME_NIGHT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_NIGHT 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the night theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_night(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_NIGHT_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_templ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_TEMPL_H 7 | #define LV_THEME_TEMPL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_TEMPL 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the templ theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_templ(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_TEMPL_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_default.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_default.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_DEFAULT_H 7 | #define LV_THEME_DEFAULT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_DEFAULT 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the default theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_default(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_TEMPL_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme_material.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_material.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_MATERIAL_H 7 | #define LV_THEME_MATERIAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_THEME_MATERIAL 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the material theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t * font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_material(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_MATERIAL_H*/ 61 | -------------------------------------------------------------------------------- /src/src/lv_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_version.h 3 | * 4 | */ 5 | 6 | #ifndef LV_VERSION_H 7 | #define LV_VERSION_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | /*Current version of LittlevGL*/ 17 | #define LVGL_VERSION_MAJOR 6 18 | #define LVGL_VERSION_MINOR 0 19 | #define LVGL_VERSION_PATCH 0 20 | #define LVGL_VERSION_INFO "" 21 | 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | 27 | /********************** 28 | * TYPEDEFS 29 | **********************/ 30 | 31 | /********************** 32 | * GLOBAL PROTOTYPES 33 | **********************/ 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | /** Gives 1 if the x.y.z version is supported in the current version 39 | * Usage: 40 | * 41 | * - Require v6 42 | * #if LV_VERSION_CHECK(6,0,0) 43 | * new_func_in_v6(); 44 | * #endif 45 | * 46 | * 47 | * - Require at least v5.3 48 | * #if LV_VERSION_CHECK(5,3,0) 49 | * new_feature_from_v5_3(); 50 | * #endif 51 | * 52 | * 53 | * - Require v5.3.2 bugfixes 54 | * #if LV_VERSION_CHECK(5,3,2) 55 | * bugfix_in_v5_3_2(); 56 | * #endif 57 | * 58 | * */ 59 | #define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH))) 60 | 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif /*LV_VERSION_H*/ 67 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_arc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_ARC_H 7 | #define LV_DRAW_ARC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw an arc. (Can draw pie too with great thickness.) 32 | * @param center_x the x coordinate of the center of the arc 33 | * @param center_y the y coordinate of the center of the arc 34 | * @param radius the radius of the arc 35 | * @param mask the arc will be drawn only in this mask 36 | * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) 37 | * @param end_angle the end angle of the arc 38 | * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) 39 | * @param opa_scale scale down all opacities by the factor 40 | */ 41 | void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask, 42 | uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | #ifdef __cplusplus 49 | } /* extern "C" */ 50 | #endif 51 | 52 | #endif /*LV_DRAW_ARC*/ 53 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_async.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_async.h 3 | * 4 | */ 5 | 6 | #ifndef LV_ASYNC_H 7 | #define LV_ASYNC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "lv_task.h" 18 | #include "lv_types.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /** 31 | * Type for async callback. 32 | */ 33 | typedef void (*lv_async_cb_t)(void *); 34 | 35 | typedef struct _lv_async_info_t { 36 | lv_async_cb_t cb; 37 | void *user_data; 38 | } lv_async_info_t; 39 | 40 | struct _lv_obj_t; 41 | 42 | /********************** 43 | * GLOBAL PROTOTYPES 44 | **********************/ 45 | 46 | /** 47 | * Call an asynchronous function the next time lv_task_handler() is run. This function is likely to return 48 | * **before** the call actually happens! 49 | * @param task_xcb a callback which is the task itself. 50 | * (the 'x' in the argument name indicates that its not a fully generic function because it not follows 51 | * the `func_name(object, callback, ...)` convention) 52 | * @param user_data custom parameter 53 | */ 54 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data); 55 | 56 | /********************** 57 | * MACROS 58 | **********************/ 59 | 60 | #ifdef __cplusplus 61 | } /* extern "C" */ 62 | #endif 63 | 64 | #endif /*LV_TEMPL_H*/ 65 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_triangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_triangle.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_TRIANGLE_H 7 | #define LV_DRAW_TRIANGLE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * 32 | * @param points pointer to an array with 3 points 33 | * @param mask the triangle will be drawn only in this mask 34 | * @param style style for of the triangle 35 | * @param opa_scale scale down all opacities by the factor (0..255) 36 | */ 37 | void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); 38 | 39 | /** 40 | * Draw a polygon from triangles. Only convex polygons are supported 41 | * @param points an array of points 42 | * @param point_cnt number of points 43 | * @param mask polygon will be drawn only in this mask 44 | * @param style style of the polygon 45 | * @param opa_scale scale down all opacities by the factor (0..255) 46 | */ 47 | void lv_draw_polygon(const lv_point_t * points, uint32_t point_cnt, const lv_area_t * mask, const lv_style_t * style, 48 | lv_opa_t opa_scale); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #ifdef __cplusplus 55 | } /* extern "C" */ 56 | #endif 57 | 58 | #endif /*LV_DRAW_TRIANGLE_H*/ 59 | -------------------------------------------------------------------------------- /src/src/lv_hal/lv_hal_tick.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal_tick.h 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | #ifndef LV_HAL_TICK_H 7 | #define LV_HAL_TICK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | #include 22 | #include 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | #ifndef LV_ATTRIBUTE_TICK_INC 28 | #define LV_ATTRIBUTE_TICK_INC 29 | #endif 30 | 31 | /********************** 32 | * TYPEDEFS 33 | **********************/ 34 | 35 | /********************** 36 | * GLOBAL PROTOTYPES 37 | **********************/ 38 | 39 | //! @cond Doxygen_Suppress 40 | 41 | /** 42 | * You have to call this function periodically 43 | * @param tick_period the call period of this function in milliseconds 44 | */ 45 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); 46 | 47 | //! @endcond 48 | 49 | /** 50 | * Get the elapsed milliseconds since start up 51 | * @return the elapsed milliseconds 52 | */ 53 | uint32_t lv_tick_get(void); 54 | 55 | /** 56 | * Get the elapsed milliseconds since a previous time stamp 57 | * @param prev_tick a previous time stamp (return value of systick_get() ) 58 | * @return the elapsed milliseconds since 'prev_tick' 59 | */ 60 | uint32_t lv_tick_elaps(uint32_t prev_tick); 61 | 62 | /********************** 63 | * MACROS 64 | **********************/ 65 | 66 | #ifdef __cplusplus 67 | } /* extern "C" */ 68 | #endif 69 | 70 | #endif /*LV_HAL_TICK_H*/ 71 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_async.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_async.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_async.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | /********************** 21 | * STATIC PROTOTYPES 22 | **********************/ 23 | 24 | static void lv_async_task_cb(lv_task_t *task); 25 | 26 | /********************** 27 | * STATIC VARIABLES 28 | **********************/ 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data) 39 | { 40 | /*Allocate an info structure */ 41 | lv_async_info_t *info = lv_mem_alloc(sizeof(lv_async_info_t)); 42 | 43 | if(info == NULL) 44 | return LV_RES_INV; 45 | 46 | /* Create a new task */ 47 | /* Use highest priority so that it will run before a refresh */ 48 | lv_task_t *task = lv_task_create(lv_async_task_cb, 0, LV_TASK_PRIO_HIGHEST, info); 49 | 50 | if(task == NULL) { 51 | lv_mem_free(info); 52 | return LV_RES_INV; 53 | } 54 | 55 | info->cb = async_xcb; 56 | info->user_data = user_data; 57 | 58 | /* Set the task's user data */ 59 | task->user_data = info; 60 | lv_task_once(task); 61 | return LV_RES_OK; 62 | } 63 | 64 | /********************** 65 | * STATIC FUNCTIONS 66 | **********************/ 67 | 68 | static void lv_async_task_cb(lv_task_t *task) 69 | { 70 | lv_async_info_t *info = (lv_async_info_t *)task->user_data; 71 | 72 | info->cb(info->user_data); 73 | 74 | lv_mem_free(info); 75 | } 76 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_utils.h 3 | * 4 | */ 5 | 6 | #ifndef LV_UTILS_H 7 | #define LV_UTILS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | /** 31 | * Convert a number to string 32 | * @param num a number 33 | * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 34 | * @return same as `buf` (just for convenience) 35 | */ 36 | char * lv_utils_num_to_str(int32_t num, char * buf); 37 | 38 | /** Searches base[0] to base[n - 1] for an item that matches *key. 39 | * 40 | * @note The function cmp must return negative if its first 41 | * argument (the search key) is less that its second (a table entry), 42 | * zero if equal, and positive if greater. 43 | * 44 | * @note Items in the array must be in ascending order. 45 | * 46 | * @param key Pointer to item being searched for 47 | * @param base Pointer to first element to search 48 | * @param n Number of elements 49 | * @param size Size of each element 50 | * @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function 51 | * example) 52 | * 53 | * @return a pointer to a matching item, or NULL if none exists. 54 | */ 55 | void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, 56 | int32_t (*cmp)(const void * pRef, const void * pElement)); 57 | 58 | /********************** 59 | * MACROS 60 | **********************/ 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_math.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file math_base.h 3 | * 4 | */ 5 | 6 | #ifndef LV_MATH_H 7 | #define LV_MATH_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | #define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) 22 | #define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) 23 | #define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) 24 | 25 | #define LV_TRIGO_SIN_MAX 32767 26 | #define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/ 27 | 28 | #define LV_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers) */ 29 | #define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/ 30 | 31 | /********************** 32 | * TYPEDEFS 33 | **********************/ 34 | 35 | /********************** 36 | * GLOBAL PROTOTYPES 37 | **********************/ 38 | 39 | /** 40 | * Return with sinus of an angle 41 | * @param angle 42 | * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 43 | */ 44 | int16_t lv_trigo_sin(int16_t angle); 45 | 46 | /** 47 | * Calculate a value of a Cubic Bezier function. 48 | * @param t time in range of [0..LV_BEZIER_VAL_MAX] 49 | * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] 50 | * @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX] 51 | * @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX] 52 | * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] 53 | * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] 54 | */ 55 | int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); 56 | 57 | /********************** 58 | * MACROS 59 | **********************/ 60 | 61 | #ifdef __cplusplus 62 | } /* extern "C" */ 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_circ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_circ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_CIRC_H 7 | #define LV_CIRC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include "lv_area.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | #define LV_CIRC_OCT1_X(p) (p.x) 23 | #define LV_CIRC_OCT1_Y(p) (p.y) 24 | #define LV_CIRC_OCT2_X(p) (p.y) 25 | #define LV_CIRC_OCT2_Y(p) (p.x) 26 | #define LV_CIRC_OCT3_X(p) (-p.y) 27 | #define LV_CIRC_OCT3_Y(p) (p.x) 28 | #define LV_CIRC_OCT4_X(p) (-p.x) 29 | #define LV_CIRC_OCT4_Y(p) (p.y) 30 | #define LV_CIRC_OCT5_X(p) (-p.x) 31 | #define LV_CIRC_OCT5_Y(p) (-p.y) 32 | #define LV_CIRC_OCT6_X(p) (-p.y) 33 | #define LV_CIRC_OCT6_Y(p) (-p.x) 34 | #define LV_CIRC_OCT7_X(p) (p.y) 35 | #define LV_CIRC_OCT7_Y(p) (-p.x) 36 | #define LV_CIRC_OCT8_X(p) (p.x) 37 | #define LV_CIRC_OCT8_Y(p) (-p.y) 38 | 39 | /********************** 40 | * TYPEDEFS 41 | **********************/ 42 | 43 | /********************** 44 | * GLOBAL PROTOTYPES 45 | **********************/ 46 | 47 | /** 48 | * Initialize the circle drawing 49 | * @param c pointer to a point. The coordinates will be calculated here 50 | * @param tmp point to a variable. It will store temporary data 51 | * @param radius radius of the circle 52 | */ 53 | void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius); 54 | 55 | /** 56 | * Test the circle drawing is ready or not 57 | * @param c same as in circ_init 58 | * @return true if the circle is not ready yet 59 | */ 60 | bool lv_circ_cont(lv_point_t * c); 61 | 62 | /** 63 | * Get the next point from the circle 64 | * @param c same as in circ_init. The next point stored here. 65 | * @param tmp same as in circ_init. 66 | */ 67 | void lv_circ_next(lv_point_t * c, lv_coord_t * tmp); 68 | 69 | /********************** 70 | * MACROS 71 | **********************/ 72 | 73 | #ifdef __cplusplus 74 | } /* extern "C" */ 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_circ.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_circ.c 3 | * Circle drawing algorithm (with Bresenham) 4 | * Only a 1/8 circle is calculated. Use CIRC_OCT1_X, CIRC_OCT1_Y macros to get 5 | * the other octets. 6 | */ 7 | 8 | /********************* 9 | * INCLUDES 10 | *********************/ 11 | #include "lv_circ.h" 12 | 13 | /********************* 14 | * DEFINES 15 | *********************/ 16 | 17 | /********************** 18 | * TYPEDEFS 19 | **********************/ 20 | 21 | /********************** 22 | * STATIC PROTOTYPES 23 | **********************/ 24 | 25 | /********************** 26 | * STATIC VARIABLES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | /********************** 34 | * GLOBAL FUNCTIONS 35 | **********************/ 36 | 37 | /** 38 | * Initialize the circle drawing 39 | * @param c pointer to a point. The coordinates will be calculated here 40 | * @param tmp point to a variable. It will store temporary data 41 | * @param radius radius of the circle 42 | */ 43 | void lv_circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius) 44 | { 45 | c->x = radius; 46 | c->y = 0; 47 | *tmp = 1 - radius; 48 | } 49 | 50 | /** 51 | * Test the circle drawing is ready or not 52 | * @param c same as in circ_init 53 | * @return true if the circle is not ready yet 54 | */ 55 | bool lv_circ_cont(lv_point_t * c) 56 | { 57 | return c->y <= c->x ? true : false; 58 | } 59 | 60 | /** 61 | * Get the next point from the circle 62 | * @param c same as in circ_init. The next point stored here. 63 | * @param tmp same as in circ_init. 64 | */ 65 | void lv_circ_next(lv_point_t * c, lv_coord_t * tmp) 66 | { 67 | c->y++; 68 | 69 | if(*tmp <= 0) { 70 | (*tmp) += 2 * c->y + 1; // Change in decision criterion for y -> y+1 71 | } else { 72 | c->x--; 73 | (*tmp) += 2 * (c->y - c->x) + 1; // Change for y -> y+1, x -> x-1 74 | } 75 | } 76 | 77 | /********************** 78 | * STATIC FUNCTIONS 79 | **********************/ 80 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_log.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_log.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_log.h" 10 | #if LV_USE_LOG 11 | 12 | #if LV_LOG_PRINTF 13 | #include 14 | #endif 15 | /********************* 16 | * DEFINES 17 | *********************/ 18 | 19 | /********************** 20 | * TYPEDEFS 21 | **********************/ 22 | 23 | /********************** 24 | * STATIC PROTOTYPES 25 | **********************/ 26 | 27 | /********************** 28 | * STATIC VARIABLES 29 | **********************/ 30 | static lv_log_print_g_cb_t custom_print_cb; 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL FUNCTIONS 38 | **********************/ 39 | 40 | /** 41 | * Register custom print/write function to call when a log is added. 42 | * It can format its "File path", "Line number" and "Description" as required 43 | * and send the formatted log message to a consol or serial port. 44 | * @param print_cb a function pointer to print a log 45 | */ 46 | void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb) 47 | { 48 | custom_print_cb = print_cb; 49 | } 50 | 51 | /** 52 | * Add a log 53 | * @param level the level of log. (From `lv_log_level_t` enum) 54 | * @param file name of the file when the log added 55 | * @param line line number in the source code where the log added 56 | * @param dsc description of the log 57 | */ 58 | void lv_log_add(lv_log_level_t level, const char * file, int line, const char * dsc) 59 | { 60 | if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/ 61 | 62 | if(level >= LV_LOG_LEVEL) { 63 | 64 | #if LV_LOG_PRINTF 65 | static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error"}; 66 | printf("%s: %s \t(%s #%d)\n", lvl_prefix[level], dsc, file, line); 67 | #else 68 | if(custom_print_cb) custom_print_cb(level, file, line, dsc); 69 | #endif 70 | } 71 | } 72 | 73 | /********************** 74 | * STATIC FUNCTIONS 75 | **********************/ 76 | 77 | #endif /*LV_USE_LOG*/ 78 | -------------------------------------------------------------------------------- /src/scripts/built_in_font/built_in_font_gen.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | from argparse import RawTextHelpFormatter 3 | import os 4 | import sys 5 | 6 | parser = argparse.ArgumentParser(description="""Create fonts for LittelvGL including the built-in symbols. lv_font_conv needs to be installed. See https://github.com/littlevgl/lv_font_conv 7 | Example: python built_in_font_gen.py --size 16 -o lv_font_roboto_16.c --bpp 4 -r 0x20-0x7F""", formatter_class=RawTextHelpFormatter) 8 | parser.add_argument('-s', '--size', 9 | type=int, 10 | metavar = 'px', 11 | nargs='?', 12 | help='Size of the font in px') 13 | parser.add_argument('--bpp', 14 | type=int, 15 | metavar = '1,2,4', 16 | nargs='?', 17 | help='Bit per pixel') 18 | parser.add_argument('-r', '--range', 19 | nargs='+', 20 | metavar = 'start-end', 21 | default='0x20-0x7F', 22 | help='Ranges and/or characters to include. Default is 0x20-7F (ASCII). E.g. -r 0x20-0x7F, 0x200, 324') 23 | parser.add_argument('--font', 24 | metavar = 'file', 25 | nargs='?', 26 | default='Roboto-Regular.woff', 27 | help='A TTF or WOFF file') 28 | parser.add_argument('-o', '--output', 29 | nargs='?', 30 | metavar='file', 31 | help='Output file name. E.g. my_font_20.c') 32 | parser.add_argument('--compressed', action='store_true', 33 | help='Compress the bitmaps') 34 | 35 | args = parser.parse_args() 36 | 37 | if args.compressed == False: 38 | compr = "--no-compress --no-prefilter" 39 | else: 40 | compr = "" 41 | 42 | #Built in symbols 43 | syms = "61441,61448,61451,61452,61453,61457,61459,61460,61461,61465,61468,61473,61478,61479,61480,61502,61504,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62099" 44 | 45 | #Run the command 46 | cmd = "lv_font_conv {} --bpp {} --size {} --font ./Roboto-Regular.woff -r {} --font FontAwesome.ttf -r {} --format lvgl -o {} --force-fast-kern-format".format(compr, args.bpp, args.size, args.range[0], syms, args.output) 47 | os.system(cmd) 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LittlevGL Arduino library 2 | 3 | This library allows to use LittlevGL (v6.x) as an Arduino library. Library can be installed via Arduino IDE Library Manager or as an .ZIP library. 4 | 5 | ## Example 6 | 7 | There is simple example which uses https://github.com/Bodmer/TFT_eSPI library as an TFT driver to simplify testing. To get all this to work you have to setup TFT_eSPI to work with your TFT display type via editing the `User_Setup.h` file in TFT_eSPI library folder, or by selecting your own configurtion in the `User_Setup_Select.h` file in TFT_eSPI library folder. 8 | 9 | LittlevGL library has its own configuration file in `lv_conf.h` file, which is locatd in LittlevGL library folder. Please get in mind to check that corresponding resolutions in LVGL configuration match the ones in TFT_eSPI and with physical resolution of your display. 10 | 11 | Example result should look like this: 12 | 13 | ![LVGL Arduino example result](extras/img/lvglarduino.jpg) 14 | 15 | Tested with: 16 | 17 | * My own ESP32 board, module ESP32 Wroom 18 | * PC OS: Linux, Ubuntu 18.04 LTS 19 | * IDE: Arduino IDE 1.8.9 20 | * ESP32 Core: 1.0.2 21 | 22 | ## Debugging 23 | 24 | In case of trouble there are debug information inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug information to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`: 25 | 26 | ```c 27 | /*Log settings*/ 28 | #define USE_LV_LOG 1 /*Enable/disable the log module*/ 29 | #if USE_LV_LOG 30 | /* How important log should be added: 31 | * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information 32 | * LV_LOG_LEVEL_INFO Log important events 33 | * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't caused problem 34 | * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail 35 | */ 36 | # define LV_LOG_LEVEL LV_LOG_LEVEL_TRACE 37 | ``` 38 | 39 | After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to he `Serial` port @ 115200 Bd. After each line sent there is 100ms delay to allow the serial transfer to finish. This delay can be commentd out in `my_print` method. 40 | -------------------------------------------------------------------------------- /src/src/lv_font/lv_font.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_font.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_font.h" 11 | #include "../lv_misc/lv_utils.h" 12 | #include "../lv_misc/lv_log.h" 13 | 14 | /********************* 15 | * DEFINES 16 | *********************/ 17 | 18 | /********************** 19 | * TYPEDEFS 20 | **********************/ 21 | 22 | /********************** 23 | * STATIC PROTOTYPES 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC VARIABLES 28 | **********************/ 29 | 30 | /********************** 31 | * GLOBAL PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | /********************** 39 | * GLOBAL FUNCTIONS 40 | **********************/ 41 | 42 | /** 43 | * Return with the bitmap of a font. 44 | * @param font_p pointer to a font 45 | * @param letter an UNICODE character code 46 | * @return pointer to the bitmap of the letter 47 | */ 48 | const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter) 49 | { 50 | return font_p->get_glyph_bitmap(font_p, letter); 51 | } 52 | 53 | /** 54 | * Get the descriptor of a glyph 55 | * @param font_p pointer to font 56 | * @param dsc_out store the result descriptor here 57 | * @param letter an UNICODE letter code 58 | * @return true: descriptor is successfully loaded into `dsc_out`. 59 | * false: the letter was not found, no data is loaded to `dsc_out` 60 | */ 61 | bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next) 62 | { 63 | return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next); 64 | } 65 | 66 | /** 67 | * Get the width of a glyph with kerning 68 | * @param font pointer to a font 69 | * @param letter an UNICODE letter 70 | * @param letter_next the next letter after `letter`. Used for kerning 71 | * @return the width of the glyph 72 | */ 73 | uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next) 74 | { 75 | lv_font_glyph_dsc_t g; 76 | bool ret; 77 | ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next); 78 | if(ret) return g.adv_w; 79 | else return 0; 80 | } 81 | 82 | /********************** 83 | * STATIC FUNCTIONS 84 | **********************/ 85 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_label.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_label.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LABEL_H 7 | #define LV_DRAW_LABEL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /** Store some info to speed up drawing of very large texts 27 | * It takes a lot of time to get the first visible character because 28 | * all the previous characters needs to be checked to calculate the positions. 29 | * This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line. 30 | * Therefore the calculations can start from here.*/ 31 | typedef struct { 32 | /** Index of the line at `y` coordinate*/ 33 | int32_t line_start; 34 | 35 | /** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/ 36 | int32_t y; 37 | 38 | /** The 'y1' coordinate of the label when the hint was saved. 39 | * Used to invalidate the hint if the label has moved too much. */ 40 | int32_t coord_y; 41 | }lv_draw_label_hint_t; 42 | 43 | /********************** 44 | * GLOBAL PROTOTYPES 45 | **********************/ 46 | 47 | /** 48 | * Write a text 49 | * @param coords coordinates of the label 50 | * @param mask the label will be drawn only in this area 51 | * @param style pointer to a style 52 | * @param opa_scale scale down all opacities by the factor 53 | * @param txt 0 terminated text to write 54 | * @param flag settings for the text from 'txt_flag_t' enum 55 | * @param offset text offset in x and y direction (NULL if unused) 56 | * @param sel_start start index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) 57 | * @param sel_end end index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) 58 | */ 59 | void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, 60 | const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end, 61 | lv_draw_label_hint_t * hint); 62 | 63 | /********************** 64 | * MACROS 65 | **********************/ 66 | 67 | #ifdef __cplusplus 68 | } /* extern "C" */ 69 | #endif 70 | 71 | #endif /*LV_DRAW_LABEL_H*/ 72 | -------------------------------------------------------------------------------- /src/lvgl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lvgl.h 3 | * Include all LittleV GL related headers 4 | */ 5 | 6 | #ifndef LVGL_H 7 | #define LVGL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "src/lv_version.h" 18 | 19 | #include "src/lv_misc/lv_log.h" 20 | #include "src/lv_misc/lv_task.h" 21 | #include "src/lv_misc/lv_math.h" 22 | #include "src/lv_misc/lv_async.h" 23 | 24 | #include "src/lv_hal/lv_hal.h" 25 | 26 | #include "src/lv_core/lv_obj.h" 27 | #include "src/lv_core/lv_group.h" 28 | 29 | #include "src/lv_core/lv_refr.h" 30 | #include "src/lv_core/lv_disp.h" 31 | 32 | #include "src/lv_themes/lv_theme.h" 33 | 34 | #include "src/lv_font/lv_font.h" 35 | #include "src/lv_font/lv_font_fmt_txt.h" 36 | 37 | #include "src/lv_objx/lv_btn.h" 38 | #include "src/lv_objx/lv_imgbtn.h" 39 | #include "src/lv_objx/lv_img.h" 40 | #include "src/lv_objx/lv_label.h" 41 | #include "src/lv_objx/lv_line.h" 42 | #include "src/lv_objx/lv_page.h" 43 | #include "src/lv_objx/lv_cont.h" 44 | #include "src/lv_objx/lv_list.h" 45 | #include "src/lv_objx/lv_chart.h" 46 | #include "src/lv_objx/lv_table.h" 47 | #include "src/lv_objx/lv_cb.h" 48 | #include "src/lv_objx/lv_bar.h" 49 | #include "src/lv_objx/lv_slider.h" 50 | #include "src/lv_objx/lv_led.h" 51 | #include "src/lv_objx/lv_btnm.h" 52 | #include "src/lv_objx/lv_kb.h" 53 | #include "src/lv_objx/lv_ddlist.h" 54 | #include "src/lv_objx/lv_roller.h" 55 | #include "src/lv_objx/lv_ta.h" 56 | #include "src/lv_objx/lv_canvas.h" 57 | #include "src/lv_objx/lv_win.h" 58 | #include "src/lv_objx/lv_tabview.h" 59 | #include "src/lv_objx/lv_tileview.h" 60 | #include "src/lv_objx/lv_mbox.h" 61 | #include "src/lv_objx/lv_gauge.h" 62 | #include "src/lv_objx/lv_lmeter.h" 63 | #include "src/lv_objx/lv_sw.h" 64 | #include "src/lv_objx/lv_kb.h" 65 | #include "src/lv_objx/lv_arc.h" 66 | #include "src/lv_objx/lv_preload.h" 67 | #include "src/lv_objx/lv_calendar.h" 68 | #include "src/lv_objx/lv_spinbox.h" 69 | 70 | #include "src/lv_draw/lv_img_cache.h" 71 | 72 | /********************* 73 | * DEFINES 74 | *********************/ 75 | 76 | /********************** 77 | * TYPEDEFS 78 | **********************/ 79 | 80 | /********************** 81 | * GLOBAL PROTOTYPES 82 | **********************/ 83 | 84 | /********************** 85 | * MACROS 86 | **********************/ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif /*LVGL_H*/ 93 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_img_cache.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_img_cache.h 3 | * 4 | */ 5 | 6 | #ifndef LV_IMG_CACHE_H 7 | #define LV_IMG_CACHE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_img_decoder.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /** 27 | * When loading images from the network it can take a long time to download and decode the image. 28 | * 29 | * To avoid repeating this heavy load images can be cached. 30 | */ 31 | typedef struct 32 | { 33 | lv_img_decoder_dsc_t dec_dsc; /**< Image information */ 34 | 35 | /** Count the cache entries's life. Add `time_tio_open` to `life` when the entry is used. 36 | * Decrement all lifes by one every in every ::lv_img_cache_open. 37 | * If life == 0 the entry can be reused */ 38 | int32_t life; 39 | } lv_img_cache_entry_t; 40 | 41 | /********************** 42 | * GLOBAL PROTOTYPES 43 | **********************/ 44 | 45 | /** 46 | * Open an image using the image decoder interface and cache it. 47 | * The image will be left open meaning if the image decoder open callback allocated memory then it will remain. 48 | * The image is closed if a new image is opened and the new image takes its place in the cache. 49 | * @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable 50 | * @param style style of the image 51 | * @return pointer to the cache entry or NULL if can open the image 52 | */ 53 | lv_img_cache_entry_t * lv_img_cache_open(const void * src, const lv_style_t * style); 54 | 55 | /** 56 | * Set the number of images to be cached. 57 | * More cached images mean more opened image at same time which might mean more memory usage. 58 | * E.g. if 20 PNG or JPG images are open in the RAM they consume memory while opened in the cache. 59 | * @param new_entry_cnt number of image to cache 60 | */ 61 | void lv_img_cache_set_size(uint16_t new_slot_num); 62 | 63 | /** 64 | * Invalidate an image source in the cache. 65 | * Useful if the image source is updated therefore it needs to be cached again. 66 | * @param src an image source path to a file or pointer to an `lv_img_dsc_t` variable. 67 | */ 68 | void lv_img_cache_invalidate_src(const void * src); 69 | 70 | /********************** 71 | * MACROS 72 | **********************/ 73 | 74 | #ifdef __cplusplus 75 | } /* extern "C" */ 76 | #endif 77 | 78 | #endif /*LV_IMG_CACHE_H*/ 79 | -------------------------------------------------------------------------------- /src/src/lv_core/lv_refr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_refr.h 3 | * 4 | */ 5 | 6 | #ifndef LV_REFR_H 7 | #define LV_REFR_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_obj.h" 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * STATIC PROTOTYPES 29 | **********************/ 30 | 31 | /********************** 32 | * STATIC VARIABLES 33 | **********************/ 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | 39 | /********************** 40 | * GLOBAL FUNCTIONS 41 | **********************/ 42 | 43 | /** 44 | * Initialize the screen refresh subsystem 45 | */ 46 | void lv_refr_init(void); 47 | 48 | /** 49 | * Redraw the invalidated areas now. 50 | * Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process 51 | * can prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process 52 | * (e.g. progress bar) this function can be called when the screen should be updated. 53 | * @param disp pointer to display to refresh. NULL to refresh all displays. 54 | */ 55 | void lv_refr_now(lv_disp_t * disp); 56 | 57 | /** 58 | * Invalidate an area on display to redraw it 59 | * @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas) 60 | * @param disp pointer to display where the area should be invalidated (NULL can be used if there is 61 | * only one display) 62 | */ 63 | void lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); 64 | 65 | /** 66 | * Get the display which is being refreshed 67 | * @return the display being refreshed 68 | */ 69 | lv_disp_t * lv_refr_get_disp_refreshing(void); 70 | 71 | /** 72 | * Set the display which is being refreshed. 73 | * It shouldn1t be used directly by the user. 74 | * It can be used to trick the drawing functions about there is an active display. 75 | * @param the display being refreshed 76 | */ 77 | void lv_refr_set_disp_refreshing(lv_disp_t * disp); 78 | 79 | /** 80 | * Called periodically to handle the refreshing 81 | * @param task pointer to the task itself 82 | */ 83 | void lv_disp_refr_task(lv_task_t * task); 84 | 85 | /********************** 86 | * STATIC FUNCTIONS 87 | **********************/ 88 | 89 | #ifdef __cplusplus 90 | } /* extern "C" */ 91 | #endif 92 | 93 | #endif /*LV_REFR_H*/ 94 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_gc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_GC_H 7 | #define LV_GC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #ifdef LV_CONF_INCLUDE_SIMPLE 18 | #include "lv_conf.h" 19 | #else 20 | #include "../../../lv_conf.h" 21 | #endif 22 | 23 | #include 24 | #include 25 | #include "lv_mem.h" 26 | #include "lv_ll.h" 27 | #include "../lv_draw/lv_img_cache.h" 28 | 29 | /********************* 30 | * DEFINES 31 | *********************/ 32 | 33 | #define LV_GC_ROOTS(prefix) \ 34 | prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \ 35 | prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \ 36 | prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \ 37 | prefix lv_ll_t _lv_drv_ll; \ 38 | prefix lv_ll_t _lv_file_ll; \ 39 | prefix lv_ll_t _lv_anim_ll; \ 40 | prefix lv_ll_t _lv_group_ll; \ 41 | prefix lv_ll_t _lv_img_defoder_ll; \ 42 | prefix lv_img_cache_entry_t * _lv_img_cache_array; \ 43 | prefix void * _lv_task_act; \ 44 | prefix void * _lv_draw_buf; 45 | 46 | #define LV_NO_PREFIX 47 | #define LV_ROOTS LV_GC_ROOTS(LV_NO_PREFIX) 48 | 49 | #if LV_ENABLE_GC == 1 50 | #if LV_MEM_CUSTOM != 1 51 | #error "GC requires CUSTOM_MEM" 52 | #endif /* LV_MEM_CUSTOM */ 53 | #else /* LV_ENABLE_GC */ 54 | #define LV_GC_ROOT(x) x 55 | LV_GC_ROOTS(extern) 56 | #endif /* LV_ENABLE_GC */ 57 | 58 | /********************** 59 | * TYPEDEFS 60 | **********************/ 61 | 62 | /********************** 63 | * GLOBAL PROTOTYPES 64 | **********************/ 65 | 66 | /********************** 67 | * MACROS 68 | **********************/ 69 | 70 | #ifdef __cplusplus 71 | } /* extern "C" */ 72 | #endif 73 | 74 | #endif /*LV_GC_H*/ 75 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_basic.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_basic.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_BASIC_H 7 | #define LV_DRAW_BASIC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #include "../lv_font/lv_font.h" 23 | #include "../lv_misc/lv_color.h" 24 | #include "../lv_misc/lv_area.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL PROTOTYPES 36 | **********************/ 37 | 38 | void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); 39 | /** 40 | * Fill an area in the Virtual Display Buffer 41 | * @param cords_p coordinates of the area to fill 42 | * @param mask_p fill only o this mask 43 | * @param color fill color 44 | * @param opa opacity of the area (0..255) 45 | */ 46 | void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); 47 | 48 | /** 49 | * Draw a letter in the Virtual Display Buffer 50 | * @param pos_p left-top coordinate of the latter 51 | * @param mask_p the letter will be drawn only on this area 52 | * @param font_p pointer to font 53 | * @param letter a letter to draw 54 | * @param color color of letter 55 | * @param opa opacity of letter (0..255) 56 | */ 57 | void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, uint32_t letter, 58 | lv_color_t color, lv_opa_t opa); 59 | 60 | /** 61 | * Draw a color map to the display (image) 62 | * @param cords_p coordinates the color map 63 | * @param mask_p the map will drawn only on this area (truncated to VDB area) 64 | * @param map_p pointer to a lv_color_t array 65 | * @param opa opacity of the map 66 | * @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels 67 | * @param alpha_byte true: extra alpha byte is inserted for every pixel 68 | * @param recolor mix the pixels with this color 69 | * @param recolor_opa the intense of recoloring 70 | */ 71 | void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, lv_opa_t opa, 72 | bool chroma_key, bool alpha_byte, lv_color_t recolor, lv_opa_t recolor_opa); 73 | 74 | /********************** 75 | * MACROS 76 | **********************/ 77 | 78 | #ifdef __cplusplus 79 | } /* extern "C" */ 80 | #endif 81 | 82 | #endif /*LV_DRAW_BASIC_H*/ 83 | -------------------------------------------------------------------------------- /src/src/lv_hal/lv_hal_tick.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file systick.c 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #ifdef LV_CONF_INCLUDE_SIMPLE 10 | #include "lv_conf.h" 11 | #else 12 | #include "../../../lv_conf.h" 13 | #endif 14 | 15 | #include "lv_hal_tick.h" 16 | #include 17 | 18 | #if LV_TICK_CUSTOM == 1 19 | #include LV_TICK_CUSTOM_INCLUDE 20 | #endif 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC VARIABLES 36 | **********************/ 37 | static uint32_t sys_time = 0; 38 | static volatile uint8_t tick_irq_flag; 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | /********************** 45 | * GLOBAL FUNCTIONS 46 | **********************/ 47 | 48 | /** 49 | * You have to call this function periodically 50 | * @param tick_period the call period of this function in milliseconds 51 | */ 52 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) 53 | { 54 | tick_irq_flag = 0; 55 | sys_time += tick_period; 56 | } 57 | 58 | /** 59 | * Get the elapsed milliseconds since start up 60 | * @return the elapsed milliseconds 61 | */ 62 | uint32_t lv_tick_get(void) 63 | { 64 | #if LV_TICK_CUSTOM == 0 65 | uint32_t result; 66 | do { 67 | tick_irq_flag = 1; 68 | result = sys_time; 69 | } while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. 70 | Continue until make a non interrupted cycle */ 71 | 72 | return result; 73 | #else 74 | return LV_TICK_CUSTOM_SYS_TIME_EXPR; 75 | #endif 76 | } 77 | 78 | /** 79 | * Get the elapsed milliseconds since a previous time stamp 80 | * @param prev_tick a previous time stamp (return value of systick_get() ) 81 | * @return the elapsed milliseconds since 'prev_tick' 82 | */ 83 | uint32_t lv_tick_elaps(uint32_t prev_tick) 84 | { 85 | uint32_t act_time = lv_tick_get(); 86 | 87 | /*If there is no overflow in sys_time simple subtract*/ 88 | if(act_time >= prev_tick) { 89 | prev_tick = act_time - prev_tick; 90 | } else { 91 | prev_tick = UINT32_MAX - prev_tick + 1; 92 | prev_tick += act_time; 93 | } 94 | 95 | return prev_tick; 96 | } 97 | 98 | /********************** 99 | * STATIC FUNCTIONS 100 | **********************/ 101 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_objx_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | /* TODO Remove these instructions 7 | * Search an replace: template -> object normal name with lower case (e.g. button, label etc.) 8 | * templ -> object short name with lower case(e.g. btn, label etc) 9 | * TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.) 10 | * 11 | */ 12 | 13 | #ifndef LV_TEMPL_H 14 | #define LV_TEMPL_H 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | /********************* 21 | * INCLUDES 22 | *********************/ 23 | #ifdef LV_CONF_INCLUDE_SIMPLE 24 | #include "lv_conf.h" 25 | #else 26 | #include "../../../lv_conf.h" 27 | #endif 28 | 29 | #if LV_USE_TEMPL != 0 30 | 31 | #include "../lv_core/lv_obj.h" 32 | 33 | /********************* 34 | * DEFINES 35 | *********************/ 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | /*Data of template*/ 41 | typedef struct 42 | { 43 | lv_ANCESTOR_ext_t ANCESTOR; /*Ext. of ancestor*/ 44 | /*New data for this type */ 45 | } lv_templ_ext_t; 46 | 47 | /*Styles*/ 48 | enum { 49 | LV_TEMPL_STYLE_X, 50 | LV_TEMPL_STYLE_Y, 51 | }; 52 | typedef uint8_t lv_templ_style_t; 53 | 54 | /********************** 55 | * GLOBAL PROTOTYPES 56 | **********************/ 57 | 58 | /** 59 | * Create a template objects 60 | * @param par pointer to an object, it will be the parent of the new template 61 | * @param copy pointer to a template object, if not NULL then the new object will be copied from it 62 | * @return pointer to the created template 63 | */ 64 | lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy); 65 | 66 | /*====================== 67 | * Add/remove functions 68 | *=====================*/ 69 | 70 | /*===================== 71 | * Setter functions 72 | *====================*/ 73 | 74 | /** 75 | * Set a style of a template. 76 | * @param templ pointer to template object 77 | * @param type which style should be set 78 | * @param style pointer to a style 79 | */ 80 | void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, const lv_style_t * style); 81 | 82 | /*===================== 83 | * Getter functions 84 | *====================*/ 85 | 86 | /** 87 | * Get style of a template. 88 | * @param templ pointer to template object 89 | * @param type which style should be get 90 | * @return style pointer to the style 91 | */ 92 | lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type); 93 | 94 | /*===================== 95 | * Other functions 96 | *====================*/ 97 | 98 | /********************** 99 | * MACROS 100 | **********************/ 101 | 102 | #endif /*LV_USE_TEMPL*/ 103 | 104 | #ifdef __cplusplus 105 | } /* extern "C" */ 106 | #endif 107 | 108 | #endif /*LV_TEMPL_H*/ 109 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_arc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_ARC_H 7 | #define LV_ARC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_ARC != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | /*Data of arc*/ 34 | typedef struct 35 | { 36 | /*New data for this type */ 37 | lv_coord_t angle_start; 38 | lv_coord_t angle_end; 39 | } lv_arc_ext_t; 40 | 41 | /*Styles*/ 42 | enum { 43 | LV_ARC_STYLE_MAIN, 44 | }; 45 | typedef uint8_t lv_arc_style_t; 46 | 47 | /********************** 48 | * GLOBAL PROTOTYPES 49 | **********************/ 50 | 51 | /** 52 | * Create a arc objects 53 | * @param par pointer to an object, it will be the parent of the new arc 54 | * @param copy pointer to a arc object, if not NULL then the new object will be copied from it 55 | * @return pointer to the created arc 56 | */ 57 | lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy); 58 | 59 | /*====================== 60 | * Add/remove functions 61 | *=====================*/ 62 | 63 | /*===================== 64 | * Setter functions 65 | *====================*/ 66 | 67 | /** 68 | * Set the start and end angles of an arc. 0 deg: bottom, 90 deg: right etc. 69 | * @param arc pointer to an arc object 70 | * @param start the start angle [0..360] 71 | * @param end the end angle [0..360] 72 | */ 73 | void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end); 74 | 75 | /** 76 | * Set a style of a arc. 77 | * @param arc pointer to arc object 78 | * @param type which style should be set 79 | * @param style pointer to a style 80 | * */ 81 | void lv_arc_set_style(lv_obj_t * arc, lv_arc_style_t type, const lv_style_t * style); 82 | 83 | /*===================== 84 | * Getter functions 85 | *====================*/ 86 | 87 | /** 88 | * Get the start angle of an arc. 89 | * @param arc pointer to an arc object 90 | * @return the start angle [0..360] 91 | */ 92 | uint16_t lv_arc_get_angle_start(lv_obj_t * arc); 93 | 94 | /** 95 | * Get the end angle of an arc. 96 | * @param arc pointer to an arc object 97 | * @return the end angle [0..360] 98 | */ 99 | uint16_t lv_arc_get_angle_end(lv_obj_t * arc); 100 | 101 | /** 102 | * Get style of a arc. 103 | * @param arc pointer to arc object 104 | * @param type which style should be get 105 | * @return style pointer to the style 106 | * */ 107 | const lv_style_t * lv_arc_get_style(const lv_obj_t * arc, lv_arc_style_t type); 108 | 109 | /*===================== 110 | * Other functions 111 | *====================*/ 112 | 113 | /********************** 114 | * MACROS 115 | **********************/ 116 | 117 | #endif /*LV_USE_ARC*/ 118 | 119 | #ifdef __cplusplus 120 | } /* extern "C" */ 121 | #endif 122 | 123 | #endif /*LV_ARC_H*/ 124 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_H 7 | #define LV_DRAW_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #include "../lv_core/lv_style.h" 23 | #include "../lv_misc/lv_txt.h" 24 | #include "lv_img_decoder.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL PROTOTYPES 36 | **********************/ 37 | 38 | /** 39 | * Give a buffer with the given to use during drawing. 40 | * Be careful to not use the buffer while other processes are using it. 41 | * @param size the required size 42 | */ 43 | void * lv_draw_get_buf(uint32_t size); 44 | 45 | /** 46 | * Free the draw buffer 47 | */ 48 | void lv_draw_free_buf(void); 49 | 50 | #if LV_ANTIALIAS 51 | 52 | /** 53 | * Get the opacity of a pixel based it's position in a line segment 54 | * @param seg segment length 55 | * @param px_id position of of a pixel which opacity should be get [0..seg-1] 56 | * @param base_opa the base opacity 57 | * @return the opacity of the given pixel 58 | */ 59 | lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa); 60 | 61 | /** 62 | * Add a vertical anti-aliasing segment (pixels with decreasing opacity) 63 | * @param x start point x coordinate 64 | * @param y start point y coordinate 65 | * @param length length of segment (negative value to start from 0 opacity) 66 | * @param mask draw only in this area 67 | * @param color color of pixels 68 | * @param opa maximum opacity 69 | */ 70 | void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, 71 | lv_opa_t opa); 72 | 73 | /** 74 | * Add a horizontal anti-aliasing segment (pixels with decreasing opacity) 75 | * @param x start point x coordinate 76 | * @param y start point y coordinate 77 | * @param length length of segment (negative value to start from 0 opacity) 78 | * @param mask draw only in this area 79 | * @param color color of pixels 80 | * @param opa maximum opacity 81 | */ 82 | void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, 83 | lv_opa_t opa); 84 | #endif 85 | 86 | /********************** 87 | * GLOBAL VARIABLES 88 | **********************/ 89 | 90 | /********************** 91 | * MACROS 92 | **********************/ 93 | 94 | /********************** 95 | * POST INCLUDES 96 | *********************/ 97 | #include "lv_draw_basic.h" 98 | #include "lv_draw_rect.h" 99 | #include "lv_draw_label.h" 100 | #include "lv_draw_img.h" 101 | #include "lv_draw_line.h" 102 | #include "lv_draw_triangle.h" 103 | #include "lv_draw_arc.h" 104 | 105 | #ifdef __cplusplus 106 | } /* extern "C" */ 107 | #endif 108 | 109 | #endif /*LV_DRAW_H*/ 110 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_led.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_led.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LED_H 7 | #define LV_LED_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_LED != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /*Data of led*/ 35 | typedef struct 36 | { 37 | /*No inherited ext.*/ 38 | /*New data for this type */ 39 | uint8_t bright; /*Current brightness of the LED (0..255)*/ 40 | } lv_led_ext_t; 41 | 42 | /*Styles*/ 43 | enum { 44 | LV_LED_STYLE_MAIN, 45 | }; 46 | typedef uint8_t lv_led_style_t; 47 | 48 | /********************** 49 | * GLOBAL PROTOTYPES 50 | **********************/ 51 | 52 | /** 53 | * Create a led objects 54 | * @param par pointer to an object, it will be the parent of the new led 55 | * @param copy pointer to a led object, if not NULL then the new object will be copied from it 56 | * @return pointer to the created led 57 | */ 58 | lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy); 59 | 60 | /** 61 | * Set the brightness of a LED object 62 | * @param led pointer to a LED object 63 | * @param bright 0 (max. dark) ... 255 (max. light) 64 | */ 65 | void lv_led_set_bright(lv_obj_t * led, uint8_t bright); 66 | 67 | /** 68 | * Light on a LED 69 | * @param led pointer to a LED object 70 | */ 71 | void lv_led_on(lv_obj_t * led); 72 | 73 | /** 74 | * Light off a LED 75 | * @param led pointer to a LED object 76 | */ 77 | void lv_led_off(lv_obj_t * led); 78 | 79 | /** 80 | * Toggle the state of a LED 81 | * @param led pointer to a LED object 82 | */ 83 | void lv_led_toggle(lv_obj_t * led); 84 | 85 | /** 86 | * Set the style of a led 87 | * @param led pointer to a led object 88 | * @param type which style should be set (can be only `LV_LED_STYLE_MAIN`) 89 | * @param style pointer to a style 90 | */ 91 | static inline void lv_led_set_style(lv_obj_t * led, lv_led_style_t type, const lv_style_t * style) 92 | { 93 | (void)type; /*Unused*/ 94 | lv_obj_set_style(led, style); 95 | } 96 | 97 | /** 98 | * Get the brightness of a LEd object 99 | * @param led pointer to LED object 100 | * @return bright 0 (max. dark) ... 255 (max. light) 101 | */ 102 | uint8_t lv_led_get_bright(const lv_obj_t * led); 103 | 104 | /** 105 | * Get the style of an led object 106 | * @param led pointer to an led object 107 | * @param type which style should be get (can be only `LV_CHART_STYLE_MAIN`) 108 | * @return pointer to the led's style 109 | */ 110 | static inline const lv_style_t * lv_led_get_style(const lv_obj_t * led, lv_led_style_t type) 111 | { 112 | (void)type; /*Unused*/ 113 | return lv_obj_get_style(led); 114 | } 115 | 116 | /********************** 117 | * MACROS 118 | **********************/ 119 | 120 | #endif /*LV_USE_LED*/ 121 | 122 | #ifdef __cplusplus 123 | } /* extern "C" */ 124 | #endif 125 | 126 | #endif /*LV_LED_H*/ 127 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_utils.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_utils.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include 10 | 11 | #include "lv_utils.h" 12 | #include "lv_math.h" 13 | 14 | /********************* 15 | * DEFINES 16 | *********************/ 17 | 18 | /********************** 19 | * TYPEDEFS 20 | **********************/ 21 | 22 | /********************** 23 | * STATIC PROTOTYPES 24 | **********************/ 25 | 26 | /********************** 27 | * STATIC VARIABLES 28 | **********************/ 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | /** 39 | * Convert a number to string 40 | * @param num a number 41 | * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 42 | * @return same as `buf` (just for convenience) 43 | */ 44 | char * lv_utils_num_to_str(int32_t num, char * buf) 45 | { 46 | if(num == 0) { 47 | buf[0] = '0'; 48 | buf[1] = '\0'; 49 | return buf; 50 | } 51 | int8_t digitCount = 0; 52 | int8_t i = 0; 53 | if(num < 0) { 54 | buf[digitCount++] = '-'; 55 | num = LV_MATH_ABS(num); 56 | ++i; 57 | } 58 | while(num) { 59 | char digit = num % 10; 60 | buf[digitCount++] = digit + 48; 61 | num /= 10; 62 | } 63 | buf[digitCount] = '\0'; 64 | digitCount--; 65 | while(digitCount > i) { 66 | char temp = buf[i]; 67 | buf[i] = buf[digitCount]; 68 | buf[digitCount] = temp; 69 | digitCount--; 70 | i++; 71 | } 72 | return buf; 73 | } 74 | 75 | /** Searches base[0] to base[n - 1] for an item that matches *key. 76 | * 77 | * @note The function cmp must return negative if its first 78 | * argument (the search key) is less that its second (a table entry), 79 | * zero if equal, and positive if greater. 80 | * 81 | * @note Items in the array must be in ascending order. 82 | * 83 | * @param key Pointer to item being searched for 84 | * @param base Pointer to first element to search 85 | * @param n Number of elements 86 | * @param size Size of each element 87 | * @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function 88 | * example) 89 | * 90 | * @return a pointer to a matching item, or NULL if none exists. 91 | */ 92 | void * lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, 93 | int32_t (*cmp)(const void * pRef, const void * pElement)) 94 | { 95 | const char * middle; 96 | int32_t c; 97 | 98 | for(middle = base; n != 0;) { 99 | middle += (n / 2) * size; 100 | if((c = (*cmp)(key, middle)) > 0) { 101 | n = (n / 2) - ((n & 1) == 0); 102 | base = (middle += size); 103 | } else if(c < 0) { 104 | n /= 2; 105 | middle = base; 106 | } else { 107 | return (char *)middle; 108 | } 109 | } 110 | return NULL; 111 | } 112 | 113 | /********************** 114 | * STATIC FUNCTIONS 115 | **********************/ 116 | -------------------------------------------------------------------------------- /src/docs/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [atom@github.com](mailto:atom@github.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /examples/SIPEED_MAIX_lvgl/SIPEED_MAIX_lvgl.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define LVGL_TICK_PERIOD 20 6 | 7 | SPIClass spi_(SPI0);// MUST be SPI0 for Maix series on board LCD 8 | Ticker tick; /* timer for interrupt handler */ 9 | Sipeed_ST7789 lcd(320, 240, spi_); 10 | static lv_disp_buf_t disp_buf; 11 | static lv_color_t buf[LV_HOR_RES_MAX * 10]; 12 | #if USE_LV_LOG != 0 13 | /* Serial debugging */ 14 | void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc) 15 | { 16 | 17 | Serial.printf("%s@%d->%s\r\n", file, line, dsc); 18 | delay(100); 19 | } 20 | #endif 21 | 22 | /* Display flushing */ 23 | void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) { 24 | int32_t w = area->x2-area->x1+1; 25 | int32_t h = area->y2-area->y1+1; 26 | int32_t x,y; 27 | int32_t i=0; 28 | uint16_t* data = (uint16_t*)malloc( w*h*2 ); 29 | uint16_t* pixels = data; 30 | 31 | for(y=area->y1; y<=area->y2; ++y) 32 | { 33 | for(x=area->x1; x<=area->x2; ++x) 34 | { 35 | pixels[i++]= (color_p->ch.red<<3) | (color_p->ch.blue<<8) | (color_p->ch.green>>3&0x07 | color_p->ch.green<<13); 36 | // or LV_COLOR_16_SWAP = 1 37 | ++color_p; 38 | } 39 | } 40 | lcd.drawImage((uint16_t)area->x1, (uint16_t)area->y1, (uint16_t)w, (uint16_t)h, data); 41 | free(data); 42 | lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */ 43 | } 44 | 45 | /* Interrupt driven periodic handler */ 46 | static void lv_tick_handler(void) 47 | { 48 | 49 | lv_tick_inc(LVGL_TICK_PERIOD); 50 | } 51 | 52 | /* Reading input device (simulated encoder here) */ 53 | bool read_encoder(lv_indev_drv_t * indev, lv_indev_data_t * data) 54 | { 55 | static int32_t last_diff = 0; 56 | int32_t diff = 0; /* Dummy - no movement */ 57 | int btn_state = LV_INDEV_STATE_REL; /* Dummy - no press */ 58 | 59 | data->enc_diff = diff - last_diff;; 60 | data->state = btn_state; 61 | 62 | last_diff = diff; 63 | 64 | return false; 65 | } 66 | 67 | void setup() { 68 | 69 | Serial.begin(115200); /* prepare for possible serial debug */ 70 | lcd.begin(15000000, COLOR_WHITE); 71 | lv_init(); 72 | 73 | #if USE_LV_LOG != 0 74 | lv_log_register_print(my_print); /* register print function for debugging */ 75 | #endif 76 | 77 | lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); 78 | /*Initialize the display*/ 79 | lv_disp_drv_t disp_drv; 80 | lv_disp_drv_init(&disp_drv); 81 | disp_drv.hor_res = 320; 82 | disp_drv.ver_res = 240; 83 | disp_drv.flush_cb = my_disp_flush; 84 | disp_drv.buffer = &disp_buf; 85 | lv_disp_drv_register(&disp_drv); 86 | 87 | 88 | /*Initialize the touch pad*/ 89 | lv_indev_drv_t indev_drv; 90 | lv_indev_drv_init(&indev_drv); 91 | indev_drv.type = LV_INDEV_TYPE_ENCODER; 92 | indev_drv.read_cb = read_encoder; 93 | lv_indev_drv_register(&indev_drv); 94 | 95 | /*Initialize the graphics library's tick*/ 96 | tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler); 97 | 98 | /* Create simple label */ 99 | lv_obj_t *label = lv_label_create(lv_scr_act(), NULL); 100 | lv_label_set_text(label, "Hello Maixduino! (V6.0)"); 101 | lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); 102 | } 103 | 104 | 105 | void loop() { 106 | 107 | lv_task_handler(); /* let the GUI do its work */ 108 | delay(5); 109 | } 110 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_math.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_math.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_math.h" 10 | #include 11 | #include 12 | 13 | /********************* 14 | * DEFINES 15 | *********************/ 16 | 17 | /********************** 18 | * TYPEDEFS 19 | **********************/ 20 | 21 | /********************** 22 | * STATIC PROTOTYPES 23 | **********************/ 24 | 25 | /********************** 26 | * STATIC VARIABLES 27 | **********************/ 28 | static int16_t sin0_90_table[] = { 29 | 0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, 5690, 6252, 6813, 7371, 7927, 8481, 30 | 9032, 9580, 10126, 10668, 11207, 11743, 12275, 12803, 13328, 13848, 14364, 14876, 15383, 15886, 16383, 16876, 31 | 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621, 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, 32 | 24351, 24730, 25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196, 33 | 29451, 29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, 34 | 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767}; 35 | 36 | /********************** 37 | * MACROS 38 | **********************/ 39 | 40 | /********************** 41 | * GLOBAL FUNCTIONS 42 | **********************/ 43 | 44 | /** 45 | * Return with sinus of an angle 46 | * @param angle 47 | * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 48 | */ 49 | int16_t lv_trigo_sin(int16_t angle) 50 | { 51 | int16_t ret = 0; 52 | angle = angle % 360; 53 | 54 | if(angle < 0) angle = 360 + angle; 55 | 56 | if(angle < 90) { 57 | ret = sin0_90_table[angle]; 58 | } else if(angle >= 90 && angle < 180) { 59 | angle = 180 - angle; 60 | ret = sin0_90_table[angle]; 61 | } else if(angle >= 180 && angle < 270) { 62 | angle = angle - 180; 63 | ret = -sin0_90_table[angle]; 64 | } else { /*angle >=270*/ 65 | angle = 360 - angle; 66 | ret = -sin0_90_table[angle]; 67 | } 68 | 69 | return ret; 70 | } 71 | 72 | /** 73 | * Calculate a value of a Cubic Bezier function. 74 | * @param t time in range of [0..LV_BEZIER_VAL_MAX] 75 | * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] 76 | * @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX] 77 | * @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX] 78 | * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] 79 | * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] 80 | */ 81 | int32_t lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3) 82 | { 83 | uint32_t t_rem = 1024 - t; 84 | uint32_t t_rem2 = (t_rem * t_rem) >> 10; 85 | uint32_t t_rem3 = (t_rem2 * t_rem) >> 10; 86 | uint32_t t2 = (t * t) >> 10; 87 | uint32_t t3 = (t2 * t) >> 10; 88 | 89 | uint32_t v1 = ((uint32_t)t_rem3 * u0) >> 10; 90 | uint32_t v2 = ((uint32_t)3 * t_rem2 * t * u1) >> 20; 91 | uint32_t v3 = ((uint32_t)3 * t_rem * t2 * u2) >> 20; 92 | uint32_t v4 = ((uint32_t)t3 * u3) >> 10; 93 | 94 | return v1 + v2 + v3 + v4; 95 | } 96 | 97 | /********************** 98 | * STATIC FUNCTIONS 99 | **********************/ 100 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_color.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_color.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_color.h" 10 | 11 | /********************* 12 | * DEFINES 13 | *********************/ 14 | 15 | /********************** 16 | * TYPEDEFS 17 | **********************/ 18 | 19 | /********************** 20 | * STATIC PROTOTYPES 21 | **********************/ 22 | 23 | /********************** 24 | * STATIC VARIABLES 25 | **********************/ 26 | 27 | /********************** 28 | * MACROS 29 | **********************/ 30 | 31 | /********************** 32 | * GLOBAL FUNCTIONS 33 | **********************/ 34 | 35 | /********************** 36 | * STATIC FUNCTIONS 37 | **********************/ 38 | 39 | /** 40 | * Convert a HSV color to RGB 41 | * @param h hue [0..359] 42 | * @param s saturation [0..100] 43 | * @param v value [0..100] 44 | * @return the given RGB color in RGB (with LV_COLOR_DEPTH depth) 45 | */ 46 | lv_color_t lv_color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v) 47 | { 48 | h = (uint32_t)((uint32_t)h * 255) / 360; 49 | s = (uint16_t)((uint16_t)s * 255) / 100; 50 | v = (uint16_t)((uint16_t)v * 255) / 100; 51 | 52 | uint8_t r, g, b; 53 | 54 | uint8_t region, remainder, p, q, t; 55 | 56 | if(s == 0) { 57 | r = v; 58 | g = v; 59 | b = v; 60 | return lv_color_make(v, v, v); 61 | } 62 | 63 | region = h / 43; 64 | remainder = (h - (region * 43)) * 6; 65 | 66 | p = (v * (255 - s)) >> 8; 67 | q = (v * (255 - ((s * remainder) >> 8))) >> 8; 68 | t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8; 69 | 70 | switch(region) { 71 | case 0: 72 | r = v; 73 | g = t; 74 | b = p; 75 | break; 76 | case 1: 77 | r = q; 78 | g = v; 79 | b = p; 80 | break; 81 | case 2: 82 | r = p; 83 | g = v; 84 | b = t; 85 | break; 86 | case 3: 87 | r = p; 88 | g = q; 89 | b = v; 90 | break; 91 | case 4: 92 | r = t; 93 | g = p; 94 | b = v; 95 | break; 96 | default: 97 | r = v; 98 | g = p; 99 | b = q; 100 | break; 101 | } 102 | 103 | lv_color_t result = lv_color_make(r, g, b); 104 | return result; 105 | } 106 | 107 | /** 108 | * Convert an RGB color to HSV 109 | * @param r red 110 | * @param g green 111 | * @param b blue 112 | * @return the given RGB color n HSV 113 | */ 114 | lv_color_hsv_t lv_color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b) 115 | { 116 | lv_color_hsv_t hsv; 117 | uint8_t rgbMin, rgbMax; 118 | 119 | rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b); 120 | rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b); 121 | 122 | hsv.v = rgbMax; 123 | if(hsv.v == 0) { 124 | hsv.h = 0; 125 | hsv.s = 0; 126 | return hsv; 127 | } 128 | 129 | hsv.s = 255 * (long)(rgbMax - rgbMin) / hsv.v; 130 | if(hsv.s == 0) { 131 | hsv.h = 0; 132 | return hsv; 133 | } 134 | 135 | if(rgbMax == r) 136 | hsv.h = 0 + 43 * (g - b) / (rgbMax - rgbMin); 137 | else if(rgbMax == g) 138 | hsv.h = 85 + 43 * (b - r) / (rgbMax - rgbMin); 139 | else 140 | hsv.h = 171 + 43 * (r - g) / (rgbMax - rgbMin); 141 | 142 | return hsv; 143 | } 144 | -------------------------------------------------------------------------------- /src/src/lv_themes/lv_theme.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_theme.h" 10 | #include "../lv_core/lv_obj.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | /********************** 21 | * STATIC PROTOTYPES 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC VARIABLES 26 | **********************/ 27 | 28 | #if LV_THEME_LIVE_UPDATE == 0 29 | static lv_theme_t * current_theme; 30 | #else 31 | /* If live update is used then a big `lv_style_t` array is used to store the real styles of the 32 | * theme not only pointers. On `lv_theme_set_current` the styles of the theme are copied to this 33 | * array. The pointers in `current_theme` are initialized to point to the styles in the array. This 34 | * way the theme styles will always point to the same memory address even after theme is change. 35 | * (The pointers in the theme points to the styles declared by the theme itself) */ 36 | 37 | /* Store the styles in this array. */ 38 | static lv_style_t th_styles[LV_THEME_STYLE_COUNT]; 39 | static bool inited = false; 40 | static lv_theme_t current_theme; 41 | #endif 42 | 43 | /********************** 44 | * MACROS 45 | **********************/ 46 | 47 | /********************** 48 | * GLOBAL FUNCTIONS 49 | **********************/ 50 | 51 | /** 52 | * Set a theme for the system. 53 | * From now, all the created objects will use styles from this theme by default 54 | * @param th pointer to theme (return value of: 'lv_theme_init_xxx()') 55 | */ 56 | void lv_theme_set_current(lv_theme_t * th) 57 | { 58 | #if LV_THEME_LIVE_UPDATE == 0 59 | current_theme = th; 60 | 61 | #if LV_USE_GROUP 62 | /*Copy group style modification callback functions*/ 63 | memcpy(¤t_theme->group, &th->group, sizeof(th->group)); 64 | #endif 65 | 66 | /*Let the object know their style might change*/ 67 | lv_obj_report_style_mod(NULL); 68 | 69 | #else 70 | uint32_t style_num = sizeof(th->style) / sizeof(lv_style_t *); /*Number of styles in a theme*/ 71 | 72 | if(!inited) { 73 | /*Initialize the style pointers `current_theme` to point to the `th_styles` style array */ 74 | uint16_t i; 75 | lv_style_t ** cur_th_style_p = (lv_style_t **)¤t_theme.style; 76 | for(i = 0; i < style_num; i++) { 77 | uintptr_t adr = (uintptr_t)&th_styles[i]; 78 | memcpy(&cur_th_style_p[i], &adr, sizeof(lv_style_t *)); 79 | } 80 | inited = true; 81 | } 82 | 83 | /*Copy the styles pointed by the new theme to the `th_styles` style array*/ 84 | uint16_t i; 85 | lv_style_t ** th_style = (lv_style_t **)&th->style; 86 | for(i = 0; i < style_num; i++) { 87 | uintptr_t s = (uintptr_t)th_style[i]; 88 | if(s) memcpy(&th_styles[i], (void *)s, sizeof(lv_style_t)); 89 | } 90 | 91 | #if LV_USE_GROUP 92 | /*Copy group style modification callback functions*/ 93 | memcpy(¤t_theme.group, &th->group, sizeof(th->group)); 94 | #endif 95 | 96 | /*Let the object know their style might change*/ 97 | lv_obj_report_style_mod(NULL); 98 | 99 | #endif 100 | 101 | #if LV_USE_GROUP 102 | lv_group_report_style_mod(NULL); 103 | #endif 104 | } 105 | 106 | /** 107 | * Get the current system theme. 108 | * @return pointer to the current system theme. NULL if not set. 109 | */ 110 | lv_theme_t * lv_theme_get_current(void) 111 | { 112 | #if LV_THEME_LIVE_UPDATE == 0 113 | return current_theme; 114 | #else 115 | if(!inited) 116 | return NULL; 117 | else 118 | return ¤t_theme; 119 | #endif 120 | } 121 | 122 | /********************** 123 | * STATIC FUNCTIONS 124 | **********************/ 125 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_mem.h 3 | * 4 | */ 5 | 6 | #ifndef LV_MEM_H 7 | #define LV_MEM_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #include 23 | #include 24 | #include "lv_log.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | // Check windows 30 | #ifdef __WIN64 31 | #define LV_MEM_ENV64 32 | #endif 33 | 34 | // Check GCC 35 | #ifdef __GNUC__ 36 | #if defined(__x86_64__) || defined(__ppc64__) 37 | #define LV_MEM_ENV64 38 | #endif 39 | #endif 40 | 41 | /********************** 42 | * TYPEDEFS 43 | **********************/ 44 | 45 | /** 46 | * Heap information structure. 47 | */ 48 | typedef struct 49 | { 50 | uint32_t total_size; /**< Total heap size */ 51 | uint32_t free_cnt; 52 | uint32_t free_size; /**< Size of available memory */ 53 | uint32_t free_biggest_size; 54 | uint32_t used_cnt; 55 | uint8_t used_pct; /**< Percentage used */ 56 | uint8_t frag_pct; /**< Amount of fragmentation */ 57 | } lv_mem_monitor_t; 58 | 59 | /********************** 60 | * GLOBAL PROTOTYPES 61 | **********************/ 62 | 63 | /** 64 | * Initiaize the dyn_mem module (work memory and other variables) 65 | */ 66 | void lv_mem_init(void); 67 | 68 | /** 69 | * Allocate a memory dynamically 70 | * @param size size of the memory to allocate in bytes 71 | * @return pointer to the allocated memory 72 | */ 73 | void * lv_mem_alloc(uint32_t size); 74 | 75 | /** 76 | * Free an allocated data 77 | * @param data pointer to an allocated memory 78 | */ 79 | void lv_mem_free(const void * data); 80 | 81 | /** 82 | * Reallocate a memory with a new size. The old content will be kept. 83 | * @param data pointer to an allocated memory. 84 | * Its content will be copied to the new memory block and freed 85 | * @param new_size the desired new size in byte 86 | * @return pointer to the new memory 87 | */ 88 | void * lv_mem_realloc(void * data_p, uint32_t new_size); 89 | 90 | /** 91 | * Join the adjacent free memory blocks 92 | */ 93 | void lv_mem_defrag(void); 94 | 95 | /** 96 | * Give information about the work memory of dynamic allocation 97 | * @param mon_p pointer to a dm_mon_p variable, 98 | * the result of the analysis will be stored here 99 | */ 100 | void lv_mem_monitor(lv_mem_monitor_t * mon_p); 101 | 102 | /** 103 | * Give the size of an allocated memory 104 | * @param data pointer to an allocated memory 105 | * @return the size of data memory in bytes 106 | */ 107 | uint32_t lv_mem_get_size(const void * data); 108 | 109 | /********************** 110 | * MACROS 111 | **********************/ 112 | 113 | /** 114 | * Halt on NULL pointer 115 | * p pointer to a memory 116 | */ 117 | #if LV_USE_LOG == 0 118 | #define lv_mem_assert(p) \ 119 | { \ 120 | if(p == NULL) \ 121 | while(1) \ 122 | ; \ 123 | } 124 | #else 125 | #define lv_mem_assert(p) \ 126 | { \ 127 | if(p == NULL) { \ 128 | LV_LOG_ERROR("Out of memory!"); \ 129 | while(1) \ 130 | ; \ 131 | } \ 132 | } 133 | #endif 134 | #ifdef __cplusplus 135 | } /* extern "C" */ 136 | #endif 137 | 138 | #endif /*LV_MEM_H*/ 139 | -------------------------------------------------------------------------------- /examples/SIPEED_MAIX_touch/SIPEED_MAIX_touch.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define LVGL_TICK_PERIOD 20 7 | 8 | SPIClass spi_(SPI0);// MUST be SPI0 for Maix series on board LCD 9 | Ticker tick; /* timer for interrupt handler */ 10 | Sipeed_ST7789 lcd(320, 240, spi_); 11 | static lv_disp_buf_t disp_buf; 12 | static lv_color_t buf[LV_HOR_RES_MAX * 10]; 13 | TouchScreen touchscreen; 14 | int ledstate = 1; 15 | #if USE_LV_LOG != 0 16 | /* Serial debugging */ 17 | void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc) 18 | { 19 | 20 | Serial.printf("%s@%d->%s\r\n", file, line, dsc); 21 | delay(100); 22 | } 23 | #endif 24 | 25 | /* Display flushing */ 26 | void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) { 27 | int32_t w = area->x2-area->x1+1; 28 | int32_t h = area->y2-area->y1+1; 29 | int32_t x,y; 30 | int32_t i=0; 31 | uint16_t* data = (uint16_t*)malloc( w*h*2 ); 32 | uint16_t* pixels = data; 33 | 34 | for(y=area->y1; y<=area->y2; ++y) 35 | { 36 | for(x=area->x1; x<=area->x2; ++x) 37 | { 38 | pixels[i++]= (color_p->ch.red<<3) | (color_p->ch.blue<<8) | (color_p->ch.green>>3&0x07 | color_p->ch.green<<13); 39 | // or LV_COLOR_16_SWAP = 1 40 | ++color_p; 41 | } 42 | } 43 | lcd.drawImage((uint16_t)area->x1, (uint16_t)area->y1, (uint16_t)w, (uint16_t)h, data); 44 | free(data); 45 | lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */ 46 | } 47 | 48 | /* Interrupt driven periodic handler */ 49 | static void lv_tick_handler(void) 50 | { 51 | 52 | lv_tick_inc(LVGL_TICK_PERIOD); 53 | } 54 | 55 | /* Reading input device */ 56 | bool read_touchscreen(lv_indev_drv_t * drv, lv_indev_data_t * data) 57 | { 58 | int status, x, y; 59 | touchscreen.read(); 60 | status = touchscreen.getStatus(); 61 | x = touchscreen.getX(); 62 | y = touchscreen.getY(); 63 | switch(status) 64 | { 65 | case TOUCHSCREEN_STATUS_RELEASE: 66 | data->state = LV_INDEV_STATE_REL; 67 | break; 68 | case TOUCHSCREEN_STATUS_PRESS: 69 | case TOUCHSCREEN_STATUS_MOVE: 70 | data->state = LV_INDEV_STATE_PR; 71 | break; 72 | default: 73 | return false; 74 | } 75 | data->point.x = x; 76 | data->point.y = y; 77 | return false; 78 | } 79 | 80 | static void event_handler(lv_obj_t * btn, lv_event_t event) 81 | { 82 | if(event == LV_EVENT_CLICKED) { 83 | Serial.printf("Clicked\n"); 84 | } 85 | else if(event == LV_EVENT_VALUE_CHANGED) { 86 | Serial.printf("Toggled\n"); 87 | } 88 | } 89 | 90 | void setup() { 91 | 92 | Serial.begin(115200); /* prepare for possible serial debug */ 93 | lcd.begin(15000000, COLOR_WHITE); 94 | touchscreen.begin(); 95 | lv_init(); 96 | pinMode(LED_BUILTIN, OUTPUT); 97 | digitalWrite(LED_BUILTIN,ledstate);//power off led 98 | #if USE_LV_LOG != 0 99 | lv_log_register_print(my_print); /* register print function for debugging */ 100 | #endif 101 | 102 | lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); 103 | /*Initialize the display*/ 104 | lv_disp_drv_t disp_drv; 105 | lv_disp_drv_init(&disp_drv); 106 | disp_drv.hor_res = 320; 107 | disp_drv.ver_res = 240; 108 | disp_drv.flush_cb = my_disp_flush; 109 | disp_drv.buffer = &disp_buf; 110 | lv_disp_drv_register(&disp_drv); 111 | 112 | 113 | /*Initialize the touch pad*/ 114 | lv_indev_drv_t indev_drv; 115 | lv_indev_drv_init(&indev_drv); 116 | indev_drv.type = LV_INDEV_TYPE_POINTER; 117 | indev_drv.read_cb = read_touchscreen; 118 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv); 119 | 120 | /*Initialize the graphics library's tick*/ 121 | tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler); 122 | 123 | /* Create simple label */ 124 | lv_obj_t * label; 125 | 126 | lv_obj_t * btn1 = lv_btn_create(lv_scr_act(), NULL); 127 | lv_obj_set_event_cb(btn1, event_handler); 128 | lv_obj_align(btn1, NULL, LV_ALIGN_CENTER, 0, -40); 129 | 130 | label = lv_label_create(btn1, NULL); 131 | lv_label_set_text(label, "Button"); 132 | 133 | lv_obj_t * btn2 = lv_btn_create(lv_scr_act(), NULL); 134 | lv_obj_set_event_cb(btn2, event_handler); 135 | lv_obj_align(btn2, NULL, LV_ALIGN_CENTER, 0, 40); 136 | lv_btn_set_toggle(btn2, true); 137 | lv_btn_toggle(btn2); 138 | lv_btn_set_fit2(btn2, LV_FIT_NONE, LV_FIT_TIGHT); 139 | 140 | label = lv_label_create(btn2, NULL); 141 | lv_label_set_text(label, "Toggled"); 142 | } 143 | 144 | 145 | void loop() { 146 | 147 | lv_task_handler(); /* let the GUI do its work */ 148 | delay(5); 149 | } 150 | -------------------------------------------------------------------------------- /src/src/lv_draw/lv_draw_img.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_img.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_IMG_H 7 | #define LV_DRAW_IMG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | #include "lv_img_decoder.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | 31 | /** 32 | * Draw an image 33 | * @param coords the coordinates of the image 34 | * @param mask the image will be drawn only in this area 35 | * @param src pointer to a lv_color_t array which contains the pixels of the image 36 | * @param style style of the image 37 | * @param opa_scale scale down all opacities by the factor 38 | */ 39 | void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_style_t * style, 40 | lv_opa_t opa_scale); 41 | 42 | /** 43 | * Get the type of an image source 44 | * @param src pointer to an image source: 45 | * - pointer to an 'lv_img_t' variable (image stored internally and compiled into the code) 46 | * - a path to a file (e.g. "S:/folder/image.bin") 47 | * - or a symbol (e.g. LV_SYMBOL_CLOSE) 48 | * @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN 49 | */ 50 | lv_img_src_t lv_img_src_get_type(const void * src); 51 | 52 | /** 53 | * Get the color of an image's pixel 54 | * @param dsc an image descriptor 55 | * @param x x coordinate of the point to get 56 | * @param y x coordinate of the point to get 57 | * @param style style of the image. In case of `LV_IMG_CF_ALPHA_1/2/4/8` `style->image.color` shows 58 | * the color. Can be `NULL` but for `ALPHA` images black will be returned. In other cases it is not 59 | * used. 60 | * @return color of the point 61 | */ 62 | lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, const lv_style_t * style); 63 | /** 64 | * Get the alpha value of an image's pixel 65 | * @param dsc pointer to an image descriptor 66 | * @param x x coordinate of the point to set 67 | * @param y x coordinate of the point to set 68 | * @return alpha value of the point 69 | */ 70 | lv_opa_t lv_img_buf_get_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y); 71 | 72 | /** 73 | * Set the color of a pixel of an image. The alpha channel won't be affected. 74 | * @param dsc pointer to an image descriptor 75 | * @param x x coordinate of the point to set 76 | * @param y x coordinate of the point to set 77 | * @param c color of the point 78 | */ 79 | void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_color_t c); 80 | 81 | /** 82 | * Set the alpha value of a pixel of an image. The color won't be affected 83 | * @param dsc pointer to an image descriptor 84 | * @param x x coordinate of the point to set 85 | * @param y x coordinate of the point to set 86 | * @param opa the desired opacity 87 | */ 88 | void lv_img_buf_set_px_alpha(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_opa_t opa); 89 | 90 | /** 91 | * Set the palette color of an indexed image. Valid only for `LV_IMG_CF_INDEXED1/2/4/8` 92 | * @param dsc pointer to an image descriptor 93 | * @param id the palette color to set: 94 | * - for `LV_IMG_CF_INDEXED1`: 0..1 95 | * - for `LV_IMG_CF_INDEXED2`: 0..3 96 | * - for `LV_IMG_CF_INDEXED4`: 0..15 97 | * - for `LV_IMG_CF_INDEXED8`: 0..255 98 | * @param c the color to set 99 | */ 100 | void lv_img_buf_set_palette(lv_img_dsc_t * dsc, uint8_t id, lv_color_t c); 101 | 102 | /** 103 | * Get the pixel size of a color format in bits 104 | * @param cf a color format (`LV_IMG_CF_...`) 105 | * @return the pixel size in bits 106 | */ 107 | uint8_t lv_img_color_format_get_px_size(lv_img_cf_t cf); 108 | 109 | /** 110 | * Check if a color format is chroma keyed or not 111 | * @param cf a color format (`LV_IMG_CF_...`) 112 | * @return true: chroma keyed; false: not chroma keyed 113 | */ 114 | bool lv_img_color_format_is_chroma_keyed(lv_img_cf_t cf); 115 | 116 | /** 117 | * Check if a color format has alpha channel or not 118 | * @param cf a color format (`LV_IMG_CF_...`) 119 | * @return true: has alpha channel; false: doesn't have alpha channel 120 | */ 121 | bool lv_img_color_format_has_alpha(lv_img_cf_t cf); 122 | 123 | /********************** 124 | * MACROS 125 | **********************/ 126 | 127 | #ifdef __cplusplus 128 | } /* extern "C" */ 129 | #endif 130 | 131 | #endif /*LV_TEMPL_H*/ 132 | -------------------------------------------------------------------------------- /src/src/lv_core/lv_disp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_disp.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DISP_H 7 | #define LV_DISP_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_hal/lv_hal.h" 17 | #include "lv_obj.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | 31 | /** 32 | * Return with a pointer to the active screen 33 | * @param disp pointer to display which active screen should be get. (NULL to use the default 34 | * screen) 35 | * @return pointer to the active screen object (loaded by 'lv_scr_load()') 36 | */ 37 | lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp); 38 | 39 | /** 40 | * Make a screen active 41 | * @param scr pointer to a screen 42 | */ 43 | void lv_disp_load_scr(lv_obj_t * scr); 44 | 45 | /** 46 | * Return with the top layer. (Same on every screen and it is above the normal screen layer) 47 | * @param disp pointer to display which top layer should be get. (NULL to use the default screen) 48 | * @return pointer to the top layer object (transparent screen sized lv_obj) 49 | */ 50 | lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp); 51 | 52 | /** 53 | * Return with the sys. layer. (Same on every screen and it is above the normal screen and the top 54 | * layer) 55 | * @param disp pointer to display which sys. layer should be get. (NULL to use the default screen) 56 | * @return pointer to the sys layer object (transparent screen sized lv_obj) 57 | */ 58 | lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp); 59 | 60 | /** 61 | * Assign a screen to a display. 62 | * @param disp pointer to a display where to assign the screen 63 | * @param scr pointer to a screen object to assign 64 | */ 65 | void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr); 66 | 67 | /** 68 | * Get a pointer to the screen refresher task to 69 | * modify its parameters with `lv_task_...` functions. 70 | * @param disp pointer to a display 71 | * @return pointer to the display refresher task. (NULL on error) 72 | */ 73 | lv_task_t * lv_disp_get_refr_task(lv_disp_t * disp); 74 | 75 | /** 76 | * Get elapsed time since last user activity on a display (e.g. click) 77 | * @param disp pointer to an display (NULL to get the overall smallest inactivity) 78 | * @return elapsed ticks (milliseconds) since the last activity 79 | */ 80 | uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp); 81 | 82 | /** 83 | * Manually trigger an activity on a display 84 | * @param disp pointer to an display (NULL to use the default display) 85 | */ 86 | void lv_disp_trig_activity(lv_disp_t * disp); 87 | 88 | /*------------------------------------------------ 89 | * To improve backward compatibility 90 | * Recommended only if you have one display 91 | *------------------------------------------------*/ 92 | 93 | /** 94 | * Get the active screen of the default display 95 | * @return pointer to the active screen 96 | */ 97 | static inline lv_obj_t * lv_scr_act(void) 98 | { 99 | return lv_disp_get_scr_act(lv_disp_get_default()); 100 | } 101 | 102 | /** 103 | * Get the top layer of the default display 104 | * @return pointer to the top layer 105 | */ 106 | static inline lv_obj_t * lv_layer_top(void) 107 | { 108 | return lv_disp_get_layer_top(lv_disp_get_default()); 109 | } 110 | 111 | /** 112 | * Get the active screen of the deafult display 113 | * @return pointer to the sys layer 114 | */ 115 | static inline lv_obj_t * lv_layer_sys(void) 116 | { 117 | return lv_disp_get_layer_sys(lv_disp_get_default()); 118 | } 119 | 120 | static inline void lv_scr_load(lv_obj_t * scr) 121 | { 122 | lv_disp_load_scr(scr); 123 | } 124 | 125 | /********************** 126 | * MACROS 127 | **********************/ 128 | 129 | /*------------------------------------------------ 130 | * To improve backward compatibility 131 | * Recommended only if you have one display 132 | *------------------------------------------------*/ 133 | 134 | #ifndef LV_HOR_RES 135 | /** 136 | * The horizontal resolution of the currently active display. 137 | */ 138 | #define LV_HOR_RES lv_disp_get_hor_res(lv_disp_get_default()) 139 | #endif 140 | 141 | #ifndef LV_VER_RES 142 | /** 143 | * The vertical resolution of the currently active display. 144 | */ 145 | #define LV_VER_RES lv_disp_get_ver_res(lv_disp_get_default()) 146 | #endif 147 | 148 | #ifdef __cplusplus 149 | } /* extern "C" */ 150 | #endif 151 | 152 | #endif /*LV_TEMPL_H*/ 153 | -------------------------------------------------------------------------------- /src/src/lv_font/lv_font.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_font.h 3 | * 4 | */ 5 | 6 | #ifndef LV_FONT_H 7 | #define LV_FONT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "lv_symbol_def.h" 27 | 28 | /********************* 29 | * DEFINES 30 | *********************/ 31 | /*Number of fractional digits in the advanced width (`adv_w`) field of `lv_font_glyph_dsc_t`*/ 32 | #define LV_FONT_WIDTH_FRACT_DIGIT 4 33 | 34 | #define LV_FONT_KERN_POSITIVE 0 35 | #define LV_FONT_KERN_NEGATIVE 1 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | 41 | /*------------------ 42 | * General types 43 | *-----------------*/ 44 | 45 | /** Describes the properties of a glyph. */ 46 | typedef struct 47 | { 48 | uint16_t adv_w; /**< The glyph needs this space. Draw the next glyph after this width. 8 bit integer, 4 bit fractional */ 49 | uint8_t box_w; /**< Width of the glyph's bounding box*/ 50 | uint8_t box_h; /**< Height of the glyph's bounding box*/ 51 | int8_t ofs_x; /**< x offset of the bounding box*/ 52 | int8_t ofs_y; /**< y offset of the bounding box*/ 53 | uint8_t bpp; /**< Bit-per-pixel: 1, 2, 4, 8*/ 54 | }lv_font_glyph_dsc_t; 55 | 56 | /*Describe the properties of a font*/ 57 | typedef struct _lv_font_struct 58 | { 59 | /** Get a glyph's descriptor from a font*/ 60 | bool (*get_glyph_dsc)(const struct _lv_font_struct *, lv_font_glyph_dsc_t *, uint32_t letter, uint32_t letter_next); 61 | 62 | /** Get a glyph's bitmap from a font*/ 63 | const uint8_t * (*get_glyph_bitmap)(const struct _lv_font_struct *, uint32_t); 64 | 65 | /*Pointer to the font in a font pack (must have the same line height)*/ 66 | uint8_t line_height; /**< The real line height where any text fits*/ 67 | uint8_t base_line; /**< Base line measured from the top of the line_height*/ 68 | void * dsc; /**< Store implementation specific data here*/ 69 | #if LV_USE_USER_DATA 70 | lv_font_user_data_t user_data; /**< Custom user data for font. */ 71 | #endif 72 | } lv_font_t; 73 | 74 | /********************** 75 | * GLOBAL PROTOTYPES 76 | **********************/ 77 | 78 | /** 79 | * Return with the bitmap of a font. 80 | * @param font_p pointer to a font 81 | * @param letter an UNICODE character code 82 | * @return pointer to the bitmap of the letter 83 | */ 84 | const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter); 85 | 86 | /** 87 | * Get the descriptor of a glyph 88 | * @param font_p pointer to font 89 | * @param dsc_out store the result descriptor here 90 | * @param letter an UNICODE letter code 91 | * @return true: descriptor is successfully loaded into `dsc_out`. 92 | * false: the letter was not found, no data is loaded to `dsc_out` 93 | */ 94 | bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter, uint32_t letter_next); 95 | 96 | /** 97 | * Get the width of a glyph with kerning 98 | * @param font pointer to a font 99 | * @param letter an UNICODE letter 100 | * @param letter_next the next letter after `letter`. Used for kerning 101 | * @return the width of the glyph 102 | */ 103 | uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next); 104 | 105 | /** 106 | * Get the line height of a font. All characters fit into this height 107 | * @param font_p pointer to a font 108 | * @return the height of a font 109 | */ 110 | static inline uint8_t lv_font_get_line_height(const lv_font_t * font_p) 111 | { 112 | return font_p->line_height; 113 | } 114 | 115 | /********************** 116 | * MACROS 117 | **********************/ 118 | 119 | #define LV_FONT_DECLARE(font_name) extern lv_font_t font_name; 120 | 121 | #if LV_FONT_ROBOTO_12 122 | LV_FONT_DECLARE(lv_font_roboto_12) 123 | #endif 124 | 125 | #if LV_FONT_ROBOTO_16 126 | LV_FONT_DECLARE(lv_font_roboto_16) 127 | #endif 128 | 129 | #if LV_FONT_ROBOTO_22 130 | LV_FONT_DECLARE(lv_font_roboto_22) 131 | #endif 132 | 133 | #if LV_FONT_ROBOTO_28 134 | LV_FONT_DECLARE(lv_font_roboto_28) 135 | #endif 136 | 137 | #if LV_FONT_UNSCII_8 138 | LV_FONT_DECLARE(lv_font_unscii_8) 139 | #endif 140 | 141 | /*Declare the custom (user defined) fonts*/ 142 | #ifdef LV_FONT_CUSTOM_DECLARE 143 | LV_FONT_CUSTOM_DECLARE 144 | #endif 145 | 146 | #ifdef __cplusplus 147 | } /* extern "C" */ 148 | #endif 149 | 150 | #endif /*USE_FONT*/ 151 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_sw.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_sw.h 3 | * 4 | */ 5 | 6 | #ifndef LV_SW_H 7 | #define LV_SW_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_SW != 0 23 | 24 | /*Testing of dependencies*/ 25 | #if LV_USE_SLIDER == 0 26 | #error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1)" 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "lv_slider.h" 31 | 32 | /********************* 33 | * DEFINES 34 | *********************/ 35 | #define LV_SW_MAX_VALUE 100 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | /*Data of switch*/ 41 | typedef struct 42 | { 43 | lv_slider_ext_t slider; /*Ext. of ancestor*/ 44 | /*New data for this type */ 45 | const lv_style_t * style_knob_off; /**< Style of the knob when the switch is OFF*/ 46 | const lv_style_t * style_knob_on; /**< Style of the knob when the switch is ON (NULL to use the same as OFF)*/ 47 | lv_coord_t start_x; 48 | uint8_t changed : 1; /*Indicates the switch state explicitly changed by drag*/ 49 | uint8_t slided : 1; 50 | #if LV_USE_ANIMATION 51 | uint16_t anim_time; /*switch animation time */ 52 | #endif 53 | } lv_sw_ext_t; 54 | 55 | /** 56 | * Switch styles. 57 | */ 58 | enum { 59 | LV_SW_STYLE_BG, /**< Switch background. */ 60 | LV_SW_STYLE_INDIC, /**< Switch fill area. */ 61 | LV_SW_STYLE_KNOB_OFF, /**< Switch knob (when off). */ 62 | LV_SW_STYLE_KNOB_ON, /**< Switch knob (when on). */ 63 | }; 64 | typedef uint8_t lv_sw_style_t; 65 | 66 | /********************** 67 | * GLOBAL PROTOTYPES 68 | **********************/ 69 | 70 | /** 71 | * Create a switch objects 72 | * @param par pointer to an object, it will be the parent of the new switch 73 | * @param copy pointer to a switch object, if not NULL then the new object will be copied from it 74 | * @return pointer to the created switch 75 | */ 76 | lv_obj_t * lv_sw_create(lv_obj_t * par, const lv_obj_t * copy); 77 | 78 | /*===================== 79 | * Setter functions 80 | *====================*/ 81 | 82 | /** 83 | * Turn ON the switch 84 | * @param sw pointer to a switch object 85 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 86 | */ 87 | void lv_sw_on(lv_obj_t * sw, lv_anim_enable_t anim); 88 | 89 | /** 90 | * Turn OFF the switch 91 | * @param sw pointer to a switch object 92 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 93 | */ 94 | void lv_sw_off(lv_obj_t * sw, lv_anim_enable_t anim); 95 | 96 | /** 97 | * Toggle the position of the switch 98 | * @param sw pointer to a switch object 99 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 100 | * @return resulting state of the switch. 101 | */ 102 | bool lv_sw_toggle(lv_obj_t * sw, lv_anim_enable_t anim); 103 | 104 | /** 105 | * Set a style of a switch 106 | * @param sw pointer to a switch object 107 | * @param type which style should be set 108 | * @param style pointer to a style 109 | */ 110 | void lv_sw_set_style(lv_obj_t * sw, lv_sw_style_t type, const lv_style_t * style); 111 | 112 | /** 113 | * Set the animation time of the switch 114 | * @param sw pointer to a switch object 115 | * @param anim_time animation time 116 | * @return style pointer to a style 117 | */ 118 | void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time); 119 | 120 | /*===================== 121 | * Getter functions 122 | *====================*/ 123 | 124 | /** 125 | * Get the state of a switch 126 | * @param sw pointer to a switch object 127 | * @return false: OFF; true: ON 128 | */ 129 | static inline bool lv_sw_get_state(const lv_obj_t * sw) 130 | { 131 | return lv_bar_get_value(sw) < LV_SW_MAX_VALUE / 2 ? false : true; 132 | } 133 | 134 | /** 135 | * Get a style of a switch 136 | * @param sw pointer to a switch object 137 | * @param type which style should be get 138 | * @return style pointer to a style 139 | */ 140 | const lv_style_t * lv_sw_get_style(const lv_obj_t * sw, lv_sw_style_t type); 141 | 142 | /** 143 | * Get the animation time of the switch 144 | * @param sw pointer to a switch object 145 | * @return style pointer to a style 146 | */ 147 | uint16_t lv_sw_get_anim_time(const lv_obj_t * sw); 148 | 149 | /********************** 150 | * MACROS 151 | **********************/ 152 | 153 | #endif /*LV_USE_SW*/ 154 | 155 | #ifdef __cplusplus 156 | } /* extern "C" */ 157 | #endif 158 | 159 | #endif /*LV_SW_H*/ 160 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_line.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_line.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LINE_H 7 | #define LV_LINE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_LINE != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /*Data of line*/ 35 | typedef struct 36 | { 37 | /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ 38 | const lv_point_t * point_array; /*Pointer to an array with the points of the line*/ 39 | uint16_t point_num; /*Number of points in 'point_array' */ 40 | uint8_t auto_size : 1; /*1: set obj. width to x max and obj. height to y max */ 41 | uint8_t y_inv : 1; /*1: y == 0 will be on the bottom*/ 42 | } lv_line_ext_t; 43 | 44 | /*Styles*/ 45 | enum { 46 | LV_LINE_STYLE_MAIN, 47 | }; 48 | typedef uint8_t lv_line_style_t; 49 | 50 | /********************** 51 | * GLOBAL PROTOTYPES 52 | **********************/ 53 | 54 | /** 55 | * Create a line objects 56 | * @param par pointer to an object, it will be the parent of the new line 57 | * @return pointer to the created line 58 | */ 59 | lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy); 60 | 61 | /*===================== 62 | * Setter functions 63 | *====================*/ 64 | 65 | /** 66 | * Set an array of points. The line object will connect these points. 67 | * @param line pointer to a line object 68 | * @param point_a an array of points. Only the address is saved, 69 | * so the array can NOT be a local variable which will be destroyed 70 | * @param point_num number of points in 'point_a' 71 | */ 72 | void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t point_num); 73 | 74 | /** 75 | * Enable (or disable) the auto-size option. The size of the object will fit to its points. 76 | * (set width to x max and height to y max) 77 | * @param line pointer to a line object 78 | * @param en true: auto size is enabled, false: auto size is disabled 79 | */ 80 | void lv_line_set_auto_size(lv_obj_t * line, bool en); 81 | 82 | /** 83 | * Enable (or disable) the y coordinate inversion. 84 | * If enabled then y will be subtracted from the height of the object, 85 | * therefore the y=0 coordinate will be on the bottom. 86 | * @param line pointer to a line object 87 | * @param en true: enable the y inversion, false:disable the y inversion 88 | */ 89 | void lv_line_set_y_invert(lv_obj_t * line, bool en); 90 | 91 | #define lv_line_set_y_inv \ 92 | lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will \ 93 | work */ 94 | 95 | /** 96 | * Set the style of a line 97 | * @param line pointer to a line object 98 | * @param type which style should be set (can be only `LV_LINE_STYLE_MAIN`) 99 | * @param style pointer to a style 100 | */ 101 | static inline void lv_line_set_style(lv_obj_t * line, lv_line_style_t type, const lv_style_t * style) 102 | { 103 | (void)type; /*Unused*/ 104 | lv_obj_set_style(line, style); 105 | } 106 | 107 | /*===================== 108 | * Getter functions 109 | *====================*/ 110 | 111 | /** 112 | * Get the auto size attribute 113 | * @param line pointer to a line object 114 | * @return true: auto size is enabled, false: disabled 115 | */ 116 | bool lv_line_get_auto_size(const lv_obj_t * line); 117 | 118 | /** 119 | * Get the y inversion attribute 120 | * @param line pointer to a line object 121 | * @return true: y inversion is enabled, false: disabled 122 | */ 123 | bool lv_line_get_y_invert(const lv_obj_t * line); 124 | 125 | /** 126 | * Get the style of an line object 127 | * @param line pointer to an line object 128 | * @param type which style should be get (can be only `LV_LINE_STYLE_MAIN`) 129 | * @return pointer to the line's style 130 | */ 131 | static inline const lv_style_t * lv_line_get_style(const lv_obj_t * line, lv_line_style_t type) 132 | { 133 | (void)type; /*Unused*/ 134 | return lv_obj_get_style(line); 135 | } 136 | 137 | /********************** 138 | * MACROS 139 | **********************/ 140 | 141 | #endif /*LV_USE_LINE*/ 142 | 143 | #ifdef __cplusplus 144 | } /* extern "C" */ 145 | #endif 146 | 147 | #endif /*LV_LINE_H*/ 148 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_lmeter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_lmeter.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LMETER_H 7 | #define LV_LMETER_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_LMETER != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | /*Data of line meter*/ 34 | typedef struct 35 | { 36 | /*No inherited ext.*/ /*Ext. of ancestor*/ 37 | /*New data for this type */ 38 | uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/ 39 | uint8_t line_cnt; /*Count of lines */ 40 | int16_t cur_value; 41 | int16_t min_value; 42 | int16_t max_value; 43 | } lv_lmeter_ext_t; 44 | 45 | /*Styles*/ 46 | enum { 47 | LV_LMETER_STYLE_MAIN, 48 | }; 49 | typedef uint8_t lv_lmeter_style_t; 50 | 51 | /********************** 52 | * GLOBAL PROTOTYPES 53 | **********************/ 54 | 55 | /** 56 | * Create a line meter objects 57 | * @param par pointer to an object, it will be the parent of the new line meter 58 | * @param copy pointer to a line meter object, if not NULL then the new object will be copied from 59 | * it 60 | * @return pointer to the created line meter 61 | */ 62 | lv_obj_t * lv_lmeter_create(lv_obj_t * par, const lv_obj_t * copy); 63 | 64 | /*===================== 65 | * Setter functions 66 | *====================*/ 67 | 68 | /** 69 | * Set a new value on the line meter 70 | * @param lmeter pointer to a line meter object 71 | * @param value new value 72 | */ 73 | void lv_lmeter_set_value(lv_obj_t * lmeter, int16_t value); 74 | 75 | /** 76 | * Set minimum and the maximum values of a line meter 77 | * @param lmeter pointer to he line meter object 78 | * @param min minimum value 79 | * @param max maximum value 80 | */ 81 | void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max); 82 | 83 | /** 84 | * Set the scale settings of a line meter 85 | * @param lmeter pointer to a line meter object 86 | * @param angle angle of the scale (0..360) 87 | * @param line_cnt number of lines 88 | */ 89 | void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt); 90 | 91 | /** 92 | * Set the styles of a line meter 93 | * @param lmeter pointer to a line meter object 94 | * @param type which style should be set (can be only `LV_LMETER_STYLE_MAIN`) 95 | * @param style set the style of the line meter 96 | */ 97 | static inline void lv_lmeter_set_style(lv_obj_t * lmeter, lv_lmeter_style_t type, lv_style_t * style) 98 | { 99 | (void)type; /*Unused*/ 100 | lv_obj_set_style(lmeter, style); 101 | } 102 | 103 | /*===================== 104 | * Getter functions 105 | *====================*/ 106 | 107 | /** 108 | * Get the value of a line meter 109 | * @param lmeter pointer to a line meter object 110 | * @return the value of the line meter 111 | */ 112 | int16_t lv_lmeter_get_value(const lv_obj_t * lmeter); 113 | 114 | /** 115 | * Get the minimum value of a line meter 116 | * @param lmeter pointer to a line meter object 117 | * @return the minimum value of the line meter 118 | */ 119 | int16_t lv_lmeter_get_min_value(const lv_obj_t * lmeter); 120 | 121 | /** 122 | * Get the maximum value of a line meter 123 | * @param lmeter pointer to a line meter object 124 | * @return the maximum value of the line meter 125 | */ 126 | int16_t lv_lmeter_get_max_value(const lv_obj_t * lmeter); 127 | 128 | /** 129 | * Get the scale number of a line meter 130 | * @param lmeter pointer to a line meter object 131 | * @return number of the scale units 132 | */ 133 | uint8_t lv_lmeter_get_line_count(const lv_obj_t * lmeter); 134 | 135 | /** 136 | * Get the scale angle of a line meter 137 | * @param lmeter pointer to a line meter object 138 | * @return angle of the scale 139 | */ 140 | uint16_t lv_lmeter_get_scale_angle(const lv_obj_t * lmeter); 141 | 142 | /** 143 | * Get the style of a line meter 144 | * @param lmeter pointer to a line meter object 145 | * @param type which style should be get (can be only `LV_LMETER_STYLE_MAIN`) 146 | * @return pointer to the line meter's style 147 | */ 148 | static inline const lv_style_t * lv_lmeter_get_style(const lv_obj_t * lmeter, lv_lmeter_style_t type) 149 | { 150 | (void)type; /*Unused*/ 151 | return lv_obj_get_style(lmeter); 152 | } 153 | 154 | /********************** 155 | * MACROS 156 | **********************/ 157 | 158 | #endif /*LV_USE_LMETER*/ 159 | 160 | #ifdef __cplusplus 161 | } /* extern "C" */ 162 | #endif 163 | 164 | #endif /*LV_LMETER_H*/ 165 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_ll.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_ll.c 3 | * Handle linked lists. The nodes are dynamically allocated by the 'lv_mem' module. 4 | */ 5 | 6 | #ifndef LV_LL_H 7 | #define LV_LL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_mem.h" 17 | #include 18 | #include 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /** Dummy type to make handling easier*/ 30 | typedef uint8_t lv_ll_node_t; 31 | 32 | /** Description of a linked list*/ 33 | typedef struct 34 | { 35 | uint32_t n_size; 36 | lv_ll_node_t * head; 37 | lv_ll_node_t * tail; 38 | } lv_ll_t; 39 | 40 | /********************** 41 | * GLOBAL PROTOTYPES 42 | **********************/ 43 | 44 | /** 45 | * Initialize linked list 46 | * @param ll_dsc pointer to ll_dsc variable 47 | * @param node_size the size of 1 node in bytes 48 | */ 49 | void lv_ll_init(lv_ll_t * ll_p, uint32_t node_size); 50 | 51 | /** 52 | * Add a new head to a linked list 53 | * @param ll_p pointer to linked list 54 | * @return pointer to the new head 55 | */ 56 | void * lv_ll_ins_head(lv_ll_t * ll_p); 57 | 58 | /** 59 | * Insert a new node in front of the n_act node 60 | * @param ll_p pointer to linked list 61 | * @param n_act pointer a node 62 | * @return pointer to the new head 63 | */ 64 | void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act); 65 | 66 | /** 67 | * Add a new tail to a linked list 68 | * @param ll_p pointer to linked list 69 | * @return pointer to the new tail 70 | */ 71 | void * lv_ll_ins_tail(lv_ll_t * ll_p); 72 | 73 | /** 74 | * Remove the node 'node_p' from 'll_p' linked list. 75 | * It does not free the the memory of node. 76 | * @param ll_p pointer to the linked list of 'node_p' 77 | * @param node_p pointer to node in 'll_p' linked list 78 | */ 79 | void lv_ll_rem(lv_ll_t * ll_p, void * node_p); 80 | 81 | /** 82 | * Remove and free all elements from a linked list. The list remain valid but become empty. 83 | * @param ll_p pointer to linked list 84 | */ 85 | void lv_ll_clear(lv_ll_t * ll_p); 86 | 87 | /** 88 | * Move a node to a new linked list 89 | * @param ll_ori_p pointer to the original (old) linked list 90 | * @param ll_new_p pointer to the new linked list 91 | * @param node pointer to a node 92 | * @param head true: be the head in the new list 93 | * false be the head in the new list 94 | */ 95 | void lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool head); 96 | 97 | /** 98 | * Return with head node of the linked list 99 | * @param ll_p pointer to linked list 100 | * @return pointer to the head of 'll_p' 101 | */ 102 | void * lv_ll_get_head(const lv_ll_t * ll_p); 103 | 104 | /** 105 | * Return with tail node of the linked list 106 | * @param ll_p pointer to linked list 107 | * @return pointer to the head of 'll_p' 108 | */ 109 | void * lv_ll_get_tail(const lv_ll_t * ll_p); 110 | 111 | /** 112 | * Return with the pointer of the next node after 'n_act' 113 | * @param ll_p pointer to linked list 114 | * @param n_act pointer a node 115 | * @return pointer to the next node 116 | */ 117 | void * lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act); 118 | 119 | /** 120 | * Return with the pointer of the previous node after 'n_act' 121 | * @param ll_p pointer to linked list 122 | * @param n_act pointer a node 123 | * @return pointer to the previous node 124 | */ 125 | void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act); 126 | 127 | /** 128 | * Return the length of the linked list. 129 | * @param ll_p pointer to linked list 130 | * @return length of the linked list 131 | */ 132 | uint32_t lv_ll_get_len(const lv_ll_t * ll_p); 133 | 134 | /** 135 | * Move a nodw before an other node in the same linked list 136 | * @param ll_p pointer to a linked list 137 | * @param n_act pointer to node to move 138 | * @param n_after pointer to a node which should be after `n_act` 139 | */ 140 | void lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after); 141 | 142 | /** 143 | * Check if a linked list is empty 144 | * @param ll_p pointer to a linked list 145 | * @return true: the linked list is empty; false: not empty 146 | */ 147 | bool lv_ll_is_empty(lv_ll_t * ll_p); 148 | /********************** 149 | * MACROS 150 | **********************/ 151 | 152 | #define LV_LL_READ(list, i) for(i = lv_ll_get_head(&list); i != NULL; i = lv_ll_get_next(&list, i)) 153 | 154 | #define LV_LL_READ_BACK(list, i) for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i)) 155 | 156 | #ifdef __cplusplus 157 | } /* extern "C" */ 158 | #endif 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_task.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_task.c 3 | * An 'lv_task' is a void (*fp) (void* param) type function which will be called periodically. 4 | * A priority (5 levels + disable) can be assigned to lv_tasks. 5 | */ 6 | 7 | #ifndef LV_TASK_H 8 | #define LV_TASK_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /********************* 15 | * INCLUDES 16 | *********************/ 17 | #ifdef LV_CONF_INCLUDE_SIMPLE 18 | #include "lv_conf.h" 19 | #else 20 | #include "../../../lv_conf.h" 21 | #endif 22 | 23 | #include 24 | #include 25 | #include "lv_mem.h" 26 | #include "lv_ll.h" 27 | 28 | /********************* 29 | * DEFINES 30 | *********************/ 31 | #ifndef LV_ATTRIBUTE_TASK_HANDLER 32 | #define LV_ATTRIBUTE_TASK_HANDLER 33 | #endif 34 | /********************** 35 | * TYPEDEFS 36 | **********************/ 37 | 38 | struct _lv_task_t; 39 | 40 | /** 41 | * Tasks execute this type type of functions. 42 | */ 43 | typedef void (*lv_task_cb_t)(struct _lv_task_t *); 44 | 45 | /** 46 | * Possible priorities for lv_tasks 47 | */ 48 | enum { 49 | LV_TASK_PRIO_OFF = 0, 50 | LV_TASK_PRIO_LOWEST, 51 | LV_TASK_PRIO_LOW, 52 | LV_TASK_PRIO_MID, 53 | LV_TASK_PRIO_HIGH, 54 | LV_TASK_PRIO_HIGHEST, 55 | _LV_TASK_PRIO_NUM, 56 | }; 57 | typedef uint8_t lv_task_prio_t; 58 | 59 | /** 60 | * Descriptor of a lv_task 61 | */ 62 | typedef struct _lv_task_t 63 | { 64 | uint32_t period; /**< How often the task should run */ 65 | uint32_t last_run; /**< Last time the task ran */ 66 | lv_task_cb_t task_cb; /**< Task function */ 67 | 68 | void * user_data; /**< Custom user data */ 69 | 70 | uint8_t prio : 3; /**< Task priority */ 71 | uint8_t once : 1; /**< 1: one shot task */ 72 | } lv_task_t; 73 | 74 | /********************** 75 | * GLOBAL PROTOTYPES 76 | **********************/ 77 | 78 | /** 79 | * Init the lv_task module 80 | */ 81 | void lv_task_core_init(void); 82 | 83 | //! @cond Doxygen_Suppress 84 | 85 | /** 86 | * Call it periodically to handle lv_tasks. 87 | */ 88 | LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void); 89 | 90 | //! @endcond 91 | 92 | /** 93 | * Create an "empty" task. It needs to initialzed with at least 94 | * `lv_task_set_cb` and `lv_task_set_period` 95 | * @return pointer to the craeted task 96 | */ 97 | lv_task_t * lv_task_create_basic(void); 98 | 99 | /** 100 | * Create a new lv_task 101 | * @param task_xcb a callback which is the task itself. It will be called periodically. 102 | * (the 'x' in the argument name indicates that its not a fully generic function because it not follows 103 | * the `func_name(object, callback, ...)` convention) 104 | * @param period call period in ms unit 105 | * @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) 106 | * @param user_data custom parameter 107 | * @return pointer to the new task 108 | */ 109 | lv_task_t * lv_task_create(lv_task_cb_t task_xcb, uint32_t period, lv_task_prio_t prio, void * user_data); 110 | 111 | /** 112 | * Delete a lv_task 113 | * @param task pointer to task_cb created by task 114 | */ 115 | void lv_task_del(lv_task_t * task); 116 | 117 | /** 118 | * Set the callback the task (the function to call periodically) 119 | * @param task pointer to a task 120 | * @param task_cb the function to call periodically 121 | */ 122 | void lv_task_set_cb(lv_task_t * task, lv_task_cb_t task_cb); 123 | 124 | /** 125 | * Set new priority for a lv_task 126 | * @param task pointer to a lv_task 127 | * @param prio the new priority 128 | */ 129 | void lv_task_set_prio(lv_task_t * task, lv_task_prio_t prio); 130 | 131 | /** 132 | * Set new period for a lv_task 133 | * @param task pointer to a lv_task 134 | * @param period the new period 135 | */ 136 | void lv_task_set_period(lv_task_t * task, uint32_t period); 137 | 138 | /** 139 | * Make a lv_task ready. It will not wait its period. 140 | * @param task pointer to a lv_task. 141 | */ 142 | void lv_task_ready(lv_task_t * task); 143 | 144 | /** 145 | * Delete the lv_task after one call 146 | * @param task pointer to a lv_task. 147 | */ 148 | void lv_task_once(lv_task_t * task); 149 | 150 | /** 151 | * Reset a lv_task. 152 | * It will be called the previously set period milliseconds later. 153 | * @param task pointer to a lv_task. 154 | */ 155 | void lv_task_reset(lv_task_t * task); 156 | 157 | /** 158 | * Enable or disable the whole lv_task handling 159 | * @param en: true: lv_task handling is running, false: lv_task handling is suspended 160 | */ 161 | void lv_task_enable(bool en); 162 | 163 | /** 164 | * Get idle percentage 165 | * @return the lv_task idle in percentage 166 | */ 167 | uint8_t lv_task_get_idle(void); 168 | 169 | /********************** 170 | * MACROS 171 | **********************/ 172 | 173 | #ifdef __cplusplus 174 | } /* extern "C" */ 175 | #endif 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /src/src/lv_font/lv_symbol_def.h: -------------------------------------------------------------------------------- 1 | #ifndef LV_SYMBOL_DEF_H 2 | #define LV_SYMBOL_DEF_H 3 | /* clang-format off */ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | #ifdef LV_CONF_INCLUDE_SIMPLE 9 | #include "lv_conf.h" 10 | #else 11 | #include "../../../lv_conf.h" 12 | #endif 13 | 14 | 15 | #define LV_SYMBOL_AUDIO "\xef\x80\x81" 16 | #define LV_SYMBOL_VIDEO "\xef\x80\x88" 17 | #define LV_SYMBOL_LIST "\xef\x80\x8b" 18 | #define LV_SYMBOL_OK "\xef\x80\x8c" 19 | #define LV_SYMBOL_CLOSE "\xef\x80\x8d" 20 | #define LV_SYMBOL_POWER "\xef\x80\x91" 21 | #define LV_SYMBOL_SETTINGS "\xef\x80\x93" 22 | #define LV_SYMBOL_TRASH "\xef\x80\x94" 23 | #define LV_SYMBOL_HOME "\xef\x80\x95" 24 | #define LV_SYMBOL_DOWNLOAD "\xef\x80\x99" 25 | #define LV_SYMBOL_DRIVE "\xef\x80\x9c" 26 | #define LV_SYMBOL_REFRESH "\xef\x80\xa1" 27 | #define LV_SYMBOL_MUTE "\xef\x80\xa6" 28 | #define LV_SYMBOL_VOLUME_MID "\xef\x80\xa7" 29 | #define LV_SYMBOL_VOLUME_MAX "\xef\x80\xa8" 30 | #define LV_SYMBOL_IMAGE "\xef\x80\xbe" 31 | #define LV_SYMBOL_EDIT "\xef\x81\x80" 32 | #define LV_SYMBOL_PREV "\xef\x81\x88" 33 | #define LV_SYMBOL_PLAY "\xef\x81\x8b" 34 | #define LV_SYMBOL_PAUSE "\xef\x81\x8c" 35 | #define LV_SYMBOL_STOP "\xef\x81\x8d" 36 | #define LV_SYMBOL_NEXT "\xef\x81\x91" 37 | #define LV_SYMBOL_EJECT "\xef\x81\x92" 38 | #define LV_SYMBOL_LEFT "\xef\x81\x93" 39 | #define LV_SYMBOL_RIGHT "\xef\x81\x94" 40 | #define LV_SYMBOL_PLUS "\xef\x81\xa7" 41 | #define LV_SYMBOL_MINUS "\xef\x81\xa8" 42 | #define LV_SYMBOL_WARNING "\xef\x81\xb1" 43 | #define LV_SYMBOL_SHUFFLE "\xef\x81\xb4" 44 | #define LV_SYMBOL_UP "\xef\x81\xb7" 45 | #define LV_SYMBOL_DOWN "\xef\x81\xb8" 46 | #define LV_SYMBOL_LOOP "\xef\x81\xb9" 47 | #define LV_SYMBOL_DIRECTORY "\xef\x81\xbb" 48 | #define LV_SYMBOL_UPLOAD "\xef\x82\x93" 49 | #define LV_SYMBOL_CALL "\xef\x82\x95" 50 | #define LV_SYMBOL_CUT "\xef\x83\x84" 51 | #define LV_SYMBOL_COPY "\xef\x83\x85" 52 | #define LV_SYMBOL_SAVE "\xef\x83\x87" 53 | #define LV_SYMBOL_CHARGE "\xef\x83\xa7" 54 | #define LV_SYMBOL_BELL "\xef\x83\xb3" 55 | #define LV_SYMBOL_KEYBOARD "\xef\x84\x9c" 56 | #define LV_SYMBOL_GPS "\xef\x84\xa4" 57 | #define LV_SYMBOL_FILE "\xef\x85\x9b" 58 | #define LV_SYMBOL_WIFI "\xef\x87\xab" 59 | #define LV_SYMBOL_BATTERY_FULL "\xef\x89\x80" 60 | #define LV_SYMBOL_BATTERY_3 "\xef\x89\x81" 61 | #define LV_SYMBOL_BATTERY_2 "\xef\x89\x82" 62 | #define LV_SYMBOL_BATTERY_1 "\xef\x89\x83" 63 | #define LV_SYMBOL_BATTERY_EMPTY "\xef\x89\x84" 64 | #define LV_SYMBOL_BLUETOOTH "\xef\x8a\x93" 65 | 66 | /** Invalid symbol at (U+F8FF). If written before a string then `lv_img` will show it as a label*/ 67 | #define LV_SYMBOL_DUMMY "\xEF\xA3\xBF" 68 | 69 | /* 70 | * The following list is generated using 71 | * cat src/lv_misc/lv_symbol_def.h | sed -E -n 's/^#define\s+(LV_SYMBOL_\w+).*"$/ _LV_STR_\1,/p' 72 | */ 73 | enum { 74 | _LV_STR_SYMBOL_AUDIO, 75 | _LV_STR_SYMBOL_VIDEO, 76 | _LV_STR_SYMBOL_LIST, 77 | _LV_STR_SYMBOL_OK, 78 | _LV_STR_SYMBOL_CLOSE, 79 | _LV_STR_SYMBOL_POWER, 80 | _LV_STR_SYMBOL_SETTINGS, 81 | _LV_STR_SYMBOL_TRASH, 82 | _LV_STR_SYMBOL_HOME, 83 | _LV_STR_SYMBOL_DOWNLOAD, 84 | _LV_STR_SYMBOL_DRIVE, 85 | _LV_STR_SYMBOL_REFRESH, 86 | _LV_STR_SYMBOL_MUTE, 87 | _LV_STR_SYMBOL_VOLUME_MID, 88 | _LV_STR_SYMBOL_VOLUME_MAX, 89 | _LV_STR_SYMBOL_IMAGE, 90 | _LV_STR_SYMBOL_EDIT, 91 | _LV_STR_SYMBOL_PREV, 92 | _LV_STR_SYMBOL_PLAY, 93 | _LV_STR_SYMBOL_PAUSE, 94 | _LV_STR_SYMBOL_STOP, 95 | _LV_STR_SYMBOL_NEXT, 96 | _LV_STR_SYMBOL_EJECT, 97 | _LV_STR_SYMBOL_LEFT, 98 | _LV_STR_SYMBOL_RIGHT, 99 | _LV_STR_SYMBOL_PLUS, 100 | _LV_STR_SYMBOL_MINUS, 101 | _LV_STR_SYMBOL_WARNING, 102 | _LV_STR_SYMBOL_SHUFFLE, 103 | _LV_STR_SYMBOL_UP, 104 | _LV_STR_SYMBOL_DOWN, 105 | _LV_STR_SYMBOL_LOOP, 106 | _LV_STR_SYMBOL_DIRECTORY, 107 | _LV_STR_SYMBOL_UPLOAD, 108 | _LV_STR_SYMBOL_CALL, 109 | _LV_STR_SYMBOL_CUT, 110 | _LV_STR_SYMBOL_COPY, 111 | _LV_STR_SYMBOL_SAVE, 112 | _LV_STR_SYMBOL_CHARGE, 113 | _LV_STR_SYMBOL_BELL, 114 | _LV_STR_SYMBOL_KEYBOARD, 115 | _LV_STR_SYMBOL_GPS, 116 | _LV_STR_SYMBOL_FILE, 117 | _LV_STR_SYMBOL_WIFI, 118 | _LV_STR_SYMBOL_BATTERY_FULL, 119 | _LV_STR_SYMBOL_BATTERY_3, 120 | _LV_STR_SYMBOL_BATTERY_2, 121 | _LV_STR_SYMBOL_BATTERY_1, 122 | _LV_STR_SYMBOL_BATTERY_EMPTY, 123 | _LV_STR_SYMBOL_BLUETOOTH, 124 | _LV_STR_SYMBOL_DUMMY, 125 | }; 126 | 127 | #ifdef __cplusplus 128 | } /* extern "C" */ 129 | #endif 130 | 131 | 132 | #endif /*LV_SYMBOL_DEF_H*/ 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /src/src/lv_core/lv_indev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_indev.h 3 | * 4 | */ 5 | 6 | #ifndef LV_INDEV_H 7 | #define LV_INDEV_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_obj.h" 17 | #include "../lv_hal/lv_hal_indev.h" 18 | #include "../lv_core/lv_group.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /** 33 | * Initialize the display input device subsystem 34 | */ 35 | void lv_indev_init(void); 36 | 37 | /** 38 | * Called periodically to read the input devices 39 | * @param task pointer to the task itself 40 | */ 41 | void lv_indev_read_task(lv_task_t * task); 42 | 43 | /** 44 | * Get the currently processed input device. Can be used in action functions too. 45 | * @return pointer to the currently processed input device or NULL if no input device processing 46 | * right now 47 | */ 48 | lv_indev_t * lv_indev_get_act(void); 49 | 50 | /** 51 | * Get the type of an input device 52 | * @param indev pointer to an input device 53 | * @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`) 54 | */ 55 | lv_indev_type_t lv_indev_get_type(const lv_indev_t * indev); 56 | 57 | /** 58 | * Reset one or all input devices 59 | * @param indev pointer to an input device to reset or NULL to reset all of them 60 | */ 61 | void lv_indev_reset(lv_indev_t * indev); 62 | 63 | /** 64 | * Reset the long press state of an input device 65 | * @param indev_proc pointer to an input device 66 | */ 67 | void lv_indev_reset_long_press(lv_indev_t * indev); 68 | 69 | /** 70 | * Enable or disable an input devices 71 | * @param indev pointer to an input device 72 | * @param en true: enable; false: disable 73 | */ 74 | void lv_indev_enable(lv_indev_t * indev, bool en); 75 | 76 | /** 77 | * Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON) 78 | * @param indev pointer to an input device 79 | * @param cur_obj pointer to an object to be used as cursor 80 | */ 81 | void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj); 82 | 83 | #if LV_USE_GROUP 84 | /** 85 | * Set a destination group for a keypad input device (for LV_INDEV_TYPE_KEYPAD) 86 | * @param indev pointer to an input device 87 | * @param group point to a group 88 | */ 89 | void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group); 90 | #endif 91 | 92 | /** 93 | * Set the an array of points for LV_INDEV_TYPE_BUTTON. 94 | * These points will be assigned to the buttons to press a specific point on the screen 95 | * @param indev pointer to an input device 96 | * @param group point to a group 97 | */ 98 | void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points); 99 | 100 | /** 101 | * Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) 102 | * @param indev pointer to an input device 103 | * @param point pointer to a point to store the result 104 | */ 105 | void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point); 106 | 107 | /** 108 | * Get the last pressed key of an input device (for LV_INDEV_TYPE_KEYPAD) 109 | * @param indev pointer to an input device 110 | * @return the last pressed key (0 on error) 111 | */ 112 | uint32_t lv_indev_get_key(const lv_indev_t * indev); 113 | 114 | /** 115 | * Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and 116 | * LV_INDEV_TYPE_BUTTON) 117 | * @param indev pointer to an input device 118 | * @return true: drag is in progress 119 | */ 120 | bool lv_indev_is_dragging(const lv_indev_t * indev); 121 | 122 | /** 123 | * Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and 124 | * LV_INDEV_TYPE_BUTTON) 125 | * @param indev pointer to an input device 126 | * @param point pointer to a point to store the vector 127 | */ 128 | void lv_indev_get_vect(const lv_indev_t * indev, lv_point_t * point); 129 | 130 | /** 131 | * Do nothing until the next release 132 | * @param indev pointer to an input device 133 | */ 134 | void lv_indev_wait_release(lv_indev_t * indev); 135 | 136 | /** 137 | * Get a pointer to the indev read task to 138 | * modify its parameters with `lv_task_...` functions. 139 | * @param indev pointer to an inout device 140 | * @return pointer to the indev read refresher task. (NULL on error) 141 | */ 142 | lv_task_t * lv_indev_get_read_task(lv_disp_t * indev); 143 | 144 | /** 145 | * Gets a pointer to the currently active object in indev proc functions. 146 | * NULL if no object is currently being handled or if groups aren't used. 147 | * @return pointer to currently active object 148 | */ 149 | lv_obj_t * lv_indev_get_obj_act(void); 150 | 151 | /********************** 152 | * MACROS 153 | **********************/ 154 | 155 | #ifdef __cplusplus 156 | } /* extern "C" */ 157 | #endif 158 | 159 | #endif /*LV_INDEV_H*/ 160 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_cb.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_cb.h 3 | * 4 | */ 5 | 6 | #ifndef LV_CB_H 7 | #define LV_CB_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_CB != 0 23 | 24 | /*Testing of dependencies*/ 25 | #if LV_USE_BTN == 0 26 | #error "lv_cb: lv_btn is required. Enable it in lv_conf.h (LV_USE_BTN 1) " 27 | #endif 28 | 29 | #if LV_USE_LABEL == 0 30 | #error "lv_cb: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) " 31 | #endif 32 | 33 | #include "../lv_core/lv_obj.h" 34 | #include "lv_btn.h" 35 | #include "lv_label.h" 36 | 37 | /********************* 38 | * DEFINES 39 | *********************/ 40 | 41 | /********************** 42 | * TYPEDEFS 43 | **********************/ 44 | 45 | /*Data of check box*/ 46 | typedef struct 47 | { 48 | lv_btn_ext_t bg_btn; /*Ext. of ancestor*/ 49 | /*New data for this type */ 50 | lv_obj_t * bullet; /*Pointer to button*/ 51 | lv_obj_t * label; /*Pointer to label*/ 52 | } lv_cb_ext_t; 53 | 54 | /** Checkbox styles. */ 55 | enum { 56 | LV_CB_STYLE_BG, /**< Style of object background. */ 57 | LV_CB_STYLE_BOX_REL, /**< Style of box (released). */ 58 | LV_CB_STYLE_BOX_PR, /**< Style of box (pressed). */ 59 | LV_CB_STYLE_BOX_TGL_REL, /**< Style of box (released but checked). */ 60 | LV_CB_STYLE_BOX_TGL_PR, /**< Style of box (pressed and checked). */ 61 | LV_CB_STYLE_BOX_INA, /**< Style of disabled box */ 62 | }; 63 | typedef uint8_t lv_cb_style_t; 64 | 65 | /********************** 66 | * GLOBAL PROTOTYPES 67 | **********************/ 68 | 69 | /** 70 | * Create a check box objects 71 | * @param par pointer to an object, it will be the parent of the new check box 72 | * @param copy pointer to a check box object, if not NULL then the new object will be copied from it 73 | * @return pointer to the created check box 74 | */ 75 | lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy); 76 | 77 | /*===================== 78 | * Setter functions 79 | *====================*/ 80 | 81 | /** 82 | * Set the text of a check box. `txt` will be copied and may be deallocated 83 | * after this function returns. 84 | * @param cb pointer to a check box 85 | * @param txt the text of the check box. NULL to refresh with the current text. 86 | */ 87 | void lv_cb_set_text(lv_obj_t * cb, const char * txt); 88 | 89 | /** 90 | * Set the text of a check box. `txt` must not be deallocated during the life 91 | * of this checkbox. 92 | * @param cb pointer to a check box 93 | * @param txt the text of the check box. NULL to refresh with the current text. 94 | */ 95 | void lv_cb_set_static_text(lv_obj_t * cb, const char * txt); 96 | 97 | /** 98 | * Set the state of the check box 99 | * @param cb pointer to a check box object 100 | * @param checked true: make the check box checked; false: make it unchecked 101 | */ 102 | static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked) 103 | { 104 | lv_btn_set_state(cb, checked ? LV_BTN_STATE_TGL_REL : LV_BTN_STATE_REL); 105 | } 106 | 107 | /** 108 | * Make the check box inactive (disabled) 109 | * @param cb pointer to a check box object 110 | */ 111 | static inline void lv_cb_set_inactive(lv_obj_t * cb) 112 | { 113 | lv_btn_set_state(cb, LV_BTN_STATE_INA); 114 | } 115 | 116 | /** 117 | * Set a style of a check box 118 | * @param cb pointer to check box object 119 | * @param type which style should be set 120 | * @param style pointer to a style 121 | * */ 122 | void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style); 123 | 124 | /*===================== 125 | * Getter functions 126 | *====================*/ 127 | 128 | /** 129 | * Get the text of a check box 130 | * @param cb pointer to check box object 131 | * @return pointer to the text of the check box 132 | */ 133 | const char * lv_cb_get_text(const lv_obj_t * cb); 134 | 135 | /** 136 | * Get the current state of the check box 137 | * @param cb pointer to a check box object 138 | * @return true: checked; false: not checked 139 | */ 140 | static inline bool lv_cb_is_checked(const lv_obj_t * cb) 141 | { 142 | return lv_btn_get_state(cb) == LV_BTN_STATE_REL ? false : true; 143 | } 144 | 145 | /** 146 | * Get whether the check box is inactive or not. 147 | * @param cb pointer to a check box object 148 | * @return true: inactive; false: not inactive 149 | */ 150 | static inline bool lv_cb_is_inactive(const lv_obj_t * cb) 151 | { 152 | return lv_btn_get_state(cb) == LV_BTN_STATE_INA ? false : true; 153 | } 154 | 155 | /** 156 | * Get a style of a button 157 | * @param cb pointer to check box object 158 | * @param type which style should be get 159 | * @return style pointer to the style 160 | * */ 161 | const lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type); 162 | 163 | /********************** 164 | * MACROS 165 | **********************/ 166 | 167 | #endif /*LV_USE_CB*/ 168 | 169 | #ifdef __cplusplus 170 | } /* extern "C" */ 171 | #endif 172 | 173 | #endif /*LV_CB_H*/ 174 | -------------------------------------------------------------------------------- /src/src/lv_hal/lv_hal_indev.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal_indev.c 3 | * 4 | * @description Input device HAL interface 5 | * 6 | */ 7 | 8 | /********************* 9 | * INCLUDES 10 | *********************/ 11 | #include "../lv_hal/lv_hal_indev.h" 12 | #include "../lv_core/lv_indev.h" 13 | #include "../lv_misc/lv_mem.h" 14 | #include "../lv_misc/lv_gc.h" 15 | #include "lv_hal_disp.h" 16 | 17 | #if defined(LV_GC_INCLUDE) 18 | #include LV_GC_INCLUDE 19 | #endif /* LV_ENABLE_GC */ 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * STATIC PROTOTYPES 31 | **********************/ 32 | 33 | /********************** 34 | * STATIC VARIABLES 35 | **********************/ 36 | 37 | /********************** 38 | * MACROS 39 | **********************/ 40 | 41 | /********************** 42 | * GLOBAL FUNCTIONS 43 | **********************/ 44 | 45 | /** 46 | * Initialize an input device driver with default values. 47 | * It is used to surly have known values in the fields ant not memory junk. 48 | * After it you can set the fields. 49 | * @param driver pointer to driver variable to initialize 50 | */ 51 | void lv_indev_drv_init(lv_indev_drv_t * driver) 52 | { 53 | memset(driver, 0, sizeof(lv_indev_drv_t)); 54 | 55 | driver->type = LV_INDEV_TYPE_NONE; 56 | driver->drag_limit = LV_INDEV_DEF_DRAG_LIMIT; 57 | driver->drag_throw = LV_INDEV_DEF_DRAG_THROW; 58 | driver->long_press_time = LV_INDEV_DEF_LONG_PRESS_TIME; 59 | driver->long_press_rep_time = LV_INDEV_DEF_LONG_PRESS_REP_TIME; 60 | } 61 | 62 | /** 63 | * Register an initialized input device driver. 64 | * @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable) 65 | * @return pointer to the new input device or NULL on error 66 | */ 67 | lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) 68 | { 69 | 70 | if(driver->disp == NULL) driver->disp = lv_disp_get_default(); 71 | 72 | if(driver->disp == NULL) { 73 | LV_LOG_WARN("lv_indev_drv_register: no display registered hence can't attache the indev to " 74 | "a display"); 75 | return NULL; 76 | } 77 | 78 | lv_indev_t * indev = lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll)); 79 | if(!indev) { 80 | lv_mem_assert(indev); 81 | return NULL; 82 | } 83 | 84 | memset(indev, 0, sizeof(lv_indev_t)); 85 | memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); 86 | 87 | indev->proc.reset_query = 1; 88 | indev->cursor = NULL; 89 | indev->group = NULL; 90 | indev->btn_points = NULL; 91 | 92 | indev->driver.read_task = lv_task_create(lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_MID, indev); 93 | 94 | return indev; 95 | } 96 | 97 | /** 98 | * Update the driver in run time. 99 | * @param indev pointer to a input device. (return value of `lv_indev_drv_register`) 100 | * @param new_drv pointer to the new driver 101 | */ 102 | void lv_indev_drv_update(lv_indev_t * indev, lv_indev_drv_t * new_drv) 103 | { 104 | memcpy(&indev->driver, new_drv, sizeof(lv_indev_drv_t)); 105 | } 106 | 107 | /** 108 | * Get the next input device. 109 | * @param indev pointer to the current input device. NULL to initialize. 110 | * @return the next input devise or NULL if no more. Give the first input device when the parameter 111 | * is NULL 112 | */ 113 | lv_indev_t * lv_indev_get_next(lv_indev_t * indev) 114 | { 115 | if(indev == NULL) 116 | return lv_ll_get_head(&LV_GC_ROOT(_lv_indev_ll)); 117 | else 118 | return lv_ll_get_next(&LV_GC_ROOT(_lv_indev_ll), indev); 119 | } 120 | 121 | /** 122 | * Read data from an input device. 123 | * @param indev pointer to an input device 124 | * @param data input device will write its data here 125 | * @return false: no more data; true: there more data to read (buffered) 126 | */ 127 | bool lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) 128 | { 129 | bool cont = false; 130 | 131 | memset(data, 0, sizeof(lv_indev_data_t)); 132 | 133 | /* For touchpad sometimes users don't the last pressed coordinate on release. 134 | * So be sure a coordinates are initialized to the last point */ 135 | if(indev->driver.type == LV_INDEV_TYPE_POINTER) { 136 | data->point.x = indev->proc.types.pointer.act_point.x; 137 | data->point.y = indev->proc.types.pointer.act_point.y; 138 | } 139 | /*Similarly set at least the last key in case of the the user doesn't set it on release*/ 140 | else if(indev->driver.type == LV_INDEV_TYPE_KEYPAD) { 141 | data->key = indev->proc.types.keypad.last_key; 142 | } 143 | 144 | if(indev->driver.read_cb) { 145 | LV_LOG_TRACE("idnev read started"); 146 | cont = indev->driver.read_cb(&indev->driver, data); 147 | LV_LOG_TRACE("idnev read finished"); 148 | } else { 149 | LV_LOG_WARN("indev function registered"); 150 | } 151 | 152 | return cont; 153 | } 154 | 155 | /********************** 156 | * STATIC FUNCTIONS 157 | **********************/ 158 | -------------------------------------------------------------------------------- /src/src/lv_misc/lv_area.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_area.h 3 | * 4 | */ 5 | 6 | #ifndef LV_AREA_H 7 | #define LV_AREA_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include 18 | #include 19 | #ifdef LV_CONF_INCLUDE_SIMPLE 20 | #include "lv_conf.h" 21 | #else 22 | #include "../../../lv_conf.h" 23 | #endif 24 | 25 | /********************* 26 | * DEFINES 27 | *********************/ 28 | /*To avoid overflow don't let the max ranges (reduce with 1000) */ 29 | #define LV_COORD_MAX ((lv_coord_t)((uint32_t)((uint32_t)1 << (8 * sizeof(lv_coord_t) - 1)) - 1000)) 30 | #define LV_COORD_MIN (-LV_COORD_MAX) 31 | 32 | /********************** 33 | * TYPEDEFS 34 | **********************/ 35 | 36 | /** 37 | * Represents a point on the screen. 38 | */ 39 | typedef struct 40 | { 41 | lv_coord_t x; 42 | lv_coord_t y; 43 | } lv_point_t; 44 | 45 | /** Represents an area of the screen. */ 46 | typedef struct 47 | { 48 | lv_coord_t x1; 49 | lv_coord_t y1; 50 | lv_coord_t x2; 51 | lv_coord_t y2; 52 | } lv_area_t; 53 | 54 | /********************** 55 | * GLOBAL PROTOTYPES 56 | **********************/ 57 | 58 | /** 59 | * Initialize an area 60 | * @param area_p pointer to an area 61 | * @param x1 left coordinate of the area 62 | * @param y1 top coordinate of the area 63 | * @param x2 right coordinate of the area 64 | * @param y2 bottom coordinate of the area 65 | */ 66 | void lv_area_set(lv_area_t * area_p, lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2); 67 | 68 | /** 69 | * Copy an area 70 | * @param dest pointer to the destination area 71 | * @param src pointer to the source area 72 | */ 73 | inline static void lv_area_copy(lv_area_t * dest, const lv_area_t * src) 74 | { 75 | memcpy(dest, src, sizeof(lv_area_t)); 76 | } 77 | 78 | /** 79 | * Get the width of an area 80 | * @param area_p pointer to an area 81 | * @return the width of the area (if x1 == x2 -> width = 1) 82 | */ 83 | static inline lv_coord_t lv_area_get_width(const lv_area_t * area_p) 84 | { 85 | return area_p->x2 - area_p->x1 + 1; 86 | } 87 | 88 | /** 89 | * Get the height of an area 90 | * @param area_p pointer to an area 91 | * @return the height of the area (if y1 == y2 -> height = 1) 92 | */ 93 | static inline lv_coord_t lv_area_get_height(const lv_area_t * area_p) 94 | { 95 | return area_p->y2 - area_p->y1 + 1; 96 | } 97 | 98 | /** 99 | * Set the width of an area 100 | * @param area_p pointer to an area 101 | * @param w the new width of the area (w == 1 makes x1 == x2) 102 | */ 103 | void lv_area_set_width(lv_area_t * area_p, lv_coord_t w); 104 | 105 | /** 106 | * Set the height of an area 107 | * @param area_p pointer to an area 108 | * @param h the new height of the area (h == 1 makes y1 == y2) 109 | */ 110 | void lv_area_set_height(lv_area_t * area_p, lv_coord_t h); 111 | 112 | /** 113 | * Set the position of an area (width and height will be kept) 114 | * @param area_p pointer to an area 115 | * @param x the new x coordinate of the area 116 | * @param y the new y coordinate of the area 117 | */ 118 | void lv_area_set_pos(lv_area_t * area_p, lv_coord_t x, lv_coord_t y); 119 | 120 | /** 121 | * Return with area of an area (x * y) 122 | * @param area_p pointer to an area 123 | * @return size of area 124 | */ 125 | uint32_t lv_area_get_size(const lv_area_t * area_p); 126 | 127 | /** 128 | * Get the common parts of two areas 129 | * @param res_p pointer to an area, the result will be stored her 130 | * @param a1_p pointer to the first area 131 | * @param a2_p pointer to the second area 132 | * @return false: the two area has NO common parts, res_p is invalid 133 | */ 134 | bool lv_area_intersect(lv_area_t * res_p, const lv_area_t * a1_p, const lv_area_t * a2_p); 135 | 136 | /** 137 | * Join two areas into a third which involves the other two 138 | * @param res_p pointer to an area, the result will be stored here 139 | * @param a1_p pointer to the first area 140 | * @param a2_p pointer to the second area 141 | */ 142 | void lv_area_join(lv_area_t * a_res_p, const lv_area_t * a1_p, const lv_area_t * a2_p); 143 | 144 | /** 145 | * Check if a point is on an area 146 | * @param a_p pointer to an area 147 | * @param p_p pointer to a point 148 | * @return false:the point is out of the area 149 | */ 150 | bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p); 151 | 152 | /** 153 | * Check if two area has common parts 154 | * @param a1_p pointer to an area. 155 | * @param a2_p pointer to an other area 156 | * @return false: a1_p and a2_p has no common parts 157 | */ 158 | bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p); 159 | 160 | /** 161 | * Check if an area is fully on an other 162 | * @param ain_p pointer to an area which could be on aholder_p 163 | * @param aholder pointer to an area which could involve ain_p 164 | * @return 165 | */ 166 | bool lv_area_is_in(const lv_area_t * ain_p, const lv_area_t * aholder_p); 167 | 168 | /********************** 169 | * MACROS 170 | **********************/ 171 | 172 | #ifdef __cplusplus 173 | } /* extern "C" */ 174 | #endif 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /src/src/lv_core/lv_disp.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_disp.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_disp.h" 10 | #include "../lv_misc/lv_math.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | /********************** 21 | * STATIC PROTOTYPES 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC VARIABLES 26 | **********************/ 27 | 28 | /********************** 29 | * MACROS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL FUNCTIONS 34 | **********************/ 35 | 36 | /** 37 | * Return with a pointer to the active screen 38 | * @param disp pointer to display which active screen should be get. (NULL to use the default 39 | * screen) 40 | * @return pointer to the active screen object (loaded by 'lv_scr_load()') 41 | */ 42 | lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp) 43 | { 44 | if(!disp) disp = lv_disp_get_default(); 45 | if(!disp) { 46 | LV_LOG_WARN("lv_scr_act: no display registered to get its top layer"); 47 | return NULL; 48 | } 49 | 50 | return disp->act_scr; 51 | } 52 | 53 | /** 54 | * Make a screen active 55 | * @param scr pointer to a screen 56 | */ 57 | void lv_disp_load_scr(lv_obj_t * scr) 58 | { 59 | lv_disp_t * d = lv_obj_get_disp(scr); 60 | 61 | d->act_scr = scr; 62 | 63 | lv_obj_invalidate(scr); 64 | } 65 | 66 | /** 67 | * Return with the top layer. (Same on every screen and it is above the normal screen layer) 68 | * @param disp pointer to display which top layer should be get. (NULL to use the default screen) 69 | * @return pointer to the top layer object (transparent screen sized lv_obj) 70 | */ 71 | lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp) 72 | { 73 | if(!disp) disp = lv_disp_get_default(); 74 | if(!disp) { 75 | LV_LOG_WARN("lv_layer_top: no display registered to get its top layer"); 76 | return NULL; 77 | } 78 | 79 | return disp->top_layer; 80 | } 81 | 82 | /** 83 | * Return with the sys. layer. (Same on every screen and it is above the normal screen and the top 84 | * layer) 85 | * @param disp pointer to display which sys. layer should be get. (NULL to use the default screen) 86 | * @return pointer to the sys layer object (transparent screen sized lv_obj) 87 | */ 88 | lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp) 89 | { 90 | if(!disp) disp = lv_disp_get_default(); 91 | if(!disp) { 92 | LV_LOG_WARN("lv_layer_sys: no display registered to get its top layer"); 93 | return NULL; 94 | } 95 | 96 | return disp->sys_layer; 97 | } 98 | 99 | /** 100 | * Assign a screen to a display. 101 | * @param disp pointer to a display where to assign the screen 102 | * @param scr pointer to a screen object to assign 103 | */ 104 | void lv_disp_assign_screen(lv_disp_t * disp, lv_obj_t * scr) 105 | { 106 | if(lv_obj_get_parent(scr) != NULL) { 107 | LV_LOG_WARN("lv_disp_assign_screen: try to assign a non-screen object"); 108 | return; 109 | } 110 | 111 | lv_disp_t * old_disp = lv_obj_get_disp(scr); 112 | 113 | if(old_disp == disp) return; 114 | 115 | lv_ll_chg_list(&old_disp->scr_ll, &disp->scr_ll, scr, true); 116 | } 117 | 118 | /** 119 | * Get a pointer to the screen refresher task to 120 | * modify its parameters with `lv_task_...` functions. 121 | * @param disp pointer to a display 122 | * @return pointer to the display refresher task. (NULL on error) 123 | */ 124 | lv_task_t * lv_disp_get_refr_task(lv_disp_t * disp) 125 | { 126 | if(!disp) disp = lv_disp_get_default(); 127 | if(!disp) { 128 | LV_LOG_WARN("lv_disp_get_refr_task: no display registered"); 129 | return NULL; 130 | } 131 | 132 | return disp->refr_task; 133 | } 134 | 135 | /** 136 | * Get elapsed time since last user activity on a display (e.g. click) 137 | * @param disp pointer to an display (NULL to get the overall smallest inactivity) 138 | * @return elapsed ticks (milliseconds) since the last activity 139 | */ 140 | uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp) 141 | { 142 | if(!disp) disp = lv_disp_get_default(); 143 | if(!disp) { 144 | LV_LOG_WARN("lv_disp_get_inactive_time: no display registered"); 145 | return 0; 146 | } 147 | 148 | if(disp) return lv_tick_elaps(disp->last_activity_time); 149 | 150 | lv_disp_t * d; 151 | uint32_t t = UINT32_MAX; 152 | d = lv_disp_get_next(NULL); 153 | while(d) { 154 | t = LV_MATH_MIN(t, lv_tick_elaps(d->last_activity_time)); 155 | d = lv_disp_get_next(d); 156 | } 157 | 158 | return t; 159 | } 160 | 161 | /** 162 | * Manually trigger an activity on a display 163 | * @param disp pointer to an display (NULL to use the default display) 164 | */ 165 | void lv_disp_trig_activity(lv_disp_t * disp) 166 | { 167 | if(!disp) disp = lv_disp_get_default(); 168 | if(!disp) { 169 | LV_LOG_WARN("lv_disp_trig_activity: no display registered"); 170 | return; 171 | } 172 | 173 | disp->last_activity_time = lv_tick_get(); 174 | } 175 | 176 | /********************** 177 | * STATIC FUNCTIONS 178 | **********************/ 179 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_tileview.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_tileview.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TILEVIEW_H 7 | #define LV_TILEVIEW_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_TILEVIEW != 0 23 | 24 | #include "../lv_objx/lv_page.h" 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /*Data of tileview*/ 35 | typedef struct 36 | { 37 | lv_page_ext_t page; 38 | /*New data for this type */ 39 | const lv_point_t * valid_pos; 40 | uint16_t valid_pos_cnt; 41 | #if LV_USE_ANIMATION 42 | uint16_t anim_time; 43 | #endif 44 | lv_point_t act_id; 45 | uint8_t drag_top_en : 1; 46 | uint8_t drag_bottom_en : 1; 47 | uint8_t drag_left_en : 1; 48 | uint8_t drag_right_en : 1; 49 | uint8_t drag_hor : 1; 50 | uint8_t drag_ver : 1; 51 | } lv_tileview_ext_t; 52 | 53 | /*Styles*/ 54 | enum { 55 | LV_TILEVIEW_STYLE_MAIN, 56 | }; 57 | typedef uint8_t lv_tileview_style_t; 58 | 59 | /********************** 60 | * GLOBAL PROTOTYPES 61 | **********************/ 62 | 63 | /** 64 | * Create a tileview objects 65 | * @param par pointer to an object, it will be the parent of the new tileview 66 | * @param copy pointer to a tileview object, if not NULL then the new object will be copied from it 67 | * @return pointer to the created tileview 68 | */ 69 | lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy); 70 | 71 | /*====================== 72 | * Add/remove functions 73 | *=====================*/ 74 | 75 | /** 76 | * Register an object on the tileview. The register object will able to slide the tileview 77 | * @param tileview pointer to a Tileview object 78 | * @param element pointer to an object 79 | */ 80 | void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element); 81 | 82 | /*===================== 83 | * Setter functions 84 | *====================*/ 85 | 86 | /** 87 | * Set the valid position's indices. The scrolling will be possible only to these positions. 88 | * @param tileview pointer to a Tileview object 89 | * @param valid_pos array width the indices. E.g. `lv_point_t p[] = {{0,0}, {1,0}, {1,1}`. Only the 90 | * pointer is saved so can't be a local variable. 91 | * @param valid_pos_cnt numner of elements in `valid_pos` array 92 | */ 93 | void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t * valid_pos, uint16_t valid_pos_cnt); 94 | 95 | /** 96 | * Set the tile to be shown 97 | * @param tileview pointer to a tileview object 98 | * @param x column id (0, 1, 2...) 99 | * @param y line id (0, 1, 2...) 100 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 101 | */ 102 | void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim); 103 | 104 | /** 105 | * Enable the edge flash effect. (Show an arc when the an edge is reached) 106 | * @param tileview pointer to a Tileview 107 | * @param en true or false to enable/disable end flash 108 | */ 109 | static inline void lv_tileview_set_edge_flash(lv_obj_t * tileview, bool en) 110 | { 111 | lv_page_set_edge_flash(tileview, en); 112 | } 113 | 114 | /** 115 | * Set the animation time for the Tile view 116 | * @param tileview pointer to a page object 117 | * @param anim_time animation time in milliseconds 118 | */ 119 | static inline void lv_tileview_set_anim_time(lv_obj_t * tileview, uint16_t anim_time) 120 | { 121 | lv_page_set_anim_time(tileview, anim_time); 122 | } 123 | 124 | /** 125 | * Set a style of a tileview. 126 | * @param tileview pointer to tileview object 127 | * @param type which style should be set 128 | * @param style pointer to a style 129 | */ 130 | void lv_tileview_set_style(lv_obj_t * tileview, lv_tileview_style_t type, const lv_style_t * style); 131 | 132 | /*===================== 133 | * Getter functions 134 | *====================*/ 135 | 136 | /** 137 | * Get the scroll propagation property 138 | * @param tileview pointer to a Tileview 139 | * @return true or false 140 | */ 141 | static inline bool lv_tileview_get_edge_flash(lv_obj_t * tileview) 142 | { 143 | return lv_page_get_edge_flash(tileview); 144 | } 145 | 146 | /** 147 | * Get the animation time for the Tile view 148 | * @param tileview pointer to a page object 149 | * @return animation time in milliseconds 150 | */ 151 | static inline uint16_t lv_tileview_get_anim_time(lv_obj_t * tileview) 152 | { 153 | return lv_page_get_anim_time(tileview); 154 | } 155 | 156 | /** 157 | * Get style of a tileview. 158 | * @param tileview pointer to tileview object 159 | * @param type which style should be get 160 | * @return style pointer to the style 161 | */ 162 | const lv_style_t * lv_tileview_get_style(const lv_obj_t * tileview, lv_tileview_style_t type); 163 | 164 | /*===================== 165 | * Other functions 166 | *====================*/ 167 | 168 | /********************** 169 | * MACROS 170 | **********************/ 171 | 172 | #endif /*LV_USE_TILEVIEW*/ 173 | 174 | #ifdef __cplusplus 175 | } /* extern "C" */ 176 | #endif 177 | 178 | #endif /*LV_TILEVIEW_H*/ 179 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_img.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_img.h 3 | * 4 | */ 5 | 6 | #ifndef LV_IMG_H 7 | #define LV_IMG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_IMG != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | #include "../lv_misc/lv_fs.h" 26 | #include "lv_label.h" 27 | #include "../lv_draw/lv_draw.h" 28 | 29 | /********************* 30 | * DEFINES 31 | *********************/ 32 | 33 | /********************** 34 | * TYPEDEFS 35 | **********************/ 36 | /*Data of image*/ 37 | typedef struct 38 | { 39 | /*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/ 40 | /*New data for this type */ 41 | const void * src; /*Image source: Pointer to an array or a file or a symbol*/ 42 | lv_point_t offset; 43 | lv_coord_t w; /*Width of the image (Handled by the library)*/ 44 | lv_coord_t h; /*Height of the image (Handled by the library)*/ 45 | uint8_t src_type : 2; /*See: lv_img_src_t*/ 46 | uint8_t auto_size : 1; /*1: automatically set the object size to the image size*/ 47 | uint8_t cf : 5; /*Color format from `lv_img_color_format_t`*/ 48 | } lv_img_ext_t; 49 | 50 | /*Styles*/ 51 | enum { 52 | LV_IMG_STYLE_MAIN, 53 | }; 54 | typedef uint8_t lv_img_style_t; 55 | 56 | /********************** 57 | * GLOBAL PROTOTYPES 58 | **********************/ 59 | 60 | /** 61 | * Create an image objects 62 | * @param par pointer to an object, it will be the parent of the new button 63 | * @param copy pointer to a image object, if not NULL then the new object will be copied from it 64 | * @return pointer to the created image 65 | */ 66 | lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy); 67 | 68 | /*===================== 69 | * Setter functions 70 | *====================*/ 71 | 72 | /** 73 | * Set the pixel map to display by the image 74 | * @param img pointer to an image object 75 | * @param data the image data 76 | */ 77 | void lv_img_set_src(lv_obj_t * img, const void * src_img); 78 | 79 | /** 80 | * Enable the auto size feature. 81 | * If enabled the object size will be same as the picture size. 82 | * @param img pointer to an image 83 | * @param en true: auto size enable, false: auto size disable 84 | */ 85 | void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en); 86 | 87 | /** 88 | * Set an offset for the source of an image. 89 | * so the image will be displayed from the new origin. 90 | * @param img pointer to an image 91 | * @param x: the new offset along x axis. 92 | */ 93 | void lv_img_set_offset_x(lv_obj_t * img, lv_coord_t x); 94 | 95 | /** 96 | * Set an offset for the source of an image. 97 | * so the image will be displayed from the new origin. 98 | * @param img pointer to an image 99 | * @param y: the new offset along y axis. 100 | */ 101 | void lv_img_set_offset_y(lv_obj_t * img, lv_coord_t y); 102 | 103 | /** 104 | * Set the style of an image 105 | * @param img pointer to an image object 106 | * @param type which style should be set (can be only `LV_IMG_STYLE_MAIN`) 107 | * @param style pointer to a style 108 | */ 109 | static inline void lv_img_set_style(lv_obj_t * img, lv_img_style_t type, const lv_style_t * style) 110 | { 111 | (void)type; /*Unused*/ 112 | lv_obj_set_style(img, style); 113 | } 114 | 115 | /*===================== 116 | * Getter functions 117 | *====================*/ 118 | 119 | /** 120 | * Get the source of the image 121 | * @param img pointer to an image object 122 | * @return the image source (symbol, file name or C array) 123 | */ 124 | const void * lv_img_get_src(lv_obj_t * img); 125 | 126 | /** 127 | * Get the name of the file set for an image 128 | * @param img pointer to an image 129 | * @return file name 130 | */ 131 | const char * lv_img_get_file_name(const lv_obj_t * img); 132 | 133 | /** 134 | * Get the auto size enable attribute 135 | * @param img pointer to an image 136 | * @return true: auto size is enabled, false: auto size is disabled 137 | */ 138 | bool lv_img_get_auto_size(const lv_obj_t * img); 139 | 140 | /** 141 | * Get the offset.x attribute of the img object. 142 | * @param img pointer to an image 143 | * @return offset.x value. 144 | */ 145 | lv_coord_t lv_img_get_offset_x(lv_obj_t * img); 146 | 147 | /** 148 | * Get the offset.y attribute of the img object. 149 | * @param img pointer to an image 150 | * @return offset.y value. 151 | */ 152 | lv_coord_t lv_img_get_offset_y(lv_obj_t * img); 153 | 154 | /** 155 | * Get the style of an image object 156 | * @param img pointer to an image object 157 | * @param type which style should be get (can be only `LV_IMG_STYLE_MAIN`) 158 | * @return pointer to the image's style 159 | */ 160 | static inline const lv_style_t * lv_img_get_style(const lv_obj_t * img, lv_img_style_t type) 161 | { 162 | (void)type; /*Unused*/ 163 | return lv_obj_get_style(img); 164 | } 165 | 166 | /********************** 167 | * MACROS 168 | **********************/ 169 | 170 | /*Use this macro to declare an image in a c file*/ 171 | #define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name; 172 | 173 | #endif /*LV_USE_IMG*/ 174 | 175 | #ifdef __cplusplus 176 | } /* extern "C" */ 177 | #endif 178 | 179 | #endif /*LV_IMG_H*/ 180 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_spinbox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_spinbox.h 3 | * 4 | */ 5 | 6 | #ifndef LV_SPINBOX_H 7 | #define LV_SPINBOX_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_SPINBOX != 0 23 | 24 | /*Testing of dependencies*/ 25 | #if LV_USE_TA == 0 26 | #error "lv_spinbox: lv_ta is required. Enable it in lv_conf.h (LV_USE_TA 1) " 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "../lv_objx/lv_ta.h" 31 | 32 | /********************* 33 | * DEFINES 34 | *********************/ 35 | #define LV_SPINBOX_MAX_DIGIT_COUNT 16 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | 41 | /*Data of spinbox*/ 42 | typedef struct 43 | { 44 | lv_ta_ext_t ta; /*Ext. of ancestor*/ 45 | /*New data for this type */ 46 | int32_t value; 47 | int32_t range_max; 48 | int32_t range_min; 49 | int32_t step; 50 | uint16_t digit_count : 4; 51 | uint16_t dec_point_pos : 4; /*if 0, there is no separator and the number is an integer*/ 52 | uint16_t digit_padding_left : 4; 53 | } lv_spinbox_ext_t; 54 | 55 | /*Styles*/ 56 | enum { 57 | LV_SPINBOX_STYLE_BG, 58 | LV_SPINBOX_STYLE_SB, 59 | LV_SPINBOX_STYLE_CURSOR, 60 | }; 61 | typedef uint8_t lv_spinbox_style_t; 62 | 63 | /********************** 64 | * GLOBAL PROTOTYPES 65 | **********************/ 66 | 67 | /** 68 | * Create a spinbox objects 69 | * @param par pointer to an object, it will be the parent of the new spinbox 70 | * @param copy pointer to a spinbox object, if not NULL then the new object will be copied from it 71 | * @return pointer to the created spinbox 72 | */ 73 | lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy); 74 | 75 | /*===================== 76 | * Setter functions 77 | *====================*/ 78 | 79 | /** 80 | * Set a style of a spinbox. 81 | * @param templ pointer to template object 82 | * @param type which style should be set 83 | * @param style pointer to a style 84 | */ 85 | static inline void lv_spinbox_set_style(lv_obj_t * spinbox, lv_spinbox_style_t type, lv_style_t * style) 86 | { 87 | lv_ta_set_style(spinbox, type, style); 88 | } 89 | 90 | /** 91 | * Set spinbox value 92 | * @param spinbox pointer to spinbox 93 | * @param i value to be set 94 | */ 95 | void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i); 96 | 97 | /** 98 | * Set spinbox digit format (digit count and decimal format) 99 | * @param spinbox pointer to spinbox 100 | * @param digit_count number of digit excluding the decimal separator and the sign 101 | * @param separator_position number of digit before the decimal point. If 0, decimal point is not 102 | * shown 103 | */ 104 | void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_t separator_position); 105 | 106 | /** 107 | * Set spinbox step 108 | * @param spinbox pointer to spinbox 109 | * @param step steps on increment/decrement 110 | */ 111 | void lv_spinbox_set_step(lv_obj_t * spinbox, uint32_t step); 112 | 113 | /** 114 | * Set spinbox value range 115 | * @param spinbox pointer to spinbox 116 | * @param range_min maximum value, inclusive 117 | * @param range_max minimum value, inclusive 118 | */ 119 | void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_max); 120 | 121 | /** 122 | * Set spinbox left padding in digits count (added between sign and first digit) 123 | * @param spinbox pointer to spinbox 124 | * @param cb Callback function called on value change event 125 | */ 126 | void lv_spinbox_set_padding_left(lv_obj_t * spinbox, uint8_t padding); 127 | 128 | /*===================== 129 | * Getter functions 130 | *====================*/ 131 | 132 | /** 133 | * Get style of a spinbox. 134 | * @param templ pointer to template object 135 | * @param type which style should be get 136 | * @return style pointer to the style 137 | */ 138 | static inline const lv_style_t * lv_spinbox_get_style(lv_obj_t * spinbox, lv_spinbox_style_t type) 139 | { 140 | return lv_ta_get_style(spinbox, type); 141 | } 142 | 143 | /** 144 | * Get the spinbox numeral value (user has to convert to float according to its digit format) 145 | * @param spinbox pointer to spinbox 146 | * @return value integer value of the spinbox 147 | */ 148 | int32_t lv_spinbox_get_value(lv_obj_t * spinbox); 149 | 150 | /*===================== 151 | * Other functions 152 | *====================*/ 153 | 154 | /** 155 | * Select next lower digit for edition by dividing the step by 10 156 | * @param spinbox pointer to spinbox 157 | */ 158 | void lv_spinbox_step_next(lv_obj_t * spinbox); 159 | 160 | /** 161 | * Select next higher digit for edition by multiplying the step by 10 162 | * @param spinbox pointer to spinbox 163 | */ 164 | void lv_spinbox_step_prev(lv_obj_t * spinbox); 165 | 166 | /** 167 | * Increment spinbox value by one step 168 | * @param spinbox pointer to spinbox 169 | */ 170 | void lv_spinbox_increment(lv_obj_t * spinbox); 171 | 172 | /** 173 | * Decrement spinbox value by one step 174 | * @param spinbox pointer to spinbox 175 | */ 176 | void lv_spinbox_decrement(lv_obj_t * spinbox); 177 | 178 | /********************** 179 | * MACROS 180 | **********************/ 181 | 182 | #endif /*LV_USE_SPINBOX*/ 183 | 184 | #ifdef __cplusplus 185 | } /* extern "C" */ 186 | #endif 187 | 188 | #endif /*LV_SPINBOX_H*/ 189 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_bar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_bar.h 3 | * 4 | */ 5 | 6 | #ifndef LV_BAR_H 7 | #define LV_BAR_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_BAR != 0 23 | 24 | #include "../lv_core/lv_obj.h" 25 | #include "../lv_misc/lv_anim.h" 26 | #include "lv_cont.h" 27 | #include "lv_btn.h" 28 | #include "lv_label.h" 29 | 30 | /********************* 31 | * DEFINES 32 | *********************/ 33 | 34 | /** Bar animation start value. (Not the real value of the Bar just indicates process animation)*/ 35 | #define LV_BAR_ANIM_STATE_START 0 36 | 37 | /** Bar animation end value. (Not the real value of the Bar just indicates process animation)*/ 38 | #define LV_BAR_ANIM_STATE_END 256 39 | 40 | /** Mark no animation is in progress */ 41 | #define LV_BAR_ANIM_STATE_INV -1 42 | 43 | /** log2(LV_BAR_ANIM_STATE_END) used to normalize data*/ 44 | #define LV_BAR_ANIM_STATE_NORM 8 45 | 46 | /********************** 47 | * TYPEDEFS 48 | **********************/ 49 | 50 | /** Data of bar*/ 51 | typedef struct 52 | { 53 | /*No inherited ext, derived from the base object */ 54 | 55 | /*New data for this type */ 56 | int16_t cur_value; /*Current value of the bar*/ 57 | int16_t min_value; /*Minimum value of the bar*/ 58 | int16_t max_value; /*Maximum value of the bar*/ 59 | #if LV_USE_ANIMATION 60 | lv_anim_value_t anim_start; 61 | lv_anim_value_t anim_end; 62 | lv_anim_value_t anim_state; 63 | lv_anim_value_t anim_time; 64 | #endif 65 | uint8_t sym : 1; /*Symmetric: means the center is around zero value*/ 66 | const lv_style_t * style_indic; /*Style of the indicator*/ 67 | } lv_bar_ext_t; 68 | 69 | /** Bar styles. */ 70 | enum { 71 | LV_BAR_STYLE_BG, /** Bar background style. */ 72 | LV_BAR_STYLE_INDIC, /** Bar fill area style. */ 73 | }; 74 | typedef uint8_t lv_bar_style_t; 75 | 76 | /********************** 77 | * GLOBAL PROTOTYPES 78 | **********************/ 79 | 80 | /** 81 | * Create a bar objects 82 | * @param par pointer to an object, it will be the parent of the new bar 83 | * @param copy pointer to a bar object, if not NULL then the new object will be copied from it 84 | * @return pointer to the created bar 85 | */ 86 | lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy); 87 | 88 | /*===================== 89 | * Setter functions 90 | *====================*/ 91 | 92 | /** 93 | * Set a new value on the bar 94 | * @param bar pointer to a bar object 95 | * @param value new value 96 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 97 | */ 98 | void lv_bar_set_value(lv_obj_t * bar, int16_t value, lv_anim_enable_t anim); 99 | 100 | /** 101 | * Set minimum and the maximum values of a bar 102 | * @param bar pointer to the bar object 103 | * @param min minimum value 104 | * @param max maximum value 105 | */ 106 | void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max); 107 | 108 | /** 109 | * Make the bar symmetric to zero. The indicator will grow from zero instead of the minimum 110 | * position. 111 | * @param bar pointer to a bar object 112 | * @param en true: enable disable symmetric behavior; false: disable 113 | */ 114 | void lv_bar_set_sym(lv_obj_t * bar, bool en); 115 | 116 | /** 117 | * Set the animation time of the bar 118 | * @param bar pointer to a bar object 119 | * @param anim_time the animation time in milliseconds. 120 | */ 121 | void lv_bar_set_anim_time(lv_obj_t * bar, uint16_t anim_time); 122 | 123 | /** 124 | * Set a style of a bar 125 | * @param bar pointer to a bar object 126 | * @param type which style should be set 127 | * @param style pointer to a style 128 | */ 129 | void lv_bar_set_style(lv_obj_t * bar, lv_bar_style_t type, const lv_style_t * style); 130 | 131 | /*===================== 132 | * Getter functions 133 | *====================*/ 134 | 135 | /** 136 | * Get the value of a bar 137 | * @param bar pointer to a bar object 138 | * @return the value of the bar 139 | */ 140 | int16_t lv_bar_get_value(const lv_obj_t * bar); 141 | 142 | /** 143 | * Get the minimum value of a bar 144 | * @param bar pointer to a bar object 145 | * @return the minimum value of the bar 146 | */ 147 | int16_t lv_bar_get_min_value(const lv_obj_t * bar); 148 | 149 | /** 150 | * Get the maximum value of a bar 151 | * @param bar pointer to a bar object 152 | * @return the maximum value of the bar 153 | */ 154 | int16_t lv_bar_get_max_value(const lv_obj_t * bar); 155 | 156 | /** 157 | * Get whether the bar is symmetric or not. 158 | * @param bar pointer to a bar object 159 | * @return true: symmetric is enabled; false: disable 160 | */ 161 | bool lv_bar_get_sym(lv_obj_t * bar); 162 | 163 | /** 164 | * Get the animation time of the bar 165 | * @param bar pointer to a bar object 166 | * @return the animation time in milliseconds. 167 | */ 168 | uint16_t lv_bar_get_anim_time(lv_obj_t * bar); 169 | 170 | /** 171 | * Get a style of a bar 172 | * @param bar pointer to a bar object 173 | * @param type which style should be get 174 | * @return style pointer to a style 175 | */ 176 | const lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type); 177 | 178 | /********************** 179 | * MACROS 180 | **********************/ 181 | 182 | #endif /*LV_USE_BAR*/ 183 | 184 | #ifdef __cplusplus 185 | } /* extern "C" */ 186 | #endif 187 | 188 | #endif /*LV_BAR_H*/ 189 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_slider.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_slider.h 3 | * 4 | */ 5 | 6 | #ifndef LV_SLIDER_H 7 | #define LV_SLIDER_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_SLIDER != 0 23 | 24 | /*Testing of dependencies*/ 25 | #if LV_USE_BAR == 0 26 | #error "lv_slider: lv_bar is required. Enable it in lv_conf.h (LV_USE_BAR 1) " 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "lv_bar.h" 31 | 32 | /********************* 33 | * DEFINES 34 | *********************/ 35 | 36 | /********************** 37 | * TYPEDEFS 38 | **********************/ 39 | /*Data of slider*/ 40 | typedef struct 41 | { 42 | lv_bar_ext_t bar; /*Ext. of ancestor*/ 43 | /*New data for this type */ 44 | const lv_style_t * style_knob; /*Style of the knob*/ 45 | int16_t drag_value; /*Store a temporal value during press until release (Handled by the library)*/ 46 | uint8_t knob_in : 1; /*1: Draw the knob inside the bar*/ 47 | } lv_slider_ext_t; 48 | 49 | /** Built-in styles of slider*/ 50 | enum { 51 | LV_SLIDER_STYLE_BG, /** Slider background style. */ 52 | LV_SLIDER_STYLE_INDIC, /** Slider indicator (filled area) style. */ 53 | LV_SLIDER_STYLE_KNOB, /** Slider knob style. */ 54 | }; 55 | typedef uint8_t lv_slider_style_t; 56 | 57 | /********************** 58 | * GLOBAL PROTOTYPES 59 | **********************/ 60 | 61 | /** 62 | * Create a slider objects 63 | * @param par pointer to an object, it will be the parent of the new slider 64 | * @param copy pointer to a slider object, if not NULL then the new object will be copied from it 65 | * @return pointer to the created slider 66 | */ 67 | lv_obj_t * lv_slider_create(lv_obj_t * par, const lv_obj_t * copy); 68 | 69 | /*===================== 70 | * Setter functions 71 | *====================*/ 72 | 73 | /** 74 | * Set a new value on the slider 75 | * @param slider pointer to a slider object 76 | * @param value new value 77 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 78 | */ 79 | static inline void lv_slider_set_value(lv_obj_t * slider, int16_t value, lv_anim_enable_t anim) 80 | { 81 | lv_bar_set_value(slider, value, anim); 82 | } 83 | 84 | /** 85 | * Set minimum and the maximum values of a bar 86 | * @param slider pointer to the slider object 87 | * @param min minimum value 88 | * @param max maximum value 89 | */ 90 | static inline void lv_slider_set_range(lv_obj_t * slider, int16_t min, int16_t max) 91 | { 92 | lv_bar_set_range(slider, min, max); 93 | } 94 | 95 | /** 96 | * Set the animation time of the slider 97 | * @param slider pointer to a bar object 98 | * @param anim_time the animation time in milliseconds. 99 | */ 100 | static inline void lv_slider_set_anim_time(lv_obj_t * slider, uint16_t anim_time) 101 | { 102 | lv_bar_set_anim_time(slider, anim_time); 103 | } 104 | 105 | /** 106 | * Set the 'knob in' attribute of a slider 107 | * @param slider pointer to slider object 108 | * @param in true: the knob is drawn always in the slider; 109 | * false: the knob can be out on the edges 110 | */ 111 | void lv_slider_set_knob_in(lv_obj_t * slider, bool in); 112 | 113 | /** 114 | * Set a style of a slider 115 | * @param slider pointer to a slider object 116 | * @param type which style should be set 117 | * @param style pointer to a style 118 | */ 119 | void lv_slider_set_style(lv_obj_t * slider, lv_slider_style_t type, const lv_style_t * style); 120 | 121 | /*===================== 122 | * Getter functions 123 | *====================*/ 124 | 125 | /** 126 | * Get the value of a slider 127 | * @param slider pointer to a slider object 128 | * @return the value of the slider 129 | */ 130 | int16_t lv_slider_get_value(const lv_obj_t * slider); 131 | 132 | /** 133 | * Get the minimum value of a slider 134 | * @param slider pointer to a slider object 135 | * @return the minimum value of the slider 136 | */ 137 | static inline int16_t lv_slider_get_min_value(const lv_obj_t * slider) 138 | { 139 | return lv_bar_get_min_value(slider); 140 | } 141 | 142 | /** 143 | * Get the maximum value of a slider 144 | * @param slider pointer to a slider object 145 | * @return the maximum value of the slider 146 | */ 147 | static inline int16_t lv_slider_get_max_value(const lv_obj_t * slider) 148 | { 149 | return lv_bar_get_max_value(slider); 150 | } 151 | 152 | /** 153 | * Give the slider is being dragged or not 154 | * @param slider pointer to a slider object 155 | * @return true: drag in progress false: not dragged 156 | */ 157 | bool lv_slider_is_dragged(const lv_obj_t * slider); 158 | 159 | /** 160 | * Get the 'knob in' attribute of a slider 161 | * @param slider pointer to slider object 162 | * @return true: the knob is drawn always in the slider; 163 | * false: the knob can be out on the edges 164 | */ 165 | bool lv_slider_get_knob_in(const lv_obj_t * slider); 166 | 167 | /** 168 | * Get a style of a slider 169 | * @param slider pointer to a slider object 170 | * @param type which style should be get 171 | * @return style pointer to a style 172 | */ 173 | const lv_style_t * lv_slider_get_style(const lv_obj_t * slider, lv_slider_style_t type); 174 | 175 | /********************** 176 | * MACROS 177 | **********************/ 178 | 179 | #endif /*LV_USE_SLIDER*/ 180 | 181 | #ifdef __cplusplus 182 | } /* extern "C" */ 183 | #endif 184 | 185 | #endif /*LV_SLIDER_H*/ 186 | -------------------------------------------------------------------------------- /src/src/lv_objx/lv_preload.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_preload.h 3 | * 4 | */ 5 | 6 | #ifndef LV_PRELOAD_H 7 | #define LV_PRELOAD_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../../lv_conf.h" 20 | #endif 21 | 22 | #if LV_USE_PRELOAD != 0 23 | 24 | /*Testing of dependencies*/ 25 | #if LV_USE_ARC == 0 26 | #error "lv_preload: lv_arc is required. Enable it in lv_conf.h (LV_USE_ARC 1) " 27 | #endif 28 | 29 | #if LV_USE_ANIMATION == 0 30 | #error "lv_preload: animations are required. Enable it in lv_conf.h (LV_USE_ANIMATION 1) " 31 | #endif 32 | 33 | #include "../lv_core/lv_obj.h" 34 | #include "../lv_misc/lv_anim.h" 35 | #include "lv_arc.h" 36 | 37 | /********************* 38 | * DEFINES 39 | *********************/ 40 | 41 | /********************** 42 | * TYPEDEFS 43 | **********************/ 44 | 45 | /** 46 | * Type of preloader. 47 | */ 48 | enum { 49 | LV_PRELOAD_TYPE_SPINNING_ARC, 50 | LV_PRELOAD_TYPE_FILLSPIN_ARC, 51 | }; 52 | typedef uint8_t lv_preload_type_t; 53 | 54 | /** 55 | * Direction the preloader should spin. 56 | */ 57 | enum { 58 | LV_PRELOAD_DIR_FORWARD, 59 | LV_PRELOAD_DIR_BACKWARD, 60 | }; 61 | typedef uint8_t lv_preload_dir_t; 62 | 63 | /*Data of pre loader*/ 64 | typedef struct 65 | { 66 | lv_arc_ext_t arc; /*Ext. of ancestor*/ 67 | /*New data for this type */ 68 | lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/ 69 | uint16_t time; /*Time of one round*/ 70 | lv_preload_type_t anim_type : 1; /*Type of the arc animation*/ 71 | lv_preload_dir_t anim_dir : 1; /*Animation Direction*/ 72 | } lv_preload_ext_t; 73 | 74 | /*Styles*/ 75 | enum { 76 | LV_PRELOAD_STYLE_MAIN, 77 | }; 78 | typedef uint8_t lv_preload_style_t; 79 | 80 | /********************** 81 | * GLOBAL PROTOTYPES 82 | **********************/ 83 | 84 | /** 85 | * Create a pre loader objects 86 | * @param par pointer to an object, it will be the parent of the new pre loader 87 | * @param copy pointer to a pre loader object, if not NULL then the new object will be copied from 88 | * it 89 | * @return pointer to the created pre loader 90 | */ 91 | lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy); 92 | 93 | /*====================== 94 | * Add/remove functions 95 | *=====================*/ 96 | 97 | /** 98 | * Set the length of the spinning arc in degrees 99 | * @param preload pointer to a preload object 100 | * @param deg length of the arc 101 | */ 102 | void lv_preload_set_arc_length(lv_obj_t * preload, lv_anim_value_t deg); 103 | 104 | /** 105 | * Set the spin time of the arc 106 | * @param preload pointer to a preload object 107 | * @param time time of one round in milliseconds 108 | */ 109 | void lv_preload_set_spin_time(lv_obj_t * preload, uint16_t time); 110 | 111 | /*===================== 112 | * Setter functions 113 | *====================*/ 114 | 115 | /** 116 | * Set a style of a pre loader. 117 | * @param preload pointer to pre loader object 118 | * @param type which style should be set 119 | * @param style pointer to a style 120 | * */ 121 | void lv_preload_set_style(lv_obj_t * preload, lv_preload_style_t type, const lv_style_t * style); 122 | 123 | /** 124 | * Set the animation type of a preloader. 125 | * @param preload pointer to pre loader object 126 | * @param type animation type of the preload 127 | * */ 128 | void lv_preload_set_type(lv_obj_t * preload, lv_preload_type_t type); 129 | 130 | /** 131 | * Set the animation direction of a preloader 132 | * @param preload pointer to pre loader object 133 | * @param direction animation direction of the preload 134 | */ 135 | void lv_preload_set_dir(lv_obj_t * preload, lv_preload_dir_t dir); 136 | 137 | /*===================== 138 | * Getter functions 139 | *====================*/ 140 | 141 | /** 142 | * Get the arc length [degree] of the a pre loader 143 | * @param preload pointer to a pre loader object 144 | */ 145 | lv_anim_value_t lv_preload_get_arc_length(const lv_obj_t * preload); 146 | 147 | /** 148 | * Get the spin time of the arc 149 | * @param preload pointer to a pre loader object [milliseconds] 150 | */ 151 | uint16_t lv_preload_get_spin_time(const lv_obj_t * preload); 152 | 153 | /** 154 | * Get style of a pre loader. 155 | * @param preload pointer to pre loader object 156 | * @param type which style should be get 157 | * @return style pointer to the style 158 | * */ 159 | const lv_style_t * lv_preload_get_style(const lv_obj_t * preload, lv_preload_style_t type); 160 | 161 | /** 162 | * Get the animation type of a preloader. 163 | * @param preload pointer to pre loader object 164 | * @return animation type 165 | * */ 166 | lv_preload_type_t lv_preload_get_type(lv_obj_t * preload); 167 | 168 | /** 169 | * Get the animation direction of a preloader 170 | * @param preload pointer to pre loader object 171 | * @return animation direction 172 | */ 173 | lv_preload_dir_t lv_preload_get_dir(lv_obj_t * preload); 174 | 175 | /*===================== 176 | * Other functions 177 | *====================*/ 178 | 179 | /** 180 | * Animator function (exec_cb) to rotate the arc of spinner. 181 | * @param ptr pointer to preloader 182 | * @param val the current desired value [0..360] 183 | */ 184 | void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val); 185 | 186 | /********************** 187 | * MACROS 188 | **********************/ 189 | 190 | #endif /*LV_USE_PRELOAD*/ 191 | 192 | #ifdef __cplusplus 193 | } /* extern "C" */ 194 | #endif 195 | 196 | #endif /*LV_PRELOAD_H*/ 197 | --------------------------------------------------------------------------------