├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── all-other-issues.md │ ├── bug-report.md │ └── config.yml ├── auto-comment.yml ├── stale.yml └── workflows │ ├── ccpp.yml │ └── merge-to-dev.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── LICENCE.txt ├── Makefile ├── README.md ├── a ├── demo ├── lv_demo_widgets.c └── lv_demo_widgets.h ├── docs ├── CODE_OF_CONDUCT.md ├── CODING_STYLE.md └── CONTRIBUTING.md ├── examples ├── arduino │ ├── ESP32_TFT_eSPI │ │ ├── ESP32_TFT_eSPI.ino │ │ └── README.md │ └── README.md └── porting │ ├── lv_port_disp_template.c │ ├── lv_port_disp_template.h │ ├── lv_port_fs_template.c │ ├── lv_port_fs_template.h │ ├── lv_port_indev_template.c │ └── lv_port_indev_template.h ├── library.json ├── logs ├── application-click-com.ubuntu.filemanager_filemanager_0.7.5.log ├── syslog └── unity8.log ├── lv_conf.h ├── lv_conf_template.h ├── lvgl.h ├── lvgl.mk ├── scripts ├── Doxyfile ├── built_in_font │ ├── DejaVuSans.ttf │ ├── FontAwesome5-Solid+Brands+Regular.woff │ ├── Montserrat-Medium.ttf │ ├── SimSun.woff │ ├── built_in_font_gen.py │ └── generate_all.py ├── code-format.cfg ├── code-format.sh ├── cppcheck_run.sh ├── infer_run.sh ├── lv_conf_checker.py └── release.py ├── src ├── lv_api_map.h ├── lv_conf_internal.h ├── lv_core │ ├── lv_core.mk │ ├── lv_disp.c │ ├── lv_disp.h │ ├── lv_group.c │ ├── lv_group.h │ ├── lv_indev.c │ ├── lv_indev.h │ ├── lv_obj.c │ ├── lv_obj.h │ ├── lv_obj_style_dec.h │ ├── lv_refr.c │ ├── lv_refr.h │ ├── lv_style.c │ └── lv_style.h ├── lv_draw │ ├── lv_draw.h │ ├── lv_draw.mk │ ├── lv_draw_arc.c │ ├── lv_draw_arc.h │ ├── lv_draw_blend.c │ ├── lv_draw_blend.h │ ├── lv_draw_img.c │ ├── lv_draw_img.h │ ├── lv_draw_label.c │ ├── lv_draw_label.h │ ├── lv_draw_line.c │ ├── lv_draw_line.h │ ├── lv_draw_mask.c │ ├── lv_draw_mask.h │ ├── lv_draw_rect.c │ ├── lv_draw_rect.h │ ├── lv_draw_triangle.c │ ├── lv_draw_triangle.h │ ├── lv_img_buf.c │ ├── lv_img_buf.h │ ├── lv_img_cache.c │ ├── lv_img_cache.h │ ├── lv_img_decoder.c │ └── lv_img_decoder.h ├── lv_font │ ├── lv_font.c │ ├── lv_font.h │ ├── lv_font.mk │ ├── lv_font_dejavu_16_persian_hebrew.c │ ├── lv_font_fmt_txt.c │ ├── lv_font_fmt_txt.h │ ├── lv_font_montserrat_12.c │ ├── lv_font_montserrat_12_subpx.c │ ├── lv_font_montserrat_14.c │ ├── lv_font_montserrat_16.c │ ├── lv_font_montserrat_18.c │ ├── lv_font_montserrat_20.c │ ├── lv_font_montserrat_22.c │ ├── lv_font_montserrat_24.c │ ├── lv_font_montserrat_26.c │ ├── lv_font_montserrat_28.c │ ├── lv_font_montserrat_28_compressed.c │ ├── lv_font_montserrat_30.c │ ├── lv_font_montserrat_32.c │ ├── lv_font_montserrat_34.c │ ├── lv_font_montserrat_36.c │ ├── lv_font_montserrat_38.c │ ├── lv_font_montserrat_40.c │ ├── lv_font_montserrat_42.c │ ├── lv_font_montserrat_44.c │ ├── lv_font_montserrat_46.c │ ├── lv_font_montserrat_48.c │ ├── lv_font_simsun_16_cjk.c │ ├── lv_font_unscii_8.c │ └── lv_symbol_def.h ├── lv_gpu │ ├── lv_gpu.mk │ ├── lv_gpu_stm32_dma2d.c │ └── lv_gpu_stm32_dma2d.h ├── lv_hal │ ├── lv_hal.h │ ├── lv_hal.mk │ ├── lv_hal_disp.c │ ├── lv_hal_disp.h │ ├── lv_hal_indev.c │ ├── lv_hal_indev.h │ ├── lv_hal_tick.c │ └── lv_hal_tick.h ├── lv_misc │ ├── lv_anim.c │ ├── lv_anim.h │ ├── lv_area.c │ ├── lv_area.h │ ├── lv_async.c │ ├── lv_async.h │ ├── lv_bidi.c │ ├── lv_bidi.h │ ├── lv_color.c │ ├── lv_color.h │ ├── lv_debug.c │ ├── lv_debug.h │ ├── lv_fs.c │ ├── lv_fs.h │ ├── lv_gc.c │ ├── lv_gc.h │ ├── lv_ll.c │ ├── lv_ll.h │ ├── lv_log.c │ ├── lv_log.h │ ├── lv_math.c │ ├── lv_math.h │ ├── lv_mem.c │ ├── lv_mem.h │ ├── lv_misc.mk │ ├── lv_printf.c │ ├── lv_printf.h │ ├── lv_task.c │ ├── lv_task.h │ ├── lv_templ.c │ ├── lv_templ.h │ ├── lv_txt.c │ ├── lv_txt.h │ ├── lv_txt_ap.c │ ├── lv_txt_ap.h │ ├── lv_types.h │ ├── lv_utils.c │ └── lv_utils.h ├── lv_themes │ ├── lv_theme.c │ ├── lv_theme.h │ ├── lv_theme_empty.c │ ├── lv_theme_empty.h │ ├── lv_theme_material.c │ ├── lv_theme_material.h │ ├── lv_theme_mono.c │ ├── lv_theme_mono.h │ ├── lv_theme_template.c │ ├── lv_theme_template.h │ └── lv_themes.mk ├── lv_widgets │ ├── lv_arc.c │ ├── lv_arc.h │ ├── lv_bar.c │ ├── lv_bar.h │ ├── lv_btn.c │ ├── lv_btn.h │ ├── lv_btnmatrix.c │ ├── lv_btnmatrix.h │ ├── lv_calendar.c │ ├── lv_calendar.h │ ├── lv_canvas.c │ ├── lv_canvas.h │ ├── lv_chart.c │ ├── lv_chart.h │ ├── lv_checkbox.c │ ├── lv_checkbox.h │ ├── lv_cont.c │ ├── lv_cont.h │ ├── lv_cpicker.c │ ├── lv_cpicker.h │ ├── lv_dropdown.c │ ├── lv_dropdown.h │ ├── lv_gauge.c │ ├── lv_gauge.h │ ├── lv_img.c │ ├── lv_img.h │ ├── lv_imgbtn.c │ ├── lv_imgbtn.h │ ├── lv_keyboard.c │ ├── lv_keyboard.h │ ├── lv_label.c │ ├── lv_label.h │ ├── lv_led.c │ ├── lv_led.h │ ├── lv_line.c │ ├── lv_line.h │ ├── lv_linemeter.c │ ├── lv_linemeter.h │ ├── lv_list.c │ ├── lv_list.h │ ├── lv_msgbox.c │ ├── lv_msgbox.h │ ├── lv_objmask.c │ ├── lv_objmask.h │ ├── lv_objx_templ.c │ ├── lv_objx_templ.h │ ├── lv_page.c │ ├── lv_page.h │ ├── lv_roller.c │ ├── lv_roller.h │ ├── lv_slider.c │ ├── lv_slider.h │ ├── lv_spinbox.c │ ├── lv_spinbox.h │ ├── lv_spinner.c │ ├── lv_spinner.h │ ├── lv_switch.c │ ├── lv_switch.h │ ├── lv_table.c │ ├── lv_table.h │ ├── lv_tabview.c │ ├── lv_tabview.h │ ├── lv_textarea.c │ ├── lv_textarea.h │ ├── lv_tileview.c │ ├── lv_tileview.h │ ├── lv_widgets.mk │ ├── lv_win.c │ └── lv_win.h └── lvgl.h ├── tests ├── Makefile ├── build.py ├── icon.png ├── icon2.png ├── lv_test_assert.c ├── lv_test_assert.h ├── lv_test_conf.h ├── lv_test_core │ ├── lv_test_core.c │ ├── lv_test_core.h │ ├── lv_test_obj.c │ ├── lv_test_obj.h │ ├── lv_test_style.c │ └── lv_test_style.h ├── lv_test_main.c ├── lv_test_objx │ ├── lv_test_cont.c │ └── lv_test_cont.h └── lv_test_ref_imgs │ └── lv_test_obj_1_1.png └── wayland ├── lv_port_disp.c ├── lv_port_disp.h ├── lvgl.c ├── lvgl.sh ├── run.sh ├── shader.c ├── texture.c ├── util.c └── util.h /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{c,h}] 2 | indent_style = space 3 | indent_size = 4 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | 8 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ["https://littlevgl.com/donate"] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/all-other-issues.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: All other issues 3 | about: Questions and enhancement requests should go to the forum. 4 | title: '' 5 | labels: not-template 6 | assignees: '' 7 | 8 | --- 9 | 10 | # All enhancement requests or questions should be directed to the Forum. 11 | 12 | 13 | We use GitHub issues for development related discussions. 14 | Please use the [forum](https://forum.littlevgl.com/) to ask questions. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | > # Important: issues that don't use this template will be ignored/closed. 11 | 12 | **Describe the bug** 13 | 14 | A clear and concise description of what the bug is. 15 | 16 | **To Reproduce** 17 | 18 | Please provide a small, independent code sample that can be used to reproduce the issue. Ideally this should work in the PC simulator unless the problem is specific to one platform. 19 | 20 | **Expected behavior** 21 | 22 | A clear and concise description of what you expected to happen. 23 | 24 | **Screenshots** 25 | If applicable, add screenshots to help explain your problem. 26 | 27 | **Additional context** 28 | 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Documentation 4 | url: https://docs.lvgl.io 5 | about: Be sure to read to documentation first 6 | - name: Forum 7 | url: https://forum.lvgl.io 8 | about: For how-to questions use the forum 9 | - name: CONTIBUTING.md 10 | url: https://github.com/lvgl/lvgl/blob/master/docs/CONTRIBUTING.md#faq-about-contributing 11 | about: The basic rules of contributing 12 | - name: CODING_STYLE.md 13 | url: https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md 14 | about: Quick summary of LVGL's code style 15 | -------------------------------------------------------------------------------- /.github/auto-comment.yml: -------------------------------------------------------------------------------- 1 | # Comment to a new issue. 2 | pullRequestOpened: | 3 | Thank you for raising your pull request. 4 | 5 | To ensure that all licensing criteria is met all repositories of the LVGL project apply a process called DCO (Developer's Certificate of Origin). 6 | 7 | The text of DCO can be read here: https://developercertificate.org/ 8 | For a more detailed description see the [Documentation](https://docs.lvgl.io/latest/en/html/contributing/index.html#developer-certification-of-origin-dco) site. 9 | 10 | By contributing to any repositories of the LVGL project you state that your contribution corresponds with the DCO. 11 | 12 | No further action is required if your contribution fulfills the DCO. If you are not sure about it feel free to ask us in a comment. 13 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.github/workflows/ccpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master, dev ] 6 | pull_request: 7 | branches: [master, dev ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Run tests 17 | run: cd tests; python ./build.py 18 | -------------------------------------------------------------------------------- /.github/workflows/merge-to-dev.yml: -------------------------------------------------------------------------------- 1 | name: Merge master branch to dev 2 | on: 3 | push: 4 | branches: 5 | - 'master' 6 | jobs: 7 | merge-branch: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@master 11 | - name: Merge to dev branch 12 | uses: devmasx/merge-branch@v1.1.0 13 | with: 14 | type: now 15 | target_branch: 'dev' 16 | env: 17 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.o 2 | **/*bin 3 | **/*.swp 4 | **/*.swo 5 | tags 6 | docs/api_doc 7 | scripts/cppcheck_res.txt 8 | scripts/built_in_font/lv_font_* 9 | wayland/lvgl 10 | lvgl.map 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/.gitmodules -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | MIT licence 2 | Copyright (c) 2020 LVGL LLC 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Build LVGL on PinePhone Ubuntu Touch 2 | 3 | # Define $(CSRCS) 4 | LVGL_DIR := . 5 | LVGL_DIR_NAME := . 6 | include lvgl.mk 7 | 8 | WAYLAND_CSRCS := \ 9 | demo/lv_demo_widgets.c \ 10 | wayland/lv_port_disp.c \ 11 | wayland/shader.c \ 12 | wayland/texture.c \ 13 | wayland/util.c 14 | 15 | TARGETS:= wayland/lvgl 16 | 17 | DEPS := lv_conf.h 18 | 19 | CC := gcc 20 | 21 | CCFLAGS := \ 22 | -g \ 23 | -I src/lv_core \ 24 | -D LV_USE_DEMO_WIDGETS 25 | 26 | LDFLAGS := \ 27 | -Wl,-Map=wayland/lvgl.map \ 28 | -L/usr/lib/aarch64-linux-gnu/mesa-egl \ 29 | -lwayland-client \ 30 | -lwayland-server \ 31 | -lwayland-egl \ 32 | -lEGL \ 33 | -lGLESv2 34 | 35 | MAINS := $(addsuffix .o, $(TARGETS) ) 36 | OBJ := \ 37 | $(MAINS) \ 38 | $(CSRCS:.c=.o) \ 39 | $(WAYLAND_CSRCS:.c=.o) 40 | 41 | .PHONY: all clean 42 | 43 | all: $(TARGETS) 44 | 45 | clean: 46 | rm -f $(TARGETS) $(OBJ) 47 | 48 | $(OBJ): %.o : %.c $(DEPS) 49 | $(CC) -c -o $@ $< $(CCFLAGS) 50 | 51 | $(TARGETS): % : $(filter-out $(MAINS), $(OBJ)) %.o 52 | $(CC) -o $@ \ 53 | -Wl,--start-group \ 54 | $(LIBS) \ 55 | $^ \ 56 | -Wl,--end-group \ 57 | $(CCFLAGS) \ 58 | $(LDFLAGS) 59 | -------------------------------------------------------------------------------- /a: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script to start SSH service and show IP address 3 | 4 | # Start SSH service 5 | sudo service ssh start 6 | 7 | # Show IP address 8 | ifconfig | \ 9 | grep -v "127.0.0.1" | \ 10 | grep "inet addr:" 11 | 12 | # Ping repeatedly to keep WiFi alive 13 | ping google.com 14 | -------------------------------------------------------------------------------- /demo/lv_demo_widgets.h: -------------------------------------------------------------------------------- 1 | // From https://github.com/lvgl/lv_examples/blob/master/src/lv_demo_widgets/lv_demo_widgets.h 2 | /** 3 | * @file lv_demo_widgets.h 4 | * 5 | */ 6 | 7 | #ifndef LV_DEMO_WIDGETS_H 8 | #define LV_DEMO_WIDGETS_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /********************* 15 | * INCLUDES 16 | *********************/ 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | void lv_demo_widgets(void); 30 | 31 | /********************** 32 | * MACROS 33 | **********************/ 34 | 35 | #ifdef __cplusplus 36 | } /* extern "C" */ 37 | #endif 38 | 39 | #endif /*LV_DEMO_WIDGETS_H*/ -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docs/CODING_STYLE.md: -------------------------------------------------------------------------------- 1 | # Coding style 2 | 3 | ## File format 4 | Use [lv_misc/lv_templ.c](https://github.com/lvgl/lvgl/blob/master/src/lv_misc/lv_templ.c) and [lv_misc/lv_templ.h](https://github.com/lvgl/lvgl/blob/master/src/lv_misc/lv_templ.h) 5 | 6 | ## Naming conventions 7 | * Words are separated by '_' 8 | * In variable and function names use only lower case letters (e.g. *height_tmp*) 9 | * In enums and defines use only upper case letters (e.g. *e.g. MAX_LINE_NUM*) 10 | * Global names (API): 11 | * starts with *lv* 12 | * followed by module name: *btn*, *label*, *style* etc. 13 | * followed by the action (for functions): *set*, *get*, *refr* etc. 14 | * closed with the subject: *name*, *size*, *state* etc. 15 | * Typedefs 16 | * prefer `typedef struct` and `typedef enum` instead of `struct name` and `enum name` 17 | * always end `typedef struct` and `typedef enum` type names with `_t` 18 | * Abbreviations: 19 | * Only words longer or equal than 6 characters can be abbreviated. 20 | * Abbreviate only if it makes the word at least half as long 21 | * Use only very straightforward and well-known abbreviations (e.g. pos: position, def: default, btn: button) 22 | 23 | ## Coding guide 24 | * Functions: 25 | * Try to write function shorter than is 50 lines 26 | * Always shorter than 200 lines (except very straightforwards) 27 | * Variables: 28 | * One line, one declaration (BAD: char x, y;) 29 | * Use `` (*uint8_t*, *int32_t* etc) 30 | * Declare variables where needed (not all at function start) 31 | * Use the smallest required scope 32 | * Variables in a file (outside functions) are always *static* 33 | * Do not use global variables (use functions to set/get static variables) 34 | 35 | ## Comments 36 | Before every function have a comment like this: 37 | 38 | ```c 39 | /** 40 | * Return with the screen of an object 41 | * @param obj pointer to an object 42 | * @return pointer to a screen 43 | */ 44 | lv_obj_t * lv_obj_get_scr(lv_obj_t * obj); 45 | ``` 46 | 47 | Always use `/* Something */` format and NOT `//Something` 48 | 49 | Write readable code to avoid descriptive comments like: 50 | `x++; /* Add 1 to x */`. 51 | The code should show clearly what you are doing. 52 | 53 | You should write **why** have you done this: 54 | `x++; /*Because of closing '\0' of the string */` 55 | 56 | Short "code summaries" of a few lines are accepted. E.g. `/*Calculate the new coordinates*/` 57 | 58 | In comments use \` \` when referring to a variable. E.g. ``/*Update the value of `x_act`*/`` 59 | 60 | ### Formatting 61 | Here is example to show bracket placing and using of white spaces: 62 | ```c 63 | /** 64 | * Set a new text for a label. Memory will be allocated to store the text by the label. 65 | * @param label pointer to a label object 66 | * @param text '\0' terminated character string. NULL to refresh with the current text. 67 | */ 68 | void lv_label_set_text(lv_obj_t * label, const char * text) 69 | { /* Main brackets of functions in new line*/ 70 | 71 | if(label == NULL) return; /*No bracket only if the command is inline with the if statement*/ 72 | 73 | lv_obj_inv(label); 74 | 75 | lv_label_ext_t * ext = lv_obj_get_ext(label); 76 | 77 | /*Comment before a section */ 78 | if(text == ext->txt || text == NULL) { /*Bracket of statements start inline*/ 79 | lv_label_refr_text(label); 80 | return; 81 | } 82 | 83 | ... 84 | } 85 | ``` 86 | 87 | Use 4 spaces indentation instead of tab. 88 | 89 | You can use **astyle** to format the code. Run `code-formatter.sh` from the `scrips` folder. 90 | -------------------------------------------------------------------------------- /docs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to LVGL 2 | 3 | Thank you for considering contributing to LVGL. 4 | 5 | For a detailed description of contribution opportunities, please visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation. 6 | -------------------------------------------------------------------------------- /examples/arduino/ESP32_TFT_eSPI/ESP32_TFT_eSPI.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | TFT_eSPI tft = TFT_eSPI(); /* TFT instance */ 5 | static lv_disp_buf_t disp_buf; 6 | static lv_color_t buf[LV_HOR_RES_MAX * 10]; 7 | 8 | #if USE_LV_LOG != 0 9 | /* Serial debugging */ 10 | void my_print(lv_log_level_t level, const char * file, uint32_t line, const char * dsc) 11 | { 12 | 13 | Serial.printf("%s@%d->%s\r\n", file, line, dsc); 14 | Serial.flush(); 15 | } 16 | #endif 17 | 18 | /* Display flushing */ 19 | void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p) 20 | { 21 | uint32_t w = (area->x2 - area->x1 + 1); 22 | uint32_t h = (area->y2 - area->y1 + 1); 23 | 24 | tft.startWrite(); 25 | tft.setAddrWindow(area->x1, area->y1, w, h); 26 | tft.pushColors(&color_p->full, w * h, true); 27 | tft.endWrite(); 28 | 29 | lv_disp_flush_ready(disp); 30 | } 31 | 32 | /*Read the touchpad*/ 33 | bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) 34 | { 35 | uint16_t touchX, touchY; 36 | 37 | bool touched = tft.getTouch(&touchX, &touchY, 600); 38 | 39 | if(!touched) 40 | { 41 | data->state = LV_INDEV_STATE_REL; 42 | return false; 43 | } 44 | else 45 | { 46 | data->state = LV_INDEV_STATE_PR; 47 | } 48 | 49 | if(touchX>screenWidth || touchY > screenHeight) 50 | { 51 | Serial.println("Y or y outside of expected parameters.."); 52 | Serial.print("y:"); 53 | Serial.print(touchX); 54 | Serial.print(" x:"); 55 | Serial.print(touchY); 56 | } 57 | else 58 | { 59 | /*Set the coordinates*/ 60 | data->point.x = touchX; 61 | data->point.y = touchY; 62 | 63 | Serial.print("Data x"); 64 | Serial.println(touchX); 65 | 66 | Serial.print("Data y"); 67 | Serial.println(touchY); 68 | 69 | } 70 | 71 | return false; /*Return `false` because we are not buffering and no more data to read*/ 72 | } 73 | 74 | void setup() 75 | { 76 | Serial.begin(115200); /* prepare for possible serial debug */ 77 | 78 | lv_init(); 79 | 80 | #if USE_LV_LOG != 0 81 | lv_log_register_print_cb(my_print); /* register print function for debugging */ 82 | #endif 83 | 84 | tft.begin(); /* TFT init */ 85 | tft.setRotation(1); /* Landscape orientation */ 86 | 87 | uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; 88 | tft.setTouch(calData); 89 | 90 | lv_disp_buf_init(&disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); 91 | 92 | /*Initialize the display*/ 93 | lv_disp_drv_t disp_drv; 94 | lv_disp_drv_init(&disp_drv); 95 | disp_drv.hor_res = 320; 96 | disp_drv.ver_res = 240; 97 | disp_drv.flush_cb = my_disp_flush; 98 | disp_drv.buffer = &disp_buf; 99 | lv_disp_drv_register(&disp_drv); 100 | 101 | /*Initialize the (dummy) input device driver*/ 102 | lv_indev_drv_t indev_drv; 103 | lv_indev_drv_init(&indev_drv); 104 | indev_drv.type = LV_INDEV_TYPE_POINTER; 105 | indev_drv.read_cb = my_touchpad_read; 106 | lv_indev_drv_register(&indev_drv); 107 | 108 | /* Try an example from the lv_examples repository 109 | * https://github.com/lvgl/lv_examples*/ 110 | lv_ex_btn_1(); 111 | } 112 | 113 | 114 | void loop() 115 | { 116 | 117 | lv_task_handler(); /* let the GUI do its work */ 118 | delay(5); 119 | } 120 | -------------------------------------------------------------------------------- /examples/arduino/ESP32_TFT_eSPI/README.md: -------------------------------------------------------------------------------- 1 | # Example for lv_arduino using a slider 2 | 3 | This example has the screen set to 320x480 (ILI9488), change this by altering the following lines in the main ino file: 4 | 5 | ```C 6 | int screenWidth = 480; 7 | int screenHeight = 320; 8 | ``` 9 | 10 | ## Backlight 11 | 12 | Change pin 32 to your preferred backlight pin using a PNP transistor (2N3906) or remove the following code and connect directly to +ve: 13 | 14 | ```C 15 | ledcSetup(10, 5000/*freq*/, 10 /*resolution*/); 16 | ledcAttachPin(32, 10); 17 | analogReadResolution(10); 18 | ledcWrite(10,768); 19 | ``` 20 | 21 | ## Theme selection 22 | 23 | Change the following to change the theme: 24 | 25 | ```C 26 | lv_theme_t * th = lv_theme_night_init(210, NULL); //Set a HUE value and a Font for the Night Theme 27 | lv_theme_set_current(th); 28 | ``` 29 | 30 | ## Calibration 31 | 32 | This is using the bodmer tft_espi driver for touch. To correctly set the calibration load the calibration sketch and replace the following with your values: 33 | 34 | ```C 35 | uint16_t calData[5] = { 275, 3620, 264, 3532, 1 }; 36 | ``` 37 | 38 | ## Screen rotation 39 | 40 | Check the following if you need to alter your screen rotation: 41 | 42 | ```C 43 | tft.setRotation(3); 44 | ``` 45 | -------------------------------------------------------------------------------- /examples/arduino/README.md: -------------------------------------------------------------------------------- 1 | # LVGL Arduino examples 2 | 3 | LVGL can be installed via Arduino IDE Library Manager or as an .ZIP library. 4 | It will install [lv_exmaples](https://github.com/lvgl/lv_examples) which contains a lot of examples and demos to try LVGL. 5 | 6 | ## Example 7 | 8 | There are simple examples which use the [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing. 9 | 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. 10 | 11 | LVGL library has its own configuration file called `lv_conf.h`. When LVGL is installed to followings needs to be done to configure it: 12 | 1. Go to directory of the installed Arduno libraries 13 | 2. Go to `lvgl` and copy `lv_conf_template.h` as `lvgl.h` next to the `lvgl` folder. 14 | 3. Open `lv_conf.h` and change the first `#if 0` to `#if 1` 15 | 4. Set the resolution of your display in `LV_HOR_RES_MAX` and `LV_VER_RES_MAX` 16 | 5. Set the color depth of you display in `LV_COLOR_DEPTH` 17 | 6. Set `LV_TICK_CUSTOM 1` 18 | 19 | ## Debugging 20 | 21 | In case of trouble there are debug informations inside LVGL. In the `ESP32_TFT_eSPI` example there is `my_print` method, which allow to send this debug informations to the serial interface. To enable this feature you have to edit `lv_conf.h` file and enable logging in section `log settings`: 22 | 23 | ```c 24 | /*Log settings*/ 25 | #define USE_LV_LOG 1 /*Enable/disable the log module*/ 26 | #if LV_USE_LOG 27 | /* How important log should be added: 28 | * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information 29 | * LV_LOG_LEVEL_INFO Log important events 30 | * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem 31 | * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail 32 | * LV_LOG_LEVEL_NONE Do not log anything 33 | */ 34 | # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN 35 | ``` 36 | 37 | After enabling log module and setting LV_LOG_LEVEL accordingly the output log is sent to the `Serial` port @ 115200 Bd. 38 | -------------------------------------------------------------------------------- /examples/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 | -------------------------------------------------------------------------------- /examples/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 | -------------------------------------------------------------------------------- /examples/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 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lvgl", 3 | "version": "7.1.0", 4 | "keywords": "graphics, gui, embedded, tft, lvgl", 5 | "description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/lvgl/lvgl.git" 9 | }, 10 | "build": { 11 | "includeDir": "." 12 | }, 13 | "license": "MIT", 14 | "homepage": "https://lvgl.io", 15 | "frameworks": "*", 16 | "platforms": "*" 17 | } 18 | -------------------------------------------------------------------------------- /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_misc/lv_log.h" 18 | #include "src/lv_misc/lv_task.h" 19 | #include "src/lv_misc/lv_math.h" 20 | #include "src/lv_misc/lv_async.h" 21 | 22 | #include "src/lv_hal/lv_hal.h" 23 | 24 | #include "src/lv_core/lv_obj.h" 25 | #include "src/lv_core/lv_group.h" 26 | #include "src/lv_core/lv_indev.h" 27 | 28 | #include "src/lv_core/lv_refr.h" 29 | #include "src/lv_core/lv_disp.h" 30 | 31 | #include "src/lv_themes/lv_theme.h" 32 | 33 | #include "src/lv_font/lv_font.h" 34 | #include "src/lv_font/lv_font_fmt_txt.h" 35 | #include "src/lv_misc/lv_printf.h" 36 | 37 | #include "src/lv_widgets/lv_btn.h" 38 | #include "src/lv_widgets/lv_imgbtn.h" 39 | #include "src/lv_widgets/lv_img.h" 40 | #include "src/lv_widgets/lv_label.h" 41 | #include "src/lv_widgets/lv_line.h" 42 | #include "src/lv_widgets/lv_page.h" 43 | #include "src/lv_widgets/lv_cont.h" 44 | #include "src/lv_widgets/lv_list.h" 45 | #include "src/lv_widgets/lv_chart.h" 46 | #include "src/lv_widgets/lv_table.h" 47 | #include "src/lv_widgets/lv_checkbox.h" 48 | #include "src/lv_widgets/lv_cpicker.h" 49 | #include "src/lv_widgets/lv_bar.h" 50 | #include "src/lv_widgets/lv_slider.h" 51 | #include "src/lv_widgets/lv_led.h" 52 | #include "src/lv_widgets/lv_btnmatrix.h" 53 | #include "src/lv_widgets/lv_keyboard.h" 54 | #include "src/lv_widgets/lv_dropdown.h" 55 | #include "src/lv_widgets/lv_roller.h" 56 | #include "src/lv_widgets/lv_textarea.h" 57 | #include "src/lv_widgets/lv_canvas.h" 58 | #include "src/lv_widgets/lv_win.h" 59 | #include "src/lv_widgets/lv_tabview.h" 60 | #include "src/lv_widgets/lv_tileview.h" 61 | #include "src/lv_widgets/lv_msgbox.h" 62 | #include "src/lv_widgets/lv_objmask.h" 63 | #include "src/lv_widgets/lv_gauge.h" 64 | #include "src/lv_widgets/lv_linemeter.h" 65 | #include "src/lv_widgets/lv_switch.h" 66 | #include "src/lv_widgets/lv_arc.h" 67 | #include "src/lv_widgets/lv_spinner.h" 68 | #include "src/lv_widgets/lv_calendar.h" 69 | #include "src/lv_widgets/lv_spinbox.h" 70 | 71 | #include "src/lv_draw/lv_img_cache.h" 72 | 73 | #include "src/lv_api_map.h" 74 | 75 | /********************* 76 | * DEFINES 77 | *********************/ 78 | /*Current version of LVGL*/ 79 | #define LVGL_VERSION_MAJOR 7 80 | #define LVGL_VERSION_MINOR 2 81 | #define LVGL_VERSION_PATCH 0 82 | #define LVGL_VERSION_INFO "dev" 83 | 84 | /********************** 85 | * TYPEDEFS 86 | **********************/ 87 | 88 | /********************** 89 | * GLOBAL PROTOTYPES 90 | **********************/ 91 | 92 | /********************** 93 | * MACROS 94 | **********************/ 95 | 96 | /** Gives 1 if the x.y.z version is supported in the current version 97 | * Usage: 98 | * 99 | * - Require v6 100 | * #if LV_VERSION_CHECK(6,0,0) 101 | * new_func_in_v6(); 102 | * #endif 103 | * 104 | * 105 | * - Require at least v5.3 106 | * #if LV_VERSION_CHECK(5,3,0) 107 | * new_feature_from_v5_3(); 108 | * #endif 109 | * 110 | * 111 | * - Require v5.3.2 bugfixes 112 | * #if LV_VERSION_CHECK(5,3,2) 113 | * bugfix_in_v5_3_2(); 114 | * #endif 115 | * 116 | * */ 117 | #define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH))) 118 | 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif /*LVGL_H*/ 125 | -------------------------------------------------------------------------------- /lvgl.mk: -------------------------------------------------------------------------------- 1 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core/lv_core.mk 2 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal/lv_hal.mk 3 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets/lv_widgets.mk 4 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font/lv_font.mk 5 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc/lv_misc.mk 6 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes/lv_themes.mk 7 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw/lv_draw.mk 8 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu/lv_gpu.mk 9 | 10 | 11 | -------------------------------------------------------------------------------- /scripts/built_in_font/DejaVuSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/scripts/built_in_font/DejaVuSans.ttf -------------------------------------------------------------------------------- /scripts/built_in_font/FontAwesome5-Solid+Brands+Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/scripts/built_in_font/FontAwesome5-Solid+Brands+Regular.woff -------------------------------------------------------------------------------- /scripts/built_in_font/Montserrat-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/scripts/built_in_font/Montserrat-Medium.ttf -------------------------------------------------------------------------------- /scripts/built_in_font/SimSun.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/scripts/built_in_font/SimSun.woff -------------------------------------------------------------------------------- /scripts/built_in_font/built_in_font_gen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3.6 2 | 3 | import argparse 4 | from argparse import RawTextHelpFormatter 5 | import os 6 | import sys 7 | 8 | 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 9 | Example: python built_in_font_gen.py --size 16 -o lv_font_roboto_16.c --bpp 4 -r 0x20-0x7F""", formatter_class=RawTextHelpFormatter) 10 | parser.add_argument('-s', '--size', 11 | type=int, 12 | metavar = 'px', 13 | nargs='?', 14 | help='Size of the font in px') 15 | parser.add_argument('--bpp', 16 | type=int, 17 | metavar = '1,2,4', 18 | nargs='?', 19 | help='Bit per pixel') 20 | parser.add_argument('-r', '--range', 21 | nargs='+', 22 | metavar = 'start-end', 23 | default=['0x20-0x7F,0xB0,0x2022'], 24 | help='Ranges and/or characters to include. Default is 0x20-7F (ASCII). E.g. -r 0x20-0x7F, 0x200, 324') 25 | parser.add_argument('--symbols', 26 | nargs='+', 27 | metavar = 'sym', 28 | default=[''], 29 | help=u'Symbols to include. E.g. -s ÁÉŐ'.encode('utf-8')) 30 | parser.add_argument('--font', 31 | metavar = 'file', 32 | nargs='?', 33 | default='Montserrat-Medium.ttf', 34 | help='A TTF or WOFF file') 35 | parser.add_argument('-o', '--output', 36 | nargs='?', 37 | metavar='file', 38 | help='Output file name. E.g. my_font_20.c') 39 | parser.add_argument('--compressed', action='store_true', 40 | help='Compress the bitmaps') 41 | parser.add_argument('--subpx', action='store_true', 42 | help='3 times wider letters for sub pixel rendering') 43 | 44 | args = parser.parse_args() 45 | 46 | if args.compressed == False: 47 | compr = "--no-compress --no-prefilter" 48 | else: 49 | compr = "" 50 | 51 | if len(args.symbols[0]) != 0: 52 | args.symbols[0] = "--symbols " + args.symbols[0] 53 | 54 | #Built in symbols 55 | syms = "61441,61448,61451,61452,61452,61453,61457,61459,61461,61465,61468,61473,61478,61479,61480,61502,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61550,61552,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61674,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62087,62099,62212,62189,62810,63426,63650" 56 | 57 | #Run the command (Add degree and bbullet symbol) 58 | cmd = "lv_font_conv {} --bpp {} --size {} --font {} -r {} {} --font FontAwesome5-Solid+Brands+Regular.woff -r {} --format lvgl -o {} --force-fast-kern-format".format(compr, args.bpp, args.size, args.font, args.range[0], args.symbols[0], syms, args.output) 59 | os.system(cmd) 60 | -------------------------------------------------------------------------------- /scripts/code-format.cfg: -------------------------------------------------------------------------------- 1 | --style=kr 2 | --indent=spaces=4 3 | --indent-classes 4 | --indent-switches 5 | --indent-cases 6 | --indent-preproc-block 7 | --indent-preproc-define 8 | --indent-col1-comments 9 | --pad-oper 10 | --unpad-paren 11 | --align-pointer=middle 12 | --align-reference=middle 13 | --convert-tabs 14 | --max-code-length=120 15 | --break-after-logical 16 | --break-closing-braces 17 | --attach-closing-while 18 | --min-conditional-indent=0 19 | --max-continuation-indent=120 20 | --mode=c 21 | --lineend=linux 22 | --recursive 23 | --suffix=none 24 | --preserve-date 25 | --formatted 26 | --exclude=lv_conf_internal.h 27 | --exclude=../src/lv_font/lv_font_montserrat_12.c 28 | --exclude=../src/lv_font/lv_font_montserrat_14.c 29 | --exclude=../src/lv_font/lv_font_montserrat_16.c 30 | --exclude=../src/lv_font/lv_font_montserrat_18.c 31 | --exclude=../src/lv_font/lv_font_montserrat_20.c 32 | --exclude=../src/lv_font/lv_font_montserrat_22.c 33 | --exclude=../src/lv_font/lv_font_montserrat_24.c 34 | --exclude=../src/lv_font/lv_font_montserrat_26.c 35 | --exclude=../src/lv_font/lv_font_montserrat_28.c 36 | --exclude=../src/lv_font/lv_font_montserrat_30.c 37 | --exclude=../src/lv_font/lv_font_montserrat_32.c 38 | --exclude=../src/lv_font/lv_font_montserrat_34.c 39 | --exclude=../src/lv_font/lv_font_montserrat_36.c 40 | --exclude=../src/lv_font/lv_font_montserrat_38.c 41 | --exclude=../src/lv_font/lv_font_montserrat_40.c 42 | --exclude=../src/lv_font/lv_font_montserrat_42.c 43 | --exclude=../src/lv_font/lv_font_montserrat_44.c 44 | --exclude=../src/lv_font/lv_font_montserrat_46.c 45 | --exclude=../src/lv_font/lv_font_montserrat_48.c 46 | --exclude=../src/lv_font/lv_font_montserrat_12_subpx.c 47 | --exclude=../src/lv_font/lv_font_montserrat_28_compressed.c 48 | --exclude=../src/lv_font/lv_font_simsun_16_cjk.c 49 | --exclude=../src/lv_font/lv_font_dejavu_16_persian_hebrew.c 50 | 51 | -------------------------------------------------------------------------------- /scripts/code-format.sh: -------------------------------------------------------------------------------- 1 | astyle --options=code-format.cfg "../src/*.c,*.h" 2 | -------------------------------------------------------------------------------- /scripts/cppcheck_run.sh: -------------------------------------------------------------------------------- 1 | cppcheck -j8 --template="{severity}\t{file}:{line}\t{id}: {message}" --enable=all ../src/ --output-file=cppcheck_res.txt --suppress=unusedFunction --suppress=preprocessorErrorDirective --force 2 | 3 | -------------------------------------------------------------------------------- /scripts/infer_run.sh: -------------------------------------------------------------------------------- 1 | # https://github.com/facebook/infer 2 | # 3 | # Install: 4 | # VERSION=0.17.0; \ 5 | # curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" \ 6 | # | sudo tar -C /opt -xJ && \ 7 | # sudoln -s "/opt/infer-linux64-v$VERSION/bin/infer" /usr/local/bin/infer 8 | 9 | 10 | infer run -- make -j8 11 | -------------------------------------------------------------------------------- /scripts/lv_conf_checker.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | ''' 4 | Generates a checker file for lv_conf.h from lv_conf_templ.h define all the not defined values 5 | ''' 6 | 7 | 8 | import sys 9 | import re 10 | 11 | if sys.version_info < (3,6,0): 12 | print("Python >=3.6 is required", file=sys.stderr) 13 | exit(1) 14 | 15 | fin = open("../lv_conf_template.h", "r") 16 | fout = open("../src/lv_conf_internal.h", "w") 17 | 18 | 19 | fout.write( 20 | '''/** 21 | * GENERATED FILE, DO NOT EDIT IT! 22 | * @file lv_conf_internal.h 23 | * Make sure all the defines of lv_conf.h have a default value 24 | **/ 25 | 26 | #ifndef LV_CONF_INTERNAL_H 27 | #define LV_CONF_INTERNAL_H 28 | /* clang-format off */ 29 | 30 | #include 31 | 32 | #if defined(LV_CONF_PATH) 33 | #define __LV_TO_STR_AUX(x) #x 34 | #define __LV_TO_STR(x) __LV_TO_STR_AUX(x) 35 | #include __LV_TO_STR(LV_CONF_PATH) 36 | #undef __LV_TO_STR_AUX 37 | #undef __LV_TO_STR 38 | #elif defined(LV_CONF_INCLUDE_SIMPLE) 39 | #include "lv_conf.h" 40 | #else 41 | #include "../../lv_conf.h" 42 | #endif 43 | 44 | ''' 45 | ) 46 | 47 | started = 0 48 | 49 | for i in fin.read().splitlines(): 50 | if not started: 51 | if '#define LV_CONF_H' in i: 52 | started = 1 53 | continue 54 | else: 55 | continue 56 | 57 | if '/*--END OF LV_CONF_H--*/' in i: break 58 | 59 | r = re.search(r'^ *# *define ([^\s]+).*$', i) 60 | 61 | if r: 62 | line = re.sub('\(.*?\)', '', r[1], 1) #remove parentheses from macros 63 | fout.write( 64 | f'#ifndef {line}\n' 65 | f'{i}\n' 66 | '#endif\n' 67 | ) 68 | elif re.search('^ *typedef .*;.*$', i): 69 | continue #ignore typedefs to avoide redeclaration 70 | else: 71 | fout.write(f'{i}\n') 72 | 73 | 74 | fout.write( 75 | ''' 76 | #endif /*LV_CONF_CHECKER_H*/ 77 | ''' 78 | ) 79 | 80 | fin.close() 81 | fout.close() 82 | -------------------------------------------------------------------------------- /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_DIR_NAME)/src/lv_core 9 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core 10 | 11 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_core" 12 | -------------------------------------------------------------------------------- /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 | #define LV_REFR_TASK_PRIO LV_TASK_PRIO_MID 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 the screen refresh subsystem 47 | */ 48 | void _lv_refr_init(void); 49 | 50 | /** 51 | * Redraw the invalidated areas now. 52 | * Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process 53 | * can prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process 54 | * (e.g. progress bar) this function can be called when the screen should be updated. 55 | * @param disp pointer to display to refresh. NULL to refresh all displays. 56 | */ 57 | void lv_refr_now(lv_disp_t * disp); 58 | 59 | /** 60 | * Invalidate an area on display to redraw it 61 | * @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas) 62 | * @param disp pointer to display where the area should be invalidated (NULL can be used if there is 63 | * only one display) 64 | */ 65 | void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p); 66 | 67 | /** 68 | * Get the display which is being refreshed 69 | * @return the display being refreshed 70 | */ 71 | lv_disp_t * _lv_refr_get_disp_refreshing(void); 72 | 73 | /** 74 | * Set the display which is being refreshed. 75 | * It shouldn't be used directly by the user. 76 | * It can be used to trick the drawing functions about there is an active display. 77 | * @param the display being refreshed 78 | */ 79 | void _lv_refr_set_disp_refreshing(lv_disp_t * disp); 80 | 81 | /** 82 | * Called periodically to handle the refreshing 83 | * @param task pointer to the task itself 84 | */ 85 | void _lv_disp_refr_task(lv_task_t * task); 86 | 87 | /********************** 88 | * STATIC FUNCTIONS 89 | **********************/ 90 | 91 | #ifdef __cplusplus 92 | } /* extern "C" */ 93 | #endif 94 | 95 | #endif /*LV_REFR_H*/ 96 | -------------------------------------------------------------------------------- /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 | #include "../lv_conf_internal.h" 17 | 18 | #include "../lv_core/lv_style.h" 19 | #include "../lv_misc/lv_txt.h" 20 | #include "lv_img_decoder.h" 21 | 22 | #include "lv_draw_rect.h" 23 | #include "lv_draw_label.h" 24 | #include "lv_draw_img.h" 25 | #include "lv_draw_line.h" 26 | #include "lv_draw_triangle.h" 27 | #include "lv_draw_arc.h" 28 | #include "lv_draw_blend.h" 29 | #include "lv_draw_mask.h" 30 | 31 | /********************* 32 | * DEFINES 33 | *********************/ 34 | 35 | /********************** 36 | * TYPEDEFS 37 | **********************/ 38 | 39 | /********************** 40 | * GLOBAL PROTOTYPES 41 | **********************/ 42 | 43 | /********************** 44 | * GLOBAL VARIABLES 45 | **********************/ 46 | 47 | /********************** 48 | * MACROS 49 | **********************/ 50 | 51 | /********************** 52 | * POST INCLUDES 53 | *********************/ 54 | 55 | #ifdef __cplusplus 56 | } /* extern "C" */ 57 | #endif 58 | 59 | #endif /*LV_DRAW_H*/ 60 | -------------------------------------------------------------------------------- /src/lv_draw/lv_draw.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_draw_mask.c 2 | CSRCS += lv_draw_blend.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 | CSRCS += lv_img_buf.c 12 | 13 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw 14 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw 15 | 16 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_draw" 17 | -------------------------------------------------------------------------------- /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_line.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, uint16_t start_angle, uint16_t end_angle, 42 | const lv_area_t * clip_area, lv_draw_line_dsc_t * dsc); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | #ifdef __cplusplus 49 | } /* extern "C" */ 50 | #endif 51 | 52 | #endif /*LV_DRAW_ARC*/ 53 | -------------------------------------------------------------------------------- /src/lv_draw/lv_draw_blend.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_blend.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_BLEND_H 7 | #define LV_DRAW_BLEND_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_misc/lv_color.h" 17 | #include "../lv_misc/lv_area.h" 18 | #include "lv_draw_mask.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | enum { 28 | LV_BLEND_MODE_NORMAL, 29 | LV_BLEND_MODE_ADDITIVE, 30 | LV_BLEND_MODE_SUBTRACTIVE, 31 | }; 32 | 33 | typedef uint8_t lv_blend_mode_t; 34 | 35 | /********************** 36 | * GLOBAL PROTOTYPES 37 | **********************/ 38 | 39 | //! @cond Doxygen_Suppress 40 | LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_area_t * fill_area, lv_color_t color, 41 | lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode); 42 | 43 | 44 | LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area, 45 | const lv_color_t * map_buf, 46 | lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa, lv_blend_mode_t mode); 47 | 48 | //! @endcond 49 | /********************** 50 | * MACROS 51 | **********************/ 52 | 53 | #ifdef __cplusplus 54 | } /* extern "C" */ 55 | #endif 56 | 57 | #endif /*LV_DRAW_BLEND_H*/ 58 | -------------------------------------------------------------------------------- /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_img_decoder.h" 17 | #include "lv_img_buf.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * MACROS 25 | **********************/ 26 | 27 | /********************** 28 | * TYPEDEFS 29 | **********************/ 30 | 31 | typedef struct { 32 | lv_opa_t opa; 33 | 34 | uint16_t angle; 35 | lv_point_t pivot; 36 | uint16_t zoom; 37 | 38 | lv_opa_t recolor_opa; 39 | lv_color_t recolor; 40 | 41 | lv_blend_mode_t blend_mode; 42 | 43 | uint8_t antialias : 1; 44 | } lv_draw_img_dsc_t; 45 | 46 | /********************** 47 | * GLOBAL PROTOTYPES 48 | **********************/ 49 | 50 | void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc); 51 | /** 52 | * Draw an image 53 | * @param coords the coordinates of the image 54 | * @param mask the image will be drawn only in this area 55 | * @param src pointer to a lv_color_t array which contains the pixels of the image 56 | * @param style style of the image 57 | * @param angle rotation angle of the image 58 | * @param center rotation center of the image 59 | * @param antialias anti-alias transformations (rotate, zoom) or not 60 | * @param opa_scale scale down all opacities by the factor 61 | */ 62 | void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, lv_draw_img_dsc_t * dsc); 63 | 64 | /** 65 | * Get the type of an image source 66 | * @param src pointer to an image source: 67 | * - pointer to an 'lv_img_t' variable (image stored internally and compiled into the code) 68 | * - a path to a file (e.g. "S:/folder/image.bin") 69 | * - or a symbol (e.g. LV_SYMBOL_CLOSE) 70 | * @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN 71 | */ 72 | lv_img_src_t lv_img_src_get_type(const void * src); 73 | 74 | /** 75 | * Get the pixel size of a color format in bits 76 | * @param cf a color format (`LV_IMG_CF_...`) 77 | * @return the pixel size in bits 78 | */ 79 | uint8_t lv_img_cf_get_px_size(lv_img_cf_t cf); 80 | 81 | /** 82 | * Check if a color format is chroma keyed or not 83 | * @param cf a color format (`LV_IMG_CF_...`) 84 | * @return true: chroma keyed; false: not chroma keyed 85 | */ 86 | bool lv_img_cf_is_chroma_keyed(lv_img_cf_t cf); 87 | 88 | /** 89 | * Check if a color format has alpha channel or not 90 | * @param cf a color format (`LV_IMG_CF_...`) 91 | * @return true: has alpha channel; false: doesn't have alpha channel 92 | */ 93 | bool lv_img_cf_has_alpha(lv_img_cf_t cf); 94 | 95 | 96 | #ifdef __cplusplus 97 | } /* extern "C" */ 98 | #endif 99 | 100 | #endif /*LV_TEMPL_H*/ 101 | -------------------------------------------------------------------------------- /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_misc/lv_bidi.h" 17 | #include "../lv_misc/lv_txt.h" 18 | #include "../lv_core/lv_style.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | #define LV_DRAW_LABEL_NO_TXT_SEL (0xFFFF) 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | typedef struct { 30 | lv_color_t color; 31 | lv_color_t sel_color; 32 | const lv_font_t * font; 33 | lv_opa_t opa; 34 | lv_style_int_t line_space; 35 | lv_style_int_t letter_space; 36 | uint32_t sel_start; 37 | uint32_t sel_end; 38 | lv_coord_t ofs_x; 39 | lv_coord_t ofs_y; 40 | lv_bidi_dir_t bidi_dir; 41 | lv_txt_flag_t flag; 42 | lv_text_decor_t decor; 43 | lv_blend_mode_t blend_mode; 44 | } lv_draw_label_dsc_t; 45 | 46 | /** Store some info to speed up drawing of very large texts 47 | * It takes a lot of time to get the first visible character because 48 | * all the previous characters needs to be checked to calculate the positions. 49 | * This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line. 50 | * Therefore the calculations can start from here.*/ 51 | typedef struct { 52 | /** Index of the line at `y` coordinate*/ 53 | int32_t line_start; 54 | 55 | /** Give the `y` coordinate of the first letter at `line start` index. Relative to the label's coordinates*/ 56 | int32_t y; 57 | 58 | /** The 'y1' coordinate of the label when the hint was saved. 59 | * Used to invalidate the hint if the label has moved too much. */ 60 | int32_t coord_y; 61 | } lv_draw_label_hint_t; 62 | 63 | /********************** 64 | * GLOBAL PROTOTYPES 65 | **********************/ 66 | 67 | //! @cond Doxygen_Suppress 68 | 69 | LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc); 70 | 71 | /** 72 | * Write a text 73 | * @param coords coordinates of the label 74 | * @param mask the label will be drawn only in this area 75 | * @param dsc pointer to draw descriptor 76 | * @param txt `\0` terminated text to write 77 | * @param hint pointer to a `lv_draw_label_hint_t` variable. 78 | * It is managed by the drawer to speed up the drawing of very long texts (thousands of lines). 79 | */ 80 | LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_label_dsc_t * dsc, 81 | const char * txt, lv_draw_label_hint_t * hint); 82 | 83 | //! @endcond 84 | /*********************** 85 | * GLOBAL VARIABLES 86 | ***********************/ 87 | extern const uint8_t _lv_bpp2_opa_table[]; 88 | extern const uint8_t _lv_bpp3_opa_table[]; 89 | extern const uint8_t _lv_bpp1_opa_table[]; 90 | extern const uint8_t _lv_bpp4_opa_table[]; 91 | extern const uint8_t _lv_bpp8_opa_table[]; 92 | 93 | /********************** 94 | * MACROS 95 | **********************/ 96 | 97 | #ifdef __cplusplus 98 | } /* extern "C" */ 99 | #endif 100 | 101 | #endif /*LV_DRAW_LABEL_H*/ 102 | -------------------------------------------------------------------------------- /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 | #include "../lv_core/lv_style.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | typedef struct { 26 | lv_color_t color; 27 | lv_style_int_t width; 28 | lv_style_int_t dash_width; 29 | lv_style_int_t dash_gap; 30 | lv_opa_t opa; 31 | lv_blend_mode_t blend_mode : 2; 32 | uint8_t round_start : 1; 33 | uint8_t round_end : 1; 34 | uint8_t raw_end : 1; /*Do not bother with perpendicular line ending is it's not visible for any reason*/ 35 | } lv_draw_line_dsc_t; 36 | 37 | /********************** 38 | * GLOBAL PROTOTYPES 39 | **********************/ 40 | 41 | //! @cond Doxygen_Suppress 42 | /** 43 | * Draw a line 44 | * @param point1 first point of the line 45 | * @param point2 second point of the line 46 | * @param mask the line will be drawn only on this area 47 | * @param style pointer to a line's style 48 | * @param opa_scale scale down all opacities by the factor 49 | */ 50 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, 51 | lv_draw_line_dsc_t * dsc); 52 | 53 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc); 54 | 55 | 56 | //! @endcond 57 | 58 | /********************** 59 | * MACROS 60 | **********************/ 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif /*LV_DRAW_LINE_H*/ 67 | -------------------------------------------------------------------------------- /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_core/lv_style.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | typedef struct { 27 | lv_style_int_t radius; 28 | 29 | /*Background*/ 30 | lv_color_t bg_color; 31 | lv_color_t bg_grad_color; 32 | lv_grad_dir_t bg_grad_dir; 33 | lv_style_int_t bg_main_color_stop; 34 | lv_style_int_t bg_grad_color_stop; 35 | lv_opa_t bg_opa; 36 | lv_blend_mode_t bg_blend_mode; 37 | 38 | /*Border*/ 39 | lv_color_t border_color; 40 | lv_style_int_t border_width; 41 | lv_style_int_t border_side; 42 | lv_opa_t border_opa; 43 | lv_blend_mode_t border_blend_mode; 44 | 45 | /*Outline*/ 46 | lv_color_t outline_color; 47 | lv_style_int_t outline_width; 48 | lv_style_int_t outline_pad; 49 | lv_opa_t outline_opa; 50 | lv_blend_mode_t outline_blend_mode; 51 | 52 | /*Shadow*/ 53 | lv_color_t shadow_color; 54 | lv_style_int_t shadow_width; 55 | lv_style_int_t shadow_ofs_x; 56 | lv_style_int_t shadow_ofs_y; 57 | lv_style_int_t shadow_spread; 58 | lv_opa_t shadow_opa; 59 | lv_blend_mode_t shadow_blend_mode; 60 | 61 | /*Pattern*/ 62 | const void * pattern_image; 63 | const lv_font_t * pattern_font; 64 | lv_color_t pattern_recolor; 65 | lv_opa_t pattern_opa; 66 | lv_opa_t pattern_recolor_opa; 67 | uint8_t pattern_repeat : 1; 68 | lv_blend_mode_t pattern_blend_mode; 69 | 70 | /*Value*/ 71 | const char * value_str; 72 | const lv_font_t * value_font; 73 | lv_opa_t value_opa; 74 | lv_color_t value_color; 75 | lv_style_int_t value_ofs_x; 76 | lv_style_int_t value_ofs_y; 77 | lv_style_int_t value_letter_space; 78 | lv_style_int_t value_line_space; 79 | lv_align_t value_align; 80 | lv_blend_mode_t value_blend_mode; 81 | } lv_draw_rect_dsc_t; 82 | 83 | /********************** 84 | * GLOBAL PROTOTYPES 85 | **********************/ 86 | 87 | LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc); 88 | 89 | //! @endcond 90 | 91 | /** 92 | * Draw a rectangle 93 | * @param coords the coordinates of the rectangle 94 | * @param mask the rectangle will be drawn only in this mask 95 | * @param style pointer to a style 96 | */ 97 | void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, lv_draw_rect_dsc_t * dsc); 98 | 99 | /** 100 | * Draw a pixel 101 | * @param point the coordinates of the point to draw 102 | * @param mask the pixel will be drawn only in this mask 103 | * @param style pointer to a style 104 | */ 105 | void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style); 106 | 107 | /********************** 108 | * MACROS 109 | **********************/ 110 | 111 | #ifdef __cplusplus 112 | } /* extern "C" */ 113 | #endif 114 | 115 | #endif /*LV_DRAW_RECT_H*/ 116 | -------------------------------------------------------------------------------- /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_rect.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw a triangle 32 | * @param points pointer to an array with 3 points 33 | * @param clip_area the triangle will be drawn only in this area 34 | * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable 35 | */ 36 | void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, lv_draw_rect_dsc_t * draw_dsc); 37 | 38 | /** 39 | * Draw a polygon. Only convex polygons are supported. 40 | * @param points an array of points 41 | * @param point_cnt number of points 42 | * @param clip_area polygon will be drawn only in this area 43 | * @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable 44 | */ 45 | void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * mask, 46 | lv_draw_rect_dsc_t * draw_dsc); 47 | 48 | /********************** 49 | * MACROS 50 | **********************/ 51 | 52 | #ifdef __cplusplus 53 | } /* extern "C" */ 54 | #endif 55 | 56 | #endif /*LV_DRAW_TRIANGLE_H*/ 57 | -------------------------------------------------------------------------------- /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 | lv_img_decoder_dsc_t dec_dsc; /**< Image information */ 33 | 34 | /** Count the cache entries's life. Add `time_tio_open` to `life` when the entry is used. 35 | * Decrement all lifes by one every in every ::lv_img_cache_open. 36 | * If life == 0 the entry can be reused */ 37 | int32_t life; 38 | } lv_img_cache_entry_t; 39 | 40 | /********************** 41 | * GLOBAL PROTOTYPES 42 | **********************/ 43 | 44 | /** 45 | * Open an image using the image decoder interface and cache it. 46 | * The image will be left open meaning if the image decoder open callback allocated memory then it will remain. 47 | * The image is closed if a new image is opened and the new image takes its place in the cache. 48 | * @param src source of the image. Path to file or pointer to an `lv_img_dsc_t` variable 49 | * @param style style of the image 50 | * @return pointer to the cache entry or NULL if can open the image 51 | */ 52 | lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color); 53 | 54 | /** 55 | * Set the number of images to be cached. 56 | * More cached images mean more opened image at same time which might mean more memory usage. 57 | * E.g. if 20 PNG or JPG images are open in the RAM they consume memory while opened in the cache. 58 | * @param new_entry_cnt number of image to cache 59 | */ 60 | void lv_img_cache_set_size(uint16_t new_slot_num); 61 | 62 | /** 63 | * Invalidate an image source in the cache. 64 | * Useful if the image source is updated therefore it needs to be cached again. 65 | * @param src an image source path to a file or pointer to an `lv_img_dsc_t` variable. 66 | */ 67 | void lv_img_cache_invalidate_src(const void * src); 68 | 69 | /********************** 70 | * MACROS 71 | **********************/ 72 | 73 | #ifdef __cplusplus 74 | } /* extern "C" */ 75 | #endif 76 | 77 | #endif /*LV_IMG_CACHE_H*/ 78 | -------------------------------------------------------------------------------- /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, 62 | uint32_t letter_next) 63 | { 64 | return font_p->get_glyph_dsc(font_p, dsc_out, letter, letter_next); 65 | } 66 | 67 | /** 68 | * Get the width of a glyph with kerning 69 | * @param font pointer to a font 70 | * @param letter an UNICODE letter 71 | * @param letter_next the next letter after `letter`. Used for kerning 72 | * @return the width of the glyph 73 | */ 74 | uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next) 75 | { 76 | lv_font_glyph_dsc_t g; 77 | bool ret; 78 | ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next); 79 | if(ret) return g.adv_w; 80 | else return 0; 81 | } 82 | 83 | /********************** 84 | * STATIC FUNCTIONS 85 | **********************/ 86 | -------------------------------------------------------------------------------- /src/lv_font/lv_font.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font.c 2 | CSRCS += lv_font_fmt_txt.c 3 | CSRCS += lv_font_montserrat_12.c 4 | CSRCS += lv_font_montserrat_14.c 5 | CSRCS += lv_font_montserrat_16.c 6 | CSRCS += lv_font_montserrat_18.c 7 | CSRCS += lv_font_montserrat_20.c 8 | CSRCS += lv_font_montserrat_22.c 9 | CSRCS += lv_font_montserrat_24.c 10 | CSRCS += lv_font_montserrat_26.c 11 | CSRCS += lv_font_montserrat_28.c 12 | CSRCS += lv_font_montserrat_30.c 13 | CSRCS += lv_font_montserrat_32.c 14 | CSRCS += lv_font_montserrat_34.c 15 | CSRCS += lv_font_montserrat_36.c 16 | CSRCS += lv_font_montserrat_38.c 17 | CSRCS += lv_font_montserrat_40.c 18 | CSRCS += lv_font_montserrat_42.c 19 | CSRCS += lv_font_montserrat_44.c 20 | CSRCS += lv_font_montserrat_46.c 21 | CSRCS += lv_font_montserrat_48.c 22 | CSRCS += lv_font_montserrat_12_subpx.c 23 | CSRCS += lv_font_montserrat_28_compressed.c 24 | CSRCS += lv_font_unscii_8.c 25 | CSRCS += lv_font_dejavu_16_persian_hebrew.c 26 | 27 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font 28 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font 29 | 30 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_font" 31 | -------------------------------------------------------------------------------- /src/lv_gpu/lv_gpu.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_gpu_stm32_dma2d.c 2 | 3 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu 4 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu 5 | 6 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_gpu" 7 | -------------------------------------------------------------------------------- /src/lv_gpu/lv_gpu_stm32_dma2d.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gpu_stm32_dma2d.h 3 | * 4 | */ 5 | 6 | #ifndef LV_GPU_STM32_DMA2D_H 7 | #define LV_GPU_STM32_DMA2D_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_misc/lv_area.h" 17 | #include "../lv_misc/lv_color.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | #define LV_DMA2D_ARGB8888 0 24 | #define LV_DMA2D_RGB888 1 25 | #define LV_DMA2D_RGB565 2 26 | #define LV_DMA2D_ARGB1555 3 27 | #define LV_DMA2D_ARGB4444 4 28 | 29 | /********************** 30 | * TYPEDEFS 31 | **********************/ 32 | 33 | /********************** 34 | * GLOBAL PROTOTYPES 35 | **********************/ 36 | 37 | /** 38 | * Turn on the peripheral and set output color mode, this only needs to be done once 39 | */ 40 | void lv_gpu_stm32_dma2d_init(void); 41 | 42 | /** 43 | * Fill an area in the buffer with a color 44 | * @param buf a buffer which should be filled 45 | * @param buf_w width of the buffer in pixels 46 | * @param color fill color 47 | * @param fill_w width to fill in pixels (<= buf_w) 48 | * @param fill_h height to fill in pixels 49 | * @note `buf_w - fill_w` is offset to the next line after fill 50 | */ 51 | void lv_gpu_stm32_dma2d_fill(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, lv_coord_t fill_w, 52 | lv_coord_t fill_h); 53 | 54 | 55 | /** 56 | * Fill an area in the buffer with a color but take into account a mask which describes the opacity of each pixel 57 | * @param buf a buffer which should be filled using a mask 58 | * @param buf_w width of the buffer in pixels 59 | * @param color fill color 60 | * @param mask 0..255 values describing the opacity of the corresponding pixel. It's width is `fill_w` 61 | * @param opa overall opacity. 255 in `mask` should mean this opacity. 62 | * @param fill_w width to fill in pixels (<= buf_w) 63 | * @param fill_h height to fill in pixels 64 | * @note `buf_w - fill_w` is offset to the next line after fill 65 | */ 66 | void lv_gpu_stm32_dma2d_fill_mask(lv_color_t * buf, lv_coord_t buf_w, lv_color_t color, const lv_opa_t * mask, 67 | lv_opa_t opa, lv_coord_t fill_w, lv_coord_t fill_h); 68 | 69 | /** 70 | * Copy a map (typically RGB image) to a buffer 71 | * @param buf a buffer where map should be copied 72 | * @param buf_w width of the buffer in pixels 73 | * @param map an "image" to copy 74 | * @param map_w width of the map in pixels 75 | * @param copy_w width of the area to copy in pixels (<= buf_w) 76 | * @param copy_h height of the area to copy in pixels 77 | * @note `map_w - fill_w` is offset to the next line after copy 78 | */ 79 | void lv_gpu_stm32_dma2d_copy(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_coord_t map_w, 80 | lv_coord_t copy_w, lv_coord_t copy_h); 81 | /** 82 | * Blend a map (e.g. ARGB image or RGB image with opacity) to a buffer 83 | * @param buf a buffer where `map` should be copied 84 | * @param buf_w width of the buffer in pixels 85 | * @param map an "image" to copy 86 | * @param opa opacity of `map` 87 | * @param map_w width of the map in pixels 88 | * @param copy_w width of the area to copy in pixels (<= buf_w) 89 | * @param copy_h height of the area to copy in pixels 90 | * @note `map_w - fill_w` is offset to the next line after copy 91 | */ 92 | void lv_gpu_stm32_dma2d_blend(lv_color_t * buf, lv_coord_t buf_w, const lv_color_t * map, lv_opa_t opa, 93 | lv_coord_t map_w, lv_coord_t copy_w, lv_coord_t copy_h); 94 | /********************** 95 | * MACROS 96 | **********************/ 97 | 98 | #ifdef __cplusplus 99 | } /* extern "C" */ 100 | #endif 101 | 102 | #endif /*LV_GPU_STM32_DMA2D_H*/ 103 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_DIR_NAME)/src/lv_hal 6 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal 7 | 8 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_hal" 9 | -------------------------------------------------------------------------------- /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_misc/lv_debug.h" 12 | #include "../lv_hal/lv_hal_indev.h" 13 | #include "../lv_core/lv_indev.h" 14 | #include "../lv_misc/lv_mem.h" 15 | #include "../lv_misc/lv_gc.h" 16 | #include "lv_hal_disp.h" 17 | 18 | #if defined(LV_GC_INCLUDE) 19 | #include LV_GC_INCLUDE 20 | #endif /* LV_ENABLE_GC */ 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC VARIABLES 36 | **********************/ 37 | 38 | /********************** 39 | * MACROS 40 | **********************/ 41 | 42 | /********************** 43 | * GLOBAL FUNCTIONS 44 | **********************/ 45 | 46 | /** 47 | * Initialize an input device driver with default values. 48 | * It is used to surly have known values in the fields ant not memory junk. 49 | * After it you can set the fields. 50 | * @param driver pointer to driver variable to initialize 51 | */ 52 | void lv_indev_drv_init(lv_indev_drv_t * driver) 53 | { 54 | _lv_memset_00(driver, sizeof(lv_indev_drv_t)); 55 | 56 | driver->type = LV_INDEV_TYPE_NONE; 57 | driver->drag_limit = LV_INDEV_DEF_DRAG_LIMIT; 58 | driver->drag_throw = LV_INDEV_DEF_DRAG_THROW; 59 | driver->long_press_time = LV_INDEV_DEF_LONG_PRESS_TIME; 60 | driver->long_press_rep_time = LV_INDEV_DEF_LONG_PRESS_REP_TIME; 61 | driver->gesture_limit = LV_INDEV_DEF_GESTURE_LIMIT; 62 | driver->gesture_min_velocity = LV_INDEV_DEF_GESTURE_MIN_VELOCITY; 63 | } 64 | 65 | /** 66 | * Register an initialized input device driver. 67 | * @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable) 68 | * @return pointer to the new input device or NULL on error 69 | */ 70 | lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) 71 | { 72 | 73 | if(driver->disp == NULL) driver->disp = lv_disp_get_default(); 74 | 75 | if(driver->disp == NULL) { 76 | LV_LOG_WARN("lv_indev_drv_register: no display registered hence can't attach the indev to " 77 | "a display"); 78 | return NULL; 79 | } 80 | 81 | lv_indev_t * indev = _lv_ll_ins_head(&LV_GC_ROOT(_lv_indev_ll)); 82 | if(!indev) { 83 | LV_ASSERT_MEM(indev); 84 | return NULL; 85 | } 86 | 87 | _lv_memset_00(indev, sizeof(lv_indev_t)); 88 | _lv_memcpy(&indev->driver, driver, sizeof(lv_indev_drv_t)); 89 | 90 | indev->proc.reset_query = 1; 91 | indev->cursor = NULL; 92 | indev->group = NULL; 93 | indev->btn_points = NULL; 94 | 95 | indev->driver.read_task = lv_task_create(_lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_HIGH, indev); 96 | 97 | return indev; 98 | } 99 | 100 | /** 101 | * Update the driver in run time. 102 | * @param indev pointer to a input device. (return value of `lv_indev_drv_register`) 103 | * @param new_drv pointer to the new driver 104 | */ 105 | void lv_indev_drv_update(lv_indev_t * indev, lv_indev_drv_t * new_drv) 106 | { 107 | memcpy(&indev->driver, new_drv, sizeof(lv_indev_drv_t)); 108 | } 109 | 110 | /** 111 | * Get the next input device. 112 | * @param indev pointer to the current input device. NULL to initialize. 113 | * @return the next input devise or NULL if no more. Give the first input device when the parameter 114 | * is NULL 115 | */ 116 | lv_indev_t * lv_indev_get_next(lv_indev_t * indev) 117 | { 118 | if(indev == NULL) 119 | return _lv_ll_get_head(&LV_GC_ROOT(_lv_indev_ll)); 120 | else 121 | return _lv_ll_get_next(&LV_GC_ROOT(_lv_indev_ll), indev); 122 | } 123 | 124 | /** 125 | * Read data from an input device. 126 | * @param indev pointer to an input device 127 | * @param data input device will write its data here 128 | * @return false: no more data; true: there more data to read (buffered) 129 | */ 130 | bool _lv_indev_read(lv_indev_t * indev, lv_indev_data_t * data) 131 | { 132 | bool cont = false; 133 | 134 | _lv_memset_00(data, sizeof(lv_indev_data_t)); 135 | 136 | /* For touchpad sometimes users don't the last pressed coordinate on release. 137 | * So be sure a coordinates are initialized to the last point */ 138 | if(indev->driver.type == LV_INDEV_TYPE_POINTER) { 139 | data->point.x = indev->proc.types.pointer.act_point.x; 140 | data->point.y = indev->proc.types.pointer.act_point.y; 141 | } 142 | /*Similarly set at least the last key in case of the the user doesn't set it on release*/ 143 | else if(indev->driver.type == LV_INDEV_TYPE_KEYPAD) { 144 | data->key = indev->proc.types.keypad.last_key; 145 | } 146 | /*For compatibility assume that used button was enter (encoder push) */ 147 | else if(indev->driver.type == LV_INDEV_TYPE_ENCODER) { 148 | data->key = LV_KEY_ENTER; 149 | data->enc_diff = 0; 150 | } 151 | 152 | if(indev->driver.read_cb) { 153 | LV_LOG_TRACE("idnev read started"); 154 | cont = indev->driver.read_cb(&indev->driver, data); 155 | LV_LOG_TRACE("idnev read finished"); 156 | } 157 | else { 158 | LV_LOG_WARN("indev function registered"); 159 | } 160 | 161 | return cont; 162 | } 163 | 164 | /********************** 165 | * STATIC FUNCTIONS 166 | **********************/ 167 | -------------------------------------------------------------------------------- /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 | #include "lv_hal_tick.h" 10 | #include 11 | 12 | #if LV_TICK_CUSTOM == 1 13 | #include LV_TICK_CUSTOM_INCLUDE 14 | #endif 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | 20 | /********************** 21 | * TYPEDEFS 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC PROTOTYPES 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | static uint32_t sys_time = 0; 32 | static volatile uint8_t tick_irq_flag; 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | /********************** 39 | * GLOBAL FUNCTIONS 40 | **********************/ 41 | 42 | /** 43 | * You have to call this function periodically 44 | * @param tick_period the call period of this function in milliseconds 45 | */ 46 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period) 47 | { 48 | tick_irq_flag = 0; 49 | sys_time += tick_period; 50 | } 51 | 52 | /** 53 | * Get the elapsed milliseconds since start up 54 | * @return the elapsed milliseconds 55 | */ 56 | uint32_t lv_tick_get(void) 57 | { 58 | #if LV_TICK_CUSTOM == 0 59 | 60 | /* If `lv_tick_inc` is called from an interrupt while `sys_time` is read 61 | * the result might be corrupted. 62 | * This loop detects if `lv_tick_inc` was called while reading `sys_time`. 63 | * If `tick_irq_flag` was cleared in `lv_tick_inc` try to read again 64 | * until `tick_irq_flag` remains `1`. */ 65 | uint32_t result; 66 | do { 67 | tick_irq_flag = 1; 68 | result = sys_time; 69 | } while(!tick_irq_flag); /*Continue until see a non interrupted cycle */ 70 | 71 | return result; 72 | #else 73 | return LV_TICK_CUSTOM_SYS_TIME_EXPR; 74 | #endif 75 | } 76 | 77 | /** 78 | * Get the elapsed milliseconds since a previous time stamp 79 | * @param prev_tick a previous time stamp (return value of systick_get() ) 80 | * @return the elapsed milliseconds since 'prev_tick' 81 | */ 82 | uint32_t lv_tick_elaps(uint32_t prev_tick) 83 | { 84 | uint32_t act_time = lv_tick_get(); 85 | 86 | /*If there is no overflow in sys_time simple subtract*/ 87 | if(act_time >= prev_tick) { 88 | prev_tick = act_time - prev_tick; 89 | } 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/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 | #include "../lv_conf_internal.h" 17 | 18 | #include 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | #ifndef LV_ATTRIBUTE_TICK_INC 25 | #define LV_ATTRIBUTE_TICK_INC 26 | #endif 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | //! @cond Doxygen_Suppress 37 | 38 | /** 39 | * You have to call this function periodically 40 | * @param tick_period the call period of this function in milliseconds 41 | */ 42 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); 43 | 44 | //! @endcond 45 | 46 | /** 47 | * Get the elapsed milliseconds since start up 48 | * @return the elapsed milliseconds 49 | */ 50 | uint32_t lv_tick_get(void); 51 | 52 | /** 53 | * Get the elapsed milliseconds since a previous time stamp 54 | * @param prev_tick a previous time stamp (return value of systick_get() ) 55 | * @return the elapsed milliseconds since 'prev_tick' 56 | */ 57 | uint32_t lv_tick_elaps(uint32_t prev_tick); 58 | 59 | /********************** 60 | * MACROS 61 | **********************/ 62 | 63 | #ifdef __cplusplus 64 | } /* extern "C" */ 65 | #endif 66 | 67 | #endif /*LV_HAL_TICK_H*/ 68 | -------------------------------------------------------------------------------- /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_set_repeat_count(task, 1); 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/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 | * TYPEDEFS 26 | **********************/ 27 | 28 | /** 29 | * Type for async callback. 30 | */ 31 | typedef void (*lv_async_cb_t)(void *); 32 | 33 | typedef struct _lv_async_info_t { 34 | lv_async_cb_t cb; 35 | void * user_data; 36 | } lv_async_info_t; 37 | 38 | struct _lv_obj_t; 39 | 40 | /********************** 41 | * GLOBAL PROTOTYPES 42 | **********************/ 43 | 44 | /** 45 | * Call an asynchronous function the next time lv_task_handler() is run. This function is likely to return 46 | * **before** the call actually happens! 47 | * @param async_xcb a callback which is the task itself. 48 | * (the 'x' in the argument name indicates that its not a fully generic function because it not follows 49 | * the `func_name(object, callback, ...)` convention) 50 | * @param user_data custom parameter 51 | */ 52 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data); 53 | 54 | /********************** 55 | * MACROS 56 | **********************/ 57 | 58 | #ifdef __cplusplus 59 | } /* extern "C" */ 60 | #endif 61 | 62 | #endif /*LV_TEMPL_H*/ 63 | -------------------------------------------------------------------------------- /src/lv_misc/lv_bidi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_bifi.h 3 | * 4 | */ 5 | 6 | #ifndef LV_BIDI_H 7 | #define LV_BIDI_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #include 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | /* Special non printable strong characters. 25 | * They can be inserted to texts to affect the run's direction*/ 26 | #define LV_BIDI_LRO "\xE2\x80\xAD" /*U+202D*/ 27 | #define LV_BIDI_RLO "\xE2\x80\xAE" /*U+202E*/ 28 | 29 | /********************** 30 | * TYPEDEFS 31 | **********************/ 32 | enum { 33 | /*The first 4 values are stored in `lv_obj_t` on 2 bits*/ 34 | LV_BIDI_DIR_LTR = 0x00, 35 | LV_BIDI_DIR_RTL = 0x01, 36 | LV_BIDI_DIR_AUTO = 0x02, 37 | LV_BIDI_DIR_INHERIT = 0x03, 38 | 39 | LV_BIDI_DIR_NEUTRAL = 0x20, 40 | LV_BIDI_DIR_WEAK = 0x21, 41 | }; 42 | 43 | typedef uint8_t lv_bidi_dir_t; 44 | 45 | /********************** 46 | * GLOBAL PROTOTYPES 47 | **********************/ 48 | #if LV_USE_BIDI 49 | 50 | /** 51 | * Convert a text to get the characters in the correct visual order according to 52 | * Unicode Bidirectional Algorithm 53 | * @param str_in the text to process 54 | * @param str_out store the result here. Has the be `strlen(str_in)` length 55 | * @param base_dir `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 56 | */ 57 | void _lv_bidi_process(const char * str_in, char * str_out, lv_bidi_dir_t base_dir); 58 | 59 | /** 60 | * Auto-detect the direction of a text based on the first strong character 61 | * @param txt the text to process 62 | * @return `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 63 | */ 64 | lv_bidi_dir_t _lv_bidi_detect_base_dir(const char * txt); 65 | 66 | /** 67 | * Get the logical position of a character in a line 68 | * @param str_in the input string. Can be only one line. 69 | * @param bidi_txt internally the text is bidi processed which buffer can be get here. 70 | * If not required anymore has to freed with `lv_mem_free()` 71 | * Can be `NULL` is unused 72 | * @param len length of the line in character count 73 | * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 74 | * @param visual_pos the visual character position which logical position should be get 75 | * @param is_rtl tell the the char at `visual_pos` is RTL or LTR context 76 | * @return the logical character position 77 | */ 78 | uint16_t _lv_bidi_get_logical_pos(const char * str_in, char ** bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, 79 | uint32_t visual_pos, bool * is_rtl); 80 | 81 | /** 82 | * Get the visual position of a character in a line 83 | * @param str_in the input string. Can be only one line. 84 | * @param bidi_txt internally the text is bidi processed which buffer can be get here. 85 | * If not required anymore has to freed with `lv_mem_free()` 86 | * Can be `NULL` is unused 87 | * @param len length of the line in character count 88 | * @param base_dir base direction of the text: `LV_BIDI_DIR_LTR` or `LV_BIDI_DIR_RTL` 89 | * @param logical_pos the logical character position which visual position should be get 90 | * @param is_rtl tell the the char at `logical_pos` is RTL or LTR context 91 | * @return the visual character position 92 | */ 93 | uint16_t _lv_bidi_get_visual_pos(const char * str_in, char ** bidi_txt, uint16_t len, lv_bidi_dir_t base_dir, 94 | uint32_t logical_pos, bool * is_rtl); 95 | 96 | /** 97 | * Bidi process a paragraph of text 98 | * @param str_in the string to process 99 | * @param str_out store the result here 100 | * @param len length of the text 101 | * @param base_dir base dir of the text 102 | * @param pos_conv_out an `uint16_t` array to store the related logical position of the character. 103 | * Can be `NULL` is unused 104 | * @param pos_conv_len length of `pos_conv_out` in element count 105 | */ 106 | void _lv_bidi_process_paragraph(const char * str_in, char * str_out, uint32_t len, lv_bidi_dir_t base_dir, 107 | uint16_t * pos_conv_out, uint16_t pos_conv_len); 108 | 109 | /********************** 110 | * MACROS 111 | **********************/ 112 | 113 | #endif /*LV_USE_BIDI*/ 114 | 115 | #ifdef __cplusplus 116 | } /* extern "C" */ 117 | #endif 118 | 119 | #endif /*LV_BIDI_H*/ 120 | -------------------------------------------------------------------------------- /src/lv_misc/lv_debug.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_debug.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "lv_debug.h" 10 | 11 | #if LV_USE_DEBUG 12 | 13 | #include "lv_mem.h" 14 | #include 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | #ifndef LV_DEBUG_STR_MAX_LENGTH 20 | #define LV_DEBUG_STR_MAX_LENGTH (1024 * 8) 21 | #endif 22 | 23 | #ifndef LV_DEBUG_STR_MAX_REPEAT 24 | #define LV_DEBUG_STR_MAX_REPEAT 8 25 | #endif 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * STATIC PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC VARIABLES 36 | **********************/ 37 | 38 | /********************** 39 | * MACROS 40 | **********************/ 41 | 42 | /********************** 43 | * GLOBAL FUNCTIONS 44 | **********************/ 45 | 46 | bool lv_debug_check_null(const void * p) 47 | { 48 | if(p) return true; 49 | 50 | return false; 51 | } 52 | 53 | bool lv_debug_check_mem_integrity(void) 54 | { 55 | return lv_mem_test() == LV_RES_OK ? true : false; 56 | } 57 | 58 | bool lv_debug_check_str(const void * str) 59 | { 60 | const uint8_t * s = (const uint8_t *)str; 61 | uint8_t last_byte = 0; 62 | uint32_t rep = 0; 63 | uint32_t i; 64 | 65 | for(i = 0; i < LV_DEBUG_STR_MAX_LENGTH && s[i] != '\0'; i++) { 66 | if(s[i] != last_byte) { 67 | last_byte = s[i]; 68 | rep = 1; 69 | } 70 | else if(s[i] > 0x7F) { 71 | rep++; 72 | if(rep > LV_DEBUG_STR_MAX_REPEAT) { 73 | LV_LOG_WARN("lv_debug_check_str: a non-ASCII char has repeated more than LV_DEBUG_STR_MAX_REPEAT times)"); 74 | return false; 75 | } 76 | } 77 | 78 | if(s[i] < 10) { 79 | LV_LOG_WARN("lv_debug_check_str: invalid char in the string (< 10 value)"); 80 | return false; /*Shouldn't occur in strings*/ 81 | } 82 | } 83 | 84 | if(s[i] == '\0') return true; 85 | 86 | LV_LOG_WARN("lv_debug_check_str: string is longer than LV_DEBUG_STR_MAX_LENGTH"); 87 | return false; 88 | } 89 | 90 | void lv_debug_log_error(const char * msg, uint64_t value) 91 | { 92 | static const char hex[] = "0123456789ABCDEF"; 93 | 94 | size_t msg_len = strlen(msg); 95 | uint32_t value_len = sizeof(unsigned long int); 96 | 97 | if(msg_len < 230) { 98 | char buf[255]; 99 | char * bufp = buf; 100 | 101 | /*Add the function name*/ 102 | _lv_memcpy(bufp, msg, msg_len); 103 | bufp += msg_len; 104 | 105 | /*Add value in hey*/ 106 | *bufp = ' '; 107 | bufp ++; 108 | *bufp = '('; 109 | bufp ++; 110 | *bufp = '0'; 111 | bufp ++; 112 | *bufp = 'x'; 113 | bufp ++; 114 | 115 | int8_t i; 116 | for(i = value_len * 2 - 1; i >= 0; i--) { 117 | uint8_t x = (unsigned long int)((unsigned long int)value >> (i * 4)) & 0xF; 118 | 119 | *bufp = hex[x]; 120 | bufp++; 121 | } 122 | 123 | *bufp = ')'; 124 | bufp ++; 125 | 126 | *bufp = '\0'; 127 | LV_LOG_ERROR(buf); 128 | } 129 | else { 130 | LV_LOG_ERROR(msg); 131 | } 132 | } 133 | 134 | /********************** 135 | * STATIC FUNCTIONS 136 | **********************/ 137 | 138 | 139 | #endif /*LV_USE_DEBUG*/ 140 | 141 | -------------------------------------------------------------------------------- /src/lv_misc/lv_debug.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_debug.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DEBUG_H 7 | #define LV_DEBUG_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_DEBUG 19 | #include 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | bool lv_debug_check_null(const void * p); 33 | 34 | bool lv_debug_check_mem_integrity(void); 35 | 36 | bool lv_debug_check_str(const void * str); 37 | 38 | void lv_debug_log_error(const char * msg, uint64_t value); 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | #ifndef LV_DEBUG_ASSERT 45 | #define LV_DEBUG_ASSERT(expr, msg, value) \ 46 | do { \ 47 | if(!(expr)) { \ 48 | LV_LOG_ERROR(__func__); \ 49 | lv_debug_log_error(msg, (uint64_t)((uintptr_t)value)); \ 50 | while(1); \ 51 | } \ 52 | } while(0) 53 | #endif 54 | 55 | /*---------------- 56 | * CHECKS 57 | *----------------*/ 58 | 59 | #ifndef LV_DEBUG_IS_NULL 60 | #define LV_DEBUG_IS_NULL(p) (lv_debug_check_null(p)) 61 | #endif 62 | 63 | 64 | #ifndef LV_DEBUG_CHECK_MEM_INTEGRITY 65 | #define LV_DEBUG_CHECK_MEM_INTEGRITY() (lv_debug_check_mem_integrity()) 66 | #endif 67 | 68 | #ifndef LV_DEBUG_IS_STR 69 | #define LV_DEBUG_IS_STR(str) (lv_debug_check_null(str) && \ 70 | lv_debug_check_str(str)) 71 | #endif 72 | 73 | /*----------------- 74 | * ASSERTS 75 | *-----------------*/ 76 | 77 | /*clang-format off*/ 78 | 79 | #if LV_USE_ASSERT_NULL 80 | # ifndef LV_ASSERT_NULL 81 | # define LV_ASSERT_NULL(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "NULL pointer", p); 82 | # endif 83 | #else 84 | # define LV_ASSERT_NULL(p) true 85 | #endif 86 | 87 | #if LV_USE_ASSERT_MEM 88 | # ifndef LV_ASSERT_MEM 89 | # define LV_ASSERT_MEM(p) LV_DEBUG_ASSERT(LV_DEBUG_IS_NULL(p), "Out of memory", p); 90 | # endif 91 | #else 92 | # define LV_ASSERT_MEM(p) true 93 | #endif 94 | 95 | #if LV_USE_ASSERT_MEM_INTEGRITY 96 | # ifndef LV_ASSERT_MEM_INTEGRITY 97 | # define LV_ASSERT_MEM_INTEGRITY() LV_DEBUG_ASSERT(LV_DEBUG_CHECK_MEM_INTEGRITY(), "Memory integrity error", 0); 98 | # endif 99 | #else 100 | # define LV_ASSERT_MEM_INTEGRITY() true 101 | #endif 102 | 103 | #if LV_USE_ASSERT_STR 104 | # ifndef LV_ASSERT_STR 105 | # define LV_ASSERT_STR(str) LV_DEBUG_ASSERT(LV_DEBUG_IS_STR(str), "Strange or invalid string", str); 106 | # endif 107 | #else /* LV_USE_ASSERT_OBJ == 0 */ 108 | # if LV_USE_ASSERT_NULL /*Use at least LV_ASSERT_NULL if enabled*/ 109 | # define LV_ASSERT_STR(str) LV_ASSERT_NULL(str) 110 | # else 111 | # define LV_ASSERT_STR(str) true 112 | # endif 113 | #endif 114 | 115 | 116 | #else /* LV_USE_DEBUG == 0 */ 117 | 118 | #define LV_DEBUG_ASSERT(expr, msg, value) do{}while(0) 119 | 120 | #define LV_ASSERT_NULL(p) true 121 | #define LV_ASSERT_MEM(p) true 122 | #define LV_ASSERT_MEM_INTEGRITY() true 123 | #define LV_ASSERT_STR(p) true 124 | #define LV_ASSERT_OBJ(obj, obj_type) true 125 | 126 | #endif /* LV_USE_DEBUG */ 127 | /*clang-format on*/ 128 | 129 | #ifdef __cplusplus 130 | } /* extern "C" */ 131 | #endif 132 | 133 | #endif /*LV_DEBUG_H*/ 134 | -------------------------------------------------------------------------------- /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 | #include "string.h" 12 | 13 | #if defined(LV_GC_INCLUDE) 14 | #include LV_GC_INCLUDE 15 | #endif /* LV_ENABLE_GC */ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * STATIC PROTOTYPES 27 | **********************/ 28 | 29 | /********************** 30 | * STATIC VARIABLES 31 | **********************/ 32 | 33 | #if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 34 | LV_ROOTS 35 | #endif /* LV_ENABLE_GC */ 36 | 37 | /********************** 38 | * MACROS 39 | **********************/ 40 | 41 | /********************** 42 | * GLOBAL FUNCTIONS 43 | **********************/ 44 | 45 | void _lv_gc_clear_roots(void) 46 | { 47 | #define LV_CLEAR_ROOT(root_type, root_name) _lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name))); 48 | LV_ITERATE_ROOTS(LV_CLEAR_ROOT) 49 | } 50 | 51 | /********************** 52 | * STATIC FUNCTIONS 53 | **********************/ 54 | -------------------------------------------------------------------------------- /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 | #include 17 | #include 18 | #include "lv_mem.h" 19 | #include "lv_ll.h" 20 | #include "lv_task.h" 21 | #include "../lv_draw/lv_img_cache.h" 22 | #include "../lv_draw/lv_draw_mask.h" 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | #define LV_ITERATE_ROOTS(f) \ 29 | f(lv_ll_t, _lv_task_ll) /*Linked list to store the lv_tasks*/ \ 30 | f(lv_ll_t, _lv_disp_ll) /*Linked list of screens*/ \ 31 | f(lv_ll_t, _lv_indev_ll) /*Linked list of screens*/ \ 32 | f(lv_ll_t, _lv_drv_ll) \ 33 | f(lv_ll_t, _lv_file_ll) \ 34 | f(lv_ll_t, _lv_anim_ll) \ 35 | f(lv_ll_t, _lv_group_ll) \ 36 | f(lv_ll_t, _lv_img_defoder_ll) \ 37 | f(lv_ll_t, _lv_obj_style_trans_ll) \ 38 | f(lv_img_cache_entry_t*, _lv_img_cache_array) \ 39 | f(lv_task_t*, _lv_task_act) \ 40 | f(lv_mem_buf_arr_t , _lv_mem_buf) \ 41 | f(_lv_draw_mask_saved_arr_t , _lv_draw_mask_list) \ 42 | f(void * , _lv_theme_material_styles) \ 43 | f(void * , _lv_theme_template_styles) \ 44 | f(void * , _lv_theme_mono_styles) \ 45 | f(void * , _lv_theme_empty_styles) \ 46 | 47 | #define LV_DEFINE_ROOT(root_type, root_name) root_type root_name; 48 | #define LV_ROOTS LV_ITERATE_ROOTS(LV_DEFINE_ROOT) 49 | 50 | #if LV_ENABLE_GC == 1 51 | #if LV_MEM_CUSTOM != 1 52 | #error "GC requires CUSTOM_MEM" 53 | #endif /* LV_MEM_CUSTOM */ 54 | #else /* LV_ENABLE_GC */ 55 | #define LV_GC_ROOT(x) x 56 | #define LV_EXTERN_ROOT(root_type, root_name) extern root_type root_name; 57 | LV_ITERATE_ROOTS(LV_EXTERN_ROOT) 58 | #endif /* LV_ENABLE_GC */ 59 | 60 | /********************** 61 | * TYPEDEFS 62 | **********************/ 63 | 64 | /********************** 65 | * GLOBAL PROTOTYPES 66 | **********************/ 67 | 68 | void _lv_gc_clear_roots(void); 69 | 70 | /********************** 71 | * MACROS 72 | **********************/ 73 | 74 | #ifdef __cplusplus 75 | } /* extern "C" */ 76 | #endif 77 | 78 | #endif /*LV_GC_H*/ 79 | -------------------------------------------------------------------------------- /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 | uint32_t n_size; 35 | lv_ll_node_t * head; 36 | lv_ll_node_t * tail; 37 | } lv_ll_t; 38 | 39 | /********************** 40 | * GLOBAL PROTOTYPES 41 | **********************/ 42 | 43 | /** 44 | * Initialize linked list 45 | * @param ll_dsc pointer to ll_dsc variable 46 | * @param node_size the size of 1 node in bytes 47 | */ 48 | void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size); 49 | 50 | /** 51 | * Add a new head to a linked list 52 | * @param ll_p pointer to linked list 53 | * @return pointer to the new head 54 | */ 55 | void * _lv_ll_ins_head(lv_ll_t * ll_p); 56 | 57 | /** 58 | * Insert a new node in front of the n_act node 59 | * @param ll_p pointer to linked list 60 | * @param n_act pointer a node 61 | * @return pointer to the new head 62 | */ 63 | void * _lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act); 64 | 65 | /** 66 | * Add a new tail to a linked list 67 | * @param ll_p pointer to linked list 68 | * @return pointer to the new tail 69 | */ 70 | void * _lv_ll_ins_tail(lv_ll_t * ll_p); 71 | 72 | /** 73 | * Remove the node 'node_p' from 'll_p' linked list. 74 | * It does not free the the memory of node. 75 | * @param ll_p pointer to the linked list of 'node_p' 76 | * @param node_p pointer to node in 'll_p' linked list 77 | */ 78 | void _lv_ll_remove(lv_ll_t * ll_p, void * node_p); 79 | 80 | /** 81 | * Remove and free all elements from a linked list. The list remain valid but become empty. 82 | * @param ll_p pointer to linked list 83 | */ 84 | void _lv_ll_clear(lv_ll_t * ll_p); 85 | 86 | /** 87 | * Move a node to a new linked list 88 | * @param ll_ori_p pointer to the original (old) linked list 89 | * @param ll_new_p pointer to the new linked list 90 | * @param node pointer to a node 91 | * @param head true: be the head in the new list 92 | * false be the head in the new list 93 | */ 94 | void _lv_ll_chg_list(lv_ll_t * ll_ori_p, lv_ll_t * ll_new_p, void * node, bool head); 95 | 96 | /** 97 | * Return with head node of the linked list 98 | * @param ll_p pointer to linked list 99 | * @return pointer to the head of 'll_p' 100 | */ 101 | void * _lv_ll_get_head(const lv_ll_t * ll_p); 102 | 103 | /** 104 | * Return with tail node of the linked list 105 | * @param ll_p pointer to linked list 106 | * @return pointer to the head of 'll_p' 107 | */ 108 | void * _lv_ll_get_tail(const lv_ll_t * ll_p); 109 | 110 | /** 111 | * Return with the pointer of the next node after 'n_act' 112 | * @param ll_p pointer to linked list 113 | * @param n_act pointer a node 114 | * @return pointer to the next node 115 | */ 116 | void * _lv_ll_get_next(const lv_ll_t * ll_p, const void * n_act); 117 | 118 | /** 119 | * Return with the pointer of the previous node after 'n_act' 120 | * @param ll_p pointer to linked list 121 | * @param n_act pointer a node 122 | * @return pointer to the previous node 123 | */ 124 | void * _lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act); 125 | 126 | /** 127 | * Return the length of the linked list. 128 | * @param ll_p pointer to linked list 129 | * @return length of the linked list 130 | */ 131 | uint32_t _lv_ll_get_len(const lv_ll_t * ll_p); 132 | 133 | /** 134 | * TODO 135 | * @param ll_p 136 | * @param n1_p 137 | * @param n2_p 138 | void lv_ll_swap(lv_ll_t * ll_p, void * n1_p, void * n2_p); 139 | */ 140 | 141 | /** 142 | * Move a node before an other node in the same linked list 143 | * @param ll_p pointer to a linked list 144 | * @param n_act pointer to node to move 145 | * @param n_after pointer to a node which should be after `n_act` 146 | */ 147 | void _lv_ll_move_before(lv_ll_t * ll_p, void * n_act, void * n_after); 148 | 149 | /** 150 | * Check if a linked list is empty 151 | * @param ll_p pointer to a linked list 152 | * @return true: the linked list is empty; false: not empty 153 | */ 154 | bool _lv_ll_is_empty(lv_ll_t * ll_p); 155 | 156 | /********************** 157 | * MACROS 158 | **********************/ 159 | 160 | #define _LV_LL_READ(list, i) for(i = _lv_ll_get_head(&list); i != NULL; i = _lv_ll_get_next(&list, i)) 161 | 162 | #define _LV_LL_READ_BACK(list, i) for(i = _lv_ll_get_tail(&list); i != NULL; i = _lv_ll_get_prev(&list, i)) 163 | 164 | #ifdef __cplusplus 165 | } /* extern "C" */ 166 | #endif 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /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 | #include 13 | #include 14 | #include "lv_printf.h" 15 | 16 | #if LV_LOG_PRINTF 17 | #include 18 | #endif 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC PROTOTYPES 30 | **********************/ 31 | 32 | /********************** 33 | * STATIC VARIABLES 34 | **********************/ 35 | static lv_log_print_g_cb_t custom_print_cb; 36 | 37 | /********************** 38 | * MACROS 39 | **********************/ 40 | 41 | /********************** 42 | * GLOBAL FUNCTIONS 43 | **********************/ 44 | 45 | /** 46 | * Register custom print/write function to call when a log is added. 47 | * It can format its "File path", "Line number" and "Description" as required 48 | * and send the formatted log message to a console or serial port. 49 | * @param print_cb a function pointer to print a log 50 | */ 51 | void lv_log_register_print_cb(lv_log_print_g_cb_t print_cb) 52 | { 53 | custom_print_cb = print_cb; 54 | } 55 | 56 | 57 | /** 58 | * Add a log 59 | * @param level the level of log. (From `lv_log_level_t` enum) 60 | * @param file name of the file when the log added 61 | * @param line line number in the source code where the log added 62 | * @param func name of the function when the log added 63 | * @param format printf-like format string 64 | * @param ... parameters for `format` 65 | */ 66 | void _lv_log_add(lv_log_level_t level, const char * file, int line, const char * func, const char * format, ...) 67 | { 68 | if(level >= _LV_LOG_LEVEL_NUM) return; /*Invalid level*/ 69 | 70 | if(level >= LV_LOG_LEVEL) { 71 | va_list args; 72 | va_start(args, format); 73 | char buf[256]; 74 | lv_vsnprintf(buf, sizeof(buf), format, args); 75 | va_end(args); 76 | 77 | #if LV_LOG_PRINTF 78 | /*Use only the file name not the path*/ 79 | size_t p; 80 | for(p = strlen(file); p > 0; p--) { 81 | if(file[p] == '/' || file[p] == '\\') { 82 | p++; /*Skip the slash*/ 83 | break; 84 | } 85 | } 86 | 87 | static const char * lvl_prefix[] = {"Trace", "Info", "Warn", "Error", "User"}; 88 | printf("%s: %s \t(%s #%d %s())\n", lvl_prefix[level], buf, &file[p], line, func); 89 | #else 90 | if(custom_print_cb) custom_print_cb(level, file, line, func, buf); 91 | #endif 92 | } 93 | } 94 | 95 | /********************** 96 | * STATIC FUNCTIONS 97 | **********************/ 98 | 99 | #endif /*LV_USE_LOG*/ 100 | -------------------------------------------------------------------------------- /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 "../lv_conf_internal.h" 17 | #include 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | #define LV_MATH_MIN(a, b) ((a) < (b) ? (a) : (b)) 23 | #define LV_MATH_MIN3(a, b, c) (LV_MATH_MIN(LV_MATH_MIN(a,b), c)) 24 | #define LV_MATH_MIN4(a, b, c, d) (LV_MATH_MIN(LV_MATH_MIN(a,b), LV_MATH_MIN(c,d))) 25 | 26 | #define LV_MATH_MAX(a, b) ((a) > (b) ? (a) : (b)) 27 | #define LV_MATH_MAX3(a, b, c) (LV_MATH_MAX(LV_MATH_MAX(a,b), c)) 28 | #define LV_MATH_MAX4(a, b, c, d) (LV_MATH_MAX(LV_MATH_MAX(a,b), LV_MATH_MAX(c,d))) 29 | 30 | #define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x))) 31 | 32 | #define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17) 33 | 34 | #define LV_IS_SIGNED(t) (((t)(-1)) < ((t) 0)) 35 | #define LV_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL))) 36 | #define LV_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL))) 37 | #define LV_MAX_OF(t) ((unsigned long) (LV_IS_SIGNED(t) ? LV_SMAX_OF(t) : LV_UMAX_OF(t))) 38 | 39 | #define LV_TRIGO_SIN_MAX 32767 40 | #define LV_TRIGO_SHIFT 15 /**< >> LV_TRIGO_SHIFT to normalize*/ 41 | 42 | #define LV_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers) */ 43 | #define LV_BEZIER_VAL_SHIFT 10 /**< log2(LV_BEZIER_VAL_MAX): used to normalize up scaled values*/ 44 | 45 | 46 | 47 | /********************** 48 | * TYPEDEFS 49 | **********************/ 50 | 51 | typedef struct { 52 | uint16_t i; 53 | uint16_t f; 54 | } lv_sqrt_res_t; 55 | 56 | 57 | /********************** 58 | * GLOBAL PROTOTYPES 59 | **********************/ 60 | 61 | //! @cond Doxygen_Suppress 62 | /** 63 | * Return with sinus of an angle 64 | * @param angle 65 | * @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767 66 | */ 67 | LV_ATTRIBUTE_FAST_MEM int16_t _lv_trigo_sin(int16_t angle); 68 | 69 | //! @endcond 70 | 71 | /** 72 | * Calculate a value of a Cubic Bezier function. 73 | * @param t time in range of [0..LV_BEZIER_VAL_MAX] 74 | * @param u0 start values in range of [0..LV_BEZIER_VAL_MAX] 75 | * @param u1 control value 1 values in range of [0..LV_BEZIER_VAL_MAX] 76 | * @param u2 control value 2 in range of [0..LV_BEZIER_VAL_MAX] 77 | * @param u3 end values in range of [0..LV_BEZIER_VAL_MAX] 78 | * @return the value calculated from the given parameters in range of [0..LV_BEZIER_VAL_MAX] 79 | */ 80 | int32_t _lv_bezier3(uint32_t t, int32_t u0, int32_t u1, int32_t u2, int32_t u3); 81 | 82 | /** 83 | * Calculate the atan2 of a vector. 84 | * @param x 85 | * @param y 86 | * @return the angle in degree calculated from the given parameters in range of [0..360] 87 | */ 88 | uint16_t _lv_atan2(int x, int y); 89 | 90 | 91 | //! @cond Doxygen_Suppress 92 | 93 | /** 94 | * Get the square root of a number 95 | * @param x integer which square root should be calculated 96 | * @param q store the result here. q->i: integer part, q->f: fractional part in 1/256 unit 97 | * @param mask: optional to skip some iterations if the magnitude of the root is known. 98 | * Set to 0x8000 by default. 99 | * If root < 16: mask = 0x80 100 | * If root < 256: mask = 0x800 101 | * Else: mask = 0x8000 102 | */ 103 | LV_ATTRIBUTE_FAST_MEM void _lv_sqrt(uint32_t x, lv_sqrt_res_t * q, uint32_t mask); 104 | 105 | //! @endcond 106 | 107 | /** 108 | * Calculate the integer exponents. 109 | * @param base 110 | * @param power 111 | * @return base raised to the power exponent 112 | */ 113 | int64_t _lv_pow(int64_t base, int8_t exp); 114 | 115 | /********************** 116 | * MACROS 117 | **********************/ 118 | 119 | #ifdef __cplusplus 120 | } /* extern "C" */ 121 | #endif 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /src/lv_misc/lv_misc.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_area.c 2 | CSRCS += lv_task.c 3 | CSRCS += lv_fs.c 4 | CSRCS += lv_anim.c 5 | CSRCS += lv_mem.c 6 | CSRCS += lv_ll.c 7 | CSRCS += lv_color.c 8 | CSRCS += lv_txt.c 9 | CSRCS += lv_txt_ap.c 10 | CSRCS += lv_math.c 11 | CSRCS += lv_log.c 12 | CSRCS += lv_gc.c 13 | CSRCS += lv_utils.c 14 | CSRCS += lv_async.c 15 | CSRCS += lv_printf.c 16 | CSRCS += lv_bidi.c 17 | CSRCS += lv_debug.c 18 | 19 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc 20 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc 21 | 22 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_misc" 23 | -------------------------------------------------------------------------------- /src/lv_misc/lv_printf.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // \author (c) Marco Paland (info@paland.com) 3 | // 2014-2019, PALANDesign Hannover, Germany 4 | // 5 | // \license The MIT License (MIT) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on 26 | // embedded systems with a very limited resources. 27 | // Use this instead of bloated standard/newlib printf. 28 | // These routines are thread safe and reentrant. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _LV_PRINTF_H_ 33 | #define _LV_PRINTF_H_ 34 | 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #include "../lv_conf_internal.h" 41 | 42 | #if LV_SPRINTF_CUSTOM == 0 43 | 44 | #include 45 | #include 46 | 47 | /** 48 | * Tiny snprintf/vsnprintf implementation 49 | * \param buffer A pointer to the buffer where to store the formatted string 50 | * \param count The maximum number of characters to store in the buffer, including a terminating null character 51 | * \param format A string that specifies the format of the output 52 | * \param va A value identifying a variable arguments list 53 | * \return The number of characters that COULD have been written into the buffer, not counting the terminating 54 | * null character. A value equal or larger than count indicates truncation. Only when the returned value 55 | * is non-negative and less than count, the string has been completely written. 56 | */ 57 | int lv_snprintf(char * buffer, size_t count, const char * format, ...); 58 | int lv_vsnprintf(char * buffer, size_t count, const char * format, va_list va); 59 | 60 | #else 61 | #include LV_SPRINTF_INCLUDE 62 | #endif 63 | 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | 70 | #endif // _PRINTF_H_ 71 | -------------------------------------------------------------------------------- /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 | #include "../lv_conf_internal.h" 18 | 19 | #include 20 | #include 21 | #include "lv_mem.h" 22 | #include "lv_ll.h" 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | #ifndef LV_ATTRIBUTE_TASK_HANDLER 28 | #define LV_ATTRIBUTE_TASK_HANDLER 29 | #endif 30 | 31 | #define LV_NO_TASK_READY 0xFFFFFFFF 32 | /********************** 33 | * TYPEDEFS 34 | **********************/ 35 | 36 | struct _lv_task_t; 37 | 38 | /** 39 | * Tasks execute this type type of functions. 40 | */ 41 | typedef void (*lv_task_cb_t)(struct _lv_task_t *); 42 | 43 | /** 44 | * Possible priorities for lv_tasks 45 | */ 46 | enum { 47 | LV_TASK_PRIO_OFF = 0, 48 | LV_TASK_PRIO_LOWEST, 49 | LV_TASK_PRIO_LOW, 50 | LV_TASK_PRIO_MID, 51 | LV_TASK_PRIO_HIGH, 52 | LV_TASK_PRIO_HIGHEST, 53 | _LV_TASK_PRIO_NUM, 54 | }; 55 | typedef uint8_t lv_task_prio_t; 56 | 57 | /** 58 | * Descriptor of a lv_task 59 | */ 60 | typedef struct _lv_task_t { 61 | uint32_t period; /**< How often the task should run */ 62 | uint32_t last_run; /**< Last time the task ran */ 63 | lv_task_cb_t task_cb; /**< Task function */ 64 | 65 | void * user_data; /**< Custom user data */ 66 | 67 | int32_t repeat_count; /**< 1: Task times; -1 : infinity; 0 : stop ; n>0: residual times */ 68 | uint8_t prio : 3; /**< Task priority */ 69 | } lv_task_t; 70 | 71 | /********************** 72 | * GLOBAL PROTOTYPES 73 | **********************/ 74 | 75 | /** 76 | * Init the lv_task module 77 | */ 78 | void _lv_task_core_init(void); 79 | 80 | //! @cond Doxygen_Suppress 81 | 82 | /** 83 | * Call it periodically to handle lv_tasks. 84 | * @return time till it needs to be run next (in ms) 85 | */ 86 | LV_ATTRIBUTE_TASK_HANDLER uint32_t lv_task_handler(void); 87 | 88 | //! @endcond 89 | 90 | /** 91 | * Create an "empty" task. It needs to initialized with at least 92 | * `lv_task_set_cb` and `lv_task_set_period` 93 | * @return pointer to the created task 94 | */ 95 | lv_task_t * lv_task_create_basic(void); 96 | 97 | /** 98 | * Create a new lv_task 99 | * @param task_xcb a callback which is the task itself. It will be called periodically. 100 | * (the 'x' in the argument name indicates that its not a fully generic function because it not follows 101 | * the `func_name(object, callback, ...)` convention) 102 | * @param period call period in ms unit 103 | * @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) 104 | * @param user_data custom parameter 105 | * @return pointer to the new task 106 | */ 107 | lv_task_t * lv_task_create(lv_task_cb_t task_xcb, uint32_t period, lv_task_prio_t prio, void * user_data); 108 | 109 | /** 110 | * Delete a lv_task 111 | * @param task pointer to task_cb created by task 112 | */ 113 | void lv_task_del(lv_task_t * task); 114 | 115 | /** 116 | * Set the callback the task (the function to call periodically) 117 | * @param task pointer to a task 118 | * @param task_cb the function to call periodically 119 | */ 120 | void lv_task_set_cb(lv_task_t * task, lv_task_cb_t task_cb); 121 | 122 | /** 123 | * Set new priority for a lv_task 124 | * @param task pointer to a lv_task 125 | * @param prio the new priority 126 | */ 127 | void lv_task_set_prio(lv_task_t * task, lv_task_prio_t prio); 128 | 129 | /** 130 | * Set new period for a lv_task 131 | * @param task pointer to a lv_task 132 | * @param period the new period 133 | */ 134 | void lv_task_set_period(lv_task_t * task, uint32_t period); 135 | 136 | /** 137 | * Make a lv_task ready. It will not wait its period. 138 | * @param task pointer to a lv_task. 139 | */ 140 | void lv_task_ready(lv_task_t * task); 141 | 142 | /** 143 | * Set the number of times a task will repeat. 144 | * @param task pointer to a lv_task. 145 | * @param repeat_count -1 : infinity; 0 : stop ; n>0: residual times 146 | */ 147 | void lv_task_set_repeat_count(lv_task_t * task, int32_t repeat_count); 148 | 149 | /** 150 | * Reset a lv_task. 151 | * It will be called the previously set period milliseconds later. 152 | * @param task pointer to a lv_task. 153 | */ 154 | void lv_task_reset(lv_task_t * task); 155 | 156 | /** 157 | * Enable or disable the whole lv_task handling 158 | * @param en: true: lv_task handling is running, false: lv_task handling is suspended 159 | */ 160 | void lv_task_enable(bool en); 161 | 162 | /** 163 | * Get idle percentage 164 | * @return the lv_task idle in percentage 165 | */ 166 | uint8_t lv_task_get_idle(void); 167 | 168 | /********************** 169 | * MACROS 170 | **********************/ 171 | 172 | #ifdef __cplusplus 173 | } /* extern "C" */ 174 | #endif 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /src/lv_misc/lv_txt_ap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_txt_ap.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TXT_AP_H 7 | #define LV_TXT_AP_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include "lv_txt.h" 18 | #include "../lv_draw/lv_draw.h" 19 | 20 | #if LV_USE_ARABIC_PERSIAN_CHARS == 1 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | #define LV_UNDEF_ARABIC_PERSIAN_CHARS (UINT32_MAX) 27 | #define LV_AP_ALPHABET_BASE_CODE 0x0622 28 | #define LV_AP_END_CHARS_LIST {0,0,0,0,0,{0,0}} 29 | /********************** 30 | * TYPEDEFS 31 | **********************/ 32 | typedef struct { 33 | uint8_t char_offset; 34 | uint16_t char_end_form; 35 | int8_t char_begining_form_offset; 36 | int8_t char_middle_form_offset; 37 | int8_t char_isolated_form_offset; 38 | struct { 39 | uint8_t conj_to_previous; 40 | uint8_t conj_to_next; 41 | } ap_chars_conjunction; 42 | } ap_chars_map_t; 43 | 44 | /********************** 45 | * GLOBAL PROTOTYPES 46 | **********************/ 47 | uint32_t _lv_txt_ap_calc_bytes_cnt(const char * txt); 48 | void _lv_txt_ap_proc(const char * txt, char * txt_out); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif // LV_USE_ARABIC_PERSIAN_CHARS 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_TXT_AP_H*/ 61 | -------------------------------------------------------------------------------- /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 | #if __STDC_VERSION__ >= 199901L // If c99 or newer, use stdint.h to determine arch size 22 | #include 23 | #endif 24 | 25 | 26 | // If __UINTPTR_MAX__ or UINTPTR_MAX are available, use them to determine arch size 27 | #if defined(__UINTPTR_MAX__) && __UINTPTR_MAX__ > 0xFFFFFFFF 28 | #define LV_ARCH_64 29 | 30 | #elif defined(UINTPTR_MAX) && UINTPTR_MAX > 0xFFFFFFFF 31 | #define LV_ARCH_64 32 | 33 | // Otherwise use compiler-dependent means to determine arch size 34 | #elif defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined (__aarch64__) 35 | #define LV_ARCH_64 36 | 37 | #endif 38 | 39 | 40 | /********************** 41 | * TYPEDEFS 42 | **********************/ 43 | 44 | /** 45 | * LVGL error codes. 46 | */ 47 | enum { 48 | LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action 49 | function or an operation was failed*/ 50 | LV_RES_OK, /*The object is valid (no deleted) after the action*/ 51 | }; 52 | typedef uint8_t lv_res_t; 53 | 54 | 55 | 56 | #if __STDC_VERSION__ >= 199901L 57 | // If c99 or newer, use the definition of uintptr_t directly from 58 | typedef uintptr_t lv_uintptr_t; 59 | 60 | #else 61 | 62 | // Otherwise, use the arch size determination 63 | #ifdef LV_ARCH_64 64 | typedef uint64_t lv_uintptr_t; 65 | #else 66 | typedef uint32_t lv_uintptr_t; 67 | #endif 68 | 69 | #endif 70 | 71 | 72 | /********************** 73 | * GLOBAL PROTOTYPES 74 | **********************/ 75 | 76 | /********************** 77 | * MACROS 78 | **********************/ 79 | 80 | #define LV_UNUSED(x) ((void) x) 81 | 82 | #ifdef __cplusplus 83 | } /* extern "C" */ 84 | #endif 85 | 86 | #endif /*LV_TYPES_H*/ 87 | 88 | -------------------------------------------------------------------------------- /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 | #include "lv_printf.h" 14 | #include "lv_txt.h" 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | 20 | /********************** 21 | * TYPEDEFS 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC PROTOTYPES 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL FUNCTIONS 38 | **********************/ 39 | 40 | /** 41 | * Convert a number to string 42 | * @param num a number 43 | * @param buf pointer to a `char` buffer. The result will be stored here (max 10 elements) 44 | * @return same as `buf` (just for convenience) 45 | */ 46 | char * _lv_utils_num_to_str(int32_t num, char * buf) 47 | { 48 | if(num == 0) { 49 | buf[0] = '0'; 50 | buf[1] = '\0'; 51 | return buf; 52 | } 53 | int8_t digitCount = 0; 54 | int8_t i = 0; 55 | if(num < 0) { 56 | buf[digitCount++] = '-'; 57 | num = LV_MATH_ABS(num); 58 | ++i; 59 | } 60 | while(num) { 61 | char digit = num % 10; 62 | buf[digitCount++] = digit + 48; 63 | num /= 10; 64 | } 65 | buf[digitCount] = '\0'; 66 | digitCount--; 67 | while(digitCount > i) { 68 | char temp = buf[i]; 69 | buf[i] = buf[digitCount]; 70 | buf[digitCount] = temp; 71 | digitCount--; 72 | i++; 73 | } 74 | return buf; 75 | } 76 | 77 | /** Searches base[0] to base[n - 1] for an item that matches *key. 78 | * 79 | * @note The function cmp must return negative if its first 80 | * argument (the search key) is less that its second (a table entry), 81 | * zero if equal, and positive if greater. 82 | * 83 | * @note Items in the array must be in ascending order. 84 | * 85 | * @param key Pointer to item being searched for 86 | * @param base Pointer to first element to search 87 | * @param n Number of elements 88 | * @param size Size of each element 89 | * @param cmp Pointer to comparison function (see #lv_font_codeCompare as a comparison function 90 | * example) 91 | * 92 | * @return a pointer to a matching item, or NULL if none exists. 93 | */ 94 | void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size, 95 | int32_t (*cmp)(const void * pRef, const void * pElement)) 96 | { 97 | const char * middle; 98 | int32_t c; 99 | 100 | for(middle = base; n != 0;) { 101 | middle += (n / 2) * size; 102 | if((c = (*cmp)(key, middle)) > 0) { 103 | n = (n / 2) - ((n & 1) == 0); 104 | base = (middle += size); 105 | } 106 | else if(c < 0) { 107 | n /= 2; 108 | middle = base; 109 | } 110 | else { 111 | return (char *)middle; 112 | } 113 | } 114 | return NULL; 115 | } 116 | 117 | /********************** 118 | * STATIC FUNCTIONS 119 | **********************/ 120 | -------------------------------------------------------------------------------- /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/lv_themes/lv_theme_empty.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_empty.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include 10 | #include "../../lvgl.h" /*To see all the widgets*/ 11 | 12 | #if LV_USE_THEME_EMPTY 13 | 14 | #include "../lv_misc/lv_gc.h" 15 | 16 | #if defined(LV_GC_INCLUDE) 17 | #include LV_GC_INCLUDE 18 | #endif /* LV_ENABLE_GC */ 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | typedef struct { 28 | lv_style_t opa_cover; 29 | } theme_styles_t; 30 | 31 | /********************** 32 | * STATIC PROTOTYPES 33 | **********************/ 34 | static void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name); 35 | static void style_init_reset(lv_style_t * style); 36 | 37 | /********************** 38 | * STATIC VARIABLES 39 | **********************/ 40 | static lv_theme_t theme; 41 | static theme_styles_t * styles; 42 | 43 | static bool inited; 44 | 45 | /********************** 46 | * MACROS 47 | **********************/ 48 | 49 | /********************** 50 | * STATIC FUNCTIONS 51 | **********************/ 52 | 53 | /********************** 54 | * GLOBAL FUNCTIONS 55 | **********************/ 56 | 57 | /** 58 | * Initialize the default 59 | * @param color_primary the primary color of the theme 60 | * @param color_secondary the secondary color for the theme 61 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 62 | * @param font_small pointer to a small font 63 | * @param font_normal pointer to a normal font 64 | * @param font_subtitle pointer to a large font 65 | * @param font_title pointer to a extra large font 66 | * @return a pointer to reference this theme later 67 | */ 68 | lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 69 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 70 | const lv_font_t * font_title) 71 | { 72 | /* This trick is required only to avoid the garbage collection of 73 | * styles' data if LVGL is used in a binding (e.g. Micropython) 74 | * In a general case styles could be simple `static lv_style_t my style` variables*/ 75 | if(!inited) { 76 | LV_GC_ROOT(_lv_theme_empty_styles) = lv_mem_alloc(sizeof(theme_styles_t)); 77 | styles = (theme_styles_t *)LV_GC_ROOT(_lv_theme_empty_styles); 78 | } 79 | 80 | 81 | theme.color_primary = color_primary; 82 | theme.color_secondary = color_secondary; 83 | theme.font_small = font_small; 84 | theme.font_normal = font_normal; 85 | theme.font_subtitle = font_subtitle; 86 | theme.font_title = font_title; 87 | theme.flags = flags; 88 | 89 | style_init_reset(&styles->opa_cover); 90 | lv_style_set_bg_opa(&styles->opa_cover, LV_STATE_DEFAULT, LV_OPA_COVER); 91 | 92 | theme.apply_xcb = NULL; 93 | theme.apply_cb = theme_apply; 94 | return &theme; 95 | } 96 | 97 | 98 | void theme_apply(lv_theme_t * th, lv_obj_t * obj, lv_theme_style_t name) 99 | { 100 | LV_UNUSED(th); 101 | if(name == LV_THEME_SCR) { 102 | lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); 103 | lv_obj_add_style(obj, LV_OBJ_PART_MAIN, &styles->opa_cover); 104 | } 105 | } 106 | 107 | /********************** 108 | * STATIC FUNCTIONS 109 | **********************/ 110 | 111 | static void style_init_reset(lv_style_t * style) 112 | { 113 | if(inited) lv_style_reset(style); 114 | else lv_style_init(style); 115 | } 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/lv_themes/lv_theme_empty.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_material.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_EMPTY_H 7 | #define LV_THEME_EMPTY_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_EMPTY 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | 33 | /** 34 | * Initialize the default 35 | * @param color_primary the primary color of the theme 36 | * @param color_secondary the secondary color for the theme 37 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 38 | * @param font_small pointer to a small font 39 | * @param font_normal pointer to a normal font 40 | * @param font_subtitle pointer to a large font 41 | * @param font_title pointer to a extra large font 42 | * @return a pointer to reference this theme later 43 | */ 44 | lv_theme_t * lv_theme_empty_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 45 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 46 | const lv_font_t * font_title); 47 | /********************** 48 | * MACROS 49 | **********************/ 50 | 51 | #endif 52 | 53 | #ifdef __cplusplus 54 | } /* extern "C" */ 55 | #endif 56 | 57 | #endif /*LV_THEME_ALIEN_H*/ 58 | -------------------------------------------------------------------------------- /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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_MATERIAL 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | typedef enum { 24 | LV_THEME_MATERIAL_FLAG_DARK = 0x01, 25 | LV_THEME_MATERIAL_FLAG_LIGHT = 0x02, 26 | LV_THEME_MATERIAL_FLAG_NO_TRANSITION = 0x10, 27 | } lv_theme_material_flag_t; 28 | 29 | /********************** 30 | * TYPEDEFS 31 | **********************/ 32 | 33 | /********************** 34 | * GLOBAL PROTOTYPES 35 | **********************/ 36 | 37 | /** 38 | * Initialize the default 39 | * @param color_primary the primary color of the theme 40 | * @param color_secondary the secondary color for the theme 41 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 42 | * @param font_small pointer to a small font 43 | * @param font_normal pointer to a normal font 44 | * @param font_subtitle pointer to a large font 45 | * @param font_title pointer to a extra large font 46 | * @return a pointer to reference this theme later 47 | */ 48 | lv_theme_t * lv_theme_material_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 49 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 50 | const lv_font_t * font_title); 51 | /********************** 52 | * MACROS 53 | **********************/ 54 | 55 | #endif 56 | 57 | #ifdef __cplusplus 58 | } /* extern "C" */ 59 | #endif 60 | 61 | #endif /*LV_THEME_MATERIAL_H*/ 62 | -------------------------------------------------------------------------------- /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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_MONO 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | 33 | /** 34 | * Initialize the mono theme. 35 | * @param color_primary the primary color of the theme 36 | * @param color_secondary the secondary color for the theme 37 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 38 | * @param font_small pointer to a small font 39 | * @param font_normal pointer to a normal font 40 | * @param font_subtitle pointer to a large font 41 | * @param font_title pointer to a extra large font 42 | * @return a pointer to reference this theme later 43 | */ 44 | lv_theme_t * lv_theme_mono_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 45 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 46 | const lv_font_t * font_title); 47 | /********************** 48 | * MACROS 49 | **********************/ 50 | 51 | #endif 52 | 53 | #ifdef __cplusplus 54 | } /* extern "C" */ 55 | #endif 56 | 57 | #endif /*LV_THEME_TEMPLATE_H*/ 58 | -------------------------------------------------------------------------------- /src/lv_themes/lv_theme_template.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_template.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_TEMPLATE_H 7 | #define LV_THEME_TEMPLATE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_THEME_TEMPLATE 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | 33 | /** 34 | * Initialize the default 35 | * @param color_primary the primary color of the theme 36 | * @param color_secondary the secondary color for the theme 37 | * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` 38 | * @param font_small pointer to a small font 39 | * @param font_normal pointer to a normal font 40 | * @param font_subtitle pointer to a large font 41 | * @param font_title pointer to a extra large font 42 | * @return a pointer to reference this theme later 43 | */ 44 | lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_secondary, uint32_t flags, 45 | const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_subtitle, 46 | const lv_font_t * font_title); 47 | /********************** 48 | * MACROS 49 | **********************/ 50 | 51 | #endif 52 | 53 | #ifdef __cplusplus 54 | } /* extern "C" */ 55 | #endif 56 | 57 | #endif /*LV_THEME_TEMPLATE_H*/ 58 | -------------------------------------------------------------------------------- /src/lv_themes/lv_themes.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_theme.c 2 | CSRCS += lv_theme_material.c 3 | CSRCS += lv_theme_mono.c 4 | CSRCS += lv_theme_empty.c 5 | CSRCS += lv_theme_template.c 6 | 7 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes 8 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes 9 | 10 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_themes" 11 | -------------------------------------------------------------------------------- /src/lv_widgets/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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_ARC != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | /*Data of arc*/ 30 | typedef struct { 31 | /*New data for this type */ 32 | uint16_t rotation_angle; 33 | uint16_t arc_angle_start; 34 | uint16_t arc_angle_end; 35 | uint16_t bg_angle_start; 36 | uint16_t bg_angle_end; 37 | lv_style_list_t style_arc; 38 | } lv_arc_ext_t; 39 | 40 | /*Parts of the arc*/ 41 | enum { 42 | LV_ARC_PART_BG = LV_OBJ_PART_MAIN, 43 | LV_ARC_PART_INDIC, 44 | _LV_ARC_PART_VIRTUAL_LAST, 45 | 46 | _LV_ARC_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST, 47 | }; 48 | typedef uint8_t lv_arc_part_t; 49 | 50 | /********************** 51 | * GLOBAL PROTOTYPES 52 | **********************/ 53 | 54 | /** 55 | * Create a arc objects 56 | * @param par pointer to an object, it will be the parent of the new arc 57 | * @param copy pointer to a arc object, if not NULL then the new object will be copied from it 58 | * @return pointer to the created arc 59 | */ 60 | lv_obj_t * lv_arc_create(lv_obj_t * par, const lv_obj_t * copy); 61 | 62 | /*====================== 63 | * Add/remove functions 64 | *=====================*/ 65 | 66 | /*===================== 67 | * Setter functions 68 | *====================*/ 69 | 70 | /** 71 | * Set the start angle of an arc. 0 deg: right, 90 bottom, etc. 72 | * @param arc pointer to an arc object 73 | * @param start the start angle 74 | */ 75 | void lv_arc_set_start_angle(lv_obj_t * arc, uint16_t start); 76 | 77 | /** 78 | * Set the start angle of an arc. 0 deg: right, 90 bottom, etc. 79 | * @param arc pointer to an arc object 80 | * @param end the end angle 81 | */ 82 | void lv_arc_set_end_angle(lv_obj_t * arc, uint16_t end); 83 | 84 | /** 85 | * Set the start and end angles 86 | * @param arc pointer to an arc object 87 | * @param start the start angle 88 | * @param end the end angle 89 | */ 90 | void lv_arc_set_angles(lv_obj_t * arc, uint16_t start, uint16_t end); 91 | 92 | /** 93 | * Set the start angle of an arc background. 0 deg: right, 90 bottom, etc. 94 | * @param arc pointer to an arc object 95 | * @param start the start angle 96 | */ 97 | void lv_arc_set_bg_start_angle(lv_obj_t * arc, uint16_t start); 98 | 99 | /** 100 | * Set the start angle of an arc background. 0 deg: right, 90 bottom etc. 101 | * @param arc pointer to an arc object 102 | * @param end the end angle 103 | */ 104 | void lv_arc_set_bg_end_angle(lv_obj_t * arc, uint16_t end); 105 | 106 | /** 107 | * Set the start and end angles of the arc background 108 | * @param arc pointer to an arc object 109 | * @param start the start angle 110 | * @param end the end angle 111 | */ 112 | void lv_arc_set_bg_angles(lv_obj_t * arc, uint16_t start, uint16_t end); 113 | 114 | /** 115 | * Set the rotation for the whole arc 116 | * @param arc pointer to an arc object 117 | * @param rotation_angle rotation angle 118 | */ 119 | void lv_arc_set_rotation(lv_obj_t * arc, uint16_t rotation_angle); 120 | 121 | /*===================== 122 | * Getter functions 123 | *====================*/ 124 | 125 | /** 126 | * Get the start angle of an arc. 127 | * @param arc pointer to an arc object 128 | * @return the start angle [0..360] 129 | */ 130 | uint16_t lv_arc_get_angle_start(lv_obj_t * arc); 131 | 132 | /** 133 | * Get the end angle of an arc. 134 | * @param arc pointer to an arc object 135 | * @return the end angle [0..360] 136 | */ 137 | uint16_t lv_arc_get_angle_end(lv_obj_t * arc); 138 | 139 | /** 140 | * Get the start angle of an arc background. 141 | * @param arc pointer to an arc object 142 | * @return the start angle [0..360] 143 | */ 144 | uint16_t lv_arc_get_bg_angle_start(lv_obj_t * arc); 145 | 146 | /** 147 | * Get the end angle of an arc background. 148 | * @param arc pointer to an arc object 149 | * @return the end angle [0..360] 150 | */ 151 | uint16_t lv_arc_get_bg_angle_end(lv_obj_t * arc); 152 | 153 | /*===================== 154 | * Other functions 155 | *====================*/ 156 | 157 | /********************** 158 | * MACROS 159 | **********************/ 160 | 161 | #endif /*LV_USE_ARC*/ 162 | 163 | #ifdef __cplusplus 164 | } /* extern "C" */ 165 | #endif 166 | 167 | #endif /*LV_ARC_H*/ 168 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_checkbox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_cb.h 3 | * 4 | */ 5 | 6 | #ifndef LV_CHECKBOX_H 7 | #define LV_CHECKBOX_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_CHECKBOX != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_BTN == 0 22 | #error "lv_cb: lv_btn is required. Enable it in lv_conf.h (LV_USE_BTN 1) " 23 | #endif 24 | 25 | #if LV_USE_LABEL == 0 26 | #error "lv_cb: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) " 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "lv_btn.h" 31 | #include "lv_label.h" 32 | 33 | /********************* 34 | * DEFINES 35 | *********************/ 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | 41 | /*Data of check box*/ 42 | typedef struct { 43 | lv_btn_ext_t bg_btn; /*Ext. of ancestor*/ 44 | /*New data for this type */ 45 | lv_obj_t * bullet; /*Pointer to button*/ 46 | lv_obj_t * label; /*Pointer to label*/ 47 | } lv_checkbox_ext_t; 48 | 49 | /** Checkbox styles. */ 50 | enum { 51 | LV_CHECKBOX_PART_BG = LV_BTN_PART_MAIN, /**< Style of object background. */ 52 | _LV_CHECKBOX_PART_VIRTUAL_LAST, 53 | LV_CHECKBOX_PART_BULLET = _LV_BTN_PART_REAL_LAST, /**< Style of box (released). */ 54 | _LV_CHECKBOX_PART_REAL_LAST 55 | }; 56 | typedef uint8_t lv_checkbox_style_t; 57 | 58 | /********************** 59 | * GLOBAL PROTOTYPES 60 | **********************/ 61 | 62 | /** 63 | * Create a check box objects 64 | * @param par pointer to an object, it will be the parent of the new check box 65 | * @param copy pointer to a check box object, if not NULL then the new object will be copied from it 66 | * @return pointer to the created check box 67 | */ 68 | lv_obj_t * lv_checkbox_create(lv_obj_t * par, const lv_obj_t * copy); 69 | 70 | /*===================== 71 | * Setter functions 72 | *====================*/ 73 | 74 | /** 75 | * Set the text of a check box. `txt` will be copied and may be deallocated 76 | * after this function returns. 77 | * @param cb pointer to a check box 78 | * @param txt the text of the check box. NULL to refresh with the current text. 79 | */ 80 | void lv_checkbox_set_text(lv_obj_t * cb, const char * txt); 81 | 82 | /** 83 | * Set the text of a check box. `txt` must not be deallocated during the life 84 | * of this checkbox. 85 | * @param cb pointer to a check box 86 | * @param txt the text of the check box. NULL to refresh with the current text. 87 | */ 88 | void lv_checkbox_set_text_static(lv_obj_t * cb, const char * txt); 89 | 90 | /** 91 | * Set the state of the check box 92 | * @param cb pointer to a check box object 93 | * @param checked true: make the check box checked; false: make it unchecked 94 | */ 95 | static inline void lv_checkbox_set_checked(lv_obj_t * cb, bool checked) 96 | { 97 | lv_btn_set_state(cb, checked ? LV_BTN_STATE_CHECKED_RELEASED : LV_BTN_STATE_RELEASED); 98 | } 99 | 100 | /** 101 | * Make the check box inactive (disabled) 102 | * @param cb pointer to a check box object 103 | */ 104 | static inline void lv_checkbox_set_disabled(lv_obj_t * cb) 105 | { 106 | lv_btn_set_state(cb, LV_BTN_STATE_DISABLED); 107 | } 108 | 109 | /** 110 | * Set the state of a check box 111 | * @param cb pointer to a check box object 112 | * @param state the new state of the check box (from lv_btn_state_t enum) 113 | */ 114 | static inline void lv_checkbox_set_state(lv_obj_t * cb, lv_btn_state_t state) 115 | { 116 | lv_btn_set_state(cb, state); 117 | } 118 | /*===================== 119 | * Getter functions 120 | *====================*/ 121 | 122 | /** 123 | * Get the text of a check box 124 | * @param cb pointer to check box object 125 | * @return pointer to the text of the check box 126 | */ 127 | const char * lv_checkbox_get_text(const lv_obj_t * cb); 128 | 129 | /** 130 | * Get the current state of the check box 131 | * @param cb pointer to a check box object 132 | * @return true: checked; false: not checked 133 | */ 134 | static inline bool lv_checkbox_is_checked(const lv_obj_t * cb) 135 | { 136 | return lv_btn_get_state(cb) == LV_BTN_STATE_RELEASED ? false : true; 137 | } 138 | 139 | /** 140 | * Get whether the check box is inactive or not. 141 | * @param cb pointer to a check box object 142 | * @return true: inactive; false: not inactive 143 | */ 144 | static inline bool lv_checkbox_is_inactive(const lv_obj_t * cb) 145 | { 146 | return lv_btn_get_state(cb) == LV_BTN_STATE_DISABLED ? true : false; 147 | } 148 | 149 | /** 150 | * Get the current state of a check box 151 | * @param cb pointer to a check box object 152 | * @return the state of the check box (from lv_btn_state_t enum) 153 | */ 154 | static inline lv_btn_state_t lv_checkbox_get_state(const lv_obj_t * cb) 155 | { 156 | return lv_btn_get_state(cb); 157 | } 158 | 159 | /********************** 160 | * MACROS 161 | **********************/ 162 | 163 | #endif /*LV_USE_CHECKBOX*/ 164 | 165 | #ifdef __cplusplus 166 | } /* extern "C" */ 167 | #endif 168 | 169 | #endif /*LV_CHECKBOX_H*/ 170 | -------------------------------------------------------------------------------- /src/lv_widgets/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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_LED != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /*Data of led*/ 31 | typedef struct { 32 | /*No inherited ext.*/ 33 | /*New data for this type */ 34 | uint8_t bright; /*Current brightness of the LED (0..255)*/ 35 | } lv_led_ext_t; 36 | 37 | /*Parts of LED*/ 38 | enum { 39 | LV_LED_PART_MAIN = LV_OBJ_PART_MAIN, 40 | }; 41 | typedef uint8_t lv_led_part_t; 42 | 43 | /********************** 44 | * GLOBAL PROTOTYPES 45 | **********************/ 46 | 47 | /** 48 | * Create a led objects 49 | * @param par pointer to an object, it will be the parent of the new led 50 | * @param copy pointer to a led object, if not NULL then the new object will be copied from it 51 | * @return pointer to the created led 52 | */ 53 | lv_obj_t * lv_led_create(lv_obj_t * par, const lv_obj_t * copy); 54 | 55 | /** 56 | * Set the brightness of a LED object 57 | * @param led pointer to a LED object 58 | * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light) 59 | */ 60 | void lv_led_set_bright(lv_obj_t * led, uint8_t bright); 61 | 62 | /** 63 | * Light on a LED 64 | * @param led pointer to a LED object 65 | */ 66 | void lv_led_on(lv_obj_t * led); 67 | 68 | /** 69 | * Light off a LED 70 | * @param led pointer to a LED object 71 | */ 72 | void lv_led_off(lv_obj_t * led); 73 | 74 | /** 75 | * Toggle the state of a LED 76 | * @param led pointer to a LED object 77 | */ 78 | void lv_led_toggle(lv_obj_t * led); 79 | 80 | /** 81 | * Get the brightness of a LEd object 82 | * @param led pointer to LED object 83 | * @return bright 0 (max. dark) ... 255 (max. light) 84 | */ 85 | uint8_t lv_led_get_bright(const lv_obj_t * led); 86 | 87 | /********************** 88 | * MACROS 89 | **********************/ 90 | 91 | #endif /*LV_USE_LED*/ 92 | 93 | #ifdef __cplusplus 94 | } /* extern "C" */ 95 | #endif 96 | 97 | #endif /*LV_LED_H*/ 98 | -------------------------------------------------------------------------------- /src/lv_widgets/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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_LINE != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /*Data of line*/ 31 | typedef struct { 32 | /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ 33 | const lv_point_t * point_array; /*Pointer to an array with the points of the line*/ 34 | uint16_t point_num; /*Number of points in 'point_array' */ 35 | uint8_t auto_size : 1; /*1: set obj. width to x max and obj. height to y max */ 36 | uint8_t y_inv : 1; /*1: y == 0 will be on the bottom*/ 37 | } lv_line_ext_t; 38 | 39 | /*Styles*/ 40 | enum { 41 | LV_LINE_PART_MAIN, 42 | }; 43 | typedef uint8_t lv_line_style_t; 44 | 45 | /********************** 46 | * GLOBAL PROTOTYPES 47 | **********************/ 48 | 49 | /** 50 | * Create a line objects 51 | * @param par pointer to an object, it will be the parent of the new line 52 | * @return pointer to the created line 53 | */ 54 | lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy); 55 | 56 | /*===================== 57 | * Setter functions 58 | *====================*/ 59 | 60 | /** 61 | * Set an array of points. The line object will connect these points. 62 | * @param line pointer to a line object 63 | * @param point_a an array of points. Only the address is saved, 64 | * so the array can NOT be a local variable which will be destroyed 65 | * @param point_num number of points in 'point_a' 66 | */ 67 | void lv_line_set_points(lv_obj_t * line, const lv_point_t point_a[], uint16_t point_num); 68 | 69 | /** 70 | * Enable (or disable) the auto-size option. The size of the object will fit to its points. 71 | * (set width to x max and height to y max) 72 | * @param line pointer to a line object 73 | * @param en true: auto size is enabled, false: auto size is disabled 74 | */ 75 | void lv_line_set_auto_size(lv_obj_t * line, bool en); 76 | 77 | /** 78 | * Enable (or disable) the y coordinate inversion. 79 | * If enabled then y will be subtracted from the height of the object, 80 | * therefore the y=0 coordinate will be on the bottom. 81 | * @param line pointer to a line object 82 | * @param en true: enable the y inversion, false:disable the y inversion 83 | */ 84 | void lv_line_set_y_invert(lv_obj_t * line, bool en); 85 | 86 | #define lv_line_set_y_inv \ 87 | lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will \ 88 | work */ 89 | 90 | 91 | /*===================== 92 | * Getter functions 93 | *====================*/ 94 | 95 | /** 96 | * Get the auto size attribute 97 | * @param line pointer to a line object 98 | * @return true: auto size is enabled, false: disabled 99 | */ 100 | bool lv_line_get_auto_size(const lv_obj_t * line); 101 | 102 | /** 103 | * Get the y inversion attribute 104 | * @param line pointer to a line object 105 | * @return true: y inversion is enabled, false: disabled 106 | */ 107 | bool lv_line_get_y_invert(const lv_obj_t * line); 108 | 109 | /********************** 110 | * MACROS 111 | **********************/ 112 | 113 | #endif /*LV_USE_LINE*/ 114 | 115 | #ifdef __cplusplus 116 | } /* extern "C" */ 117 | #endif 118 | 119 | #endif /*LV_LINE_H*/ 120 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_linemeter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_linemeter.h 3 | * 4 | */ 5 | 6 | #ifndef LV_LINEMETER_H 7 | #define LV_LINEMETER_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_LINEMETER != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | /*Data of line meter*/ 30 | typedef struct { 31 | /*No inherited ext.*/ /*Ext. of ancestor*/ 32 | /*New data for this type */ 33 | uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/ 34 | uint16_t angle_ofs; 35 | uint16_t line_cnt; /*Count of lines */ 36 | int32_t cur_value; 37 | int32_t min_value; 38 | int32_t max_value; 39 | uint8_t mirrored : 1; 40 | } lv_linemeter_ext_t; 41 | 42 | /*Styles*/ 43 | enum { 44 | LV_LINEMETER_PART_MAIN, 45 | _LV_LINEMETER_PART_VIRTUAL_LAST, 46 | _LV_LINEMETER_PART_REAL_LAST = _LV_OBJ_PART_REAL_LAST, 47 | }; 48 | typedef uint8_t lv_linemeter_part_t; 49 | 50 | /********************** 51 | * GLOBAL PROTOTYPES 52 | **********************/ 53 | 54 | /** 55 | * Create a line meter objects 56 | * @param par pointer to an object, it will be the parent of the new line meter 57 | * @param copy pointer to a line meter object, if not NULL then the new object will be copied from 58 | * it 59 | * @return pointer to the created line meter 60 | */ 61 | lv_obj_t * lv_linemeter_create(lv_obj_t * par, const lv_obj_t * copy); 62 | 63 | /*===================== 64 | * Setter functions 65 | *====================*/ 66 | 67 | /** 68 | * Set a new value on the line meter 69 | * @param lmeter pointer to a line meter object 70 | * @param value new value 71 | */ 72 | void lv_linemeter_set_value(lv_obj_t * lmeter, int32_t value); 73 | 74 | /** 75 | * Set minimum and the maximum values of a line meter 76 | * @param lmeter pointer to he line meter object 77 | * @param min minimum value 78 | * @param max maximum value 79 | */ 80 | void lv_linemeter_set_range(lv_obj_t * lmeter, int32_t min, int32_t max); 81 | 82 | /** 83 | * Set the scale settings of a line meter 84 | * @param lmeter pointer to a line meter object 85 | * @param angle angle of the scale (0..360) 86 | * @param line_cnt number of lines 87 | */ 88 | void lv_linemeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint16_t line_cnt); 89 | 90 | /** 91 | * Set the set an offset for the line meter's angles to rotate it. 92 | * @param lmeter pointer to a line meter object 93 | * @param angle angle offset (0..360), rotates clockwise 94 | */ 95 | void lv_linemeter_set_angle_offset(lv_obj_t * lmeter, uint16_t angle); 96 | 97 | /** 98 | * Set the orientation of the meter growth, clockwise or counterclockwise (mirrored) 99 | * @param lmeter pointer to a line meter object 100 | * @param mirror mirror setting 101 | */ 102 | void lv_linemeter_set_mirror(lv_obj_t * lmeter, bool mirror); 103 | 104 | /*===================== 105 | * Getter functions 106 | *====================*/ 107 | 108 | /** 109 | * Get the value of a line meter 110 | * @param lmeter pointer to a line meter object 111 | * @return the value of the line meter 112 | */ 113 | int32_t lv_linemeter_get_value(const lv_obj_t * lmeter); 114 | 115 | /** 116 | * Get the minimum value of a line meter 117 | * @param lmeter pointer to a line meter object 118 | * @return the minimum value of the line meter 119 | */ 120 | int32_t lv_linemeter_get_min_value(const lv_obj_t * lmeter); 121 | 122 | /** 123 | * Get the maximum value of a line meter 124 | * @param lmeter pointer to a line meter object 125 | * @return the maximum value of the line meter 126 | */ 127 | int32_t lv_linemeter_get_max_value(const lv_obj_t * lmeter); 128 | 129 | /** 130 | * Get the scale number of a line meter 131 | * @param lmeter pointer to a line meter object 132 | * @return number of the scale units 133 | */ 134 | uint16_t lv_linemeter_get_line_count(const lv_obj_t * lmeter); 135 | 136 | /** 137 | * Get the scale angle of a line meter 138 | * @param lmeter pointer to a line meter object 139 | * @return angle of the scale 140 | */ 141 | uint16_t lv_linemeter_get_scale_angle(const lv_obj_t * lmeter); 142 | 143 | /** 144 | * Get the offset for the line meter. 145 | * @param lmeter pointer to a line meter object 146 | * @return angle offset (0..360) 147 | */ 148 | uint16_t lv_linemeter_get_angle_offset(lv_obj_t * lmeter); 149 | 150 | 151 | void lv_linemeter_draw_scale(lv_obj_t * lmeter, const lv_area_t * clip_area, uint8_t part); 152 | 153 | /** 154 | * get the mirror setting for the line meter 155 | * @param lmeter pointer to a line meter object 156 | * @return mirror (true or false) 157 | */ 158 | bool lv_linemeter_get_mirror(lv_obj_t * lmeter); 159 | 160 | /********************** 161 | * MACROS 162 | **********************/ 163 | 164 | #endif /*LV_USE_LINEMETER*/ 165 | 166 | #ifdef __cplusplus 167 | } /* extern "C" */ 168 | #endif 169 | 170 | #endif /*LV_LINEMETER_H*/ 171 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_objmask.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_objmask.h 3 | * 4 | */ 5 | 6 | #ifndef LV_OBJMASK_H 7 | #define LV_OBJMASK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_OBJMASK != 0 19 | 20 | #include "../lv_core/lv_obj.h" 21 | #include "../lv_widgets/lv_cont.h" 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | 27 | /********************** 28 | * TYPEDEFS 29 | **********************/ 30 | 31 | typedef struct { 32 | void * param; 33 | } lv_objmask_mask_t; 34 | 35 | /*Data of object mask*/ 36 | typedef struct { 37 | lv_cont_ext_t cont; /*Ext. of ancestor*/ 38 | /*New data for this type */ 39 | lv_ll_t mask_ll; /*Store the created masks*/ 40 | 41 | } lv_objmask_ext_t; 42 | 43 | /*Parts of the object*/ 44 | enum { 45 | LV_OBJMASK_PART_MAIN, 46 | }; 47 | typedef uint8_t lv_objmask_part_t; 48 | 49 | /********************** 50 | * GLOBAL PROTOTYPES 51 | **********************/ 52 | 53 | /** 54 | * Create a object mask objects 55 | * @param par pointer to an object, it will be the parent of the new object mask 56 | * @param copy pointer to a object mask object, if not NULL then the new object will be copied from it 57 | * @return pointer to the created object mask 58 | */ 59 | lv_obj_t * lv_objmask_create(lv_obj_t * par, const lv_obj_t * copy); 60 | 61 | /*====================== 62 | * Add/remove functions 63 | *=====================*/ 64 | 65 | /** 66 | * Add a mask 67 | * @param objmask pointer to an Object mask object 68 | * @param param an initialized mask parameter 69 | * @return pointer to the added mask 70 | */ 71 | lv_objmask_mask_t * lv_objmask_add_mask(lv_obj_t * objmask, void * param); 72 | 73 | /** 74 | * Update an already created mask 75 | * @param objmask pointer to an Object mask object 76 | * @param mask pointer to created mask (returned by `lv_objmask_add_mask`) 77 | * @param param an initialized mask parameter (initialized by `lv_draw_mask_line/angle/.../_init`) 78 | */ 79 | void lv_objmask_update_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask, void * param); 80 | 81 | /** 82 | * Remove a mask 83 | * @param objmask pointer to an Object mask object 84 | * @param mask pointer to created mask (returned by `lv_objmask_add_mask`) 85 | * If `NULL` passed all masks will be deleted. 86 | */ 87 | void lv_objmask_remove_mask(lv_obj_t * objmask, lv_objmask_mask_t * mask); 88 | 89 | /*===================== 90 | * Setter functions 91 | *====================*/ 92 | 93 | /*===================== 94 | * Getter functions 95 | *====================*/ 96 | 97 | /*===================== 98 | * Other functions 99 | *====================*/ 100 | 101 | /********************** 102 | * MACROS 103 | **********************/ 104 | 105 | #endif /*LV_USE_OBJMASK*/ 106 | 107 | #ifdef __cplusplus 108 | } /* extern "C" */ 109 | #endif 110 | 111 | #endif /*LV_OBJMASK_H*/ 112 | -------------------------------------------------------------------------------- /src/lv_widgets/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 | #include "../lv_conf_internal.h" 24 | 25 | #if LV_USE_TEMPL != 0 26 | 27 | #include "../lv_core/lv_obj.h" 28 | 29 | /********************* 30 | * DEFINES 31 | *********************/ 32 | 33 | /********************** 34 | * TYPEDEFS 35 | **********************/ 36 | /*Data of template*/ 37 | typedef struct { 38 | lv_ANCESTOR_ext_t ANCESTOR; /*Ext. of ancestor*/ 39 | /*New data for this type */ 40 | } lv_templ_ext_t; 41 | 42 | /*Styles*/ 43 | enum { 44 | LV_TEMPL_STYLE_X, 45 | LV_TEMPL_STYLE_Y, 46 | }; 47 | typedef uint8_t lv_templ_style_t; 48 | 49 | /********************** 50 | * GLOBAL PROTOTYPES 51 | **********************/ 52 | 53 | /** 54 | * Create a template objects 55 | * @param par pointer to an object, it will be the parent of the new template 56 | * @param copy pointer to a template object, if not NULL then the new object will be copied from it 57 | * @return pointer to the created template 58 | */ 59 | lv_obj_t * lv_templ_create(lv_obj_t * par, const lv_obj_t * copy); 60 | 61 | /*====================== 62 | * Add/remove functions 63 | *=====================*/ 64 | 65 | /*===================== 66 | * Setter functions 67 | *====================*/ 68 | 69 | /** 70 | * Set a style of a template. 71 | * @param templ pointer to template object 72 | * @param type which style should be set 73 | * @param style pointer to a style 74 | */ 75 | void lv_templ_set_style(lv_obj_t * templ, lv_templ_style_t type, const lv_style_t * style); 76 | 77 | /*===================== 78 | * Getter functions 79 | *====================*/ 80 | 81 | /** 82 | * Get style of a template. 83 | * @param templ pointer to template object 84 | * @param type which style should be get 85 | * @return style pointer to the style 86 | */ 87 | lv_style_t * lv_templ_get_style(const lv_obj_t * templ, lv_templ_style_t type); 88 | 89 | /*===================== 90 | * Other functions 91 | *====================*/ 92 | 93 | /********************** 94 | * MACROS 95 | **********************/ 96 | 97 | #endif /*LV_USE_TEMPL*/ 98 | 99 | #ifdef __cplusplus 100 | } /* extern "C" */ 101 | #endif 102 | 103 | #endif /*LV_TEMPL_H*/ 104 | -------------------------------------------------------------------------------- /src/lv_widgets/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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_SPINBOX != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_TEXTAREA == 0 22 | #error "lv_spinbox: lv_ta is required. Enable it in lv_conf.h (LV_USE_TEXTAREA 1) " 23 | #endif 24 | 25 | #include "../lv_core/lv_obj.h" 26 | #include "../lv_widgets/lv_textarea.h" 27 | 28 | /********************* 29 | * DEFINES 30 | *********************/ 31 | #define LV_SPINBOX_MAX_DIGIT_COUNT 10 32 | 33 | /********************** 34 | * TYPEDEFS 35 | **********************/ 36 | 37 | /*Data of spinbox*/ 38 | typedef struct { 39 | lv_textarea_ext_t ta; /*Ext. of ancestor*/ 40 | /*New data for this type */ 41 | int32_t value; 42 | int32_t range_max; 43 | int32_t range_min; 44 | int32_t step; 45 | uint8_t rollover : 1; // Set to true for rollover functionality 46 | uint16_t digit_count : 4; 47 | uint16_t dec_point_pos : 4; /*if 0, there is no separator and the number is an integer*/ 48 | uint16_t digit_padding_left : 4; 49 | } lv_spinbox_ext_t; 50 | 51 | /*Styles*/ 52 | enum { 53 | LV_SPINBOX_PART_BG = LV_TEXTAREA_PART_BG, 54 | LV_SPINBOX_PART_CURSOR = LV_TEXTAREA_PART_CURSOR, 55 | _LV_SPINBOX_PART_VIRTUAL_LAST = _LV_TEXTAREA_PART_VIRTUAL_LAST, 56 | _LV_SPINBOX_PART_REAL_LAST = _LV_TEXTAREA_PART_REAL_LAST, 57 | }; 58 | typedef uint8_t lv_spinbox_part_t; 59 | 60 | /********************** 61 | * GLOBAL PROTOTYPES 62 | **********************/ 63 | 64 | /** 65 | * Create a spinbox objects 66 | * @param par pointer to an object, it will be the parent of the new spinbox 67 | * @param copy pointer to a spinbox object, if not NULL then the new object will be copied from it 68 | * @return pointer to the created spinbox 69 | */ 70 | lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy); 71 | 72 | /*===================== 73 | * Setter functions 74 | *====================*/ 75 | 76 | /** 77 | * Set spinbox rollover function 78 | * @param spinbox pointer to spinbox 79 | * @param b true or false to enable or disable (default) 80 | */ 81 | void lv_spinbox_set_rollover(lv_obj_t * spinbox, bool b); 82 | 83 | /** 84 | * Set spinbox value 85 | * @param spinbox pointer to spinbox 86 | * @param i value to be set 87 | */ 88 | void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i); 89 | 90 | /** 91 | * Set spinbox digit format (digit count and decimal format) 92 | * @param spinbox pointer to spinbox 93 | * @param digit_count number of digit excluding the decimal separator and the sign 94 | * @param separator_position number of digit before the decimal point. If 0, decimal point is not 95 | * shown 96 | */ 97 | void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_t separator_position); 98 | 99 | /** 100 | * Set spinbox step 101 | * @param spinbox pointer to spinbox 102 | * @param step steps on increment/decrement 103 | */ 104 | void lv_spinbox_set_step(lv_obj_t * spinbox, uint32_t step); 105 | 106 | /** 107 | * Set spinbox value range 108 | * @param spinbox pointer to spinbox 109 | * @param range_min maximum value, inclusive 110 | * @param range_max minimum value, inclusive 111 | */ 112 | void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_max); 113 | 114 | /** 115 | * Set spinbox left padding in digits count (added between sign and first digit) 116 | * @param spinbox pointer to spinbox 117 | * @param cb Callback function called on value change event 118 | */ 119 | void lv_spinbox_set_padding_left(lv_obj_t * spinbox, uint8_t padding); 120 | 121 | /*===================== 122 | * Getter functions 123 | *====================*/ 124 | 125 | /** 126 | * Get spinbox rollover function status 127 | * @param spinbox pointer to spinbox 128 | */ 129 | bool lv_spinbox_get_rollover(lv_obj_t * spinbox); 130 | 131 | /** 132 | * Get the spinbox numeral value (user has to convert to float according to its digit format) 133 | * @param spinbox pointer to spinbox 134 | * @return value integer value of the spinbox 135 | */ 136 | int32_t lv_spinbox_get_value(lv_obj_t * spinbox); 137 | 138 | /*===================== 139 | * Other functions 140 | *====================*/ 141 | 142 | /** 143 | * Select next lower digit for edition by dividing the step by 10 144 | * @param spinbox pointer to spinbox 145 | */ 146 | void lv_spinbox_step_next(lv_obj_t * spinbox); 147 | 148 | /** 149 | * Select next higher digit for edition by multiplying the step by 10 150 | * @param spinbox pointer to spinbox 151 | */ 152 | void lv_spinbox_step_prev(lv_obj_t * spinbox); 153 | 154 | /** 155 | * Increment spinbox value by one step 156 | * @param spinbox pointer to spinbox 157 | */ 158 | void lv_spinbox_increment(lv_obj_t * spinbox); 159 | 160 | /** 161 | * Decrement spinbox value by one step 162 | * @param spinbox pointer to spinbox 163 | */ 164 | void lv_spinbox_decrement(lv_obj_t * spinbox); 165 | 166 | /********************** 167 | * MACROS 168 | **********************/ 169 | 170 | #endif /*LV_USE_SPINBOX*/ 171 | 172 | #ifdef __cplusplus 173 | } /* extern "C" */ 174 | #endif 175 | 176 | #endif /*LV_SPINBOX_H*/ 177 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_spinner.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_spinner.h 3 | * 4 | */ 5 | 6 | #ifndef LV_SPINNER_H 7 | #define LV_SPINNER_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_SPINNER != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_ARC == 0 22 | #error "lv_spinner: lv_arc is required. Enable it in lv_conf.h (LV_USE_ARC 1) " 23 | #endif 24 | 25 | #if LV_USE_ANIMATION == 0 26 | #error "lv_spinner: animations are required. Enable it in lv_conf.h (LV_USE_ANIMATION 1) " 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "../lv_misc/lv_anim.h" 31 | #include "lv_arc.h" 32 | 33 | /********************* 34 | * DEFINES 35 | *********************/ 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | 41 | /** 42 | * Type of spinner. 43 | */ 44 | enum { 45 | LV_SPINNER_TYPE_SPINNING_ARC, 46 | LV_SPINNER_TYPE_FILLSPIN_ARC, 47 | LV_SPINNER_TYPE_CONSTANT_ARC, 48 | }; 49 | typedef uint8_t lv_spinner_type_t; 50 | 51 | /** 52 | * Direction the spinner should spin. 53 | */ 54 | enum { 55 | LV_SPINNER_DIR_FORWARD, 56 | LV_SPINNER_DIR_BACKWARD, 57 | }; 58 | typedef uint8_t lv_spinner_dir_t; 59 | 60 | /*Data of spinner*/ 61 | typedef struct { 62 | lv_arc_ext_t arc; /*Ext. of ancestor*/ 63 | /*New data for this type */ 64 | lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/ 65 | uint16_t time; /*Time of one round*/ 66 | lv_spinner_type_t anim_type : 2; /*Type of the arc animation*/ 67 | lv_spinner_dir_t anim_dir : 1; /*Animation Direction*/ 68 | } lv_spinner_ext_t; 69 | 70 | /*Parts of the spinner*/ 71 | enum { 72 | LV_SPINNER_PART_BG = LV_ARC_PART_BG, 73 | LV_SPINNER_PART_INDIC = LV_ARC_PART_INDIC, 74 | _LV_SPINNER_PART_VIRTUAL_LAST, 75 | 76 | _LV_SPINNER_PART_REAL_LAST = _LV_ARC_PART_REAL_LAST, 77 | }; 78 | typedef uint8_t lv_spinner_style_t; 79 | 80 | /********************** 81 | * GLOBAL PROTOTYPES 82 | **********************/ 83 | 84 | /** 85 | * Create a spinner object 86 | * @param par pointer to an object, it will be the parent of the new spinner 87 | * @param copy pointer to a spinner object, if not NULL then the new object will be copied from 88 | * it 89 | * @return pointer to the created spinner 90 | */ 91 | lv_obj_t * lv_spinner_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 spinner pointer to a spinner object 100 | * @param deg length of the arc 101 | */ 102 | void lv_spinner_set_arc_length(lv_obj_t * spinner, lv_anim_value_t deg); 103 | 104 | /** 105 | * Set the spin time of the arc 106 | * @param spinner pointer to a spinner object 107 | * @param time time of one round in milliseconds 108 | */ 109 | void lv_spinner_set_spin_time(lv_obj_t * spinner, uint16_t time); 110 | 111 | /*===================== 112 | * Setter functions 113 | *====================*/ 114 | 115 | /** 116 | * Set the animation type of a spinner. 117 | * @param spinner pointer to spinner object 118 | * @param type animation type of the spinner 119 | * */ 120 | void lv_spinner_set_type(lv_obj_t * spinner, lv_spinner_type_t type); 121 | 122 | /** 123 | * Set the animation direction of a spinner 124 | * @param spinner pointer to spinner object 125 | * @param direction animation direction of the spinner 126 | */ 127 | void lv_spinner_set_dir(lv_obj_t * spinner, lv_spinner_dir_t dir); 128 | 129 | /*===================== 130 | * Getter functions 131 | *====================*/ 132 | 133 | /** 134 | * Get the arc length [degree] of the a spinner 135 | * @param spinner pointer to a spinner object 136 | */ 137 | lv_anim_value_t lv_spinner_get_arc_length(const lv_obj_t * spinner); 138 | 139 | /** 140 | * Get the spin time of the arc 141 | * @param spinner pointer to a spinner object [milliseconds] 142 | */ 143 | uint16_t lv_spinner_get_spin_time(const lv_obj_t * spinner); 144 | 145 | /** 146 | * Get the animation type of a spinner. 147 | * @param spinner pointer to spinner object 148 | * @return animation type 149 | * */ 150 | lv_spinner_type_t lv_spinner_get_type(lv_obj_t * spinner); 151 | 152 | /** 153 | * Get the animation direction of a spinner 154 | * @param spinner pointer to spinner object 155 | * @return animation direction 156 | */ 157 | lv_spinner_dir_t lv_spinner_get_dir(lv_obj_t * spinner); 158 | 159 | /*===================== 160 | * Other functions 161 | *====================*/ 162 | 163 | /** 164 | * Animator function (exec_cb) to rotate the arc of spinner. 165 | * @param ptr pointer to spinner 166 | * @param val the current desired value [0..360] 167 | */ 168 | void lv_spinner_anim_cb(void * ptr, lv_anim_value_t val); 169 | 170 | /********************** 171 | * MACROS 172 | **********************/ 173 | 174 | #endif /*LV_USE_SPINNER*/ 175 | 176 | #ifdef __cplusplus 177 | } /* extern "C" */ 178 | #endif 179 | 180 | #endif /*LV_SPINNER_H*/ 181 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_switch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_sw.h 3 | * 4 | */ 5 | 6 | #ifndef LV_SWITCH_H 7 | #define LV_SWITCH_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_SWITCH != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_SLIDER == 0 22 | #error "lv_sw: lv_slider is required. Enable it in lv_conf.h (LV_USE_SLIDER 1)" 23 | #endif 24 | 25 | #include "../lv_core/lv_obj.h" 26 | #include "lv_bar.h" 27 | 28 | /********************* 29 | * DEFINES 30 | *********************/ 31 | 32 | /********************** 33 | * TYPEDEFS 34 | **********************/ 35 | /*Data of switch*/ 36 | typedef struct { 37 | lv_bar_ext_t bar; /*Ext. of ancestor*/ 38 | /*New data for this type */ 39 | lv_style_list_t style_knob; /*Style of the knob*/ 40 | uint8_t state : 1; /*The current state*/ 41 | } lv_switch_ext_t; 42 | 43 | /** 44 | * Switch parts. 45 | */ 46 | enum { 47 | LV_SWITCH_PART_BG = LV_BAR_PART_BG, /**< Switch background. */ 48 | LV_SWITCH_PART_INDIC = LV_BAR_PART_INDIC, /**< Switch fill area. */ 49 | LV_SWITCH_PART_KNOB = _LV_BAR_PART_VIRTUAL_LAST, /**< Switch knob. */ 50 | _LV_SWITCH_PART_VIRTUAL_LAST 51 | }; 52 | 53 | typedef uint8_t lv_switch_part_t; 54 | 55 | /********************** 56 | * GLOBAL PROTOTYPES 57 | **********************/ 58 | 59 | /** 60 | * Create a switch objects 61 | * @param par pointer to an object, it will be the parent of the new switch 62 | * @param copy pointer to a switch object, if not NULL then the new object will be copied from it 63 | * @return pointer to the created switch 64 | */ 65 | lv_obj_t * lv_switch_create(lv_obj_t * par, const lv_obj_t * copy); 66 | 67 | /*===================== 68 | * Setter functions 69 | *====================*/ 70 | 71 | /** 72 | * Turn ON the switch 73 | * @param sw pointer to a switch object 74 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 75 | */ 76 | void lv_switch_on(lv_obj_t * sw, lv_anim_enable_t anim); 77 | 78 | /** 79 | * Turn OFF the switch 80 | * @param sw pointer to a switch object 81 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 82 | */ 83 | void lv_switch_off(lv_obj_t * sw, lv_anim_enable_t anim); 84 | 85 | /** 86 | * Toggle the position of the switch 87 | * @param sw pointer to a switch object 88 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 89 | * @return resulting state of the switch. 90 | */ 91 | bool lv_switch_toggle(lv_obj_t * sw, lv_anim_enable_t anim); 92 | 93 | /** 94 | * Set the animation time of the switch 95 | * @param sw pointer to a switch object 96 | * @param anim_time animation time 97 | * @return style pointer to a style 98 | */ 99 | static inline void lv_switch_set_anim_time(lv_obj_t * sw, uint16_t anim_time) 100 | { 101 | lv_bar_set_anim_time(sw, anim_time); 102 | } 103 | 104 | /*===================== 105 | * Getter functions 106 | *====================*/ 107 | 108 | /** 109 | * Get the state of a switch 110 | * @param sw pointer to a switch object 111 | * @return false: OFF; true: ON 112 | */ 113 | static inline bool lv_switch_get_state(const lv_obj_t * sw) 114 | { 115 | lv_switch_ext_t * ext = (lv_switch_ext_t *)lv_obj_get_ext_attr(sw); 116 | return ext->state ? true : false; 117 | } 118 | 119 | /** 120 | * Get the animation time of the switch 121 | * @param sw pointer to a switch object 122 | * @return style pointer to a style 123 | */ 124 | static inline uint16_t lv_switch_get_anim_time(const lv_obj_t * sw) 125 | { 126 | return lv_bar_get_anim_time(sw); 127 | } 128 | 129 | /********************** 130 | * MACROS 131 | **********************/ 132 | 133 | #endif /*LV_USE_SWITCH*/ 134 | 135 | #ifdef __cplusplus 136 | } /* extern "C" */ 137 | #endif 138 | 139 | #endif /*LV_SWITCH_H*/ 140 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_tabview.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_tabview.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TABVIEW_H 7 | #define LV_TABVIEW_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_TABVIEW != 0 19 | 20 | /*Testing of dependencies*/ 21 | #if LV_USE_BTNMATRIX == 0 22 | #error "lv_tabview: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) " 23 | #endif 24 | 25 | #if LV_USE_PAGE == 0 26 | #error "lv_tabview: lv_page is required. Enable it in lv_conf.h (LV_USE_PAGE 1) " 27 | #endif 28 | 29 | #include "../lv_core/lv_obj.h" 30 | #include "../lv_widgets/lv_win.h" 31 | #include "../lv_widgets/lv_page.h" 32 | 33 | /********************* 34 | * DEFINES 35 | *********************/ 36 | 37 | /********************** 38 | * TYPEDEFS 39 | **********************/ 40 | 41 | /** Position of tabview buttons. */ 42 | enum { 43 | LV_TABVIEW_TAB_POS_NONE, 44 | LV_TABVIEW_TAB_POS_TOP, 45 | LV_TABVIEW_TAB_POS_BOTTOM, 46 | LV_TABVIEW_TAB_POS_LEFT, 47 | LV_TABVIEW_TAB_POS_RIGHT 48 | }; 49 | typedef uint8_t lv_tabview_btns_pos_t; 50 | 51 | /*Data of tab*/ 52 | typedef struct { 53 | /*Ext. of ancestor*/ 54 | /*New data for this type */ 55 | lv_obj_t * btns; 56 | lv_obj_t * indic; 57 | lv_obj_t * content; /*A background page which holds tab's pages*/ 58 | const char ** tab_name_ptr; 59 | lv_point_t point_last; 60 | uint16_t tab_cur; 61 | uint16_t tab_cnt; 62 | #if LV_USE_ANIMATION 63 | uint16_t anim_time; 64 | #endif 65 | lv_tabview_btns_pos_t btns_pos : 3; 66 | } lv_tabview_ext_t; 67 | 68 | enum { 69 | LV_TABVIEW_PART_BG = LV_OBJ_PART_MAIN, 70 | _LV_TABVIEW_PART_VIRTUAL_LAST = _LV_OBJ_PART_VIRTUAL_LAST, 71 | 72 | LV_TABVIEW_PART_BG_SCRLLABLE = _LV_OBJ_PART_REAL_LAST, 73 | LV_TABVIEW_PART_TAB_BG, 74 | LV_TABVIEW_PART_TAB_BTN, 75 | LV_TABVIEW_PART_INDIC, 76 | _LV_TABVIEW_PART_REAL_LAST, 77 | }; 78 | typedef uint8_t lv_tabview_part_t; 79 | 80 | /********************** 81 | * GLOBAL PROTOTYPES 82 | **********************/ 83 | 84 | /** 85 | * Create a Tab view object 86 | * @param par pointer to an object, it will be the parent of the new tab 87 | * @param copy pointer to a tab object, if not NULL then the new object will be copied from it 88 | * @return pointer to the created tab 89 | */ 90 | lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy); 91 | 92 | /*====================== 93 | * Add/remove functions 94 | *=====================*/ 95 | 96 | /** 97 | * Add a new tab with the given name 98 | * @param tabview pointer to Tab view object where to ass the new tab 99 | * @param name the text on the tab button 100 | * @return pointer to the created page object (lv_page). You can create your content here 101 | */ 102 | lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name); 103 | 104 | /** 105 | * Delete all children of a tab created by `lv_tabview_add_tab`. 106 | * @param tab pointer to a tab 107 | */ 108 | void lv_tabview_clean_tab(lv_obj_t * tab); 109 | 110 | /*===================== 111 | * Setter functions 112 | *====================*/ 113 | 114 | /** 115 | * Set a new tab 116 | * @param tabview pointer to Tab view object 117 | * @param id index of a tab to load 118 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 119 | */ 120 | void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t anim); 121 | 122 | /** 123 | * Set the animation time of tab view when a new tab is loaded 124 | * @param tabview pointer to Tab view object 125 | * @param anim_time time of animation in milliseconds 126 | */ 127 | void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time); 128 | 129 | /** 130 | * Set the position of tab select buttons 131 | * @param tabview pointer to a tab view object 132 | * @param btns_pos which button position 133 | */ 134 | void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos); 135 | 136 | /*===================== 137 | * Getter functions 138 | *====================*/ 139 | 140 | /** 141 | * Get the index of the currently active tab 142 | * @param tabview pointer to Tab view object 143 | * @return the active tab index 144 | */ 145 | uint16_t lv_tabview_get_tab_act(const lv_obj_t * tabview); 146 | 147 | /** 148 | * Get the number of tabs 149 | * @param tabview pointer to Tab view object 150 | * @return tab count 151 | */ 152 | uint16_t lv_tabview_get_tab_count(const lv_obj_t * tabview); 153 | /** 154 | * Get the page (content area) of a tab 155 | * @param tabview pointer to Tab view object 156 | * @param id index of the tab (>= 0) 157 | * @return pointer to page (lv_page) object 158 | */ 159 | lv_obj_t * lv_tabview_get_tab(const lv_obj_t * tabview, uint16_t id); 160 | 161 | /** 162 | * Get the animation time of tab view when a new tab is loaded 163 | * @param tabview pointer to Tab view object 164 | * @return time of animation in milliseconds 165 | */ 166 | uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview); 167 | 168 | /** 169 | * Get position of tab select buttons 170 | * @param tabview pointer to a ab view object 171 | */ 172 | lv_tabview_btns_pos_t lv_tabview_get_btns_pos(const lv_obj_t * tabview); 173 | 174 | /********************** 175 | * MACROS 176 | **********************/ 177 | 178 | #endif /*LV_USE_TABVIEW*/ 179 | 180 | #ifdef __cplusplus 181 | } /* extern "C" */ 182 | #endif 183 | 184 | #endif /*LV_TABVIEW_H*/ 185 | -------------------------------------------------------------------------------- /src/lv_widgets/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 | #include "../lv_conf_internal.h" 17 | 18 | #if LV_USE_TILEVIEW != 0 19 | 20 | #include "../lv_widgets/lv_page.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /*Data of tileview*/ 31 | typedef struct { 32 | lv_page_ext_t page; 33 | /*New data for this type */ 34 | const lv_point_t * valid_pos; 35 | uint16_t valid_pos_cnt; 36 | #if LV_USE_ANIMATION 37 | uint16_t anim_time; 38 | #endif 39 | lv_point_t act_id; 40 | uint8_t drag_top_en : 1; 41 | uint8_t drag_bottom_en : 1; 42 | uint8_t drag_left_en : 1; 43 | uint8_t drag_right_en : 1; 44 | } lv_tileview_ext_t; 45 | 46 | /*Parts of the Tileview*/ 47 | enum { 48 | LV_TILEVIEW_PART_BG = LV_PAGE_PART_BG, 49 | LV_TILEVIEW_PART_SCROLLBAR = LV_PAGE_PART_SCROLLBAR, 50 | LV_TILEVIEW_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, 51 | _LV_TILEVIEW_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST, 52 | _LV_TILEVIEW_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST 53 | }; 54 | 55 | /********************** 56 | * GLOBAL PROTOTYPES 57 | **********************/ 58 | 59 | /** 60 | * Create a tileview objects 61 | * @param par pointer to an object, it will be the parent of the new tileview 62 | * @param copy pointer to a tileview object, if not NULL then the new object will be copied from it 63 | * @return pointer to the created tileview 64 | */ 65 | lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy); 66 | 67 | /*====================== 68 | * Add/remove functions 69 | *=====================*/ 70 | 71 | /** 72 | * Register an object on the tileview. The register object will able to slide the tileview 73 | * @param tileview pointer to a Tileview object 74 | * @param element pointer to an object 75 | */ 76 | void lv_tileview_add_element(lv_obj_t * tileview, lv_obj_t * element); 77 | 78 | /*===================== 79 | * Setter functions 80 | *====================*/ 81 | 82 | /** 83 | * Set the valid position's indices. The scrolling will be possible only to these positions. 84 | * @param tileview pointer to a Tileview object 85 | * @param valid_pos array width the indices. E.g. `lv_point_t p[] = {{0,0}, {1,0}, {1,1}`. 86 | * Only the pointer is saved so can't be a local variable. 87 | * @param valid_pos_cnt number of elements in `valid_pos` array 88 | */ 89 | void lv_tileview_set_valid_positions(lv_obj_t * tileview, const lv_point_t valid_pos[], uint16_t valid_pos_cnt); 90 | 91 | /** 92 | * Set the tile to be shown 93 | * @param tileview pointer to a tileview object 94 | * @param x column id (0, 1, 2...) 95 | * @param y line id (0, 1, 2...) 96 | * @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately 97 | */ 98 | void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, lv_anim_enable_t anim); 99 | 100 | /** 101 | * Enable the edge flash effect. (Show an arc when the an edge is reached) 102 | * @param tileview pointer to a Tileview 103 | * @param en true or false to enable/disable end flash 104 | */ 105 | static inline void lv_tileview_set_edge_flash(lv_obj_t * tileview, bool en) 106 | { 107 | lv_page_set_edge_flash(tileview, en); 108 | } 109 | 110 | /** 111 | * Set the animation time for the Tile view 112 | * @param tileview pointer to a page object 113 | * @param anim_time animation time in milliseconds 114 | */ 115 | static inline void lv_tileview_set_anim_time(lv_obj_t * tileview, uint16_t anim_time) 116 | { 117 | lv_page_set_anim_time(tileview, anim_time); 118 | } 119 | 120 | /*===================== 121 | * Getter functions 122 | *====================*/ 123 | /** 124 | * Get the tile to be shown 125 | * @param tileview pointer to a tileview object 126 | * @param x column id (0, 1, 2...) 127 | * @param y line id (0, 1, 2...) 128 | */ 129 | void lv_tileview_get_tile_act(lv_obj_t * tileview, lv_coord_t * x, lv_coord_t * y); 130 | /** 131 | * Get the scroll propagation property 132 | * @param tileview pointer to a Tileview 133 | * @return true or false 134 | */ 135 | static inline bool lv_tileview_get_edge_flash(lv_obj_t * tileview) 136 | { 137 | return lv_page_get_edge_flash(tileview); 138 | } 139 | 140 | /** 141 | * Get the animation time for the Tile view 142 | * @param tileview pointer to a page object 143 | * @return animation time in milliseconds 144 | */ 145 | static inline uint16_t lv_tileview_get_anim_time(lv_obj_t * tileview) 146 | { 147 | return lv_page_get_anim_time(tileview); 148 | } 149 | 150 | /*===================== 151 | * Other functions 152 | *====================*/ 153 | 154 | /********************** 155 | * MACROS 156 | **********************/ 157 | 158 | #endif /*LV_USE_TILEVIEW*/ 159 | 160 | #ifdef __cplusplus 161 | } /* extern "C" */ 162 | #endif 163 | 164 | #endif /*LV_TILEVIEW_H*/ 165 | -------------------------------------------------------------------------------- /src/lv_widgets/lv_widgets.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_arc.c 2 | CSRCS += lv_bar.c 3 | CSRCS += lv_checkbox.c 4 | CSRCS += lv_cpicker.c 5 | CSRCS += lv_dropdown.c 6 | CSRCS += lv_keyboard.c 7 | CSRCS += lv_line.c 8 | CSRCS += lv_msgbox.c 9 | CSRCS += lv_spinner.c 10 | CSRCS += lv_roller.c 11 | CSRCS += lv_table.c 12 | CSRCS += lv_tabview.c 13 | CSRCS += lv_tileview.c 14 | CSRCS += lv_btn.c 15 | CSRCS += lv_calendar.c 16 | CSRCS += lv_chart.c 17 | CSRCS += lv_canvas.c 18 | CSRCS += lv_gauge.c 19 | CSRCS += lv_label.c 20 | CSRCS += lv_list.c 21 | CSRCS += lv_slider.c 22 | CSRCS += lv_textarea.c 23 | CSRCS += lv_spinbox.c 24 | CSRCS += lv_btnmatrix.c 25 | CSRCS += lv_cont.c 26 | CSRCS += lv_img.c 27 | CSRCS += lv_imgbtn.c 28 | CSRCS += lv_led.c 29 | CSRCS += lv_linemeter.c 30 | CSRCS += lv_page.c 31 | CSRCS += lv_switch.c 32 | CSRCS += lv_win.c 33 | CSRCS += lv_objmask.c 34 | 35 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets 36 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets 37 | 38 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/lv_widgets" 39 | -------------------------------------------------------------------------------- /src/lvgl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lvgl.h 3 | * This file exists only to be compatible with Arduino's library structure 4 | */ 5 | 6 | #ifndef LVGL_SRC_H 7 | #define LVGL_SRC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | #include "../lvgl.h" 18 | 19 | /********************* 20 | * DEFINES 21 | *********************/ 22 | 23 | /********************** 24 | * TYPEDEFS 25 | **********************/ 26 | 27 | /********************** 28 | * GLOBAL PROTOTYPES 29 | **********************/ 30 | 31 | /********************** 32 | * MACROS 33 | **********************/ 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /*LVGL_SRC_H*/ 40 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile 3 | # 4 | CC ?= gcc 5 | LVGL_DIR ?= ${shell pwd}/../.. 6 | LVGL_DIR_NAME ?= lvgl 7 | 8 | WARNINGS = -Werror -Wall -Wextra \ 9 | -Wshadow -Wundef -Wmaybe-uninitialized -Wmissing-prototypes -Wpointer-arith -Wuninitialized \ 10 | -Wunreachable-code -Wreturn-type -Wmultichar -Wformat-security -Wdouble-promotion -Wclobbered -Wdeprecated \ 11 | -Wempty-body -Wshift-negative-value -Wstack-usage=2048 \ 12 | -Wtype-limits -Wsizeof-pointer-memaccess 13 | 14 | #-Wno-unused-value -Wno-unused-parameter 15 | OPTIMIZATION ?= -O3 -g0 16 | 17 | 18 | CFLAGS ?= -I$(LVGL_DIR)/ $(DEFINES) $(WARNINGS) $(OPTIMIZATION) -I$(LVGL_DIR) -I. 19 | 20 | LDFLAGS ?= -lpng 21 | BIN ?= demo 22 | 23 | 24 | #Collect the files to compile 25 | MAINSRC = ./lv_test_main.c 26 | 27 | include ../lvgl.mk 28 | 29 | CSRCS += lv_test_assert.c 30 | CSRCS += lv_test_core/lv_test_core.c 31 | CSRCS += lv_test_core/lv_test_obj.c 32 | CSRCS += lv_test_core/lv_test_style.c 33 | 34 | OBJEXT ?= .o 35 | 36 | AOBJS = $(ASRCS:.S=$(OBJEXT)) 37 | COBJS = $(CSRCS:.c=$(OBJEXT)) 38 | 39 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) 40 | 41 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) 42 | OBJS = $(AOBJS) $(COBJS) 43 | 44 | ## MAINOBJ -> OBJFILES 45 | 46 | all: default 47 | 48 | %.o: %.c 49 | @$(CC) $(CFLAGS) -c $< -o $@ 50 | @echo "CC $<" 51 | 52 | default: $(AOBJS) $(COBJS) $(MAINOBJ) 53 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS) 54 | 55 | clean: 56 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) 57 | 58 | -------------------------------------------------------------------------------- /tests/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/tests/icon.png -------------------------------------------------------------------------------- /tests/icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/tests/icon2.png -------------------------------------------------------------------------------- /tests/lv_test_assert.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_assert.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEST_ASSERT_H 7 | #define LV_TEST_ASSERT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include 17 | #include 18 | #include "../lvgl.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | void lv_test_print(const char * s, ...); 33 | void lv_test_exit(const char * s, ...); 34 | void lv_test_error(const char * s, ...); 35 | void lv_test_assert_int_eq(int32_t n1, int32_t n2, const char * s); 36 | void lv_test_assert_int_gt(int32_t n_ref, int32_t n_act, const char * s); 37 | void lv_test_assert_int_lt(int32_t n_ref, int32_t n_act, const char * s); 38 | void lv_test_assert_str_eq(const char * str1, const char * str2, const char * s); 39 | void lv_test_assert_ptr_eq(const void * p_ref, const void * p_act, const char * s); 40 | void lv_test_assert_color_eq(lv_color_t c_ref, lv_color_t c_act, const char * s); 41 | void lv_test_assert_img_eq(const char * ref_img_fn, const char * s); 42 | 43 | /********************** 44 | * MACROS 45 | **********************/ 46 | 47 | #ifdef __cplusplus 48 | } /* extern "C" */ 49 | #endif 50 | 51 | #endif /*LV_TEST_ASSERT_H*/ 52 | -------------------------------------------------------------------------------- /tests/lv_test_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_conf.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEST_CONF_H 7 | #define LV_TEST_CONF_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 | uint32_t custom_tick_get(void); 26 | #define LV_TICK_CUSTOM_SYS_TIME_EXPR custom_tick_get() 27 | 28 | typedef int16_t lv_coord_t; 29 | typedef void * lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ 30 | typedef void * lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ 31 | typedef void * lv_font_user_data_t; 32 | typedef void * lv_obj_user_data_t; 33 | typedef void * lv_anim_user_data_t; 34 | typedef void * lv_group_user_data_t; 35 | typedef void * lv_fs_drv_user_data_t; 36 | typedef void * lv_img_decoder_user_data_t; 37 | 38 | /********************** 39 | * GLOBAL PROTOTYPES 40 | **********************/ 41 | 42 | /********************** 43 | * MACROS 44 | **********************/ 45 | 46 | #ifdef __cplusplus 47 | } /* extern "C" */ 48 | #endif 49 | 50 | #endif /*LV_TEST_CONF_H*/ 51 | -------------------------------------------------------------------------------- /tests/lv_test_core/lv_test_core.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_core.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "../lv_test_assert.h" 10 | 11 | #if LV_BUILD_TEST 12 | #include "lv_test_core.h" 13 | #include "lv_test_obj.h" 14 | #include "lv_test_style.h" 15 | 16 | /********************* 17 | * DEFINES 18 | *********************/ 19 | 20 | /********************** 21 | * TYPEDEFS 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC PROTOTYPES 26 | **********************/ 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL FUNCTIONS 38 | **********************/ 39 | 40 | void lv_test_core(void) 41 | { 42 | lv_test_print(""); 43 | lv_test_print("*******************"); 44 | lv_test_print("Start lv_core tests"); 45 | lv_test_print("*******************"); 46 | 47 | lv_test_obj(); 48 | lv_test_style(); 49 | } 50 | 51 | 52 | /********************** 53 | * STATIC FUNCTIONS 54 | **********************/ 55 | #endif 56 | -------------------------------------------------------------------------------- /tests/lv_test_core/lv_test_core.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_core.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEST_CORE_H 7 | #define LV_TEST_CORE_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 | void lv_test_core(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_TEST_CORE_H*/ 39 | -------------------------------------------------------------------------------- /tests/lv_test_core/lv_test_obj.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_obj.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "../../lvgl.h" 10 | #include "../lv_test_assert.h" 11 | #include "lv_test_obj.h" 12 | 13 | #if LV_BUILD_TEST 14 | 15 | /********************* 16 | * DEFINES 17 | *********************/ 18 | 19 | /********************** 20 | * TYPEDEFS 21 | **********************/ 22 | 23 | /********************** 24 | * STATIC PROTOTYPES 25 | **********************/ 26 | static void create_delete_change_parent(void); 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL FUNCTIONS 38 | **********************/ 39 | 40 | void lv_test_obj(void) 41 | { 42 | lv_test_print(""); 43 | lv_test_print("=================="); 44 | lv_test_print("Start lv_obj tests"); 45 | lv_test_print("=================="); 46 | 47 | create_delete_change_parent(); 48 | } 49 | 50 | 51 | /********************** 52 | * STATIC FUNCTIONS 53 | **********************/ 54 | 55 | static void create_delete_change_parent(void) 56 | { 57 | 58 | lv_test_print(""); 59 | lv_test_print("Create, delete, change parent of a simple object:"); 60 | lv_test_print("-------------------------------------------------"); 61 | 62 | 63 | lv_test_print("Create an object on the default screen"); 64 | lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count before creation"); 65 | 66 | lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL); 67 | lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); 68 | lv_test_assert_int_eq(0, lv_obj_count_children(obj), "New object's children count after creation"); 69 | 70 | lv_test_print("Delete the created object"); 71 | lv_obj_del(obj); 72 | obj = NULL; 73 | lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete"); 74 | 75 | lv_test_print("Create two objects"); 76 | lv_obj_t * obj_parent = lv_obj_create(lv_scr_act(), NULL); 77 | lv_obj_t * obj_child = lv_obj_create(lv_scr_act(), NULL); 78 | lv_test_assert_int_eq(2, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); 79 | 80 | lv_test_print("Change the parent of the second object to the first"); 81 | lv_obj_set_parent(obj_child, obj_parent); 82 | lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after parent change"); 83 | lv_test_assert_int_eq(1, lv_obj_count_children(obj_parent), "Parent object's children count after parent change"); 84 | lv_test_assert_int_eq(0, lv_obj_count_children(obj_child), "Child object's children count after parent change"); 85 | 86 | lv_test_print("Remove the parent object"); 87 | lv_obj_del(obj_parent); 88 | lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete"); 89 | } 90 | #endif 91 | -------------------------------------------------------------------------------- /tests/lv_test_core/lv_test_obj.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_obj.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEST_OBJ_H 7 | #define LV_TEST_OBJ_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 | void lv_test_obj(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_TEST_OBJ_H*/ 39 | -------------------------------------------------------------------------------- /tests/lv_test_core/lv_test_style.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_style.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEST_STYLE_H 7 | #define LV_TEST_STYLE_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 | void lv_test_style(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_TEST_STYLE_H*/ 39 | -------------------------------------------------------------------------------- /tests/lv_test_main.c: -------------------------------------------------------------------------------- 1 | #include "../lvgl.h" 2 | #include 3 | #include 4 | #include 5 | #include "lv_test_core/lv_test_core.h" 6 | 7 | #if LV_BUILD_TEST 8 | 9 | static void hal_init(void); 10 | static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); 11 | 12 | int main(void) 13 | { 14 | printf("Call lv_init...\n"); 15 | lv_init(); 16 | 17 | hal_init(); 18 | 19 | lv_test_core(); 20 | 21 | printf("Exit with success!\n"); 22 | return 0; 23 | } 24 | 25 | 26 | static void hal_init(void) 27 | { 28 | static lv_disp_buf_t disp_buf; 29 | lv_color_t * disp_buf1 = (lv_color_t *)malloc(LV_HOR_RES * LV_VER_RES * sizeof(lv_color_t)); 30 | 31 | lv_disp_buf_init(&disp_buf, disp_buf1, NULL, LV_HOR_RES* LV_VER_RES); 32 | 33 | lv_disp_drv_t disp_drv; 34 | lv_disp_drv_init(&disp_drv); 35 | disp_drv.buffer = &disp_buf; 36 | disp_drv.flush_cb = dummy_flush_cb; 37 | lv_disp_drv_register(&disp_drv); 38 | } 39 | 40 | 41 | static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p) 42 | { 43 | LV_UNUSED(area); 44 | LV_UNUSED(color_p); 45 | lv_disp_flush_ready(disp_drv); 46 | } 47 | 48 | uint32_t custom_tick_get(void) 49 | { 50 | static uint64_t start_ms = 0; 51 | if(start_ms == 0) { 52 | struct timeval tv_start; 53 | gettimeofday(&tv_start, NULL); 54 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000; 55 | } 56 | 57 | struct timeval tv_now; 58 | gettimeofday(&tv_now, NULL); 59 | uint64_t now_ms; 60 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000; 61 | 62 | uint32_t time_ms = now_ms - start_ms; 63 | return time_ms; 64 | } 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /tests/lv_test_objx/lv_test_cont.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_cont.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | #include "../../lvgl.h" 10 | #include "../lv_test_assert.h" 11 | 12 | #if LV_BUILD_TEST 13 | 14 | 15 | /********************* 16 | * DEFINES 17 | *********************/ 18 | 19 | /********************** 20 | * TYPEDEFS 21 | **********************/ 22 | 23 | /********************** 24 | * STATIC PROTOTYPES 25 | **********************/ 26 | static void create_copy(void); 27 | 28 | /********************** 29 | * STATIC VARIABLES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | /********************** 37 | * GLOBAL FUNCTIONS 38 | **********************/ 39 | 40 | void lv_test_cont(void) 41 | { 42 | lv_test_print(""); 43 | lv_test_print("==================="); 44 | lv_test_print("Start lv_cont tests"); 45 | lv_test_print("==================="); 46 | 47 | create_copy(); 48 | } 49 | 50 | 51 | /********************** 52 | * STATIC FUNCTIONS 53 | **********************/ 54 | 55 | static void create_copy(void) 56 | { 57 | lv_test_print(""); 58 | lv_test_print("Create and copy a container"); 59 | lv_test_print("---------------------------"); 60 | 61 | lv_test_print("Create a container"); 62 | lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count before creation"); 63 | 64 | lv_obj_t * obj = lv_cont_create(lv_scr_act(), NULL); 65 | lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation"); 66 | 67 | lv_test_print("Test the default values"); 68 | lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_left(obj), "Default left fit"); 69 | lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_right(obj), "Default right fit"); 70 | lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_top(obj), "Default top fit"); 71 | lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_bottom(obj), "Default bottom fit"); 72 | lv_test_assert_int_eq(LV_LAYOUT_OFF, lv_cont_get_layout(obj), "Default layout"); 73 | 74 | lv_test_print("Delete the container"); 75 | lv_obj_del(obj); 76 | obj = NULL; 77 | lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete"); 78 | 79 | } 80 | #endif 81 | -------------------------------------------------------------------------------- /tests/lv_test_objx/lv_test_cont.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_test_obj.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEST_CONT_H 7 | #define LV_TEST_CONT_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 | void lv_test_cont(void); 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_TEST_CONT_H*/ 39 | -------------------------------------------------------------------------------- /tests/lv_test_ref_imgs/lv_test_obj_1_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lupyuen/lvgl-wayland/4208ca7f3ff4f2bf409e979b2c2c464957418bab/tests/lv_test_ref_imgs/lv_test_obj_1_1.png -------------------------------------------------------------------------------- /wayland/lv_port_disp.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 1 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.h" 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | 33 | void lv_port_disp_init(void); 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | 39 | 40 | #ifdef __cplusplus 41 | } /* extern "C" */ 42 | #endif 43 | 44 | #endif /*LV_PORT_DISP_TEMPL_H*/ 45 | 46 | #endif /*Disable/Enable content*/ 47 | -------------------------------------------------------------------------------- /wayland/lvgl.sh: -------------------------------------------------------------------------------- 1 | # Build and install Wayland EGL app 2 | 3 | # TODO: Install GLES2 library 4 | # sudo apt install libgles2-mesa-dev 5 | 6 | # Kill the app if it's already running 7 | pkill lvgl 8 | 9 | # Stop the script on error, echo all commands 10 | set -e -x 11 | 12 | # Build app 13 | make 14 | 15 | # Make system folders writeable 16 | sudo mount -o remount,rw / 17 | 18 | # Copy app to File Manager folder 19 | cd wayland 20 | sudo cp lvgl /usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager 21 | 22 | # Copy run script to File Manager folder 23 | # TODO: Check that run.sh contains "./lvgl" 24 | sudo cp run.sh /usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager 25 | 26 | # Set ownership on the app and the run script 27 | sudo chown clickpkg:clickpkg /usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager/lvgl 28 | sudo chown clickpkg:clickpkg /usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager/run.sh 29 | ls -l /usr/share/click/preinstalled/.click/users/@all/com.ubuntu.filemanager/lvgl 30 | 31 | # Start the File Manager 32 | echo "*** Tap on File Manager icon on PinePhone" 33 | 34 | # Monitor the log file 35 | echo >/home/phablet/.cache/upstart/application-click-com.ubuntu.filemanager_filemanager_0.7.5.log 36 | tail -f /home/phablet/.cache/upstart/application-click-com.ubuntu.filemanager_filemanager_0.7.5.log 37 | 38 | # Press Ctrl-C to stop. To kill the app: 39 | # pkill lvgl 40 | -------------------------------------------------------------------------------- /wayland/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Log Wayland messages 4 | export WAYLAND_DEBUG=1 5 | 6 | # Run lvgl app 7 | # ./lvgl 8 | 9 | # Run lvgl app with strace 10 | # ./strace \ 11 | # -s 1024 \ 12 | # ./lvgl 13 | 14 | # Debug lvgl app 15 | gdb \ 16 | -ex="r" \ 17 | -ex="bt" \ 18 | -ex="frame" \ 19 | --args ./lvgl 20 | -------------------------------------------------------------------------------- /wayland/shader.c: -------------------------------------------------------------------------------- 1 | // From https://github.com/danginsburg/opengles-book-samples/blob/master/LinuxX11/Common/esShader.c 2 | // Book: OpenGL(R) ES 2.0 Programming Guide 3 | // Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner 4 | // ISBN-10: 0321502795 5 | // ISBN-13: 9780321502797 6 | // Publisher: Addison-Wesley Professional 7 | // URLs: http://safari.informit.com/9780321563835 8 | // http://www.opengles-book.com 9 | // 10 | 11 | // ESShader.c 12 | // 13 | // Utility functions for loading shaders and creating program objects. 14 | // 15 | 16 | /// 17 | // Includes 18 | // 19 | #include "util.h" 20 | #include 21 | 22 | ////////////////////////////////////////////////////////////////// 23 | // 24 | // Private Functions 25 | // 26 | // 27 | 28 | 29 | 30 | ////////////////////////////////////////////////////////////////// 31 | // 32 | // Public Functions 33 | // 34 | // 35 | 36 | // 37 | /// 38 | /// \brief Load a shader, check for compile errors, print error messages to output log 39 | /// \param type Type of shader (GL_VERTEX_SHADER or GL_FRAGMENT_SHADER) 40 | /// \param shaderSrc Shader source string 41 | /// \return A new shader object on success, 0 on failure 42 | // 43 | GLuint ESUTIL_API esLoadShader ( GLenum type, const char *shaderSrc ) 44 | { 45 | GLuint shader; 46 | GLint compiled; 47 | 48 | // Create the shader object 49 | shader = glCreateShader ( type ); 50 | 51 | if ( shader == 0 ) 52 | return 0; 53 | 54 | // Load the shader source 55 | glShaderSource ( shader, 1, &shaderSrc, NULL ); 56 | 57 | // Compile the shader 58 | glCompileShader ( shader ); 59 | 60 | // Check the compile status 61 | glGetShaderiv ( shader, GL_COMPILE_STATUS, &compiled ); 62 | 63 | if ( !compiled ) 64 | { 65 | GLint infoLen = 0; 66 | 67 | glGetShaderiv ( shader, GL_INFO_LOG_LENGTH, &infoLen ); 68 | 69 | if ( infoLen > 1 ) 70 | { 71 | char* infoLog = malloc (sizeof(char) * infoLen ); 72 | 73 | glGetShaderInfoLog ( shader, infoLen, NULL, infoLog ); 74 | esLogMessage ( "Error compiling shader:\n%s\n", infoLog ); 75 | 76 | free ( infoLog ); 77 | } 78 | 79 | glDeleteShader ( shader ); 80 | return 0; 81 | } 82 | 83 | return shader; 84 | 85 | } 86 | 87 | 88 | // 89 | /// 90 | /// \brief Load a vertex and fragment shader, create a program object, link program. 91 | // Errors output to log. 92 | /// \param vertShaderSrc Vertex shader source code 93 | /// \param fragShaderSrc Fragment shader source code 94 | /// \return A new program object linked with the vertex/fragment shader pair, 0 on failure 95 | // 96 | GLuint ESUTIL_API esLoadProgram ( const char *vertShaderSrc, const char *fragShaderSrc ) 97 | { 98 | GLuint vertexShader; 99 | GLuint fragmentShader; 100 | GLuint programObject; 101 | GLint linked; 102 | 103 | // Load the vertex/fragment shaders 104 | vertexShader = esLoadShader ( GL_VERTEX_SHADER, vertShaderSrc ); 105 | if ( vertexShader == 0 ) 106 | return 0; 107 | 108 | fragmentShader = esLoadShader ( GL_FRAGMENT_SHADER, fragShaderSrc ); 109 | if ( fragmentShader == 0 ) 110 | { 111 | glDeleteShader( vertexShader ); 112 | return 0; 113 | } 114 | 115 | // Create the program object 116 | programObject = glCreateProgram ( ); 117 | 118 | if ( programObject == 0 ) 119 | return 0; 120 | 121 | glAttachShader ( programObject, vertexShader ); 122 | glAttachShader ( programObject, fragmentShader ); 123 | 124 | // Link the program 125 | glLinkProgram ( programObject ); 126 | 127 | // Check the link status 128 | glGetProgramiv ( programObject, GL_LINK_STATUS, &linked ); 129 | 130 | if ( !linked ) 131 | { 132 | GLint infoLen = 0; 133 | 134 | glGetProgramiv ( programObject, GL_INFO_LOG_LENGTH, &infoLen ); 135 | 136 | if ( infoLen > 1 ) 137 | { 138 | char* infoLog = malloc (sizeof(char) * infoLen ); 139 | 140 | glGetProgramInfoLog ( programObject, infoLen, NULL, infoLog ); 141 | esLogMessage ( "Error linking program:\n%s\n", infoLog ); 142 | 143 | free ( infoLog ); 144 | } 145 | 146 | glDeleteProgram ( programObject ); 147 | return 0; 148 | } 149 | 150 | // Free up no longer needed shader resources 151 | glDeleteShader ( vertexShader ); 152 | glDeleteShader ( fragmentShader ); 153 | 154 | return programObject; 155 | } --------------------------------------------------------------------------------