├── .gitignore
├── .vscode
├── c_cpp_properties.json
└── settings.json
├── LICENSE
├── README.md
├── build.zig
├── clib
├── lvgl
│ ├── lv_conf.h
│ ├── lvgl.h
│ └── src
│ │ ├── core
│ │ ├── lv_core.mk
│ │ ├── lv_disp.c
│ │ ├── lv_disp.h
│ │ ├── lv_event.c
│ │ ├── lv_event.h
│ │ ├── lv_group.c
│ │ ├── lv_group.h
│ │ ├── lv_indev.c
│ │ ├── lv_indev.h
│ │ ├── lv_indev_scroll.c
│ │ ├── lv_indev_scroll.h
│ │ ├── lv_obj.c
│ │ ├── lv_obj.h
│ │ ├── lv_obj_class.c
│ │ ├── lv_obj_class.h
│ │ ├── lv_obj_draw.c
│ │ ├── lv_obj_draw.h
│ │ ├── lv_obj_pos.c
│ │ ├── lv_obj_pos.h
│ │ ├── lv_obj_scroll.c
│ │ ├── lv_obj_scroll.h
│ │ ├── lv_obj_style.c
│ │ ├── lv_obj_style.h
│ │ ├── lv_obj_style_gen.c
│ │ ├── lv_obj_style_gen.h
│ │ ├── lv_obj_tree.c
│ │ ├── lv_obj_tree.h
│ │ ├── lv_refr.c
│ │ ├── lv_refr.h
│ │ ├── lv_theme.c
│ │ └── lv_theme.h
│ │ ├── draw
│ │ ├── lv_draw.c
│ │ ├── lv_draw.h
│ │ ├── lv_draw.mk
│ │ ├── lv_draw_arc.c
│ │ ├── lv_draw_arc.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
│ │ ├── nxp_pxp
│ │ │ ├── lv_gpu_nxp_pxp.c
│ │ │ ├── lv_gpu_nxp_pxp.h
│ │ │ ├── lv_gpu_nxp_pxp_osa.c
│ │ │ └── lv_gpu_nxp_pxp_osa.h
│ │ ├── nxp_vglite
│ │ │ ├── lv_gpu_nxp_vglite.c
│ │ │ └── lv_gpu_nxp_vglite.h
│ │ ├── sdl
│ │ │ ├── README.md
│ │ │ ├── lv_draw_sdl.c
│ │ │ ├── lv_draw_sdl.h
│ │ │ ├── lv_draw_sdl.mk
│ │ │ ├── lv_draw_sdl_arc.c
│ │ │ ├── lv_draw_sdl_bg.c
│ │ │ ├── lv_draw_sdl_composite.c
│ │ │ ├── lv_draw_sdl_composite.h
│ │ │ ├── lv_draw_sdl_img.c
│ │ │ ├── lv_draw_sdl_img.h
│ │ │ ├── lv_draw_sdl_label.c
│ │ │ ├── lv_draw_sdl_line.c
│ │ │ ├── lv_draw_sdl_mask.c
│ │ │ ├── lv_draw_sdl_mask.h
│ │ │ ├── lv_draw_sdl_polygon.c
│ │ │ ├── lv_draw_sdl_priv.h
│ │ │ ├── lv_draw_sdl_rect.c
│ │ │ ├── lv_draw_sdl_rect.h
│ │ │ ├── lv_draw_sdl_stack_blur.c
│ │ │ ├── lv_draw_sdl_stack_blur.h
│ │ │ ├── lv_draw_sdl_texture_cache.c
│ │ │ ├── lv_draw_sdl_texture_cache.h
│ │ │ ├── lv_draw_sdl_utils.c
│ │ │ └── lv_draw_sdl_utils.h
│ │ ├── stm32_dma2d
│ │ │ ├── lv_gpu_stm32_dma2d.c
│ │ │ └── lv_gpu_stm32_dma2d.h
│ │ └── sw
│ │ │ ├── lv_draw_sw.c
│ │ │ ├── lv_draw_sw.h
│ │ │ ├── lv_draw_sw.mk
│ │ │ ├── lv_draw_sw_arc.c
│ │ │ ├── lv_draw_sw_blend.c
│ │ │ ├── lv_draw_sw_blend.h
│ │ │ ├── lv_draw_sw_dither.c
│ │ │ ├── lv_draw_sw_dither.h
│ │ │ ├── lv_draw_sw_gradient.c
│ │ │ ├── lv_draw_sw_gradient.h
│ │ │ ├── lv_draw_sw_img.c
│ │ │ ├── lv_draw_sw_letter.c
│ │ │ ├── lv_draw_sw_line.c
│ │ │ ├── lv_draw_sw_polygon.c
│ │ │ └── lv_draw_sw_rect.c
│ │ ├── extra
│ │ ├── README.md
│ │ ├── extra.mk
│ │ ├── layouts
│ │ │ ├── flex
│ │ │ │ ├── lv_flex.c
│ │ │ │ └── lv_flex.h
│ │ │ ├── grid
│ │ │ │ ├── lv_grid.c
│ │ │ │ └── lv_grid.h
│ │ │ └── lv_layouts.h
│ │ ├── libs
│ │ │ ├── bmp
│ │ │ │ ├── lv_bmp.c
│ │ │ │ └── lv_bmp.h
│ │ │ ├── ffmpeg
│ │ │ │ ├── lv_ffmpeg.c
│ │ │ │ └── lv_ffmpeg.h
│ │ │ ├── freetype
│ │ │ │ ├── arial.ttf
│ │ │ │ ├── lv_freetype.c
│ │ │ │ └── lv_freetype.h
│ │ │ ├── fsdrv
│ │ │ │ ├── lv_fs_fatfs.c
│ │ │ │ ├── lv_fs_posix.c
│ │ │ │ ├── lv_fs_stdio.c
│ │ │ │ ├── lv_fs_win32.c
│ │ │ │ └── lv_fsdrv.h
│ │ │ ├── gif
│ │ │ │ ├── gifdec.c
│ │ │ │ ├── gifdec.h
│ │ │ │ ├── lv_gif.c
│ │ │ │ └── lv_gif.h
│ │ │ ├── lv_libs.h
│ │ │ ├── png
│ │ │ │ ├── lodepng.c
│ │ │ │ ├── lodepng.h
│ │ │ │ ├── lv_png.c
│ │ │ │ └── lv_png.h
│ │ │ ├── qrcode
│ │ │ │ ├── lv_qrcode.c
│ │ │ │ ├── lv_qrcode.h
│ │ │ │ ├── qrcodegen.c
│ │ │ │ └── qrcodegen.h
│ │ │ ├── rlottie
│ │ │ │ ├── lv_rlottie.c
│ │ │ │ └── lv_rlottie.h
│ │ │ └── sjpg
│ │ │ │ ├── lv_sjpg.c
│ │ │ │ ├── lv_sjpg.h
│ │ │ │ ├── tjpgd.c
│ │ │ │ ├── tjpgd.h
│ │ │ │ └── tjpgdcnf.h
│ │ ├── lv_extra.c
│ │ ├── lv_extra.h
│ │ ├── others
│ │ │ ├── gridnav
│ │ │ │ ├── lv_gridnav.c
│ │ │ │ └── lv_gridnav.h
│ │ │ ├── lv_others.h
│ │ │ ├── monkey
│ │ │ │ ├── lv_monkey.c
│ │ │ │ └── lv_monkey.h
│ │ │ └── snapshot
│ │ │ │ ├── lv_snapshot.c
│ │ │ │ └── lv_snapshot.h
│ │ ├── themes
│ │ │ ├── basic
│ │ │ │ ├── lv_theme_basic.c
│ │ │ │ └── lv_theme_basic.h
│ │ │ ├── default
│ │ │ │ ├── lv_theme_default.c
│ │ │ │ └── lv_theme_default.h
│ │ │ ├── lv_themes.h
│ │ │ └── mono
│ │ │ │ ├── lv_theme_mono.c
│ │ │ │ └── lv_theme_mono.h
│ │ └── widgets
│ │ │ ├── animimg
│ │ │ ├── lv_animimg.c
│ │ │ └── lv_animimg.h
│ │ │ ├── calendar
│ │ │ ├── lv_calendar.c
│ │ │ ├── lv_calendar.h
│ │ │ ├── lv_calendar_header_arrow.c
│ │ │ ├── lv_calendar_header_arrow.h
│ │ │ ├── lv_calendar_header_dropdown.c
│ │ │ └── lv_calendar_header_dropdown.h
│ │ │ ├── chart
│ │ │ ├── lv_chart.c
│ │ │ └── lv_chart.h
│ │ │ ├── colorwheel
│ │ │ ├── lv_colorwheel.c
│ │ │ └── lv_colorwheel.h
│ │ │ ├── imgbtn
│ │ │ ├── lv_imgbtn.c
│ │ │ └── lv_imgbtn.h
│ │ │ ├── keyboard
│ │ │ ├── lv_keyboard.c
│ │ │ └── lv_keyboard.h
│ │ │ ├── led
│ │ │ ├── lv_led.c
│ │ │ └── lv_led.h
│ │ │ ├── list
│ │ │ ├── lv_list.c
│ │ │ └── lv_list.h
│ │ │ ├── lv_widgets.h
│ │ │ ├── menu
│ │ │ ├── lv_menu.c
│ │ │ └── lv_menu.h
│ │ │ ├── meter
│ │ │ ├── lv_meter.c
│ │ │ └── lv_meter.h
│ │ │ ├── msgbox
│ │ │ ├── lv_msgbox.c
│ │ │ └── lv_msgbox.h
│ │ │ ├── span
│ │ │ ├── lv_span.c
│ │ │ └── lv_span.h
│ │ │ ├── spinbox
│ │ │ ├── lv_spinbox.c
│ │ │ └── lv_spinbox.h
│ │ │ ├── spinner
│ │ │ ├── lv_spinner.c
│ │ │ └── lv_spinner.h
│ │ │ ├── tabview
│ │ │ ├── lv_tabview.c
│ │ │ └── lv_tabview.h
│ │ │ ├── tileview
│ │ │ ├── lv_tileview.c
│ │ │ └── lv_tileview.h
│ │ │ └── win
│ │ │ ├── lv_win.c
│ │ │ └── lv_win.h
│ │ ├── font
│ │ ├── korean.ttf
│ │ ├── 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_loader.c
│ │ ├── lv_font_loader.h
│ │ ├── lv_font_montserrat_10.c
│ │ ├── 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_montserrat_8.c
│ │ ├── lv_font_simsun_16_cjk.c
│ │ ├── lv_font_unscii_16.c
│ │ ├── lv_font_unscii_8.c
│ │ └── lv_symbol_def.h
│ │ ├── gpu
│ │ └── lv_gpu.mk
│ │ ├── 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_api_map.h
│ │ ├── lv_conf_internal.h
│ │ ├── lv_conf_kconfig.h
│ │ ├── lvgl.h
│ │ ├── misc
│ │ ├── lv_anim.c
│ │ ├── lv_anim.h
│ │ ├── lv_anim_timeline.c
│ │ ├── lv_anim_timeline.h
│ │ ├── lv_area.c
│ │ ├── lv_area.h
│ │ ├── lv_assert.h
│ │ ├── lv_async.c
│ │ ├── lv_async.h
│ │ ├── lv_bidi.c
│ │ ├── lv_bidi.h
│ │ ├── lv_color.c
│ │ ├── lv_color.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_lru.c
│ │ ├── lv_lru.h
│ │ ├── lv_math.c
│ │ ├── lv_math.h
│ │ ├── lv_mem.c
│ │ ├── lv_mem.h
│ │ ├── lv_misc.mk
│ │ ├── lv_printf.c
│ │ ├── lv_printf.h
│ │ ├── lv_style.c
│ │ ├── lv_style.h
│ │ ├── lv_style_gen.c
│ │ ├── lv_style_gen.h
│ │ ├── lv_templ.c
│ │ ├── lv_templ.h
│ │ ├── lv_timer.c
│ │ ├── lv_timer.h
│ │ ├── lv_tlsf.c
│ │ ├── lv_tlsf.h
│ │ ├── lv_txt.c
│ │ ├── lv_txt.h
│ │ ├── lv_txt_ap.c
│ │ ├── lv_txt_ap.h
│ │ ├── lv_types.h
│ │ ├── lv_utils.c
│ │ └── lv_utils.h
│ │ └── 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_canvas.c
│ │ ├── lv_canvas.h
│ │ ├── lv_checkbox.c
│ │ ├── lv_checkbox.h
│ │ ├── lv_dropdown.c
│ │ ├── lv_dropdown.h
│ │ ├── lv_img.c
│ │ ├── lv_img.h
│ │ ├── lv_label.c
│ │ ├── lv_label.h
│ │ ├── lv_line.c
│ │ ├── lv_line.h
│ │ ├── lv_objx_templ.c
│ │ ├── lv_objx_templ.h
│ │ ├── lv_roller.c
│ │ ├── lv_roller.h
│ │ ├── lv_slider.c
│ │ ├── lv_slider.h
│ │ ├── lv_switch.c
│ │ ├── lv_switch.h
│ │ ├── lv_table.c
│ │ ├── lv_table.h
│ │ ├── lv_textarea.c
│ │ ├── lv_textarea.h
│ │ └── lv_widgets.mk
├── lvgl_drv
│ ├── lv_port_disp.h
│ ├── lv_port_indev.c
│ ├── lv_port_indev.h
│ ├── lv_sdl_disp.c
│ └── lv_xbox_disp.c
├── mingw-w64-winpthreads
│ ├── include
│ │ ├── pthread.h
│ │ ├── pthread_compat.h
│ │ ├── pthread_signal.h
│ │ ├── pthread_time.h
│ │ ├── pthread_unistd.h
│ │ ├── sched.h
│ │ └── semaphore.h
│ └── lib
│ │ ├── libpthread.a
│ │ ├── libpthread.dll.a
│ │ ├── libwinpthread.a
│ │ └── libwinpthread.dll.a
└── quickjs
│ ├── LICENSE
│ ├── cutils.c
│ ├── cutils.h
│ ├── hello.c
│ ├── libbf.c
│ ├── libbf.h
│ ├── libregexp-opcode.h
│ ├── libregexp.c
│ ├── libregexp.h
│ ├── libunicode-table.h
│ ├── libunicode.c
│ ├── libunicode.h
│ ├── list.h
│ ├── quickjs-atom.h
│ ├── quickjs-libc.c
│ ├── quickjs-libc.h
│ ├── quickjs-opcode.h
│ ├── quickjs.c
│ ├── quickjs.h
│ └── unicode_gen_def.h
├── demo
└── app.jsx
├── error.log
├── jslib
├── build.mjs
├── demo.html
├── dom.mjs
├── flex.mjs
└── polyfill.mjs
├── package.json
├── pnpm-lock.yaml
└── src
├── asset
└── Sans.ttf
├── component
├── button.zig
├── image.zig
├── input.zig
├── text.zig
└── view.zig
├── dummy.zig
├── flex.zig
├── jsapi
└── fetch.zig
├── lv.zig
├── lvgl.zig
├── main.zig
├── qjs.zig
├── render.zig
└── sdl.zig
/.gitignore:
--------------------------------------------------------------------------------
1 | **/node_modules
2 | node_modules/
3 | zig-out/
4 | zig-cache/
5 | dist/
6 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Win32",
5 | "includePath": [
6 | "${workspaceFolder}/**",
7 | "D:\\SDL2_2.28.4\\x86_64-w64-mingw32\\include"
8 | ],
9 | "defines": [
10 | "_DEBUG",
11 | "UNICODE",
12 | "_UNICODE"
13 | ],
14 | "compilerPath": "D:\\QRS\\VScode\\cygwin64\\bin\\gcc.exe",
15 | "cStandard": "c17",
16 | "cppStandard": "gnu++14",
17 | "intelliSenseMode": "linux-gcc-x64"
18 | }
19 | ],
20 | "version": 4
21 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.associations": {
3 | "*.zig": "zig",
4 | "*.sln": "cpp",
5 | "lvgl.h": "c",
6 | "lv_port_disp.h": "c",
7 | "sdl.h": "c"
8 | }
9 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2022, Necha Contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Homo
2 | > Lightweight Rendering engine similar to Harmony, but use Fre and quickjs
3 |
4 | *It was also called Fre native!*
5 |
6 | - Javascript Runtime with [Zig](https://github.com/ziglang/zig) and [quickjs](https://github.com/bellard/quickjs)
7 | - UI framework use [Fre.js](https://github.com/frejs/fre)
8 | - Graphics Library use [LVGL](https://github.com/lvgl/lvgl)
9 | - Event loop and Event bubbling
10 | - DOM diff and Flex layout alghrithom
11 | - cross-compilation with Zig
12 |
13 | ### Usage
14 |
15 | ```js
16 | import { render, useState } from "fre"
17 |
18 | function App() {
19 | const [count, setCount] = useState(0)
20 | const add = () => {
21 | console.log('u clicked a button')
22 | setCount(count + 1)
23 | }
24 | return (
25 |
26 | {count}
27 |
28 | )
29 | }
30 | render(, document.body)
31 | ```
32 |
33 | ### Run demo
34 |
35 | ```js
36 | zig build
37 | ./zig-out/bin/fre.exe dist/app.js
38 | ```
39 | 
40 |
41 | ### 说人话
42 |
43 | Homo 是一个小型渲染引擎,它和鸿蒙、flutter等拥有类似的架构,只不过使用 quickjs 和 fre 而已
44 |
45 | 它甚至完整演示了浏览器的运行过程,包括 `eval fre code => dom diff => flex layout => event loop => event bubbling`
46 |
47 | 和鸿蒙不同的是,Homo 更贴近 web 子集,而且 homo 的编译链路非常流畅,zig 交叉编译quickjs,特别适合前端er 学习研究
48 |
49 | 另外,homo 未来如果要上生产,嵌入式是一个研究方向,手表,手环等,fre 拥有最小的尺寸
50 |
51 | 虽然理论上它仍然可以交叉编译到安卓,但是我建议大家还是使用 flutter,因为 flutter 的完成度是个奇迹
52 |
53 | 另外一个方向是,我会研究将 homo 编译到 ue 和 unity,但那就是另外一个故事了
54 |
55 | 总之大家,这是我在前端的最后一个开源坑了,来年其他领域再贱
--------------------------------------------------------------------------------
/clib/lvgl/src/core/lv_core.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_disp.c
2 | CSRCS += lv_group.c
3 | CSRCS += lv_indev.c
4 | CSRCS += lv_indev_scroll.c
5 | CSRCS += lv_obj.c
6 | CSRCS += lv_obj_class.c
7 | CSRCS += lv_obj_draw.c
8 | CSRCS += lv_obj_pos.c
9 | CSRCS += lv_obj_scroll.c
10 | CSRCS += lv_obj_style.c
11 | CSRCS += lv_obj_style_gen.c
12 | CSRCS += lv_obj_tree.c
13 | CSRCS += lv_event.c
14 | CSRCS += lv_refr.c
15 | CSRCS += lv_theme.c
16 |
17 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core
18 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core
19 |
20 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core"
21 |
--------------------------------------------------------------------------------
/clib/lvgl/src/core/lv_indev_scroll.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_indev_scroll.h
3 | *
4 | */
5 |
6 | #ifndef LV_INDEV_SCROLL_H
7 | #define LV_INDEV_SCROLL_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "lv_obj.h"
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 |
26 | /**********************
27 | * GLOBAL PROTOTYPES
28 | **********************/
29 |
30 | /**
31 | * Handle scrolling. Called by LVGL during input device processing
32 | * @param proc pointer to an input device's proc field
33 | */
34 | void _lv_indev_scroll_handler(_lv_indev_proc_t * proc);
35 |
36 | /**
37 | * Handle throwing after scrolling. Called by LVGL during input device processing
38 | * @param proc pointer to an input device's proc field
39 | */
40 | void _lv_indev_scroll_throw_handler(_lv_indev_proc_t * proc);
41 |
42 | /**
43 | * Predict where would a scroll throw end
44 | * @param indev pointer to an input device
45 | * @param dir ` LV_DIR_VER` or `LV_DIR_HOR`
46 | * @return the difference compared to the current position when the throw would be finished
47 | */
48 | lv_coord_t lv_indev_scroll_throw_predict(lv_indev_t * indev, lv_dir_t dir);
49 |
50 | /**
51 | * Get the distance of the nearest snap point
52 | * @param obj the object on which snap points should be found
53 | * @param p save the distance of the found snap point there
54 | */
55 | void lv_indev_scroll_get_snap_dist(lv_obj_t * obj, lv_point_t * p);
56 |
57 | /**********************
58 | * MACROS
59 | **********************/
60 |
61 | #ifdef __cplusplus
62 | } /*extern "C"*/
63 | #endif
64 |
65 | #endif /*LV_INDEV_SCROLL_H*/
66 |
--------------------------------------------------------------------------------
/clib/lvgl/src/core/lv_obj_class.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_obj_class.h
3 | *
4 | */
5 |
6 | #ifndef LV_OBJ_CLASS_H
7 | #define LV_OBJ_CLASS_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 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 |
28 | struct _lv_obj_t;
29 | struct _lv_obj_class_t;
30 | struct _lv_event_t;
31 |
32 | typedef enum {
33 | LV_OBJ_CLASS_EDITABLE_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/
34 | LV_OBJ_CLASS_EDITABLE_TRUE,
35 | LV_OBJ_CLASS_EDITABLE_FALSE,
36 | } lv_obj_class_editable_t;
37 |
38 | typedef enum {
39 | LV_OBJ_CLASS_GROUP_DEF_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/
40 | LV_OBJ_CLASS_GROUP_DEF_TRUE,
41 | LV_OBJ_CLASS_GROUP_DEF_FALSE,
42 | } lv_obj_class_group_def_t;
43 |
44 | typedef void (*lv_obj_class_event_cb_t)(struct _lv_obj_class_t * class_p, struct _lv_event_t * e);
45 | /**
46 | * Describe the common methods of every object.
47 | * Similar to a C++ class.
48 | */
49 | typedef struct _lv_obj_class_t {
50 | const struct _lv_obj_class_t * base_class;
51 | void (*constructor_cb)(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj);
52 | void (*destructor_cb)(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * obj);
53 | #if LV_USE_USER_DATA
54 | void * user_data;
55 | #endif
56 | void (*event_cb)(const struct _lv_obj_class_t * class_p,
57 | struct _lv_event_t * e); /**< Widget type specific event function*/
58 | lv_coord_t width_def;
59 | lv_coord_t height_def;
60 | uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/
61 | uint32_t group_def : 2; /**< Value from ::lv_obj_class_group_def_t*/
62 | uint32_t instance_size : 16;
63 | } lv_obj_class_t;
64 |
65 | /**********************
66 | * GLOBAL PROTOTYPES
67 | **********************/
68 |
69 | /**
70 | * Create an object form a class descriptor
71 | * @param class_p pointer to a class
72 | * @param parent pointer to an object where the new object should be created
73 | * @return pointer to the created object
74 | */
75 | struct _lv_obj_t * lv_obj_class_create_obj(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent);
76 |
77 | void lv_obj_class_init_obj(struct _lv_obj_t * obj);
78 |
79 | void _lv_obj_destruct(struct _lv_obj_t * obj);
80 |
81 | bool lv_obj_is_editable(struct _lv_obj_t * obj);
82 |
83 | bool lv_obj_is_group_def(struct _lv_obj_t * obj);
84 |
85 | /**********************
86 | * MACROS
87 | **********************/
88 |
89 |
90 | #ifdef __cplusplus
91 | } /*extern "C"*/
92 | #endif
93 |
94 | #endif /*LV_OBJ_CLASS_H*/
95 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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_timer_handler` but a long blocking process
53 | * can prevent the call of `lv_timer_handler`. In this case if 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 | * Redrawn on object an all its children using the passed draw context
61 | * @param draw pointer to an initialized draw context
62 | * @param obj the start object from the redraw should start
63 | */
64 | void lv_refr_obj(lv_draw_ctx_t * draw_ctx, lv_obj_t * obj);
65 |
66 | /**
67 | * Invalidate an area on display to redraw it
68 | * @param area_p pointer to area which should be invalidated (NULL: delete the invalidated areas)
69 | * @param disp pointer to display where the area should be invalidated (NULL can be used if there is
70 | * only one display)
71 | */
72 | void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p);
73 |
74 | /**
75 | * Get the display which is being refreshed
76 | * @return the display being refreshed
77 | */
78 | lv_disp_t * _lv_refr_get_disp_refreshing(void);
79 |
80 | /**
81 | * Set the display which is being refreshed.
82 | * It shouldn't be used directly by the user.
83 | * It can be used to trick the drawing functions about there is an active display.
84 | * @param the display being refreshed
85 | */
86 | void _lv_refr_set_disp_refreshing(lv_disp_t * disp);
87 |
88 | #if LV_USE_PERF_MONITOR
89 | /**
90 | * Reset FPS counter
91 | */
92 | void lv_refr_reset_fps_counter(void);
93 |
94 | /**
95 | * Get the average FPS
96 | * @return the average FPS
97 | */
98 | uint32_t lv_refr_get_fps_avg(void);
99 | #endif
100 |
101 | /**
102 | * Called periodically to handle the refreshing
103 | * @param timer pointer to the timer itself
104 | */
105 | void _lv_disp_refr_timer(lv_timer_t * timer);
106 |
107 | /**********************
108 | * STATIC FUNCTIONS
109 | **********************/
110 |
111 | #ifdef __cplusplus
112 | } /*extern "C"*/
113 | #endif
114 |
115 | #endif /*LV_REFR_H*/
116 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/lv_draw.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "lv_draw.h"
10 | #include "sw/lv_draw_sw.h"
11 |
12 | /*********************
13 | * DEFINES
14 | *********************/
15 |
16 | /**********************
17 | * TYPEDEFS
18 | **********************/
19 |
20 | /**********************
21 | * STATIC PROTOTYPES
22 | **********************/
23 |
24 | /**********************
25 | * STATIC VARIABLES
26 | **********************/
27 |
28 | /**********************
29 | * STATIC VARIABLES
30 | **********************/
31 |
32 | /**********************
33 | * MACROS
34 | **********************/
35 |
36 | /**********************
37 | * GLOBAL FUNCTIONS
38 | **********************/
39 |
40 | void lv_draw_init(void)
41 | {
42 | // backend_head = NULL;
43 | // lv_draw_sw_init();
44 | //
45 | //#if LV_USE_GPU_STM32_DMA2D == 0
46 | // lv_gpu_stm32_dma2d_init();
47 | //#endif
48 | }
49 |
50 | /**********************
51 | * STATIC FUNCTIONS
52 | **********************/
53 |
54 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/lv_draw.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_draw_arc.c
2 | CSRCS += lv_draw.c
3 | CSRCS += lv_draw_img.c
4 | CSRCS += lv_draw_label.c
5 | CSRCS += lv_draw_line.c
6 | CSRCS += lv_draw_mask.c
7 | CSRCS += lv_draw_rect.c
8 | CSRCS += lv_draw_triangle.c
9 | CSRCS += lv_img_buf.c
10 | CSRCS += lv_img_cache.c
11 | CSRCS += lv_img_decoder.c
12 |
13 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw
14 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw
15 |
16 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw"
17 |
18 | include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sdl/lv_draw_sdl.mk
19 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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_conf_internal.h"
17 | #include "../misc/lv_color.h"
18 | #include "../misc/lv_area.h"
19 | #include "../misc/lv_style.h"
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 | typedef struct {
29 | lv_color_t color;
30 | lv_coord_t width;
31 | uint16_t start_angle;
32 | uint16_t end_angle;
33 | const void * img_src;
34 | lv_opa_t opa;
35 | lv_blend_mode_t blend_mode : 2;
36 | uint8_t rounded : 1;
37 | } lv_draw_arc_dsc_t;
38 |
39 | struct _lv_draw_ctx_t;
40 |
41 | /**********************
42 | * GLOBAL PROTOTYPES
43 | **********************/
44 |
45 | void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc);
46 |
47 | /**
48 | * Draw an arc. (Can draw pie too with great thickness.)
49 | * @param center_x the x coordinate of the center of the arc
50 | * @param center_y the y coordinate of the center of the arc
51 | * @param radius the radius of the arc
52 | * @param mask the arc will be drawn only in this mask
53 | * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
54 | * @param end_angle the end angle of the arc
55 | * @param clip_area the arc will be drawn only in this area
56 | * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
57 | */
58 | void lv_draw_arc(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center,
59 | uint16_t radius, uint16_t start_angle, uint16_t end_angle);
60 |
61 | /**
62 | * Get an area the should be invalidated when the arcs angle changed between start_angle and end_ange
63 | * @param x the x coordinate of the center of the arc
64 | * @param y the y coordinate of the center of the arc
65 | * @param radius the radius of the arc
66 | * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right)
67 | * @param end_angle the end angle of the arc
68 | * @param w width of the arc
69 | * @param rounded true: the arc is rounded
70 | * @param area store the area to invalidate here
71 | */
72 | void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
73 | lv_coord_t w, bool rounded, lv_area_t * area);
74 |
75 | /**********************
76 | * MACROS
77 | **********************/
78 |
79 | #ifdef __cplusplus
80 | } /*extern "C"*/
81 | #endif
82 |
83 | #endif /*LV_DRAW_ARC_H*/
84 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 | #include "../misc/lv_style.h"
19 |
20 | /*********************
21 | * DEFINES
22 | *********************/
23 |
24 | /**********************
25 | * MACROS
26 | **********************/
27 |
28 | /**********************
29 | * TYPEDEFS
30 | **********************/
31 |
32 | typedef struct {
33 |
34 | uint16_t angle;
35 | uint16_t zoom;
36 | lv_point_t pivot;
37 |
38 | lv_color_t recolor;
39 | lv_opa_t recolor_opa;
40 |
41 | lv_opa_t opa;
42 | lv_blend_mode_t blend_mode : 4;
43 |
44 | int32_t frame_id;
45 | uint8_t antialias : 1;
46 | } lv_draw_img_dsc_t;
47 |
48 | struct _lv_draw_ctx_t;
49 |
50 | /**********************
51 | * GLOBAL PROTOTYPES
52 | **********************/
53 |
54 | void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc);
55 | /**
56 | * Draw an image
57 | * @param coords the coordinates of the image
58 | * @param mask the image will be drawn only in this area
59 | * @param src pointer to a lv_color_t array which contains the pixels of the image
60 | * @param dsc pointer to an initialized `lv_draw_img_dsc_t` variable
61 | */
62 | void lv_draw_img(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc, const lv_area_t * coords,
63 | const void * src);
64 |
65 |
66 | void lv_draw_img_decoded(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * dsc,
67 | const lv_area_t * coords, const uint8_t * map_p, lv_img_cf_t color_format);
68 |
69 | /**
70 | * Get the type of an image source
71 | * @param src pointer to an image source:
72 | * - pointer to an 'lv_img_t' variable (image stored internally and compiled into the code)
73 | * - a path to a file (e.g. "S:/folder/image.bin")
74 | * - or a symbol (e.g. LV_SYMBOL_CLOSE)
75 | * @return type of the image source LV_IMG_SRC_VARIABLE/FILE/SYMBOL/UNKNOWN
76 | */
77 | lv_img_src_t lv_img_src_get_type(const void * src);
78 |
79 | /**
80 | * Get the pixel size of a color format in bits
81 | * @param cf a color format (`LV_IMG_CF_...`)
82 | * @return the pixel size in bits
83 | */
84 | uint8_t lv_img_cf_get_px_size(lv_img_cf_t cf);
85 |
86 | /**
87 | * Check if a color format is chroma keyed or not
88 | * @param cf a color format (`LV_IMG_CF_...`)
89 | * @return true: chroma keyed; false: not chroma keyed
90 | */
91 | bool lv_img_cf_is_chroma_keyed(lv_img_cf_t cf);
92 |
93 | /**
94 | * Check if a color format has alpha channel or not
95 | * @param cf a color format (`LV_IMG_CF_...`)
96 | * @return true: has alpha channel; false: doesn't have alpha channel
97 | */
98 | bool lv_img_cf_has_alpha(lv_img_cf_t cf);
99 |
100 | #ifdef __cplusplus
101 | } /*extern "C"*/
102 | #endif
103 |
104 | #endif /*LV_DRAW_IMG_H*/
105 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/lv_draw_line.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_line.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include
10 | #include "../core/lv_refr.h"
11 | #include "../misc/lv_math.h"
12 |
13 | /*********************
14 | * DEFINES
15 | *********************/
16 |
17 | /**********************
18 | * TYPEDEFS
19 | **********************/
20 |
21 | /**********************
22 | * STATIC PROTOTYPES
23 | **********************/
24 |
25 | /**********************
26 | * STATIC VARIABLES
27 | **********************/
28 |
29 | /**********************
30 | * MACROS
31 | **********************/
32 |
33 | /**********************
34 | * GLOBAL FUNCTIONS
35 | **********************/
36 |
37 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
38 | {
39 | lv_memset_00(dsc, sizeof(lv_draw_line_dsc_t));
40 | dsc->width = 1;
41 | dsc->opa = LV_OPA_COVER;
42 | dsc->color = lv_color_black();
43 | }
44 |
45 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
46 | const lv_point_t * point1, const lv_point_t * point2)
47 | {
48 | if(dsc->width == 0) return;
49 | if(dsc->opa <= LV_OPA_MIN) return;
50 |
51 | draw_ctx->draw_line(draw_ctx, dsc, point1, point2);
52 | }
53 |
54 | /**********************
55 | * STATIC FUNCTIONS
56 | **********************/
57 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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_conf_internal.h"
17 | #include "../misc/lv_color.h"
18 | #include "../misc/lv_area.h"
19 | #include "../misc/lv_style.h"
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 | typedef struct {
29 | lv_color_t color;
30 | lv_coord_t width;
31 | lv_coord_t dash_width;
32 | lv_coord_t dash_gap;
33 | lv_opa_t opa;
34 | lv_blend_mode_t blend_mode : 2;
35 | uint8_t round_start : 1;
36 | uint8_t round_end : 1;
37 | uint8_t raw_end : 1; /*Do not bother with perpendicular line ending if it's not visible for any reason*/
38 | } lv_draw_line_dsc_t;
39 |
40 | struct _lv_draw_ctx_t;
41 |
42 | /**********************
43 | * GLOBAL PROTOTYPES
44 | **********************/
45 |
46 | LV_ATTRIBUTE_FAST_MEM void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc);
47 |
48 | /**
49 | * Draw a line
50 | * @param point1 first point of the line
51 | * @param point2 second point of the line
52 | * @param clip the line will be drawn only in this area
53 | * @param dsc pointer to an initialized `lv_draw_line_dsc_t` variable
54 | */
55 | void lv_draw_line(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc, const lv_point_t * point1,
56 | const lv_point_t * point2);
57 |
58 |
59 | /**********************
60 | * MACROS
61 | **********************/
62 |
63 | #ifdef __cplusplus
64 | } /*extern "C"*/
65 | #endif
66 |
67 | #endif /*LV_DRAW_LINE_H*/
68 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/lv_draw_rect.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_rect.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "lv_draw.h"
10 | #include "lv_draw_rect.h"
11 | #include "../misc/lv_assert.h"
12 |
13 | /*********************
14 | * DEFINES
15 | *********************/
16 |
17 | /**********************
18 | * TYPEDEFS
19 | **********************/
20 |
21 | /**********************
22 | * STATIC PROTOTYPES
23 | **********************/
24 |
25 | /**********************
26 | * STATIC VARIABLES
27 | **********************/
28 |
29 | /**********************
30 | * MACROS
31 | **********************/
32 |
33 | /**********************
34 | * GLOBAL FUNCTIONS
35 | **********************/
36 |
37 | LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
38 | {
39 | lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t));
40 | dsc->bg_color = lv_color_white();
41 | #if __STDC_VERSION__ < 201112L
42 | dsc->bg_grad.stops[0].color = lv_color_white();
43 | #endif
44 | dsc->bg_grad.stops[1].color = lv_color_black();
45 | dsc->bg_grad.stops[1].frac = 0xFF;
46 | dsc->bg_grad.stops_count = 2;
47 | dsc->border_color = lv_color_black();
48 | dsc->shadow_color = lv_color_black();
49 | dsc->bg_img_symbol_font = LV_FONT_DEFAULT;
50 | dsc->bg_opa = LV_OPA_COVER;
51 | dsc->bg_img_opa = LV_OPA_COVER;
52 | dsc->outline_opa = LV_OPA_COVER;
53 | dsc->border_opa = LV_OPA_COVER;
54 | dsc->shadow_opa = LV_OPA_COVER;
55 | dsc->border_side = LV_BORDER_SIDE_FULL;
56 | }
57 |
58 | /**
59 | * Draw a rectangle
60 | * @param coords the coordinates of the rectangle
61 | * @param mask the rectangle will be drawn only in this mask
62 | * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
63 | */
64 | void lv_draw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)
65 | {
66 | if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
67 |
68 | draw_ctx->draw_rect(draw_ctx, dsc, coords);
69 |
70 | LV_ASSERT_MEM_INTEGRITY();
71 | }
72 |
73 | /**********************
74 | * STATIC FUNCTIONS
75 | **********************/
76 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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_conf_internal.h"
17 | #include "../misc/lv_color.h"
18 | #include "../misc/lv_area.h"
19 | #include "../misc/lv_style.h"
20 | #include "sw/lv_draw_sw_gradient.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 | #define LV_RADIUS_CIRCLE 0x7FFF /**< A very big radius to always draw as circle*/
26 | LV_EXPORT_CONST_INT(LV_RADIUS_CIRCLE);
27 |
28 | /**********************
29 | * TYPEDEFS
30 | **********************/
31 |
32 | typedef struct {
33 | lv_coord_t radius;
34 | lv_blend_mode_t blend_mode;
35 |
36 | /*Background*/
37 | lv_opa_t bg_opa;
38 | #if __STDC_VERSION__ >= 201112L
39 | union {
40 | #endif
41 | lv_color_t bg_color; /**< First element of a gradient is a color, so it maps well here*/
42 | lv_grad_dsc_t bg_grad;
43 | #if __STDC_VERSION__ >= 201112L
44 | };
45 | #endif
46 |
47 | /*Background img*/
48 | const void * bg_img_src;
49 | const void * bg_img_symbol_font;
50 | lv_color_t bg_img_recolor;
51 | lv_opa_t bg_img_opa;
52 | lv_opa_t bg_img_recolor_opa;
53 | uint8_t bg_img_tiled;
54 |
55 | /*Border*/
56 | lv_color_t border_color;
57 | lv_coord_t border_width;
58 | lv_opa_t border_opa;
59 | uint8_t border_post : 1; /*There is a border it will be drawn later.*/
60 | lv_border_side_t border_side : 5;
61 |
62 | /*Outline*/
63 | lv_color_t outline_color;
64 | lv_coord_t outline_width;
65 | lv_coord_t outline_pad;
66 | lv_opa_t outline_opa;
67 |
68 | /*Shadow*/
69 | lv_color_t shadow_color;
70 | lv_coord_t shadow_width;
71 | lv_coord_t shadow_ofs_x;
72 | lv_coord_t shadow_ofs_y;
73 | lv_coord_t shadow_spread;
74 | lv_opa_t shadow_opa;
75 | } lv_draw_rect_dsc_t;
76 |
77 | struct _lv_draw_ctx_t;
78 |
79 | /**********************
80 | * GLOBAL PROTOTYPES
81 | **********************/
82 |
83 | LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
84 |
85 |
86 | /**
87 | * Draw a rectangle
88 | * @param coords the coordinates of the rectangle
89 | * @param clip the rectangle will be drawn only in this area
90 | * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
91 | */
92 | void lv_draw_rect(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
93 |
94 | /**********************
95 | * MACROS
96 | **********************/
97 |
98 | #ifdef __cplusplus
99 | } /*extern "C"*/
100 | #endif
101 |
102 | #endif /*LV_DRAW_RECT_H*/
103 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/lv_draw_triangle.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_triangle.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "lv_draw.h"
10 | #include "lv_draw_triangle.h"
11 | #include "../misc/lv_math.h"
12 | #include "../misc/lv_mem.h"
13 |
14 | /*********************
15 | * DEFINES
16 | *********************/
17 |
18 | /**********************
19 | * TYPEDEFS
20 | **********************/
21 |
22 | /**********************
23 | * STATIC PROTOTYPES
24 | **********************/
25 |
26 | /**********************
27 | * STATIC VARIABLES
28 | **********************/
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | /**********************
35 | * GLOBAL FUNCTIONS
36 | **********************/
37 |
38 | void lv_draw_polygon(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t points[],
39 | uint16_t point_cnt)
40 | {
41 | draw_ctx->draw_polygon(draw_ctx, draw_dsc, points, point_cnt);
42 | }
43 |
44 | void lv_draw_triangle(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t points[])
45 | {
46 |
47 | draw_ctx->draw_polygon(draw_ctx, draw_dsc, points, 3);
48 | }
49 |
50 | /**********************
51 | * STATIC FUNCTIONS
52 | **********************/
53 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 | void lv_draw_polygon(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t points[],
31 | uint16_t point_cnt);
32 |
33 | void lv_draw_triangle(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc, const lv_point_t points[]);
34 | /**********************
35 | * MACROS
36 | **********************/
37 |
38 | #ifdef __cplusplus
39 | } /*extern "C"*/
40 | #endif
41 |
42 | #endif /*LV_DRAW_TRIANGLE_H*/
43 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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_to_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 color The color of the image with `LV_IMG_CF_ALPHA_...`
50 | * @param frame_id the index of the frame. Used only with animated images, set 0 for normal images
51 | * @return pointer to the cache entry or NULL if can open the image
52 | */
53 | _lv_img_cache_entry_t * _lv_img_cache_open(const void * src, lv_color_t color, int32_t frame_id);
54 |
55 | /**
56 | * Set the number of images to be cached.
57 | * More cached images mean more opened image at same time which might mean more memory usage.
58 | * E.g. if 20 PNG or JPG images are open in the RAM they consume memory while opened in the cache.
59 | * @param new_entry_cnt number of image to cache
60 | */
61 | void lv_img_cache_set_size(uint16_t new_slot_num);
62 |
63 | /**
64 | * Invalidate an image source in the cache.
65 | * Useful if the image source is updated therefore it needs to be cached again.
66 | * @param src an image source path to a file or pointer to an `lv_img_dsc_t` variable.
67 | */
68 | void lv_img_cache_invalidate_src(const void * src);
69 |
70 | /**********************
71 | * MACROS
72 | **********************/
73 |
74 | #ifdef __cplusplus
75 | } /*extern "C"*/
76 | #endif
77 |
78 | #endif /*LV_IMG_CACHE_H*/
79 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/nxp_pxp/lv_gpu_nxp_pxp_osa.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_gpu_nxp_pxp_osa.h
3 | *
4 | */
5 |
6 | /**
7 | * MIT License
8 | *
9 | * Copyright (c) 2020 NXP
10 | *
11 | * Permission is hereby granted, free of charge, to any person obtaining a copy
12 | * of this software and associated documentation files (the "Software"), to deal
13 | * in the Software without restriction, including without limitation the rights to
14 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15 | * the Software, and to permit persons to whom the Software is furnished to do so,
16 | * subject to the following conditions:
17 | *
18 | * The above copyright notice and this permission notice (including the next paragraph)
19 | * shall be included in all copies or substantial portions of the Software.
20 | *
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
22 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
26 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 | *
28 | */
29 |
30 | #ifndef LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_
31 | #define LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_
32 |
33 | #ifdef __cplusplus
34 | extern "C" {
35 | #endif
36 |
37 | #include "../../lv_conf_internal.h"
38 |
39 | #if LV_USE_GPU_NXP_PXP && LV_USE_GPU_NXP_PXP_AUTO_INIT
40 | extern lv_nxp_pxp_cfg_t pxp_default_cfg;
41 | #endif
42 |
43 | #ifdef __cplusplus
44 | } /*extern "C"*/
45 | #endif
46 |
47 | #endif /*LV_SRC_LV_GPU_LV_GPU_NXP_PXP_OSA_H_*/
48 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/README.md:
--------------------------------------------------------------------------------
1 | # SDL_Renderer Based Drawing Functions
2 |
3 | In LVGL, drawing was performed by CPU. To improve drawing performance on platforms with GPU,
4 | we should perform drawing operations on GPU if possible.
5 |
6 | This implementation has moved most bitmap blending and drawing procedures to utilize SDL_Renderer,
7 | which takes advantages of hardware acceleration APIs like DirectX or OpenGL.
8 |
9 | This implementation can be also considered as a reference implementation, for contributors wants to
10 | develop accelerated drawing functions with other APIs such as OpenGL/OpenGL ES.
11 |
12 | ## Caveats
13 | `lv_draw_arc`, `lv_draw_line` is not enabled, due to incomplete implementation. So lines and arcs will
14 | have significant impact to drawing performances.
15 |
16 | Performance of this implementation still has room to improve. Or we should use more powerful APIs
17 | such as OpenGL.
18 |
19 | ## Notices for files
20 |
21 | ### `lv_draw_sdl_stack_blur.c`
22 |
23 | Contains modified code from [android-stackblur](https://github.com/kikoso/android-stackblur) project.
24 | Apache License 2.0
25 |
26 | ### `lv_draw_sdl_lru.c`/`lv_draw_sdl_lru.h`
27 |
28 | Contains modified code from [C-LRU-Cache](https://github.com/willcannings/C-LRU-Cache) project. No license defined.
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SDL_H
7 | #define LV_DRAW_SDL_H
8 |
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | /*********************
15 | * INCLUDES
16 | *********************/
17 | #include "../../lv_conf_internal.h"
18 |
19 | #if LV_USE_GPU_SDL
20 |
21 | #include LV_GPU_SDL_INCLUDE_PATH
22 |
23 | #include "../lv_draw.h"
24 | #include "../../core/lv_disp.h"
25 |
26 | /*********************
27 | * DEFINES
28 | *********************/
29 |
30 | #if SDL_BYTEORDER == SDL_BIG_ENDIAN
31 | #define LV_DRAW_SDL_TEXTURE_FORMAT SDL_PIXELFORMAT_ARGB8888
32 | #else
33 | #define LV_DRAW_SDL_TEXTURE_FORMAT SDL_PIXELFORMAT_RGBA8888
34 | #endif
35 |
36 | /**********************
37 | * TYPEDEFS
38 | **********************/
39 |
40 | struct lv_draw_sdl_context_internals_t;
41 |
42 | typedef struct {
43 | /**
44 | * Render for display driver
45 | */
46 | SDL_Renderer * renderer;
47 | void * user_data;
48 | } lv_draw_sdl_drv_param_t;
49 |
50 | typedef struct {
51 | lv_draw_ctx_t base_draw;
52 | SDL_Renderer * renderer;
53 | struct lv_draw_sdl_context_internals_t * internals;
54 | } lv_draw_sdl_ctx_t;
55 |
56 | /**********************
57 | * GLOBAL PROTOTYPES
58 | **********************/
59 |
60 | void lv_draw_sdl_init_ctx(lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx);
61 |
62 | /**
63 | * @brief Free caches
64 | *
65 | */
66 | void lv_draw_sdl_deinit_ctx(lv_disp_drv_t * disp_drv, lv_draw_ctx_t * draw_ctx);
67 |
68 | SDL_Texture * lv_draw_sdl_create_screen_texture(SDL_Renderer * renderer, lv_coord_t hor, lv_coord_t ver);
69 |
70 | /*======================
71 | * Add/remove functions
72 | *=====================*/
73 |
74 | /*=====================
75 | * Setter functions
76 | *====================*/
77 |
78 | /*=====================
79 | * Getter functions
80 | *====================*/
81 |
82 | /*=====================
83 | * Other functions
84 | *====================*/
85 |
86 | /**********************
87 | * MACROS
88 | **********************/
89 |
90 | #endif /*LV_USE_GPU_SDL*/
91 |
92 | #ifdef __cplusplus
93 | } /*extern "C"*/
94 | #endif
95 |
96 | #endif /*LV_DRAW_SDL_H*/
97 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_draw_sdl.c
2 | CSRCS += lv_draw_sdl_arc.c
3 | CSRCS += lv_draw_sdl_bg.c
4 | CSRCS += lv_draw_sdl_composite.c
5 | CSRCS += lv_draw_sdl_img.c
6 | CSRCS += lv_draw_sdl_label.c
7 | CSRCS += lv_draw_sdl_line.c
8 | CSRCS += lv_draw_sdl_mask.c
9 | CSRCS += lv_draw_sdl_polygon.c
10 | CSRCS += lv_draw_sdl_rect.c
11 | CSRCS += lv_draw_sdl_stack_blur.c
12 | CSRCS += lv_draw_sdl_texture_cache.c
13 | CSRCS += lv_draw_sdl_utils.c
14 |
15 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sdl
16 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sdl
17 |
18 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sdl"
19 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_composite.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_composite.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SDL_COMPOSITE_H
7 | #define LV_DRAW_SDL_COMPOSITE_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 |
17 | #include "../../lv_conf_internal.h"
18 |
19 | #include LV_GPU_SDL_INCLUDE_PATH
20 |
21 | #include "lv_draw_sdl.h"
22 | #include "../../misc/lv_area.h"
23 | #include "../../misc/lv_color.h"
24 |
25 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | typedef enum lv_draw_sdl_composite_texture_id_t {
34 | LV_DRAW_SDL_COMPOSITE_TEXTURE_ID_STREAM0,
35 | LV_DRAW_SDL_COMPOSITE_TEXTURE_ID_STREAM1,
36 | LV_DRAW_SDL_COMPOSITE_TEXTURE_ID_TARGET0,
37 | LV_DRAW_SDL_COMPOSITE_TEXTURE_ID_TARGET1,
38 | } lv_draw_sdl_composite_texture_id_t;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /**
45 | * Begin drawing with mask. Render target will be switched to a temporary texture,
46 | * and drawing coordinates may get clipped or translated
47 | * @param coords_in Original coordinates
48 | * @param clip_in Original clip area
49 | * @param extension Useful for shadows or outlines, can be NULL
50 | * @param coords_out Translated coords
51 | * @param clip_out Translated clip area
52 | * @param apply_area Area of actual composited texture will be drawn
53 | * @return true if there are any mask needs to be drawn, false otherwise
54 | */
55 | bool lv_draw_sdl_composite_begin(lv_draw_sdl_ctx_t * ctx, const lv_area_t * coords_in, const lv_area_t * clip_in,
56 | const lv_area_t * extension, lv_blend_mode_t blend_mode, lv_area_t * coords_out,
57 | lv_area_t * clip_out, lv_area_t * apply_area);
58 |
59 | void lv_draw_sdl_composite_end(lv_draw_sdl_ctx_t * ctx, const lv_area_t * apply_area, lv_blend_mode_t blend_mode);
60 |
61 | SDL_Texture * lv_draw_sdl_composite_texture_obtain(lv_draw_sdl_ctx_t * ctx, lv_draw_sdl_composite_texture_id_t id,
62 | lv_coord_t w, lv_coord_t h);
63 |
64 | /**********************
65 | * MACROS
66 | **********************/
67 |
68 | #ifdef __cplusplus
69 | } /*extern "C"*/
70 | #endif
71 |
72 | #endif /*LV_DRAW_SDL_COMPOSITE_H*/
73 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_img.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_img.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SDL_IMG_H
7 | #define LV_DRAW_SDL_IMG_H
8 |
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | /*********************
15 | * INCLUDES
16 | *********************/
17 | #include "../../lv_conf_internal.h"
18 |
19 | #if LV_USE_GPU_SDL
20 |
21 | #include LV_GPU_SDL_INCLUDE_PATH
22 |
23 | #include "../lv_draw.h"
24 |
25 | #include "lv_draw_sdl_texture_cache.h"
26 |
27 | /*********************
28 | * DEFINES
29 | *********************/
30 |
31 | /**********************
32 | * TYPEDEFS
33 | **********************/
34 |
35 | typedef struct lv_draw_sdl_img_header_t {
36 | lv_img_header_t base;
37 | SDL_Rect rect;
38 | } lv_draw_sdl_img_header_t;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /*======================
45 | * Add/remove functions
46 | *=====================*/
47 |
48 | /*=====================
49 | * Setter functions
50 | *====================*/
51 |
52 | /*=====================
53 | * Getter functions
54 | *====================*/
55 |
56 | /*=====================
57 | * Other functions
58 | *====================*/
59 | bool lv_draw_sdl_img_load_texture(lv_draw_sdl_ctx_t * ctx, lv_draw_sdl_cache_key_head_img_t * key, size_t key_size,
60 | const void * src, int32_t frame_id, SDL_Texture ** texture,
61 | lv_draw_sdl_img_header_t ** header);
62 | /**********************
63 | * MACROS
64 | **********************/
65 |
66 | #endif /*LV_USE_GPU_SDL*/
67 |
68 | #ifdef __cplusplus
69 | } /*extern "C"*/
70 | #endif
71 |
72 | #endif /*LV_DRAW_SDL_IMG_H*/
73 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_mask.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_mask.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "../../lv_conf_internal.h"
10 |
11 | #if LV_USE_GPU_SDL
12 |
13 | #include "../../misc/lv_gc.h"
14 | #include "lv_draw_sdl_mask.h"
15 | #include "lv_draw_sdl_utils.h"
16 |
17 | /*********************
18 | * DEFINES
19 | *********************/
20 | #ifndef HAVE_SDL_CUSTOM_BLEND_MODE
21 | #define HAVE_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6))
22 | #endif
23 |
24 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 |
28 | /**********************
29 | * STATIC PROTOTYPES
30 | **********************/
31 |
32 | /**********************
33 | * STATIC VARIABLES
34 | **********************/
35 |
36 | /**********************
37 | * MACROS
38 | **********************/
39 |
40 | /**********************
41 | * GLOBAL FUNCTIONS
42 | **********************/
43 |
44 | lv_opa_t * lv_draw_sdl_mask_dump_opa(const lv_area_t * coords, const int16_t * ids, int16_t ids_count)
45 | {
46 | SDL_assert(coords->x2 >= coords->x1);
47 | SDL_assert(coords->y2 >= coords->y1);
48 | lv_coord_t w = lv_area_get_width(coords), h = lv_area_get_height(coords);
49 | lv_opa_t * mask_buf = lv_mem_buf_get(w * h);
50 | for(lv_coord_t y = 0; y < h; y++) {
51 | lv_opa_t * line_buf = &mask_buf[y * w];
52 | lv_memset_ff(line_buf, w);
53 | lv_coord_t abs_x = (lv_coord_t) coords->x1, abs_y = (lv_coord_t)(y + coords->y1), len = (lv_coord_t) w;
54 | lv_draw_mask_res_t res;
55 | if(ids) {
56 | res = lv_draw_mask_apply_ids(line_buf, abs_x, abs_y, len, ids, ids_count);
57 | }
58 | else {
59 | res = lv_draw_mask_apply(line_buf, abs_x, abs_y, len);
60 | }
61 | if(res == LV_DRAW_MASK_RES_TRANSP) {
62 | lv_memset_00(line_buf, w);
63 | }
64 | }
65 | return mask_buf;
66 | }
67 |
68 | SDL_Texture * lv_draw_sdl_mask_dump_texture(SDL_Renderer * renderer, const lv_area_t * coords, const int16_t * ids,
69 | int16_t ids_count)
70 | {
71 | lv_coord_t w = lv_area_get_width(coords), h = lv_area_get_height(coords);
72 | lv_opa_t * mask_buf = lv_draw_sdl_mask_dump_opa(coords, ids, ids_count);
73 | SDL_Surface * surface = lv_sdl_create_opa_surface(mask_buf, w, h, w);
74 | lv_mem_buf_release(mask_buf);
75 | SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface);
76 | SDL_FreeSurface(surface);
77 | return texture;
78 | }
79 |
80 | /**********************
81 | * STATIC FUNCTIONS
82 | **********************/
83 |
84 | #endif /*LV_USE_GPU_SDL*/
85 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_mask.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_mask.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SDL_MASK_H
7 | #define LV_DRAW_SDL_MASK_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 |
17 | #include "../../lv_conf_internal.h"
18 |
19 | #include LV_GPU_SDL_INCLUDE_PATH
20 |
21 | #include "lv_draw_sdl.h"
22 | #include "../../misc/lv_area.h"
23 | #include "../../misc/lv_color.h"
24 |
25 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | /**********************
34 | * GLOBAL PROTOTYPES
35 | **********************/
36 |
37 | lv_opa_t * lv_draw_sdl_mask_dump_opa(const lv_area_t * coords, const int16_t * ids, int16_t ids_count);
38 |
39 | SDL_Texture * lv_draw_sdl_mask_dump_texture(SDL_Renderer * renderer, const lv_area_t * coords, const int16_t * ids,
40 | int16_t ids_count);
41 |
42 |
43 | /**********************
44 | * MACROS
45 | **********************/
46 |
47 | #ifdef __cplusplus
48 | } /*extern "C"*/
49 | #endif
50 |
51 | #endif /*LV_DRAW_SDL_MASK_H*/
52 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_priv.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_priv.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SDL_PRIV_H
7 | #define LV_DRAW_SDL_PRIV_H
8 |
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | /*********************
15 | * INCLUDES
16 | *********************/
17 | #include "../../lv_conf_internal.h"
18 |
19 | #if LV_USE_GPU_SDL
20 |
21 | #include LV_GPU_SDL_INCLUDE_PATH
22 |
23 | #include "../lv_draw.h"
24 | #include "../../misc/lv_lru.h"
25 |
26 | /*********************
27 | * DEFINES
28 | *********************/
29 |
30 | /**********************
31 | * TYPEDEFS
32 | **********************/
33 |
34 | typedef struct lv_draw_sdl_context_internals_t {
35 | lv_lru_t * texture_cache;
36 | SDL_Texture * mask;
37 | SDL_Texture * composition;
38 | } lv_draw_sdl_context_internals_t;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /*======================
45 | * Add/remove functions
46 | *=====================*/
47 |
48 | /*=====================
49 | * Setter functions
50 | *====================*/
51 |
52 | /*=====================
53 | * Getter functions
54 | *====================*/
55 |
56 | /*=====================
57 | * Other functions
58 | *====================*/
59 |
60 | /**********************
61 | * MACROS
62 | **********************/
63 |
64 | #endif /*LV_USE_GPU_SDL*/
65 |
66 | #ifdef __cplusplus
67 | } /*extern "C"*/
68 | #endif
69 |
70 | #endif /*LV_DRAW_SDL_PRIV_H*/
71 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_rect.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_rect.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SDL_RECT_H
7 | #define LV_DRAW_SDL_RECT_H
8 |
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | /*********************
15 | * INCLUDES
16 | *********************/
17 | #include "../../lv_conf_internal.h"
18 |
19 | #if LV_USE_GPU_SDL
20 |
21 | #include LV_GPU_SDL_INCLUDE_PATH
22 |
23 | #include "../lv_draw.h"
24 |
25 | #include "lv_draw_sdl_texture_cache.h"
26 |
27 | /*********************
28 | * DEFINES
29 | *********************/
30 |
31 | /**********************
32 | * TYPEDEFS
33 | **********************/
34 |
35 | typedef struct lv_draw_sdl_rect_header_t {
36 | lv_img_header_t base;
37 | SDL_Rect rect;
38 | } lv_draw_sdl_rect_header_t;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /*======================
45 | * Add/remove functions
46 | *=====================*/
47 |
48 | /*=====================
49 | * Setter functions
50 | *====================*/
51 |
52 | /*=====================
53 | * Getter functions
54 | *====================*/
55 |
56 | /*=====================
57 | * Other functions
58 | *====================*/
59 |
60 | SDL_Texture * lv_draw_sdl_rect_bg_frag_obtain(lv_draw_sdl_ctx_t * ctx, lv_coord_t radius);
61 |
62 | void lv_draw_sdl_rect_bg_frag_draw_corners(lv_draw_sdl_ctx_t * ctx, SDL_Texture * frag, lv_coord_t frag_size,
63 | const lv_area_t * coords, const lv_area_t * clip, bool full);
64 |
65 | /**********************
66 | * MACROS
67 | **********************/
68 |
69 | #endif /*LV_USE_GPU_SDL*/
70 |
71 | #ifdef __cplusplus
72 | } /*extern "C"*/
73 | #endif
74 |
75 | #endif /*LV_DRAW_SDL_RECT_H*/
76 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_stack_blur.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_stack_blur.h
3 | *
4 | */
5 | #ifndef LV_DRAW_SDL_STACK_BLUR_H
6 | #define LV_DRAW_SDL_STACK_BLUR_H
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /*********************
13 | * INCLUDES
14 | *********************/
15 |
16 | #include "../../lv_conf_internal.h"
17 |
18 | #if LV_USE_GPU_SDL
19 |
20 | #include "../../misc/lv_color.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | /**********************
27 | * TYPEDEFS
28 | **********************/
29 |
30 | /**********************
31 | * GLOBAL PROTOTYPES
32 | **********************/
33 |
34 | void lv_stack_blur_grayscale(lv_opa_t * buf, uint16_t w, uint16_t h, uint16_t r);
35 |
36 | /**********************
37 | * MACROS
38 | **********************/
39 |
40 | #endif /*LV_USE_GPU_SDL*/
41 |
42 | #ifdef __cplusplus
43 | } /*extern "C"*/
44 | #endif
45 |
46 | #endif /*LV_DRAW_SDL_STACK_BLUR_H*/
47 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sdl/lv_draw_sdl_utils.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sdl_utils.h
3 | *
4 | */
5 | #ifndef LV_DRAW_SDL_UTILS_H
6 | #define LV_DRAW_SDL_UTILS_H
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /*********************
13 | * INCLUDES
14 | *********************/
15 |
16 | #include "../../lv_conf_internal.h"
17 | #if LV_USE_GPU_SDL
18 |
19 | #include "lv_draw_sdl.h"
20 | #include "../../misc/lv_color.h"
21 | #include "../../misc/lv_area.h"
22 |
23 | #include LV_GPU_SDL_INCLUDE_PATH
24 |
25 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | /**********************
34 | * GLOBAL PROTOTYPES
35 | **********************/
36 |
37 | void _lv_draw_sdl_utils_init();
38 |
39 | void _lv_draw_sdl_utils_deinit();
40 |
41 | void lv_area_to_sdl_rect(const lv_area_t * in, SDL_Rect * out);
42 |
43 | void lv_color_to_sdl_color(const lv_color_t * in, SDL_Color * out);
44 |
45 | void lv_area_zoom_to_sdl_rect(const lv_area_t * in, SDL_Rect * out, uint16_t zoom, const lv_point_t * pivot);
46 |
47 | SDL_Palette * lv_sdl_alloc_palette_for_bpp(const uint8_t * mapping, uint8_t bpp);
48 |
49 | SDL_Surface * lv_sdl_create_opa_surface(lv_opa_t * opa, lv_coord_t width, lv_coord_t height, lv_coord_t stride);
50 |
51 | SDL_Texture * lv_sdl_create_opa_texture(SDL_Renderer * renderer, lv_opa_t * pixels, lv_coord_t width,
52 | lv_coord_t height, lv_coord_t stride);
53 |
54 | void lv_sdl_to_8bpp(uint8_t * dest, const uint8_t * src, int width, int height, int stride, uint8_t bpp);
55 |
56 | /**********************
57 | * MACROS
58 | **********************/
59 |
60 | #endif /*LV_USE_GPU_SDL*/
61 | #ifdef __cplusplus
62 | } /*extern "C"*/
63 | #endif
64 |
65 | #endif /*LV_DRAW_SDL_UTILS_H*/
66 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/stm32_dma2d/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 "../../misc/lv_color.h"
17 | #include "../../hal/lv_hal_disp.h"
18 | #include "../sw/lv_draw_sw.h"
19 |
20 | #if LV_USE_GPU_STM32_DMA2D
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | #define LV_DMA2D_ARGB8888 0
27 | #define LV_DMA2D_RGB888 1
28 | #define LV_DMA2D_RGB565 2
29 | #define LV_DMA2D_ARGB1555 3
30 | #define LV_DMA2D_ARGB4444 4
31 |
32 | /**********************
33 | * TYPEDEFS
34 | **********************/
35 | typedef lv_draw_sw_ctx_t lv_draw_stm32_dma2d_ctx_t;
36 |
37 | struct _lv_disp_drv_t;
38 |
39 | /**********************
40 | * GLOBAL PROTOTYPES
41 | **********************/
42 |
43 | /**
44 | * Turn on the peripheral and set output color mode, this only needs to be done once
45 | */
46 | void lv_draw_stm32_dma2d_init(void);
47 |
48 | void lv_draw_stm32_dma2d_ctx_init(struct _lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx);
49 |
50 | void lv_draw_stm32_dma2d_ctx_deinit(struct _lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx);
51 |
52 | void lv_draw_stm32_dma2d_blend(lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
53 |
54 | void lv_gpu_stm32_dma2d_wait_cb(lv_draw_ctx_t * draw_ctx);
55 |
56 | /**********************
57 | * MACROS
58 | **********************/
59 |
60 | #endif /*LV_USE_GPU_STM32_DMA2D*/
61 |
62 | #ifdef __cplusplus
63 | } /*extern "C"*/
64 | #endif
65 |
66 | #endif /*LV_GPU_STM32_DMA2D_H*/
67 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sw/lv_draw_sw.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sw.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "../lv_draw.h"
10 | #include "lv_draw_sw.h"
11 |
12 | /*********************
13 | * DEFINES
14 | *********************/
15 |
16 | /**********************
17 | * TYPEDEFS
18 | **********************/
19 |
20 | /**********************
21 | * STATIC PROTOTYPES
22 | **********************/
23 |
24 | /**********************
25 | * GLOBAL PROTOTYPES
26 | **********************/
27 |
28 | /**********************
29 | * STATIC VARIABLES
30 | **********************/
31 |
32 | /**********************
33 | * MACROS
34 | **********************/
35 |
36 | /**********************
37 | * GLOBAL FUNCTIONS
38 | **********************/
39 |
40 | void lv_draw_sw_init_ctx(lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx)
41 | {
42 | LV_UNUSED(drv);
43 |
44 | lv_draw_sw_ctx_t * draw_sw_ctx = (lv_draw_sw_ctx_t *) draw_ctx;
45 | lv_memset_00(draw_sw_ctx, sizeof(lv_draw_sw_ctx_t));
46 |
47 | draw_sw_ctx->base_draw.draw_arc = lv_draw_sw_arc;
48 | draw_sw_ctx->base_draw.draw_rect = lv_draw_sw_rect;
49 | draw_sw_ctx->base_draw.draw_bg = lv_draw_sw_bg;
50 | draw_sw_ctx->base_draw.draw_letter = lv_draw_sw_letter;
51 | draw_sw_ctx->base_draw.draw_img_decoded = lv_draw_sw_img_decoded;
52 | draw_sw_ctx->base_draw.draw_line = lv_draw_sw_line;
53 | draw_sw_ctx->base_draw.draw_polygon = lv_draw_sw_polygon;
54 | draw_sw_ctx->base_draw.wait_for_finish = lv_draw_sw_wait_for_finish;
55 | draw_sw_ctx->blend = lv_draw_sw_blend_basic;
56 | }
57 |
58 | void lv_draw_sw_deinit_ctx(lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx)
59 | {
60 | LV_UNUSED(drv);
61 |
62 | lv_draw_sw_ctx_t * draw_sw_ctx = (lv_draw_sw_ctx_t *) draw_ctx;
63 | lv_memset_00(draw_sw_ctx, sizeof(lv_draw_sw_ctx_t));
64 | }
65 |
66 | void lv_draw_sw_wait_for_finish(lv_draw_ctx_t * draw_ctx)
67 | {
68 | LV_UNUSED(draw_ctx);
69 | /*Nothing to wait for*/
70 | }
71 |
72 | /**********************
73 | * STATIC FUNCTIONS
74 | **********************/
75 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sw/lv_draw_sw.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sw.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SW_H
7 | #define LV_DRAW_SW_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "lv_draw_sw_blend.h"
17 | #include "../lv_draw.h"
18 | #include "../../misc/lv_area.h"
19 | #include "../../misc/lv_color.h"
20 | #include "../../hal/lv_hal_disp.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | /**********************
27 | * TYPEDEFS
28 | **********************/
29 |
30 | struct _lv_disp_drv_t;
31 |
32 | typedef struct {
33 | lv_draw_ctx_t base_draw;
34 |
35 | /** Fill an area of the destination buffer with a color*/
36 | void (*blend)(lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
37 | } lv_draw_sw_ctx_t;
38 |
39 | /**********************
40 | * GLOBAL PROTOTYPES
41 | **********************/
42 |
43 | void lv_draw_sw_init_ctx(struct _lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx);
44 | void lv_draw_sw_deinit_ctx(struct _lv_disp_drv_t * drv, lv_draw_ctx_t * draw_ctx);
45 |
46 | void lv_draw_sw_wait_for_finish(lv_draw_ctx_t * draw_ctx);
47 |
48 | void lv_draw_sw_arc(lv_draw_ctx_t * draw_ctx, const lv_draw_arc_dsc_t * dsc, const lv_point_t * center, uint16_t radius,
49 | uint16_t start_angle, uint16_t end_angle);
50 |
51 | void lv_draw_sw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
52 |
53 | void lv_draw_sw_bg(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords);
54 | void lv_draw_sw_letter(lv_draw_ctx_t * draw_ctx, const lv_draw_label_dsc_t * dsc, const lv_point_t * pos_p,
55 | uint32_t letter);
56 |
57 | LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_img_decoded(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_img_dsc_t * draw_dsc,
58 | const lv_area_t * coords, const uint8_t * src_buf, lv_img_cf_t cf);
59 |
60 | LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_line(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_line_dsc_t * dsc,
61 | const lv_point_t * point1, const lv_point_t * point2);
62 |
63 | void lv_draw_sw_polygon(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * draw_dsc,
64 | const lv_point_t * points, uint16_t point_cnt);
65 |
66 | /***********************
67 | * GLOBAL VARIABLES
68 | ***********************/
69 |
70 | /**********************
71 | * MACROS
72 | **********************/
73 |
74 | #ifdef __cplusplus
75 | } /*extern "C"*/
76 | #endif
77 |
78 | #endif /*LV_DRAW_SW_H*/
79 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sw/lv_draw_sw.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_draw_sw.c
2 | CSRCS += lv_draw_sw_arc.c
3 | CSRCS += lv_draw_sw_blend.c
4 | CSRCS += lv_draw_sw_img.c
5 | CSRCS += lv_draw_sw_letter.c
6 | CSRCS += lv_draw_sw_line.c
7 | CSRCS += lv_draw_sw_rect.c
8 | CSRCS += lv_draw_sw_polygon.c
9 | CSRCS += lv_draw_sw_gradient.c
10 | CSRCS += lv_draw_sw_dither.c
11 |
12 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sw
13 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sw
14 |
15 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/sw"
16 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sw/lv_draw_sw_blend.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sw_blend.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SW_BLEND_H
7 | #define LV_DRAW_SW_BLEND_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../misc/lv_color.h"
17 | #include "../../misc/lv_area.h"
18 | #include "../../misc/lv_style.h"
19 | #include "../lv_draw_mask.h"
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 |
29 | typedef struct {
30 | const lv_area_t * blend_area; /**< The area with absolute coordinates to draw on `draw_ctx->buf`
31 | * will be clipped to `draw_ctx->clip_area` */
32 | const lv_color_t * src_buf; /**< Pointer to an image to blend. If set `fill_color` is ignored */
33 | lv_color_t color; /**< Fill color*/
34 | lv_opa_t * mask_buf; /**< NULL if ignored, or an alpha mask to apply on `blend_area`*/
35 | lv_draw_mask_res_t mask_res; /**< The result of the previous mask operation */
36 | const lv_area_t * mask_area; /**< The area of `mask_buf` with absolute coordinates*/
37 | lv_opa_t opa; /**< The overall opacity*/
38 | lv_blend_mode_t blend_mode; /**< E.g. LV_BLEND_MODE_ADDITIVE*/
39 | } lv_draw_sw_blend_dsc_t;
40 |
41 | struct _lv_draw_ctx_t;
42 |
43 | /**********************
44 | * GLOBAL PROTOTYPES
45 | **********************/
46 |
47 | /**
48 | * Call the blend function of the `draw_ctx`.
49 | * @param draw_ctx pointer to a draw context
50 | * @param dsc pointer to an initialized blend descriptor
51 | */
52 | void lv_draw_sw_blend(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
53 |
54 | /**
55 | * The basic blend function used with software rendering.
56 | * @param draw_ctx pointer to a draw context
57 | * @param dsc pointer to an initialized blend descriptor
58 | */
59 | LV_ATTRIBUTE_FAST_MEM void lv_draw_sw_blend_basic(struct _lv_draw_ctx_t * draw_ctx, const lv_draw_sw_blend_dsc_t * dsc);
60 |
61 | /**********************
62 | * MACROS
63 | **********************/
64 |
65 | #ifdef __cplusplus
66 | } /*extern "C"*/
67 | #endif
68 |
69 | #endif /*LV_DRAW_SW_BLEND_H*/
70 |
--------------------------------------------------------------------------------
/clib/lvgl/src/draw/sw/lv_draw_sw_dither.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_draw_sw_dither.h
3 | *
4 | */
5 |
6 | #ifndef LV_DRAW_SW_DITHER_H
7 | #define LV_DRAW_SW_DITHER_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../core/lv_obj_pos.h"
17 |
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 | #if LV_COLOR_DEPTH < 32 && LV_DITHER_GRADIENT == 1
23 | #define _DITHER_GRADIENT 1
24 | #else
25 | #define _DITHER_GRADIENT 0
26 | #endif
27 |
28 | /**********************
29 | * TYPEDEFS
30 | **********************/
31 | #if _DITHER_GRADIENT
32 | /*A signed error color component*/
33 | typedef struct {
34 | int8_t r, g, b;
35 | } lv_scolor24_t;
36 |
37 | struct _lv_gradient_cache_t;
38 | typedef void (*lv_dither_func_t)(struct _lv_gradient_cache_t * grad, lv_coord_t x, lv_coord_t y, lv_coord_t w);
39 |
40 | #endif
41 |
42 |
43 | /**********************
44 | * PROTOTYPES
45 | **********************/
46 | #if LV_DRAW_COMPLEX
47 | #if _DITHER_GRADIENT
48 | LV_ATTRIBUTE_FAST_MEM void lv_dither_none(struct _lv_gradient_cache_t * grad, lv_coord_t x, lv_coord_t y, lv_coord_t w);
49 |
50 | LV_ATTRIBUTE_FAST_MEM void lv_dither_ordered_hor(struct _lv_gradient_cache_t * grad, const lv_coord_t xs,
51 | const lv_coord_t y, const lv_coord_t w);
52 | LV_ATTRIBUTE_FAST_MEM void lv_dither_ordered_ver(struct _lv_gradient_cache_t * grad, const lv_coord_t xs,
53 | const lv_coord_t y, const lv_coord_t w);
54 |
55 | #if LV_DITHER_ERROR_DIFFUSION == 1
56 | LV_ATTRIBUTE_FAST_MEM void lv_dither_err_diff_hor(struct _lv_gradient_cache_t * grad, const lv_coord_t xs,
57 | const lv_coord_t y, const lv_coord_t w);
58 | LV_ATTRIBUTE_FAST_MEM void lv_dither_err_diff_ver(struct _lv_gradient_cache_t * grad, const lv_coord_t xs,
59 | const lv_coord_t y, const lv_coord_t w);
60 | #endif /* LV_DITHER_ERROR_DIFFUSION */
61 |
62 | #endif /* _DITHER_GRADIENT */
63 | #endif
64 |
65 |
66 | #ifdef __cplusplus
67 | } /*extern "C"*/
68 | #endif
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/README.md:
--------------------------------------------------------------------------------
1 | # Extra components
2 |
3 | This directory contains extra (optional) components to lvgl.
4 | It's a good place for contributions as there are less strict expectations about the completeness and flexibility of the components here.
5 |
6 | In other words, if you have created a complex widget from other widgets, or modified an existing widget with special events, styles or animations, or have a new feature that could work as a plugin to lvgl feel free to the share it here.
7 |
8 | ## How to contribute
9 | - Create a [Pull request](https://docs.lvgl.io/8.0/CONTRIBUTING.html#pull-request) with your new content
10 | - Please and follow the [Coding style](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) of LVGL
11 | - Add setter/getter functions in pair
12 | - Update [lv_conf_template.h](https://github.com/lvgl/lvgl/blob/master/lv_conf_template.h)
13 | - Add description in the [docs](https://github.com/lvgl/lvgl/tree/master/docs)
14 | - Add [examples](https://github.com/lvgl/lvgl/tree/master/examples)
15 | - Update the [changelog](https://github.com/lvgl/lvgl/tree/master/docs/CHANGELOG.md)
16 | - Add yourself to the [Contributors](#contributors) section below.
17 |
18 | ## Ideas
19 | Here some ideas as inspiration feel free to contribute with ideas too.
20 | - New [Calendar headers](https://github.com/lvgl/lvgl/tree/master/src/extra/widgets/calendar)
21 | - Color picker with RGB and or HSV bars
22 | - Ruler, horizontal or vertical with major and minor ticks and labels
23 | - New [List items types](https://github.com/lvgl/lvgl/tree/master/src/extra/widgets/list)
24 | - [Preloaders](https://www.google.com/search?q=preloader&sxsrf=ALeKk01ddA4YB0WEgLLN1bZNSm8YER7pkg:1623080551559&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiwoN6d7oXxAhVuw4sKHVedBB4Q_AUoAXoECAEQAw&biw=952&bih=940)
25 | - Drop-down list with a container to which content can be added
26 | - 9 patch button: Similar to [lv_imgbtn](https://docs.lvgl.io/8.0/widgets/extra/imgbtn.html) but 9 images for 4 corner, 4 sides and the center
27 |
28 | ## Contributors
29 | - lv_animimg: @ZhaoQiang-b45475
30 | - lv_span: @guoweilkd
31 | - lv_menu: @HX2003
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/extra.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/extra -name \*.c)
2 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/layouts/lv_layouts.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_layouts.h
3 | *
4 | */
5 |
6 | #ifndef LV_LAYOUTS_H
7 | #define LV_LAYOUTS_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "flex/lv_flex.h"
17 | #include "grid/lv_grid.h"
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 |
27 | /**********************
28 | * GLOBAL PROTOTYPES
29 | **********************/
30 |
31 | /**********************
32 | * MACROS
33 | **********************/
34 | #if LV_USE_LOG && LV_LOG_TRACE_LAYOUT
35 | # define LV_TRACE_LAYOUT(...) LV_LOG_TRACE(__VA_ARGS__)
36 | #else
37 | # define LV_TRACE_LAYOUT(...)
38 | #endif
39 |
40 | #ifdef __cplusplus
41 | } /*extern "C"*/
42 | #endif
43 |
44 | #endif /*LV_LAYOUTS_H*/
45 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/bmp/lv_bmp.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_bmp.h
3 | *
4 | */
5 |
6 | #ifndef LV_BMP_H
7 | #define LV_BMP_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lv_conf_internal.h"
17 | #if LV_USE_BMP
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 |
27 | /**********************
28 | * GLOBAL PROTOTYPES
29 | **********************/
30 | void lv_bmp_init(void);
31 |
32 | /**********************
33 | * MACROS
34 | **********************/
35 |
36 | #endif /*LV_USE_BMP*/
37 |
38 | #ifdef __cplusplus
39 | } /* extern "C" */
40 | #endif
41 |
42 | #endif /*LV_BMP_H*/
43 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/ffmpeg/lv_ffmpeg.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_ffmpeg.h
3 | *
4 | */
5 | #ifndef LV_FFMPEG_H
6 | #define LV_FFMPEG_H
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /*********************
13 | * INCLUDES
14 | *********************/
15 | #include "../../../lvgl.h"
16 | #if LV_USE_FFMPEG != 0
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 | struct ffmpeg_context_s;
26 |
27 | extern const lv_obj_class_t lv_ffmpeg_player_class;
28 |
29 | typedef struct {
30 | lv_img_t img;
31 | lv_timer_t * timer;
32 | lv_img_dsc_t imgdsc;
33 | bool auto_restart;
34 | struct ffmpeg_context_s * ffmpeg_ctx;
35 | } lv_ffmpeg_player_t;
36 |
37 | typedef enum {
38 | LV_FFMPEG_PLAYER_CMD_START,
39 | LV_FFMPEG_PLAYER_CMD_STOP,
40 | LV_FFMPEG_PLAYER_CMD_PAUSE,
41 | LV_FFMPEG_PLAYER_CMD_RESUME,
42 | _LV_FFMPEG_PLAYER_CMD_LAST
43 | } lv_ffmpeg_player_cmd_t;
44 |
45 | /**********************
46 | * GLOBAL PROTOTYPES
47 | **********************/
48 |
49 | /**
50 | * Register FFMPEG image decoder
51 | */
52 | void lv_ffmpeg_init(void);
53 |
54 | /**
55 | * Get the number of frames contained in the file
56 | * @param path image or video file name
57 | * @return Number of frames, less than 0 means failed
58 | */
59 | int lv_ffmpeg_get_frame_num(const char * path);
60 |
61 | /**
62 | * Create ffmpeg_player object
63 | * @param parent pointer to an object, it will be the parent of the new player
64 | * @return pointer to the created ffmpeg_player
65 | */
66 | lv_obj_t * lv_ffmpeg_player_create(lv_obj_t * parent);
67 |
68 | /**
69 | * Set the path of the file to be played
70 | * @param obj pointer to a ffmpeg_player object
71 | * @param path video file path
72 | * @return LV_RES_OK: no error; LV_RES_INV: can't get the info.
73 | */
74 | lv_res_t lv_ffmpeg_player_set_src(lv_obj_t * obj, const char * path);
75 |
76 | /**
77 | * Set command control video player
78 | * @param obj pointer to a ffmpeg_player object
79 | * @param cmd control commands
80 | */
81 | void lv_ffmpeg_player_set_cmd(lv_obj_t * obj, lv_ffmpeg_player_cmd_t cmd);
82 |
83 | /**
84 | * Set the video to automatically replay
85 | * @param obj pointer to a ffmpeg_player object
86 | * @param en true: enable the auto restart
87 | */
88 | void lv_ffmpeg_player_set_auto_restart(lv_obj_t * obj, bool en);
89 |
90 | /*=====================
91 | * Other functions
92 | *====================*/
93 |
94 | /**********************
95 | * MACROS
96 | **********************/
97 |
98 | #endif /*LV_USE_FFMPEG*/
99 |
100 | #ifdef __cplusplus
101 | } /*extern "C"*/
102 | #endif
103 |
104 | #endif /*LV_FFMPEG_H*/
105 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/freetype/arial.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/clib/lvgl/src/extra/libs/freetype/arial.ttf
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/freetype/lv_freetype.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_freetype.h
3 | *
4 | */
5 | #ifndef LV_FREETYPE_H
6 | #define LV_FREETYPE_H
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /*********************
13 | * INCLUDES
14 | *********************/
15 | #include "../../../lvgl.h"
16 | #if LV_USE_FREETYPE
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 | typedef enum {
26 | FT_FONT_STYLE_NORMAL = 0,
27 | FT_FONT_STYLE_ITALIC = 1 << 0,
28 | FT_FONT_STYLE_BOLD = 1 << 1
29 | } LV_FT_FONT_STYLE;
30 |
31 | typedef struct {
32 | const char * name; /* The name of the font file */
33 | const void * mem; /* The pointer of the font file */
34 | size_t mem_size; /* The size of the memory */
35 | lv_font_t * font; /* point to lvgl font */
36 | uint16_t weight; /* font size */
37 | uint16_t style; /* font style */
38 | } lv_ft_info_t;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /**
45 | * init freetype library
46 | * @param max_faces Maximum number of opened FT_Face objects managed by this cache instance. Use 0 for defaults.
47 | * @param max_sizes Maximum number of opened FT_Size objects managed by this cache instance. Use 0 for defaults.
48 | * @param max_bytes Maximum number of bytes to use for cached data nodes. Use 0 for defaults.
49 | * Note that this value does not account for managed FT_Face and FT_Size objects.
50 | * @return true on success, otherwise false.
51 | */
52 | bool lv_freetype_init(uint16_t max_faces, uint16_t max_sizes, uint32_t max_bytes);
53 |
54 | /**
55 | * Destroy freetype library
56 | */
57 | void lv_freetype_destroy(void);
58 |
59 | /**
60 | * Creates a font with info parameter specified.
61 | * @param info See lv_ft_info_t for details.
62 | * when success, lv_ft_info_t->font point to the font you created.
63 | * @return true on success, otherwise false.
64 | */
65 | bool lv_ft_font_init(lv_ft_info_t * info);
66 |
67 | /**
68 | * Destroy a font that has been created.
69 | * @param font pointer to font.
70 | */
71 | void lv_ft_font_destroy(lv_font_t * font);
72 |
73 | /**********************
74 | * MACROS
75 | **********************/
76 |
77 | #endif /*LV_USE_FREETYPE*/
78 |
79 | #ifdef __cplusplus
80 | } /* extern "C" */
81 | #endif
82 |
83 | #endif /* LV_FREETYPE_H */
84 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/fsdrv/lv_fsdrv.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_fsdrv.h
3 | *
4 | */
5 |
6 | #ifndef LV_FSDRV_H
7 | #define LV_FSDRV_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lv_conf_internal.h"
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 |
26 | /**********************
27 | * GLOBAL PROTOTYPES
28 | **********************/
29 |
30 | #if LV_USE_FS_FATFS != '\0'
31 | void lv_fs_fatfs_init(void);
32 | #endif
33 |
34 | #if LV_USE_FS_STDIO != '\0'
35 | void lv_fs_stdio_init(void);
36 | #endif
37 |
38 | #if LV_USE_FS_POSIX != '\0'
39 | void lv_fs_posix_init(void);
40 | #endif
41 |
42 | #if LV_USE_FS_WIN32 != '\0'
43 | void lv_fs_win32_init(void);
44 | #endif
45 |
46 | /**********************
47 | * MACROS
48 | **********************/
49 |
50 | #ifdef __cplusplus
51 | } /* extern "C" */
52 | #endif
53 |
54 | #endif /*LV_FSDRV_H*/
55 |
56 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/gif/gifdec.h:
--------------------------------------------------------------------------------
1 | #ifndef GIFDEC_H
2 | #define GIFDEC_H
3 |
4 | #include
5 | #include "../../../misc/lv_fs.h"
6 |
7 | #if LV_USE_GIF
8 |
9 | typedef struct gd_Palette {
10 | int size;
11 | uint8_t colors[0x100 * 3];
12 | } gd_Palette;
13 |
14 | typedef struct gd_GCE {
15 | uint16_t delay;
16 | uint8_t tindex;
17 | uint8_t disposal;
18 | int input;
19 | int transparency;
20 | } gd_GCE;
21 |
22 |
23 |
24 | typedef struct gd_GIF {
25 | lv_fs_file_t fd;
26 | const char * data;
27 | uint8_t is_file;
28 | uint32_t f_rw_p;
29 | int32_t anim_start;
30 | uint16_t width, height;
31 | uint16_t depth;
32 | uint16_t loop_count;
33 | gd_GCE gce;
34 | gd_Palette *palette;
35 | gd_Palette lct, gct;
36 | void (*plain_text)(
37 | struct gd_GIF *gif, uint16_t tx, uint16_t ty,
38 | uint16_t tw, uint16_t th, uint8_t cw, uint8_t ch,
39 | uint8_t fg, uint8_t bg
40 | );
41 | void (*comment)(struct gd_GIF *gif);
42 | void (*application)(struct gd_GIF *gif, char id[8], char auth[3]);
43 | uint16_t fx, fy, fw, fh;
44 | uint8_t bgindex;
45 | uint8_t *canvas, *frame;
46 | } gd_GIF;
47 |
48 | gd_GIF * gd_open_gif_file(const char *fname);
49 |
50 | gd_GIF * gd_open_gif_data(const void *data);
51 |
52 | void gd_render_frame(gd_GIF *gif, uint8_t *buffer);
53 |
54 | int gd_get_frame(gd_GIF *gif);
55 | void gd_rewind(gd_GIF *gif);
56 | void gd_close_gif(gd_GIF *gif);
57 |
58 | #endif /*LV_USE_GIF*/
59 |
60 | #endif /* GIFDEC_H */
61 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/gif/lv_gif.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_gif.h
3 | *
4 | */
5 |
6 | #ifndef LV_GIF_H
7 | #define LV_GIF_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 |
17 | #include "../../../lvgl.h"
18 | #if LV_USE_GIF
19 |
20 | #include "gifdec.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | /**********************
27 | * TYPEDEFS
28 | **********************/
29 |
30 | typedef struct {
31 | lv_img_t img;
32 | gd_GIF * gif;
33 | lv_timer_t * timer;
34 | lv_img_dsc_t imgdsc;
35 | uint32_t last_call;
36 | } lv_gif_t;
37 |
38 | extern const lv_obj_class_t lv_gif_class;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | lv_obj_t * lv_gif_create(lv_obj_t * parent);
45 | void lv_gif_set_src(lv_obj_t * obj, const void * src);
46 | void lv_gif_restart(lv_obj_t * gif);
47 |
48 | /**********************
49 | * MACROS
50 | **********************/
51 |
52 | #endif /*LV_USE_GIF*/
53 |
54 | #ifdef __cplusplus
55 | } /* extern "C" */
56 | #endif
57 |
58 | #endif /*LV_GIF_H*/
59 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/lv_libs.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_libs.h
3 | *
4 | */
5 |
6 | #ifndef LV_LIBS_H
7 | #define LV_LIBS_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "bmp/lv_bmp.h"
17 | #include "fsdrv/lv_fsdrv.h"
18 | #include "png/lv_png.h"
19 | #include "gif/lv_gif.h"
20 | #include "qrcode/lv_qrcode.h"
21 | #include "sjpg/lv_sjpg.h"
22 | #include "freetype/lv_freetype.h"
23 | #include "rlottie/lv_rlottie.h"
24 | #include "ffmpeg/lv_ffmpeg.h"
25 |
26 | /*********************
27 | * DEFINES
28 | *********************/
29 |
30 | /**********************
31 | * TYPEDEFS
32 | **********************/
33 |
34 | /**********************
35 | * GLOBAL PROTOTYPES
36 | **********************/
37 |
38 | /**********************
39 | * MACROS
40 | **********************/
41 |
42 | #ifdef __cplusplus
43 | } /*extern "C"*/
44 | #endif
45 |
46 | #endif /*LV_LIBS_H*/
47 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/png/lv_png.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_png.h
3 | *
4 | */
5 |
6 | #ifndef LV_PNG_H
7 | #define LV_PNG_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lv_conf_internal.h"
17 | #if LV_USE_PNG
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 |
27 | /**********************
28 | * GLOBAL PROTOTYPES
29 | **********************/
30 |
31 | /**
32 | * Register the PNG decoder functions in LVGL
33 | */
34 | void lv_png_init(void);
35 |
36 | /**********************
37 | * MACROS
38 | **********************/
39 |
40 | #endif /*LV_USE_PNG*/
41 |
42 | #ifdef __cplusplus
43 | } /* extern "C" */
44 | #endif
45 |
46 | #endif /*LV_PNG_H*/
47 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/qrcode/lv_qrcode.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_qrcode
3 | *
4 | */
5 |
6 | #ifndef LV_QRCODE_H
7 | #define LV_QRCODE_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lvgl.h"
17 | #if LV_USE_QRCODE
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | extern const lv_obj_class_t lv_qrcode_class;
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 |
29 | /**********************
30 | * GLOBAL PROTOTYPES
31 | **********************/
32 |
33 | /**
34 | * Create an empty QR code (an `lv_canvas`) object.
35 | * @param parent point to an object where to create the QR code
36 | * @param size width and height of the QR code
37 | * @param dark_color dark color of the QR code
38 | * @param light_color light color of the QR code
39 | * @return pointer to the created QR code object
40 | */
41 | lv_obj_t * lv_qrcode_create(lv_obj_t * parent, lv_coord_t size, lv_color_t dark_color, lv_color_t light_color);
42 |
43 | /**
44 | * Set the data of a QR code object
45 | * @param qrcode pointer to aQ code object
46 | * @param data data to display
47 | * @param data_len length of data in bytes
48 | * @return LV_RES_OK: if no error; LV_RES_INV: on error
49 | */
50 | lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_len);
51 |
52 | /**
53 | * DEPRECATED: Use normal lv_obj_del instead
54 | * Delete a QR code object
55 | * @param qrcode pointer to a QR code object
56 | */
57 | void lv_qrcode_delete(lv_obj_t * qrcode);
58 |
59 | /**********************
60 | * MACROS
61 | **********************/
62 |
63 | #endif /*LV_USE_QRCODE*/
64 |
65 | #ifdef __cplusplus
66 | } /* extern "C" */
67 | #endif
68 |
69 | #endif /*LV_QRCODE_H*/
70 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/rlottie/lv_rlottie.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_rlottie.h
3 | *
4 | */
5 |
6 | #ifndef LV_RLOTTIE_H
7 | #define LV_RLOTTIE_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lvgl.h"
17 | #if LV_USE_RLOTTIE
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 | typedef enum {
27 | LV_RLOTTIE_CTRL_FORWARD = 0,
28 | LV_RLOTTIE_CTRL_BACKWARD = 1,
29 | LV_RLOTTIE_CTRL_PAUSE = 2,
30 | LV_RLOTTIE_CTRL_PLAY = 0, /* Yes, play = 0 is the default mode */
31 | LV_RLOTTIE_CTRL_LOOP = 8,
32 | } lv_rlottie_ctrl_t;
33 |
34 | /** definition in lottieanimation_capi.c */
35 | struct Lottie_Animation_S;
36 | typedef struct {
37 | lv_img_t img_ext;
38 | struct Lottie_Animation_S * animation;
39 | lv_timer_t * task;
40 | lv_img_dsc_t imgdsc;
41 | size_t total_frames;
42 | size_t current_frame;
43 | size_t framerate;
44 | uint32_t * allocated_buf;
45 | size_t allocated_buffer_size;
46 | size_t scanline_width;
47 | lv_rlottie_ctrl_t play_ctrl;
48 | size_t dest_frame;
49 | } lv_rlottie_t;
50 |
51 | extern const lv_obj_class_t lv_rlottie_class;
52 |
53 | /**********************
54 | * GLOBAL PROTOTYPES
55 | **********************/
56 |
57 | lv_obj_t * lv_rlottie_create_from_file(lv_obj_t * parent, lv_coord_t width, lv_coord_t height, const char * path);
58 |
59 | lv_obj_t * lv_rlottie_create_from_raw(lv_obj_t * parent, lv_coord_t width, lv_coord_t height,
60 | const char * rlottie_desc);
61 |
62 | void lv_rlottie_set_play_mode(lv_obj_t * rlottie, const lv_rlottie_ctrl_t ctrl);
63 | void lv_rlottie_set_current_frame(lv_obj_t * rlottie, const size_t goto_frame);
64 |
65 | /**********************
66 | * MACROS
67 | **********************/
68 |
69 | #endif /*LV_USE_RLOTTIE*/
70 |
71 | #ifdef __cplusplus
72 | } /* extern "C" */
73 | #endif
74 |
75 | #endif /*LV_RLOTTIE_H*/
76 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/sjpg/lv_sjpg.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_sjpg.h
3 | *
4 | */
5 |
6 | #ifndef LV_SJPEG_H
7 | #define LV_SJPEG_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 |
17 | #if LV_USE_SJPG
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 |
27 | /**********************
28 | * GLOBAL PROTOTYPES
29 | **********************/
30 |
31 | void lv_split_jpeg_init(void);
32 |
33 | /**********************
34 | * MACROS
35 | **********************/
36 |
37 | #endif /*LV_USE_SJPG*/
38 |
39 | #ifdef __cplusplus
40 | }
41 | #endif
42 |
43 | #endif /* LV_SJPEG_H */
44 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/libs/sjpg/tjpgdcnf.h:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------*/
2 | /* TJpgDec System Configurations R0.03 */
3 | /*----------------------------------------------*/
4 |
5 | #define JD_SZBUF 512
6 | /* Specifies size of stream input buffer */
7 |
8 | #define JD_FORMAT 0
9 | /* Specifies output pixel format.
10 | / 0: RGB888 (24-bit/pix)
11 | / 1: RGB565 (16-bit/pix)
12 | / 2: Grayscale (8-bit/pix)
13 | */
14 |
15 | #define JD_USE_SCALE 1
16 | /* Switches output descaling feature.
17 | / 0: Disable
18 | / 1: Enable
19 | */
20 |
21 | #define JD_TBLCLIP 1
22 | /* Use table conversion for saturation arithmetic. A bit faster, but increases 1 KB of code size.
23 | / 0: Disable
24 | / 1: Enable
25 | */
26 |
27 | #define JD_FASTDECODE 0
28 | /* Optimization level
29 | / 0: Basic optimization. Suitable for 8/16-bit MCUs.
30 | / 1: + 32-bit barrel shifter. Suitable for 32-bit MCUs.
31 | / 2: + Table conversion for huffman decoding (wants 6 << HUFF_BIT bytes of RAM)
32 | */
33 |
34 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/lv_extra.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_extra.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "../lvgl.h"
10 |
11 | /*********************
12 | * DEFINES
13 | *********************/
14 |
15 | /**********************
16 | * TYPEDEFS
17 | **********************/
18 |
19 | /**********************
20 | * STATIC PROTOTYPES
21 | **********************/
22 |
23 | /**********************
24 | * STATIC VARIABLES
25 | **********************/
26 |
27 | /**********************
28 | * MACROS
29 | **********************/
30 |
31 | /**********************
32 | * GLOBAL FUNCTIONS
33 | **********************/
34 |
35 | void lv_extra_init(void)
36 | {
37 | #if LV_USE_FLEX
38 | lv_flex_init();
39 | #endif
40 |
41 | #if LV_USE_GRID
42 | lv_grid_init();
43 | #endif
44 |
45 | #if LV_USE_FS_FATFS != '\0'
46 | lv_fs_fatfs_init();
47 | #endif
48 |
49 | #if LV_USE_FS_STDIO != '\0'
50 | lv_fs_stdio_init();
51 | #endif
52 |
53 | #if LV_USE_FS_POSIX != '\0'
54 | lv_fs_posix_init();
55 | #endif
56 |
57 | #if LV_USE_FS_WIN32 != '\0'
58 | lv_fs_win32_init();
59 | #endif
60 |
61 | #if LV_USE_PNG
62 | lv_png_init();
63 | #endif
64 |
65 | #if LV_USE_SJPG
66 | lv_split_jpeg_init();
67 | #endif
68 |
69 | #if LV_USE_BMP
70 | lv_bmp_init();
71 | #endif
72 |
73 | #if LV_USE_FREETYPE
74 | /*Init freetype library*/
75 | # if LV_FREETYPE_CACHE_SIZE >= 0
76 | lv_freetype_init(LV_FREETYPE_CACHE_FT_FACES, LV_FREETYPE_CACHE_FT_SIZES, LV_FREETYPE_CACHE_SIZE);
77 | # else
78 | lv_freetype_init(0, 0, 0);
79 | # endif
80 | #endif
81 |
82 | #if LV_USE_FFMPEG
83 | lv_ffmpeg_init();
84 | #endif
85 | }
86 |
87 | /**********************
88 | * STATIC FUNCTIONS
89 | **********************/
90 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/lv_extra.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_extra.h
3 | *
4 | */
5 |
6 | #ifndef LV_EXTRA_H
7 | #define LV_EXTRA_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 | * Initialize the extra components
31 | */
32 | void lv_extra_init(void);
33 |
34 | /**********************
35 | * MACROS
36 | **********************/
37 |
38 | #ifdef __cplusplus
39 | } /*extern "C"*/
40 | #endif
41 |
42 | #endif /*LV_EXTRA_H*/
43 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/others/gridnav/lv_gridnav.h:
--------------------------------------------------------------------------------
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 | /**
42 | * @file lv_gridnav.h
43 | *
44 | */
45 |
46 | #ifndef LV_GRIDFOCUS_H
47 | #define LV_GRIDFOCUS_H
48 |
49 | #ifdef __cplusplus
50 | extern "C" {
51 | #endif
52 |
53 | /*********************
54 | * INCLUDES
55 | *********************/
56 | #include "../../../core/lv_obj.h"
57 |
58 | #if LV_USE_GRIDNAV
59 |
60 | /*********************
61 | * DEFINES
62 | *********************/
63 |
64 | /**********************
65 | * TYPEDEFS
66 | **********************/
67 | typedef enum {
68 | LV_GRIDNAV_CTRL_NONE = 0x0,
69 |
70 | /**
71 | * If there is no next/previous object in a direction,
72 | * the focus goes to the object in the next/previous row (on left/right keys)
73 | * or first/last row (on up/down keys)
74 | */
75 | LV_GRIDNAV_CTRL_ROLLOVER = 0x1,
76 |
77 | /**
78 | * If an arrow is pressed and the focused object can be scrolled in that direction
79 | * then it will be scrolled instead of going to the next/previous object.
80 | * If there is no more room for scrolling the next/previous object will be focused normally */
81 | LV_GRIDNAV_CTRL_SCROLL_FIRST = 0x2,
82 |
83 | } lv_gridnav_ctrl_t;
84 |
85 | /**********************
86 | * GLOBAL PROTOTYPES
87 | **********************/
88 |
89 | /**
90 | * Add grid navigation feature to an object. It expects the children to be arranged
91 | * into a grid-like layout. Although it's not required to have pixel perfect alignment.
92 | * This feature makes possible to use keys to navigate among the children and focus them.
93 | * The keys other than arrows and press/release related events
94 | * are forwarded to the focused child.
95 | * @param obj pointer to an object on which navigation should be applied.
96 | * @param ctrl control flags from `lv_gridnav_ctrl_t`.
97 | */
98 | void lv_gridnav_add(lv_obj_t * obj, lv_gridnav_ctrl_t ctrl);
99 |
100 | /**
101 | * Remove the grid navigation support from an object
102 | * @param obj pointer to an object
103 | */
104 | void lv_gridnav_remove(lv_obj_t * obj);
105 |
106 | /**********************
107 | * MACROS
108 | **********************/
109 | #endif /*LV_USE_GRIDNAV*/
110 |
111 | #ifdef __cplusplus
112 | } /*extern "C"*/
113 | #endif
114 |
115 | #endif /*LV_GRIDFOCUS_H*/
116 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/others/lv_others.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_others.h
3 | *
4 | */
5 |
6 | #ifndef LV_OTHERS_H
7 | #define LV_OTHERS_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "snapshot/lv_snapshot.h"
17 | #include "monkey/lv_monkey.h"
18 | #include "gridnav/lv_gridnav.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 /*LV_OTHERS_H*/
41 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/others/monkey/lv_monkey.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_monkey.h
3 | *
4 | */
5 | #ifndef LV_MONKEY_H
6 | #define LV_MONKEY_H
7 |
8 | #ifdef __cplusplus
9 | extern "C" {
10 | #endif
11 |
12 | /*********************
13 | * INCLUDES
14 | *********************/
15 | #include "../../../lvgl.h"
16 |
17 | #if LV_USE_MONKEY != 0
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 | struct _lv_monkey;
27 | typedef struct _lv_monkey lv_monkey_t;
28 |
29 | typedef struct {
30 | /**< Input device type*/
31 | lv_indev_type_t type;
32 |
33 | /**< Monkey execution period*/
34 | struct {
35 | uint32_t min;
36 | uint32_t max;
37 | } period_range;
38 |
39 | /**< The range of input value*/
40 | struct {
41 | int32_t min;
42 | int32_t max;
43 | } input_range;
44 | } lv_monkey_config_t;
45 |
46 | /**********************
47 | * GLOBAL PROTOTYPES
48 | **********************/
49 |
50 | /**
51 | * Initialize a monkey config with default values
52 | * @param config pointer to 'lv_monkey_config_t' variable to initialize
53 | */
54 | void lv_monkey_config_init(lv_monkey_config_t * config);
55 |
56 | /**
57 | * Create monkey for test
58 | * @param config pointer to 'lv_monkey_config_t' variable
59 | * @return pointer to the created monkey
60 | */
61 | lv_monkey_t * lv_monkey_create(const lv_monkey_config_t * config);
62 |
63 | /**
64 | * Get monkey input device
65 | * @param monkey pointer to a monkey
66 | * @return pointer to the input device
67 | */
68 | lv_indev_t * lv_monkey_get_indev(lv_monkey_t * monkey);
69 |
70 | /**
71 | * Enable monkey
72 | * @param monkey pointer to a monkey
73 | * @param en set to true to enable
74 | */
75 | void lv_monkey_set_enable(lv_monkey_t * monkey, bool en);
76 |
77 | /**
78 | * Get whether monkey is enabled
79 | * @param monkey pointer to a monkey
80 | * @return return true if monkey enabled
81 | */
82 | bool lv_monkey_get_enable(lv_monkey_t * monkey);
83 |
84 | #if LV_USE_USER_DATA
85 |
86 | /**
87 | * Set the user_data field of the monkey
88 | * @param monkey pointer to a monkey
89 | * @param user_data pointer to the new user_data.
90 | */
91 | void lv_monkey_set_user_data(lv_monkey_t * monkey, void * user_data);
92 |
93 | /**
94 | * Get the user_data field of the monkey
95 | * @param monkey pointer to a monkey
96 | * @return the pointer to the user_data of the monkey
97 | */
98 | void * lv_monkey_get_user_data(lv_monkey_t * monkey);
99 |
100 | #endif/*LV_USE_USER_DATA*/
101 |
102 | /**
103 | * Delete monkey
104 | * @param monkey pointer to monkey
105 | */
106 | void lv_monkey_del(lv_monkey_t * monkey);
107 |
108 | /**********************
109 | * MACROS
110 | **********************/
111 |
112 | #endif /*LV_USE_MONKEY*/
113 |
114 | #ifdef __cplusplus
115 | } /*extern "C"*/
116 | #endif
117 |
118 | #endif /*LV_MONKEY_H*/
119 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/others/snapshot/lv_snapshot.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_snapshot.h
3 | *
4 | */
5 |
6 | #ifndef LV_SNAPSHOT_H
7 | #define LV_SNAPSHOT_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include
17 | #include
18 |
19 | #include "../../../lv_conf_internal.h"
20 | #include "../../../core/lv_obj.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | #if LV_USE_SNAPSHOT
27 | /**********************
28 | * TYPEDEFS
29 | **********************/
30 |
31 | /**********************
32 | * GLOBAL PROTOTYPES
33 | **********************/
34 |
35 | /** Take snapshot for object with its children.
36 | *
37 | * @param obj The object to generate snapshot.
38 | * @param cf color format for generated image.
39 | *
40 | * @return a pointer to an image descriptor, or NULL if failed.
41 | */
42 | lv_img_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_img_cf_t cf);
43 |
44 | /** Free the snapshot image returned by @ref lv_snapshot_take
45 | *
46 | * It will firstly free the data image takes, then the image descriptor.
47 | *
48 | * @param dsc The image descriptor generated by lv_snapshot_take.
49 | *
50 | */
51 | void lv_snapshot_free(lv_img_dsc_t * dsc);
52 |
53 | /** Get the buffer needed for object snapshot image.
54 | *
55 | * @param obj The object to generate snapshot.
56 | * @param cf color format for generated image.
57 | *
58 | * @return the buffer size needed in bytes
59 | */
60 | uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_img_cf_t cf);
61 |
62 | /** Take snapshot for object with its children, save image info to provided buffer.
63 | *
64 | * @param obj The object to generate snapshot.
65 | * @param cf color format for generated image.
66 | * @param dsc image descriptor to store the image result.
67 | * @param buff the buffer to store image data.
68 | * @param buff_size provided buffer size in bytes.
69 | *
70 | * @return LV_RES_OK on success, LV_RES_INV on error.
71 | */
72 | lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size);
73 |
74 |
75 | /**********************
76 | * MACROS
77 | **********************/
78 | #endif /*LV_USE_SNAPSHOT*/
79 |
80 | #ifdef __cplusplus
81 | } /*extern "C"*/
82 | #endif
83 |
84 | #endif
85 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/themes/basic/lv_theme_basic.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_theme_basic.h
3 | *
4 | */
5 |
6 | #ifndef LV_THEME_BASIC_H
7 | #define LV_THEME_BASIC_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../core/lv_obj.h"
17 |
18 | #if LV_USE_THEME_BASIC
19 |
20 | /*********************
21 | * DEFINES
22 | *********************/
23 |
24 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 |
28 | /**********************
29 | * GLOBAL PROTOTYPES
30 | **********************/
31 |
32 | /**
33 | * Initialize the theme
34 | * @param disp pointer to display to attach the theme
35 | * @return a pointer to reference this theme later
36 | */
37 | lv_theme_t * lv_theme_basic_init(lv_disp_t * disp);
38 |
39 | /**
40 | * Check if the theme is initialized
41 | * @return true if default theme is initialized, false otherwise
42 | */
43 | bool lv_theme_basic_is_inited(void);
44 |
45 | /**********************
46 | * MACROS
47 | **********************/
48 |
49 | #endif
50 |
51 | #ifdef __cplusplus
52 | } /*extern "C"*/
53 | #endif
54 |
55 | #endif /*LV_THEME_BASIC_H*/
56 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/themes/default/lv_theme_default.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_theme_default.h
3 | *
4 | */
5 |
6 | #ifndef LV_THEME_DEFAULT_H
7 | #define LV_THEME_DEFAULT_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../core/lv_obj.h"
17 |
18 | #if LV_USE_THEME_DEFAULT
19 |
20 | /*********************
21 | * DEFINES
22 | *********************/
23 |
24 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 |
28 | /**********************
29 | * GLOBAL PROTOTYPES
30 | **********************/
31 |
32 | /**
33 | * Initialize the theme
34 | * @param color_primary the primary color of the theme
35 | * @param color_secondary the secondary color for the theme
36 | * @param font pointer to a font to use.
37 | * @return a pointer to reference this theme later
38 | */
39 | lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark,
40 | const lv_font_t * font);
41 |
42 | /**
43 | * Get default theme
44 | * @return a pointer to default theme, or NULL if this is not initialized
45 | */
46 | lv_theme_t * lv_theme_default_get(void);
47 |
48 | /**
49 | * Check if default theme is initialized
50 | * @return true if default theme is initialized, false otherwise
51 | */
52 | bool lv_theme_default_is_inited(void);
53 |
54 | /**********************
55 | * MACROS
56 | **********************/
57 |
58 | #endif
59 |
60 | #ifdef __cplusplus
61 | } /*extern "C"*/
62 | #endif
63 |
64 | #endif /*LV_THEME_DEFAULT_H*/
65 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/themes/lv_themes.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_themes.h
3 | *
4 | */
5 |
6 | #ifndef LV_THEMES_H
7 | #define LV_THEMES_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "default/lv_theme_default.h"
17 | #include "mono/lv_theme_mono.h"
18 | #include "basic/lv_theme_basic.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 /*LV_THEMES_H*/
41 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/themes/mono/lv_theme_mono.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_theme_mono.h
3 | *
4 | */
5 |
6 | #ifndef LV_USE_THEME_MONO_H
7 | #define LV_USE_THEME_MONO_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../core/lv_obj.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 | * Initialize the theme
34 | * @param color_primary the primary color of the theme
35 | * @param color_secondary the secondary color for the theme
36 | * @param font pointer to a font to use.
37 | * @return a pointer to reference this theme later
38 | */
39 | lv_theme_t * lv_theme_mono_init(lv_disp_t * disp, bool dark_bg, const lv_font_t * font);
40 |
41 | /**
42 | * Check if the theme is initialized
43 | * @return true if default theme is initialized, false otherwise
44 | */
45 | bool lv_theme_mono_is_inited(void);
46 |
47 | /**********************
48 | * MACROS
49 | **********************/
50 |
51 | #endif
52 |
53 | #ifdef __cplusplus
54 | } /*extern "C"*/
55 | #endif
56 |
57 | #endif /*LV_USE_THEME_MONO_H*/
58 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/animimg/lv_animimg.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_animimg.h
3 | *
4 | */
5 |
6 | #ifndef LV_ANIM_IMG_H
7 | #define LV_ANIM_IMG_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lvgl.h"
17 |
18 | #if LV_USE_ANIMIMG != 0
19 |
20 | /*Testing of dependencies*/
21 | #if LV_USE_IMG == 0
22 | #error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1)"
23 | #endif
24 |
25 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | extern const lv_obj_class_t lv_animimg_class;
34 |
35 | /*Data of image*/
36 | typedef struct {
37 | lv_img_t img;
38 | lv_anim_t anim;
39 | /*picture sequence */
40 | lv_img_dsc_t ** dsc;
41 | int8_t pic_count;
42 | } lv_animimg_t;
43 |
44 |
45 | /*Image parts*/
46 | enum {
47 | LV_ANIM_IMG_PART_MAIN,
48 | };
49 | typedef uint8_t lv_animimg_part_t;
50 |
51 | /**********************
52 | * GLOBAL PROTOTYPES
53 | **********************/
54 |
55 | /**
56 | * Create an animation image objects
57 | * @param parent pointer to an object, it will be the parent of the new button
58 | * @return pointer to the created animation image object
59 | */
60 | lv_obj_t * lv_animimg_create(lv_obj_t * parent);
61 |
62 | /*=====================
63 | * Setter functions
64 | *====================*/
65 |
66 | /**
67 | * Set the image animation images source.
68 | * @param img pointer to an animation image object
69 | * @param dsc pointer to a series images
70 | * @param num images' number
71 | */
72 | void lv_animimg_set_src(lv_obj_t * img, lv_img_dsc_t * dsc[], uint8_t num);
73 |
74 | /**
75 | * Startup the image animation.
76 | * @param obj pointer to an animation image object
77 | */
78 | void lv_animimg_start(lv_obj_t * obj);
79 |
80 | /**
81 | * Set the image animation duration time. unit:ms
82 | * @param img pointer to an animation image object
83 | */
84 | void lv_animimg_set_duration(lv_obj_t * img, uint32_t duration);
85 |
86 | /**
87 | * Set the image animation reapeatly play times.
88 | * @param img pointer to an animation image object
89 | * @param count the number of times to repeat the animation
90 | */
91 | void lv_animimg_set_repeat_count(lv_obj_t * img, uint16_t count);
92 |
93 | /*=====================
94 | * Getter functions
95 | *====================*/
96 |
97 | #endif /*LV_USE_ANIMIMG*/
98 |
99 | #ifdef __cplusplus
100 | } /* extern "C" */
101 | #endif
102 |
103 | #endif /*LV_ANIM_IMG_H*/
104 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_calendar_header_arrow.h
3 | *
4 | */
5 |
6 | #ifndef LV_CALENDAR_HEADER_ARROW_H
7 | #define LV_CALENDAR_HEADER_ARROW_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../core/lv_obj.h"
17 | #if LV_USE_CALENDAR_HEADER_ARROW
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 | extern const lv_obj_class_t lv_calendar_header_arrow_class;
27 |
28 | /**********************
29 | * GLOBAL PROTOTYPES
30 | **********************/
31 |
32 | /**
33 | * Create a calendar header with drop-drowns to select the year and month
34 | * @param parent pointer to a calendar object.
35 | * @return the created header
36 | */
37 | lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent);
38 |
39 | /**********************
40 | * MACROS
41 | **********************/
42 |
43 | #endif /*LV_USE_CALENDAR_HEADER_ARROW*/
44 |
45 | #ifdef __cplusplus
46 | } /*extern "C"*/
47 | #endif
48 |
49 | #endif /*LV_CALENDAR_HEADER_ARROW_H*/
50 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_calendar_header_dropdown.h
3 | *
4 | */
5 |
6 | #ifndef LV_CALENDAR_HEADER_DROPDOWN_H
7 | #define LV_CALENDAR_HEADER_DROPDOWN_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../core/lv_obj.h"
17 | #if LV_USE_CALENDAR_HEADER_DROPDOWN
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 | extern const lv_obj_class_t lv_calendar_header_dropdown_class;
27 |
28 | /**********************
29 | * GLOBAL PROTOTYPES
30 | **********************/
31 |
32 | /**
33 | * Create a calendar header with drop-drowns to select the year and month
34 | * @param parent pointer to a calendar object.
35 | * @return the created header
36 | */
37 | lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent);
38 |
39 | /**********************
40 | * MACROS
41 | **********************/
42 |
43 | #endif /*LV_USE_CALENDAR_HEADER_ARROW*/
44 |
45 | #ifdef __cplusplus
46 | } /*extern "C"*/
47 | #endif
48 |
49 | #endif /*LV_CALENDAR_HEADER_DROPDOWN_H*/
50 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/led/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 "../../../lvgl.h"
17 |
18 | #if LV_USE_LED
19 |
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 | /** Brightness when the LED if OFF */
25 | #ifndef LV_LED_BRIGHT_MIN
26 | # define LV_LED_BRIGHT_MIN 80
27 | #endif
28 |
29 | /** Brightness when the LED if ON */
30 | #ifndef LV_LED_BRIGHT_MAX
31 | # define LV_LED_BRIGHT_MAX 255
32 | #endif
33 |
34 | /**********************
35 | * TYPEDEFS
36 | **********************/
37 |
38 | /*Data of led*/
39 | typedef struct {
40 | lv_obj_t obj;
41 | lv_color_t color;
42 | uint8_t bright; /**< Current brightness of the LED (0..255)*/
43 | } lv_led_t;
44 |
45 | extern const lv_obj_class_t lv_led_class;
46 |
47 | /**
48 | * `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_led_class`
49 | * Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
50 | */
51 | typedef enum {
52 | LV_LED_DRAW_PART_RECTANGLE, /**< The main rectangle*/
53 | } lv_led_draw_part_type_t;
54 |
55 | /**********************
56 | * GLOBAL PROTOTYPES
57 | **********************/
58 |
59 | /**
60 | * Create a led object
61 | * @param parent pointer to an object, it will be the parent of the new led
62 | * @return pointer to the created led
63 | */
64 | lv_obj_t * lv_led_create(lv_obj_t * parent);
65 |
66 | /**
67 | * Set the color of the LED
68 | * @param led pointer to a LED object
69 | * @param color the color of the LED
70 | */
71 | void lv_led_set_color(lv_obj_t * led, lv_color_t color);
72 |
73 | /**
74 | * Set the brightness of a LED object
75 | * @param led pointer to a LED object
76 | * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light)
77 | */
78 | void lv_led_set_brightness(lv_obj_t * led, uint8_t bright);
79 |
80 | /**
81 | * Light on a LED
82 | * @param led pointer to a LED object
83 | */
84 | void lv_led_on(lv_obj_t * led);
85 |
86 | /**
87 | * Light off a LED
88 | * @param led pointer to a LED object
89 | */
90 | void lv_led_off(lv_obj_t * led);
91 |
92 | /**
93 | * Toggle the state of a LED
94 | * @param led pointer to a LED object
95 | */
96 | void lv_led_toggle(lv_obj_t * led);
97 |
98 | /**
99 | * Get the brightness of a LEd object
100 | * @param led pointer to LED object
101 | * @return bright 0 (max. dark) ... 255 (max. light)
102 | */
103 | uint8_t lv_led_get_brightness(const lv_obj_t * obj);
104 |
105 | /**********************
106 | * MACROS
107 | **********************/
108 |
109 | #endif /*LV_USE_LED*/
110 |
111 | #ifdef __cplusplus
112 | } /*extern "C"*/
113 | #endif
114 |
115 |
116 | #endif /*LV_LED_H*/
117 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/list/lv_list.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_win.h
3 | *
4 | */
5 |
6 | #ifndef LV_LIST_H
7 | #define LV_LIST_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../core/lv_obj.h"
17 | #include "../../layouts/flex/lv_flex.h"
18 |
19 | #if LV_USE_LIST
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 |
29 | extern const lv_obj_class_t lv_list_class;
30 | extern const lv_obj_class_t lv_list_text_class;
31 | extern const lv_obj_class_t lv_list_btn_class;
32 | /**********************
33 | * GLOBAL PROTOTYPES
34 | **********************/
35 |
36 | lv_obj_t * lv_list_create(lv_obj_t * parent);
37 |
38 | lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt);
39 |
40 | lv_obj_t * lv_list_add_btn(lv_obj_t * list, const char * icon, const char * txt);
41 |
42 | const char * lv_list_get_btn_text(lv_obj_t * list, lv_obj_t * btn);
43 |
44 | /**********************
45 | * MACROS
46 | **********************/
47 |
48 | #endif /*LV_USE_LIST*/
49 |
50 | #ifdef __cplusplus
51 | } /*extern "C"*/
52 | #endif
53 |
54 | #endif /*LV_LIST_H*/
55 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/lv_widgets.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_widgets.h
3 | *
4 | */
5 |
6 | #ifndef LV_WIDGETS_H
7 | #define LV_WIDGETS_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "animimg/lv_animimg.h"
17 | #include "calendar/lv_calendar.h"
18 | #include "calendar/lv_calendar_header_arrow.h"
19 | #include "calendar/lv_calendar_header_dropdown.h"
20 | #include "chart/lv_chart.h"
21 | #include "keyboard/lv_keyboard.h"
22 | #include "list/lv_list.h"
23 | #include "menu/lv_menu.h"
24 | #include "msgbox/lv_msgbox.h"
25 | #include "meter/lv_meter.h"
26 | #include "spinbox/lv_spinbox.h"
27 | #include "spinner/lv_spinner.h"
28 | #include "tabview/lv_tabview.h"
29 | #include "tileview/lv_tileview.h"
30 | #include "win/lv_win.h"
31 | #include "colorwheel/lv_colorwheel.h"
32 | #include "led/lv_led.h"
33 | #include "imgbtn/lv_imgbtn.h"
34 | #include "span/lv_span.h"
35 |
36 | /*********************
37 | * DEFINES
38 | *********************/
39 |
40 | /**********************
41 | * TYPEDEFS
42 | **********************/
43 |
44 | /**********************
45 | * GLOBAL PROTOTYPES
46 | **********************/
47 |
48 | /**********************
49 | * MACROS
50 | **********************/
51 |
52 | #ifdef __cplusplus
53 | } /*extern "C"*/
54 | #endif
55 |
56 | #endif /*LV_WIDGETS_H*/
57 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/msgbox/lv_msgbox.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_mbox.h
3 | *
4 | */
5 |
6 | #ifndef LV_MSGBOX_H
7 | #define LV_MSGBOX_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lvgl.h"
17 |
18 | #if LV_USE_MSGBOX
19 |
20 | /*Testing of dependencies*/
21 | #if LV_USE_BTNMATRIX == 0
22 | #error "lv_mbox: lv_btnm is required. Enable it in lv_conf.h (LV_USE_BTNMATRIX 1) "
23 | #endif
24 |
25 | #if LV_USE_LABEL == 0
26 | #error "lv_mbox: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1) "
27 | #endif
28 |
29 | /*********************
30 | * DEFINES
31 | *********************/
32 |
33 | /**********************
34 | * TYPEDEFS
35 | **********************/
36 |
37 | typedef struct {
38 | lv_obj_t obj;
39 | lv_obj_t * title;
40 | lv_obj_t * close_btn;
41 | lv_obj_t * content;
42 | lv_obj_t * text;
43 | lv_obj_t * btns;
44 | } lv_msgbox_t;
45 |
46 | extern const lv_obj_class_t lv_msgbox_class;
47 | extern const lv_obj_class_t lv_msgbox_content_class;
48 | extern const lv_obj_class_t lv_msgbox_backdrop_class;
49 |
50 | /**********************
51 | * GLOBAL PROTOTYPES
52 | **********************/
53 |
54 | /**
55 | * Create a message box object
56 | * @param parent pointer to parent or NULL to create a full screen modal message box
57 | * @param title the title of the message box
58 | * @param txt the text of the message box
59 | * @param btn_txts the buttons as an array of texts terminated by an "" element. E.g. {"btn1", "btn2", ""}
60 | * @param add_close_btn true: add a close button
61 | * @return pointer to the message box object
62 | */
63 | lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[],
64 | bool add_close_btn);
65 |
66 | lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj);
67 |
68 | lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj);
69 |
70 | lv_obj_t * lv_msgbox_get_text(lv_obj_t * obj);
71 |
72 | lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj);
73 |
74 | lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj);
75 |
76 | /**
77 | * Get the index of the selected button
78 | * @param mbox message box object
79 | * @return index of the button (LV_BTNMATRIX_BTN_NONE: if unset)
80 | */
81 | uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox);
82 |
83 | const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox);
84 |
85 | void lv_msgbox_close(lv_obj_t * mbox);
86 |
87 | void lv_msgbox_close_async(lv_obj_t * mbox);
88 |
89 | /**********************
90 | * MACROS
91 | **********************/
92 |
93 | #endif /*LV_USE_MSGBOX*/
94 |
95 | #ifdef __cplusplus
96 | } /*extern "C"*/
97 | #endif
98 |
99 | #endif /*LV_MSGBOX_H*/
100 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/spinner/lv_spinner.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_spinner.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "lv_spinner.h"
10 | #if LV_USE_SPINNER
11 |
12 | /*********************
13 | * DEFINES
14 | *********************/
15 |
16 | /**********************
17 | * TYPEDEFS
18 | **********************/
19 |
20 | /**********************
21 | * STATIC PROTOTYPES
22 | **********************/
23 | static void lv_spinner_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
24 | static void arc_anim_start_angle(void * obj, int32_t v);
25 | static void arc_anim_end_angle(void * obj, int32_t v);
26 |
27 | /**********************
28 | * STATIC VARIABLES
29 | **********************/
30 | const lv_obj_class_t lv_spinner_class = {
31 | .base_class = &lv_arc_class,
32 | .constructor_cb = lv_spinner_constructor
33 | };
34 |
35 | static uint32_t time_param;
36 | static uint32_t arc_length_param;
37 |
38 | /**********************
39 | * MACROS
40 | **********************/
41 |
42 | /**********************
43 | * GLOBAL FUNCTIONS
44 | **********************/
45 |
46 | /**
47 | * Create a spinner object
48 | * @param parent pointer to an object, it will be the parent of the new spinner
49 | * @return pointer to the created spinner
50 | */
51 | lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length)
52 | {
53 | time_param = time;
54 | arc_length_param = arc_length;
55 |
56 | lv_obj_t * obj = lv_obj_class_create_obj(&lv_spinner_class, parent);
57 | lv_obj_class_init_obj(obj);
58 | return obj;
59 | }
60 |
61 |
62 | /**********************
63 | * STATIC FUNCTIONS
64 | **********************/
65 |
66 | static void lv_spinner_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
67 | {
68 | LV_TRACE_OBJ_CREATE("begin");
69 |
70 | LV_UNUSED(class_p);
71 |
72 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE);
73 |
74 | lv_anim_t a;
75 | lv_anim_init(&a);
76 | lv_anim_set_var(&a, obj);
77 | lv_anim_set_exec_cb(&a, arc_anim_end_angle);
78 | lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE);
79 | lv_anim_set_time(&a, time_param);
80 | lv_anim_set_values(&a, arc_length_param, 360 + arc_length_param);
81 | lv_anim_start(&a);
82 |
83 | lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
84 | lv_anim_set_values(&a, 0, 360);
85 | lv_anim_set_exec_cb(&a, arc_anim_start_angle);
86 | lv_anim_start(&a);
87 |
88 | lv_arc_set_bg_angles(obj, 0, 360);
89 | lv_arc_set_rotation(obj, 270);
90 | }
91 |
92 |
93 | static void arc_anim_start_angle(void * obj, int32_t v)
94 | {
95 | lv_arc_set_start_angle(obj, (uint16_t) v);
96 | }
97 |
98 |
99 | static void arc_anim_end_angle(void * obj, int32_t v)
100 | {
101 | lv_arc_set_end_angle(obj, (uint16_t) v);
102 | }
103 |
104 | #endif /*LV_USE_SPINNER*/
105 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/spinner/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 "../../../lvgl.h"
17 |
18 | #if LV_USE_SPINNER
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 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 | extern const lv_obj_class_t lv_spinner_class;
33 |
34 | /**********************
35 | * GLOBAL PROTOTYPES
36 | **********************/
37 |
38 | lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length);
39 |
40 | /**********************
41 | * MACROS
42 | **********************/
43 |
44 | #endif /*LV_USE_SPINNER*/
45 |
46 | #ifdef __cplusplus
47 | } /*extern "C"*/
48 | #endif
49 |
50 | #endif /*LV_SPINNER_H*/
51 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/tabview/lv_tabview.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_templ.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 "../../../lvgl.h"
17 |
18 | #if LV_USE_TABVIEW
19 |
20 | /*********************
21 | * DEFINES
22 | *********************/
23 |
24 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 |
28 | typedef struct {
29 | lv_obj_t obj;
30 | char ** map;
31 | uint16_t tab_cnt;
32 | uint16_t tab_cur;
33 | lv_dir_t tab_pos;
34 | } lv_tabview_t;
35 |
36 | extern const lv_obj_class_t lv_tabview_class;
37 |
38 | /**********************
39 | * GLOBAL PROTOTYPES
40 | **********************/
41 | lv_obj_t * lv_tabview_create(lv_obj_t * parent, lv_dir_t tab_pos, lv_coord_t tab_size);
42 |
43 | lv_obj_t * lv_tabview_add_tab(lv_obj_t * tv, const char * name);
44 |
45 | lv_obj_t * lv_tabview_get_content(lv_obj_t * tv);
46 |
47 | lv_obj_t * lv_tabview_get_tab_btns(lv_obj_t * tv);
48 |
49 | void lv_tabview_set_act(lv_obj_t * obj, uint32_t id, lv_anim_enable_t anim_en);
50 |
51 | uint16_t lv_tabview_get_tab_act(lv_obj_t * tv);
52 |
53 | /**********************
54 | * MACROS
55 | **********************/
56 |
57 | #endif /*LV_USE_TABVIEW*/
58 |
59 | #ifdef __cplusplus
60 | } /*extern "C"*/
61 | #endif
62 |
63 | #endif /*LV_TABVIEW_H*/
64 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/tileview/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 "../../../core/lv_obj.h"
17 |
18 | #if LV_USE_TILEVIEW
19 |
20 | /*********************
21 | * DEFINES
22 | *********************/
23 |
24 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 | typedef struct {
28 | lv_obj_t obj;
29 | lv_obj_t * tile_act;
30 | } lv_tileview_t;
31 |
32 | typedef struct {
33 | lv_obj_t obj;
34 | lv_dir_t dir;
35 | } lv_tileview_tile_t;
36 |
37 | extern const lv_obj_class_t lv_tileview_class;
38 | extern const lv_obj_class_t lv_tileview_tile_class;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /**
45 | * Create a Tileview object
46 | * @param parent pointer to an object, it will be the parent of the new tileview
47 | * @return pointer to the created tileview
48 | */
49 | lv_obj_t * lv_tileview_create(lv_obj_t * parent);
50 |
51 | lv_obj_t * lv_tileview_add_tile(lv_obj_t * tv, uint8_t col_id, uint8_t row_id, lv_dir_t dir);
52 |
53 | void lv_obj_set_tile(lv_obj_t * tv, lv_obj_t * tile_obj, lv_anim_enable_t anim_en);
54 | void lv_obj_set_tile_id(lv_obj_t * tv, uint32_t col_id, uint32_t row_id, lv_anim_enable_t anim_en);
55 |
56 | lv_obj_t * lv_tileview_get_tile_act(lv_obj_t * obj);
57 |
58 | /*=====================
59 | * Other functions
60 | *====================*/
61 |
62 | /**********************
63 | * MACROS
64 | **********************/
65 |
66 | #endif /*LV_USE_TILEVIEW*/
67 |
68 | #ifdef __cplusplus
69 | } /*extern "C"*/
70 | #endif
71 |
72 | #endif /*LV_TILEVIEW_H*/
73 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/win/lv_win.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_win.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "lv_win.h"
10 | #if LV_USE_WIN
11 |
12 |
13 | /*********************
14 | * DEFINES
15 | *********************/
16 |
17 | /**********************
18 | * TYPEDEFS
19 | **********************/
20 |
21 | /**********************
22 | * STATIC PROTOTYPES
23 | **********************/
24 | static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
25 |
26 | /**********************
27 | * STATIC VARIABLES
28 | **********************/
29 | const lv_obj_class_t lv_win_class = {
30 | .constructor_cb = lv_win_constructor,
31 | .width_def = LV_PCT(100),
32 | .height_def = LV_PCT(100),
33 | .base_class = &lv_obj_class,
34 | .instance_size = sizeof(lv_win_t)
35 | };
36 | static lv_coord_t create_header_height;
37 | /**********************
38 | * MACROS
39 | **********************/
40 |
41 | /**********************
42 | * GLOBAL FUNCTIONS
43 | **********************/
44 |
45 | lv_obj_t * lv_win_create(lv_obj_t * parent, lv_coord_t header_height)
46 | {
47 | LV_LOG_INFO("begin");
48 | create_header_height = header_height;
49 |
50 | lv_obj_t * obj = lv_obj_class_create_obj(&lv_win_class, parent);
51 | lv_obj_class_init_obj(obj);
52 | return obj;
53 | }
54 |
55 | lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt)
56 | {
57 | lv_obj_t * header = lv_win_get_header(win);
58 | lv_obj_t * title = lv_label_create(header);
59 | lv_label_set_long_mode(title, LV_LABEL_LONG_DOT);
60 | lv_label_set_text(title, txt);
61 | lv_obj_set_flex_grow(title, 1);
62 | return title;
63 | }
64 |
65 | lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w)
66 | {
67 | lv_obj_t * header = lv_win_get_header(win);
68 | lv_obj_t * btn = lv_btn_create(header);
69 | lv_obj_set_size(btn, btn_w, LV_PCT(100));
70 |
71 | lv_obj_t * img = lv_img_create(btn);
72 | lv_img_set_src(img, icon);
73 | lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
74 |
75 | return btn;
76 | }
77 |
78 | lv_obj_t * lv_win_get_header(lv_obj_t * win)
79 | {
80 | return lv_obj_get_child(win, 0);
81 | }
82 |
83 | lv_obj_t * lv_win_get_content(lv_obj_t * win)
84 | {
85 | return lv_obj_get_child(win, 1);
86 | }
87 |
88 | /**********************
89 | * STATIC FUNCTIONS
90 | **********************/
91 |
92 | static void lv_win_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
93 | {
94 | LV_UNUSED(class_p);
95 | lv_obj_t * parent = lv_obj_get_parent(obj);
96 | lv_obj_set_size(obj, lv_obj_get_width(parent), lv_obj_get_height(parent));
97 | lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
98 |
99 | lv_obj_t * header = lv_obj_create(obj);
100 | lv_obj_set_size(header, LV_PCT(100), create_header_height);
101 | lv_obj_set_flex_flow(header, LV_FLEX_FLOW_ROW);
102 | lv_obj_set_flex_align(header, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
103 |
104 | lv_obj_t * cont = lv_obj_create(obj);
105 | lv_obj_set_flex_grow(cont, 1);
106 | lv_obj_set_width(cont, LV_PCT(100));
107 | }
108 |
109 | #endif
110 |
111 |
--------------------------------------------------------------------------------
/clib/lvgl/src/extra/widgets/win/lv_win.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_win.h
3 | *
4 | */
5 |
6 | #ifndef LV_WIN_H
7 | #define LV_WIN_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../../../lvgl.h"
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 | typedef struct {
26 | lv_obj_t obj;
27 | } lv_win_t;
28 |
29 | extern const lv_obj_class_t lv_win_class;
30 |
31 | /**********************
32 | * GLOBAL PROTOTYPES
33 | **********************/
34 |
35 | lv_obj_t * lv_win_create(lv_obj_t * parent, lv_coord_t header_height);
36 |
37 |
38 | lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt);
39 | lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w);
40 |
41 | lv_obj_t * lv_win_get_header(lv_obj_t * win);
42 | lv_obj_t * lv_win_get_content(lv_obj_t * win);
43 | /**********************
44 | * MACROS
45 | **********************/
46 |
47 | #ifdef __cplusplus
48 | } /*extern "C"*/
49 | #endif
50 |
51 | #endif /*LV_WIN_H*/
52 |
--------------------------------------------------------------------------------
/clib/lvgl/src/font/korean.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/clib/lvgl/src/font/korean.ttf
--------------------------------------------------------------------------------
/clib/lvgl/src/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 "../misc/lv_utils.h"
12 | #include "../misc/lv_log.h"
13 | #include "../misc/lv_assert.h"
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * STATIC PROTOTYPES
25 | **********************/
26 |
27 | /**********************
28 | * STATIC VARIABLES
29 | **********************/
30 |
31 | /**********************
32 | * GLOBAL PROTOTYPES
33 | **********************/
34 |
35 | /**********************
36 | * MACROS
37 | **********************/
38 |
39 | /**********************
40 | * GLOBAL FUNCTIONS
41 | **********************/
42 |
43 | /**
44 | * Return with the bitmap of a font.
45 | * @param font_p pointer to a font
46 | * @param letter an UNICODE character code
47 | * @return pointer to the bitmap of the letter
48 | */
49 | const uint8_t * lv_font_get_glyph_bitmap(const lv_font_t * font_p, uint32_t letter)
50 | {
51 | LV_ASSERT_NULL(font_p);
52 | return font_p->get_glyph_bitmap(font_p, letter);
53 | }
54 |
55 | /**
56 | * Get the descriptor of a glyph
57 | * @param font_p pointer to font
58 | * @param dsc_out store the result descriptor here
59 | * @param letter an UNICODE letter code
60 | * @param letter_next the next letter after `letter`. Used for kerning
61 | * @return true: descriptor is successfully loaded into `dsc_out`.
62 | * false: the letter was not found, no data is loaded to `dsc_out`
63 | */
64 | bool lv_font_get_glyph_dsc(const lv_font_t * font_p, lv_font_glyph_dsc_t * dsc_out, uint32_t letter,
65 | uint32_t letter_next)
66 | {
67 | LV_ASSERT_NULL(font_p);
68 | LV_ASSERT_NULL(dsc_out);
69 | dsc_out->resolved_font = NULL;
70 | const lv_font_t * f = font_p;
71 | bool found = false;
72 | while(f) {
73 | found = f->get_glyph_dsc(f, dsc_out, letter, letter_next);
74 | if(found && !dsc_out->is_placeholder) {
75 | dsc_out->resolved_font = f;
76 | break;
77 | }
78 | f = f->fallback;
79 | }
80 | return found;
81 | }
82 |
83 | /**
84 | * Get the width of a glyph with kerning
85 | * @param font pointer to a font
86 | * @param letter an UNICODE letter
87 | * @param letter_next the next letter after `letter`. Used for kerning
88 | * @return the width of the glyph
89 | */
90 | uint16_t lv_font_get_glyph_width(const lv_font_t * font, uint32_t letter, uint32_t letter_next)
91 | {
92 | LV_ASSERT_NULL(font);
93 | lv_font_glyph_dsc_t g;
94 | bool ret;
95 | ret = lv_font_get_glyph_dsc(font, &g, letter, letter_next);
96 | if(ret) return g.adv_w;
97 | else return 0;
98 | }
99 |
100 | /**********************
101 | * STATIC FUNCTIONS
102 | **********************/
103 |
--------------------------------------------------------------------------------
/clib/lvgl/src/font/lv_font.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_font.c
2 | CSRCS += lv_font_fmt_txt.c
3 | CSRCS += lv_font_loader.c
4 |
5 | CSRCS += lv_font_dejavu_16_persian_hebrew.c
6 | CSRCS += lv_font_montserrat_8.c
7 | CSRCS += lv_font_montserrat_10.c
8 | CSRCS += lv_font_montserrat_12.c
9 | CSRCS += lv_font_montserrat_12_subpx.c
10 | CSRCS += lv_font_montserrat_14.c
11 | CSRCS += lv_font_montserrat_16.c
12 | CSRCS += lv_font_montserrat_18.c
13 | CSRCS += lv_font_montserrat_20.c
14 | CSRCS += lv_font_montserrat_22.c
15 | CSRCS += lv_font_montserrat_24.c
16 | CSRCS += lv_font_montserrat_26.c
17 | CSRCS += lv_font_montserrat_28.c
18 | CSRCS += lv_font_montserrat_28_compressed.c
19 | CSRCS += lv_font_montserrat_30.c
20 | CSRCS += lv_font_montserrat_32.c
21 | CSRCS += lv_font_montserrat_34.c
22 | CSRCS += lv_font_montserrat_36.c
23 | CSRCS += lv_font_montserrat_38.c
24 | CSRCS += lv_font_montserrat_40.c
25 | CSRCS += lv_font_montserrat_42.c
26 | CSRCS += lv_font_montserrat_44.c
27 | CSRCS += lv_font_montserrat_46.c
28 | CSRCS += lv_font_montserrat_48.c
29 | CSRCS += lv_font_simsun_16_cjk.c
30 | CSRCS += lv_font_unscii_8.c
31 | CSRCS += lv_font_unscii_16.c
32 |
33 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font
34 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font
35 |
36 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font"
37 |
--------------------------------------------------------------------------------
/clib/lvgl/src/font/lv_font_loader.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_font_loader.h
3 | *
4 | */
5 |
6 | #ifndef LV_FONT_LOADER_H
7 | #define LV_FONT_LOADER_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 | lv_font_t * lv_font_load(const char * fontName);
30 | void lv_font_free(lv_font_t * font);
31 |
32 | /**********************
33 | * MACROS
34 | **********************/
35 |
36 | #ifdef __cplusplus
37 | } /*extern "C"*/
38 | #endif
39 |
40 | #endif /*LV_FONT_LOADER_H*/
41 |
--------------------------------------------------------------------------------
/clib/lvgl/src/gpu/lv_gpu.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_gpu_nxp_pxp.c
2 | CSRCS += lv_gpu_nxp_pxp_osa.c
3 | CSRCS += lv_gpu_nxp_vglite.c
4 | CSRCS += lv_gpu_stm32_dma2d.c
5 |
6 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/gpu
7 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/gpu
8 |
9 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/gpu"
10 |
11 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 | * Same as Android's DIP. (Different name is chosen to avoid mistype between LV_DPI and LV_DIP)
25 | * 1 dip is 1 px on a 160 DPI screen
26 | * 1 dip is 2 px on a 320 DPI screen
27 | * https://stackoverflow.com/questions/2025282/what-is-the-difference-between-px-dip-dp-and-sp
28 | */
29 | #define _LV_DPX_CALC(dpi, n) ((n) == 0 ? 0 :LV_MAX((( (dpi) * (n) + 80) / 160), 1)) /*+80 for rounding*/
30 | #define LV_DPX(n) _LV_DPX_CALC(lv_disp_get_dpi(NULL), n)
31 |
32 | /**********************
33 | * TYPEDEFS
34 | **********************/
35 |
36 | /**********************
37 | * GLOBAL PROTOTYPES
38 | **********************/
39 |
40 | /**********************
41 | * MACROS
42 | **********************/
43 |
44 | #ifdef __cplusplus
45 | } /*extern "C"*/
46 | #endif
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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/hal
6 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/hal
7 |
8 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/hal"
9 |
--------------------------------------------------------------------------------
/clib/lvgl/src/hal/lv_hal_tick.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_hal_tick.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 | #if !LV_TICK_CUSTOM
32 | static uint32_t sys_time = 0;
33 | static volatile uint8_t tick_irq_flag;
34 | #endif
35 |
36 | /**********************
37 | * MACROS
38 | **********************/
39 |
40 | /**********************
41 | * GLOBAL FUNCTIONS
42 | **********************/
43 |
44 | #if !LV_TICK_CUSTOM
45 | /**
46 | * You have to call this function periodically
47 | * @param tick_period the call period of this function in milliseconds
48 | */
49 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period)
50 | {
51 | tick_irq_flag = 0;
52 | sys_time += tick_period;
53 | }
54 | #endif
55 |
56 | /**
57 | * Get the elapsed milliseconds since start up
58 | * @return the elapsed milliseconds
59 | */
60 | uint32_t lv_tick_get(void)
61 | {
62 | #if LV_TICK_CUSTOM == 0
63 |
64 | /*If `lv_tick_inc` is called from an interrupt while `sys_time` is read
65 | *the result might be corrupted.
66 | *This loop detects if `lv_tick_inc` was called while reading `sys_time`.
67 | *If `tick_irq_flag` was cleared in `lv_tick_inc` try to read again
68 | *until `tick_irq_flag` remains `1`.*/
69 | uint32_t result;
70 | do {
71 | tick_irq_flag = 1;
72 | result = sys_time;
73 | } while(!tick_irq_flag); /*Continue until see a non interrupted cycle*/
74 |
75 | return result;
76 | #else
77 | return LV_TICK_CUSTOM_SYS_TIME_EXPR;
78 | #endif
79 | }
80 |
81 | /**
82 | * Get the elapsed milliseconds since a previous time stamp
83 | * @param prev_tick a previous time stamp (return value of lv_tick_get() )
84 | * @return the elapsed milliseconds since 'prev_tick'
85 | */
86 | uint32_t lv_tick_elaps(uint32_t prev_tick)
87 | {
88 | uint32_t act_time = lv_tick_get();
89 |
90 | /*If there is no overflow in sys_time simple subtract*/
91 | if(act_time >= prev_tick) {
92 | prev_tick = act_time - prev_tick;
93 | }
94 | else {
95 | prev_tick = UINT32_MAX - prev_tick + 1;
96 | prev_tick += act_time;
97 | }
98 |
99 | return prev_tick;
100 | }
101 |
102 | /**********************
103 | * STATIC FUNCTIONS
104 | **********************/
105 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 | #if !LV_TICK_CUSTOM
39 | /**
40 | * You have to call this function periodically
41 | * @param tick_period the call period of this function in milliseconds
42 | */
43 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period);
44 | #endif
45 |
46 | //! @endcond
47 |
48 | /**
49 | * Get the elapsed milliseconds since start up
50 | * @return the elapsed milliseconds
51 | */
52 | uint32_t lv_tick_get(void);
53 |
54 | /**
55 | * Get the elapsed milliseconds since a previous time stamp
56 | * @param prev_tick a previous time stamp (return value of lv_tick_get() )
57 | * @return the elapsed milliseconds since 'prev_tick'
58 | */
59 | uint32_t lv_tick_elaps(uint32_t prev_tick);
60 |
61 | /**********************
62 | * MACROS
63 | **********************/
64 |
65 | #ifdef __cplusplus
66 | } /*extern "C"*/
67 | #endif
68 |
69 | #endif /*LV_HAL_TICK_H*/
70 |
--------------------------------------------------------------------------------
/clib/lvgl/src/lv_api_map.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_api_map.h
3 | *
4 | */
5 |
6 | #ifndef LV_API_MAP_H
7 | #define LV_API_MAP_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../lvgl.h"
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | #define LV_NO_TASK_READY LV_NO_TIMER_READY
23 | #define LV_INDEV_STATE_REL LV_INDEV_STATE_RELEASED
24 | #define LV_INDEV_STATE_PR LV_INDEV_STATE_PRESSED
25 | #define LV_OBJ_FLAG_SNAPABLE LV_OBJ_FLAG_SNAPPABLE /*Fixed typo*/
26 |
27 | /**********************
28 | * TYPEDEFS
29 | **********************/
30 |
31 | /**********************
32 | * GLOBAL PROTOTYPES
33 | **********************/
34 |
35 | static inline LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_task_handler(void)
36 | {
37 | return lv_timer_handler();
38 | }
39 |
40 | /**********************
41 | * MACROS
42 | **********************/
43 |
44 |
45 | /**********************
46 | * INLINE FUNCTIONS
47 | **********************/
48 |
49 | /**
50 | * Move the object to the foreground.
51 | * It will look like if it was created as the last child of its parent.
52 | * It also means it can cover any of the siblings.
53 | * @param obj pointer to an object
54 | */
55 | static inline void lv_obj_move_foreground(lv_obj_t * obj)
56 | {
57 | lv_obj_t * parent = lv_obj_get_parent(obj);
58 | lv_obj_move_to_index(obj, lv_obj_get_child_cnt(parent) - 1);
59 | }
60 |
61 | /**
62 | * Move the object to the background.
63 | * It will look like if it was created as the first child of its parent.
64 | * It also means any of the siblings can cover the object.
65 | * @param obj pointer to an object
66 | */
67 | static inline void lv_obj_move_background(lv_obj_t * obj)
68 | {
69 | lv_obj_move_to_index(obj, 0);
70 | }
71 |
72 |
73 |
74 | /**********************
75 | * DEPRECATED FUNCTIONS
76 | **********************/
77 |
78 | static inline uint32_t lv_obj_get_child_id(const struct _lv_obj_t * obj)
79 | {
80 | LV_LOG_WARN("lv_obj_get_child_id(obj) is deprecated, please use lv_obj_get_index(obj).");
81 | return lv_obj_get_index(obj);
82 | }
83 |
84 | #ifdef __cplusplus
85 | } /*extern "C"*/
86 | #endif
87 |
88 | #endif /*LV_API_MAP_H*/
89 |
--------------------------------------------------------------------------------
/clib/lvgl/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 | } /*extern "C"*/
37 | #endif
38 |
39 | #endif /*LVGL_SRC_H*/
40 |
--------------------------------------------------------------------------------
/clib/lvgl/src/misc/lv_anim_timeline.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_anim_timeline.h
3 | *
4 | */
5 |
6 | #ifndef LV_ANIM_TIMELINE_H
7 | #define LV_ANIM_TIMELINE_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "lv_anim.h"
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 |
26 | struct _lv_anim_timeline_t;
27 |
28 | typedef struct _lv_anim_timeline_t lv_anim_timeline_t;
29 |
30 | /**********************
31 | * GLOBAL PROTOTYPES
32 | **********************/
33 |
34 | /**
35 | * Create an animation timeline.
36 | * @return pointer to the animation timeline.
37 | */
38 | lv_anim_timeline_t * lv_anim_timeline_create(void);
39 |
40 | /**
41 | * Delete animation timeline.
42 | * @param at pointer to the animation timeline.
43 | */
44 | void lv_anim_timeline_del(lv_anim_timeline_t * at);
45 |
46 | /**
47 | * Add animation to the animation timeline.
48 | * @param at pointer to the animation timeline.
49 | * @param start_time the time the animation started on the timeline, note that start_time will override the value of delay.
50 | * @param a pointer to an animation.
51 | */
52 | void lv_anim_timeline_add(lv_anim_timeline_t * at, uint32_t start_time, lv_anim_t * a);
53 |
54 | /**
55 | * Start the animation timeline.
56 | * @param at pointer to the animation timeline.
57 | * @return total time spent in animation timeline.
58 | */
59 | uint32_t lv_anim_timeline_start(lv_anim_timeline_t * at);
60 |
61 | /**
62 | * Stop the animation timeline.
63 | * @param at pointer to the animation timeline.
64 | */
65 | void lv_anim_timeline_stop(lv_anim_timeline_t * at);
66 |
67 | /**
68 | * Set the playback direction of the animation timeline.
69 | * @param at pointer to the animation timeline.
70 | * @param reverse whether to play in reverse.
71 | */
72 | void lv_anim_timeline_set_reverse(lv_anim_timeline_t * at, bool reverse);
73 |
74 | /**
75 | * Set the progress of the animation timeline.
76 | * @param at pointer to the animation timeline.
77 | * @param progress set value 0~65535 to map 0~100% animation progress.
78 | */
79 | void lv_anim_timeline_set_progress(lv_anim_timeline_t * at, uint16_t progress);
80 |
81 | /**
82 | * Get the time used to play the animation timeline.
83 | * @param at pointer to the animation timeline.
84 | * @return total time spent in animation timeline.
85 | */
86 | uint32_t lv_anim_timeline_get_playtime(lv_anim_timeline_t * at);
87 |
88 | /**
89 | * Get whether the animation timeline is played in reverse.
90 | * @param at pointer to the animation timeline.
91 | * @return return true if it is reverse playback.
92 | */
93 | bool lv_anim_timeline_get_reverse(lv_anim_timeline_t * at);
94 |
95 | /**********************
96 | * MACROS
97 | **********************/
98 |
99 | #ifdef __cplusplus
100 | } /*extern "C"*/
101 | #endif
102 |
103 | #endif /*LV_ANIM_TIMELINE_H*/
104 |
--------------------------------------------------------------------------------
/clib/lvgl/src/misc/lv_assert.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_assert.h
3 | *
4 | */
5 |
6 | #ifndef LV_ASSERT_H
7 | #define LV_ASSERT_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../lv_conf_internal.h"
17 | #include "lv_log.h"
18 | #include "lv_mem.h"
19 | #include LV_ASSERT_HANDLER_INCLUDE
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 |
29 | /**********************
30 | * GLOBAL PROTOTYPES
31 | **********************/
32 |
33 | /**********************
34 | * MACROS
35 | **********************/
36 |
37 | #define LV_ASSERT(expr) \
38 | do { \
39 | if(!(expr)) { \
40 | LV_LOG_ERROR("Asserted at expression: %s", #expr); \
41 | LV_ASSERT_HANDLER \
42 | } \
43 | } while(0)
44 |
45 | #define LV_ASSERT_MSG(expr, msg) \
46 | do { \
47 | if(!(expr)) { \
48 | LV_LOG_ERROR("Asserted at expression: %s (%s)", #expr, msg); \
49 | LV_ASSERT_HANDLER \
50 | } \
51 | } while(0)
52 |
53 | /*-----------------
54 | * ASSERTS
55 | *-----------------*/
56 |
57 | #if LV_USE_ASSERT_NULL
58 | # define LV_ASSERT_NULL(p) LV_ASSERT_MSG(p != NULL, "NULL pointer");
59 | #else
60 | # define LV_ASSERT_NULL(p)
61 | #endif
62 |
63 | #if LV_USE_ASSERT_MALLOC
64 | # define LV_ASSERT_MALLOC(p) LV_ASSERT_MSG(p != NULL, "Out of memory");
65 | #else
66 | # define LV_ASSERT_MALLOC(p)
67 | #endif
68 |
69 | #if LV_USE_ASSERT_MEM_INTEGRITY
70 | # define LV_ASSERT_MEM_INTEGRITY() LV_ASSERT_MSG(lv_mem_test() == LV_RES_OK, "Memory integrity error");
71 | #else
72 | # define LV_ASSERT_MEM_INTEGRITY()
73 | #endif
74 |
75 | #ifdef __cplusplus
76 | } /*extern "C"*/
77 | #endif
78 |
79 | #endif /*LV_ASSERT_H*/
80 |
--------------------------------------------------------------------------------
/clib/lvgl/src/misc/lv_async.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_async.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 |
10 | #include "lv_async.h"
11 | #include "lv_mem.h"
12 | #include "lv_timer.h"
13 |
14 | /*********************
15 | * DEFINES
16 | *********************/
17 |
18 | /**********************
19 | * TYPEDEFS
20 | **********************/
21 |
22 | typedef struct _lv_async_info_t {
23 | lv_async_cb_t cb;
24 | void * user_data;
25 | } lv_async_info_t;
26 |
27 | /**********************
28 | * STATIC PROTOTYPES
29 | **********************/
30 |
31 | static void lv_async_timer_cb(lv_timer_t * timer);
32 |
33 | /**********************
34 | * STATIC VARIABLES
35 | **********************/
36 |
37 | /**********************
38 | * MACROS
39 | **********************/
40 |
41 | /**********************
42 | * GLOBAL FUNCTIONS
43 | **********************/
44 |
45 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data)
46 | {
47 | /*Allocate an info structure*/
48 | lv_async_info_t * info = lv_mem_alloc(sizeof(lv_async_info_t));
49 |
50 | if(info == NULL)
51 | return LV_RES_INV;
52 |
53 | /*Create a new timer*/
54 | lv_timer_t * timer = lv_timer_create(lv_async_timer_cb, 0, info);
55 |
56 | if(timer == NULL) {
57 | lv_mem_free(info);
58 | return LV_RES_INV;
59 | }
60 |
61 | info->cb = async_xcb;
62 | info->user_data = user_data;
63 |
64 | lv_timer_set_repeat_count(timer, 1);
65 | return LV_RES_OK;
66 | }
67 |
68 | /**********************
69 | * STATIC FUNCTIONS
70 | **********************/
71 |
72 | static void lv_async_timer_cb(lv_timer_t * timer)
73 | {
74 | lv_async_info_t * info = (lv_async_info_t *)timer->user_data;
75 |
76 | info->cb(info->user_data);
77 | lv_mem_free(info);
78 | }
79 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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_types.h"
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 |
27 | /**
28 | * Type for async callback.
29 | */
30 | typedef void (*lv_async_cb_t)(void *);
31 |
32 | /**********************
33 | * GLOBAL PROTOTYPES
34 | **********************/
35 |
36 | /**
37 | * Call an asynchronous function the next time lv_timer_handler() is run. This function is likely to return
38 | * **before** the call actually happens!
39 | * @param async_xcb a callback which is the task itself.
40 | * (the 'x' in the argument name indicates that it's not a fully generic function because it not follows
41 | * the `func_name(object, callback, ...)` convention)
42 | * @param user_data custom parameter
43 | */
44 | lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data);
45 |
46 | /**********************
47 | * MACROS
48 | **********************/
49 |
50 | #ifdef __cplusplus
51 | } /*extern "C"*/
52 | #endif
53 |
54 | #endif /*LV_ASYNC_H*/
55 |
--------------------------------------------------------------------------------
/clib/lvgl/src/misc/lv_gc.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_gc.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #include "lv_gc.h"
10 |
11 | /*********************
12 | * DEFINES
13 | *********************/
14 |
15 | /**********************
16 | * TYPEDEFS
17 | **********************/
18 |
19 | /**********************
20 | * STATIC PROTOTYPES
21 | **********************/
22 |
23 | /**********************
24 | * STATIC VARIABLES
25 | **********************/
26 |
27 | #if(!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0
28 | LV_ROOTS
29 | #endif /*LV_ENABLE_GC*/
30 |
31 | /**********************
32 | * MACROS
33 | **********************/
34 |
35 | /**********************
36 | * GLOBAL FUNCTIONS
37 | **********************/
38 |
39 | void _lv_gc_clear_roots(void)
40 | {
41 | #define LV_CLEAR_ROOT(root_type, root_name) lv_memset_00(&LV_GC_ROOT(root_name), sizeof(LV_GC_ROOT(root_name)));
42 | LV_ITERATE_ROOTS(LV_CLEAR_ROOT)
43 | }
44 |
45 | /**********************
46 | * STATIC FUNCTIONS
47 | **********************/
48 |
--------------------------------------------------------------------------------
/clib/lvgl/src/misc/lv_lru.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_lru.h
3 | *
4 | */
5 |
6 | #ifndef LV_LRU_H
7 | #define LV_LRU_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 |
17 | #include "../lv_conf_internal.h"
18 |
19 | #include "lv_types.h"
20 |
21 | #include
22 | #include
23 |
24 |
25 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | typedef enum {
34 | LV_LRU_OK = 0,
35 | LV_LRU_MISSING_CACHE,
36 | LV_LRU_MISSING_KEY,
37 | LV_LRU_MISSING_VALUE,
38 | LV_LRU_LOCK_ERROR,
39 | LV_LRU_VALUE_TOO_LARGE
40 | } lv_lru_res_t;
41 |
42 | typedef void (lv_lru_free_t)(void * v);
43 | typedef struct _lv_lru_item_t lv_lru_item_t;
44 |
45 | typedef struct lv_lru_t {
46 | lv_lru_item_t ** items;
47 | uint64_t access_count;
48 | size_t free_memory;
49 | size_t total_memory;
50 | size_t average_item_length;
51 | size_t hash_table_size;
52 | uint32_t seed;
53 | lv_lru_free_t * value_free;
54 | lv_lru_free_t * key_free;
55 | lv_lru_item_t * free_items;
56 | } lv_lru_t;
57 |
58 |
59 | /**********************
60 | * GLOBAL PROTOTYPES
61 | **********************/
62 |
63 | lv_lru_t * lv_lru_create(size_t cache_size, size_t average_length, lv_lru_free_t * value_free,
64 | lv_lru_free_t * key_free);
65 |
66 | void lv_lru_del(lv_lru_t * cache);
67 |
68 | lv_lru_res_t lv_lru_set(lv_lru_t * cache, const void * key, size_t key_length, void * value, size_t value_length);
69 |
70 | lv_lru_res_t lv_lru_get(lv_lru_t * cache, const void * key, size_t key_size, void ** value);
71 |
72 | lv_lru_res_t lv_lru_remove(lv_lru_t * cache, const void * key, size_t key_size);
73 |
74 | /**********************
75 | * MACROS
76 | **********************/
77 | #ifdef __cplusplus
78 | } /*extern "C"*/
79 | #endif
80 |
81 | #endif /*LV_LRU_H*/
82 |
--------------------------------------------------------------------------------
/clib/lvgl/src/misc/lv_misc.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_anim.c
2 | CSRCS += lv_anim_timeline.c
3 | CSRCS += lv_area.c
4 | CSRCS += lv_async.c
5 | CSRCS += lv_bidi.c
6 | CSRCS += lv_color.c
7 | CSRCS += lv_fs.c
8 | CSRCS += lv_gc.c
9 | CSRCS += lv_ll.c
10 | CSRCS += lv_log.c
11 | CSRCS += lv_lru.c
12 | CSRCS += lv_math.c
13 | CSRCS += lv_mem.c
14 | CSRCS += lv_printf.c
15 | CSRCS += lv_style.c
16 | CSRCS += lv_style_gen.c
17 | CSRCS += lv_timer.c
18 | CSRCS += lv_tlsf.c
19 | CSRCS += lv_txt.c
20 | CSRCS += lv_txt_ap.c
21 | CSRCS += lv_utils.c
22 |
23 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/misc
24 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/misc
25 |
26 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/misc"
27 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 "../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 |
33 | /**********************
34 | * GLOBAL PROTOTYPES
35 | **********************/
36 | uint32_t _lv_txt_ap_calc_bytes_cnt(const char * txt);
37 | void _lv_txt_ap_proc(const char * txt, char * txt_out);
38 |
39 | /**********************
40 | * MACROS
41 | **********************/
42 |
43 | #endif // LV_USE_ARABIC_PERSIAN_CHARS
44 |
45 | #ifdef __cplusplus
46 | } /*extern "C"*/
47 | #endif
48 |
49 | #endif /*LV_TXT_AP_H*/
50 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 | #include
17 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | // If __UINTPTR_MAX__ or UINTPTR_MAX are available, use them to determine arch size
23 | #if defined(__UINTPTR_MAX__) && __UINTPTR_MAX__ > 0xFFFFFFFF
24 | #define LV_ARCH_64
25 |
26 | #elif defined(UINTPTR_MAX) && UINTPTR_MAX > 0xFFFFFFFF
27 | #define LV_ARCH_64
28 |
29 | // Otherwise use compiler-dependent means to determine arch size
30 | #elif defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined (__aarch64__)
31 | #define LV_ARCH_64
32 |
33 | #endif
34 |
35 | /**********************
36 | * TYPEDEFS
37 | **********************/
38 |
39 | /**
40 | * LVGL error codes.
41 | */
42 | enum {
43 | LV_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action
44 | function or an operation was failed*/
45 | LV_RES_OK, /*The object is valid (no deleted) after the action*/
46 | };
47 | typedef uint8_t lv_res_t;
48 |
49 | #if defined(__cplusplus) || __STDC_VERSION__ >= 199901L
50 | // If c99 or newer, use the definition of uintptr_t directly from
51 | typedef uintptr_t lv_uintptr_t;
52 |
53 | #else
54 |
55 | // Otherwise, use the arch size determination
56 | #ifdef LV_ARCH_64
57 | typedef uint64_t lv_uintptr_t;
58 | #else
59 | typedef uint32_t lv_uintptr_t;
60 | #endif
61 |
62 | #endif
63 |
64 | /**********************
65 | * GLOBAL PROTOTYPES
66 | **********************/
67 |
68 | /**********************
69 | * MACROS
70 | **********************/
71 |
72 | #define LV_UNUSED(x) ((void)x)
73 |
74 | #define _LV_CONCAT(x, y) x ## y
75 | #define LV_CONCAT(x, y) _LV_CONCAT(x, y)
76 |
77 | #define _LV_CONCAT3(x, y, z) x ## y ## z
78 | #define LV_CONCAT3(x, y, z) _LV_CONCAT3(x, y, z)
79 |
80 | #if defined(PYCPARSER)
81 | #define LV_FORMAT_ATTRIBUTE(fmtstr, vararg)
82 | #elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __GNUC__ > 4)
83 | #define LV_FORMAT_ATTRIBUTE(fmtstr, vararg) __attribute__((format(gnu_printf, fmtstr, vararg)))
84 | #elif (defined(__clang__) || defined(__GNUC__) || defined(__GNUG__))
85 | #define LV_FORMAT_ATTRIBUTE(fmtstr, vararg) __attribute__((format(printf, fmtstr, vararg)))
86 | #else
87 | #define LV_FORMAT_ATTRIBUTE(fmtstr, vararg)
88 | #endif
89 |
90 | #ifdef __cplusplus
91 | } /*extern "C"*/
92 | #endif
93 |
94 | #endif /*LV_TYPES_H*/
95 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 |
13 | /*********************
14 | * DEFINES
15 | *********************/
16 |
17 | /**********************
18 | * TYPEDEFS
19 | **********************/
20 |
21 | /**********************
22 | * STATIC PROTOTYPES
23 | **********************/
24 |
25 | /**********************
26 | * STATIC VARIABLES
27 | **********************/
28 |
29 | /**********************
30 | * MACROS
31 | **********************/
32 |
33 | /**********************
34 | * GLOBAL FUNCTIONS
35 | **********************/
36 |
37 | /** Searches base[0] to base[n - 1] for an item that matches *key.
38 | *
39 | * @note The function cmp must return negative if its first
40 | * argument (the search key) is less than its second (a table entry),
41 | * zero if equal, and positive if greater.
42 | *
43 | * @note Items in the array must be in ascending order.
44 | *
45 | * @param key Pointer to item being searched for
46 | * @param base Pointer to first element to search
47 | * @param n Number of elements
48 | * @param size Size of each element
49 | * @param cmp Pointer to comparison function (see #unicode_list_compare as a comparison function
50 | * example)
51 | *
52 | * @return a pointer to a matching item, or NULL if none exists.
53 | */
54 | void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size,
55 | int32_t (*cmp)(const void * pRef, const void * pElement))
56 | {
57 | const char * middle;
58 | int32_t c;
59 |
60 | for(middle = base; n != 0;) {
61 | middle += (n / 2) * size;
62 | if((c = (*cmp)(key, middle)) > 0) {
63 | n = (n / 2) - ((n & 1) == 0);
64 | base = (middle += size);
65 | }
66 | else if(c < 0) {
67 | n /= 2;
68 | middle = base;
69 | }
70 | else {
71 | return (char *)middle;
72 | }
73 | }
74 | return NULL;
75 | }
76 |
77 | /**********************
78 | * STATIC FUNCTIONS
79 | **********************/
80 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 |
18 | /*********************
19 | * DEFINES
20 | *********************/
21 |
22 | /**********************
23 | * TYPEDEFS
24 | **********************/
25 |
26 | /**********************
27 | * GLOBAL PROTOTYPES
28 | **********************/
29 |
30 | /** Searches base[0] to base[n - 1] for an item that matches *key.
31 | *
32 | * @note The function cmp must return negative if it's first
33 | * argument (the search key) is less that it's second (a table entry),
34 | * zero if equal, and positive if greater.
35 | *
36 | * @note Items in the array must be in ascending order.
37 | *
38 | * @param key Pointer to item being searched for
39 | * @param base Pointer to first element to search
40 | * @param n Number of elements
41 | * @param size Size of each element
42 | * @param cmp Pointer to comparison function (see #unicode_list_compare as a comparison function
43 | * example)
44 | *
45 | * @return a pointer to a matching item, or NULL if none exists.
46 | */
47 | void * _lv_utils_bsearch(const void * key, const void * base, uint32_t n, uint32_t size,
48 | int32_t (*cmp)(const void * pRef, const void * pElement));
49 |
50 | /**********************
51 | * MACROS
52 | **********************/
53 |
54 | #ifdef __cplusplus
55 | } /*extern "C"*/
56 | #endif
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/clib/lvgl/src/widgets/lv_btn.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_btn.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 |
10 | #include "lv_btn.h"
11 | #if LV_USE_BTN != 0
12 |
13 | #include "../extra/layouts/flex/lv_flex.h"
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 | #define MY_CLASS &lv_btn_class
19 |
20 | /**********************
21 | * TYPEDEFS
22 | **********************/
23 |
24 | /**********************
25 | * STATIC PROTOTYPES
26 | **********************/
27 | static void lv_btn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
28 |
29 | /**********************
30 | * STATIC VARIABLES
31 | **********************/
32 | const lv_obj_class_t lv_btn_class = {
33 | .constructor_cb = lv_btn_constructor,
34 | .width_def = LV_SIZE_CONTENT,
35 | .height_def = LV_SIZE_CONTENT,
36 | .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
37 | .instance_size = sizeof(lv_btn_t),
38 | .base_class = &lv_obj_class
39 | };
40 |
41 | /**********************
42 | * MACROS
43 | **********************/
44 |
45 | /**********************
46 | * GLOBAL FUNCTIONS
47 | **********************/
48 |
49 | lv_obj_t * lv_btn_create(lv_obj_t * parent)
50 | {
51 | LV_LOG_INFO("begin");
52 | lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
53 | lv_obj_class_init_obj(obj);
54 | return obj;
55 | }
56 |
57 | /**********************
58 | * STATIC FUNCTIONS
59 | **********************/
60 |
61 | static void lv_btn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
62 | {
63 | LV_UNUSED(class_p);
64 | LV_TRACE_OBJ_CREATE("begin");
65 |
66 | lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
67 | lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
68 |
69 | LV_TRACE_OBJ_CREATE("finished");
70 | }
71 |
72 | #endif
73 |
--------------------------------------------------------------------------------
/clib/lvgl/src/widgets/lv_btn.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_btn.h
3 | *
4 | */
5 |
6 | #ifndef LV_BTN_H
7 | #define LV_BTN_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_BTN != 0
19 | #include "../core/lv_obj.h"
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 |
29 | typedef struct {
30 | lv_obj_t obj;
31 | } lv_btn_t;
32 |
33 | extern const lv_obj_class_t lv_btn_class;
34 |
35 | /**********************
36 | * GLOBAL PROTOTYPES
37 | **********************/
38 |
39 | /**
40 | * Create a button object
41 | * @param parent pointer to an object, it will be the parent of the new button
42 | * @return pointer to the created button
43 | */
44 | lv_obj_t * lv_btn_create(lv_obj_t * parent);
45 |
46 | /**********************
47 | * MACROS
48 | **********************/
49 |
50 | #endif /*LV_USE_BTN*/
51 |
52 | #ifdef __cplusplus
53 | } /*extern "C"*/
54 | #endif
55 |
56 | #endif /*LV_BTN_H*/
57 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 | #include "../core/lv_obj.h"
18 |
19 | #if LV_USE_CHECKBOX != 0
20 |
21 | /*********************
22 | * DEFINES
23 | *********************/
24 |
25 | /**********************
26 | * TYPEDEFS
27 | **********************/
28 |
29 | typedef struct {
30 | lv_obj_t obj;
31 | char * txt;
32 | uint32_t static_txt : 1;
33 | } lv_checkbox_t;
34 |
35 | extern const lv_obj_class_t lv_checkbox_class;
36 |
37 | /**
38 | * `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_checkbox_class`
39 | * Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
40 | */
41 | typedef enum {
42 | LV_CHECKBOX_DRAW_PART_BOX, /**< The tick box*/
43 | } lv_checkbox_draw_part_type_t;
44 |
45 | /**********************
46 | * GLOBAL PROTOTYPES
47 | **********************/
48 |
49 | /**
50 | * Create a check box object
51 | * @param parent pointer to an object, it will be the parent of the new button
52 | * @return pointer to the created check box
53 | */
54 | lv_obj_t * lv_checkbox_create(lv_obj_t * parent);
55 |
56 | /*=====================
57 | * Setter functions
58 | *====================*/
59 |
60 | /**
61 | * Set the text of a check box. `txt` will be copied and may be deallocated
62 | * after this function returns.
63 | * @param cb pointer to a check box
64 | * @param txt the text of the check box. NULL to refresh with the current text.
65 | */
66 | void lv_checkbox_set_text(lv_obj_t * obj, const char * txt);
67 |
68 | /**
69 | * Set the text of a check box. `txt` must not be deallocated during the life
70 | * of this checkbox.
71 | * @param cb pointer to a check box
72 | * @param txt the text of the check box.
73 | */
74 | void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt);
75 |
76 | /*=====================
77 | * Getter functions
78 | *====================*/
79 |
80 | /**
81 | * Get the text of a check box
82 | * @param cb pointer to check box object
83 | * @return pointer to the text of the check box
84 | */
85 | const char * lv_checkbox_get_text(const lv_obj_t * obj);
86 |
87 | /**********************
88 | * MACROS
89 | **********************/
90 |
91 | #endif /*LV_USE_CHECKBOX*/
92 |
93 | #ifdef __cplusplus
94 | } /*extern "C"*/
95 | #endif
96 |
97 | #endif /*LV_CHECKBOX_H*/
98 |
--------------------------------------------------------------------------------
/clib/lvgl/src/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 "../core/lv_obj.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | /**********************
27 | * TYPEDEFS
28 | **********************/
29 |
30 | /*Data of line*/
31 | typedef struct {
32 | lv_obj_t obj;
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 y_inv : 1; /**< 1: y == 0 will be on the bottom*/
36 | } lv_line_t;
37 |
38 | extern const lv_obj_class_t lv_line_class;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /**
45 | * Create a line object
46 | * @param parent pointer to an object, it will be the parent of the new line
47 | * @return pointer to the created line
48 | */
49 | lv_obj_t * lv_line_create(lv_obj_t * parent);
50 |
51 | /*=====================
52 | * Setter functions
53 | *====================*/
54 |
55 | /**
56 | * Set an array of points. The line object will connect these points.
57 | * @param obj pointer to a line object
58 | * @param points an array of points. Only the address is saved, so the array needs to be alive while the line exists
59 | * @param point_num number of points in 'point_a'
60 | */
61 | void lv_line_set_points(lv_obj_t * obj, const lv_point_t points[], uint16_t point_num);
62 |
63 | /**
64 | * Enable (or disable) the y coordinate inversion.
65 | * If enabled then y will be subtracted from the height of the object,
66 | * therefore the y = 0 coordinate will be on the bottom.
67 | * @param obj pointer to a line object
68 | * @param en true: enable the y inversion, false:disable the y inversion
69 | */
70 | void lv_line_set_y_invert(lv_obj_t * obj, bool en);
71 |
72 | /*=====================
73 | * Getter functions
74 | *====================*/
75 |
76 | /**
77 | * Get the y inversion attribute
78 | * @param obj pointer to a line object
79 | * @return true: y inversion is enabled, false: disabled
80 | */
81 | bool lv_line_get_y_invert(const lv_obj_t * obj);
82 |
83 | /**********************
84 | * MACROS
85 | **********************/
86 |
87 | #endif /*LV_USE_LINE*/
88 |
89 | #ifdef __cplusplus
90 | } /*extern "C"*/
91 | #endif
92 |
93 | #endif /*LV_LINE_H*/
94 |
--------------------------------------------------------------------------------
/clib/lvgl/src/widgets/lv_objx_templ.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_templ.h
3 | *
4 | */
5 |
6 | /**
7 | * TODO Remove these instructions
8 | * Search and replace: 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 "../core/lv_obj.h"
28 |
29 | /*********************
30 | * DEFINES
31 | *********************/
32 |
33 | /**********************
34 | * TYPEDEFS
35 | **********************/
36 | /*Data of template*/
37 | typedef struct {
38 | lv_ANCESTOR_t ancestor; /*The ancestor widget, e.g. lv_slider_t slider*/
39 | /*New data for this type*/
40 | } lv_templ_t;
41 |
42 | extern const lv_obj_class_t lv_templ_class;
43 |
44 | /**********************
45 | * GLOBAL PROTOTYPES
46 | **********************/
47 |
48 | /**
49 | * Create a templ object
50 | * @param parent pointer to an object, it will be the parent of the new templ
51 | * @return pointer to the created bar
52 | */
53 | lv_obj_t * lv_templ_create(lv_obj_t * parent);
54 |
55 | /*======================
56 | * Add/remove functions
57 | *=====================*/
58 |
59 | /*=====================
60 | * Setter functions
61 | *====================*/
62 |
63 | /*=====================
64 | * Getter functions
65 | *====================*/
66 |
67 | /*=====================
68 | * Other functions
69 | *====================*/
70 |
71 | /**********************
72 | * MACROS
73 | **********************/
74 |
75 | #endif /*LV_USE_TEMPL*/
76 |
77 | #ifdef __cplusplus
78 | } /*extern "C"*/
79 | #endif
80 |
81 | #endif /*LV_TEMPL_H*/
82 |
--------------------------------------------------------------------------------
/clib/lvgl/src/widgets/lv_switch.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_switch.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 | #include "../core/lv_obj.h"
21 |
22 | /*********************
23 | * DEFINES
24 | *********************/
25 |
26 | /** Switch knob extra area correction factor */
27 | #define _LV_SWITCH_KNOB_EXT_AREA_CORRECTION 2
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | typedef struct {
34 | lv_obj_t obj;
35 | int32_t anim_state;
36 | } lv_switch_t;
37 |
38 | extern const lv_obj_class_t lv_switch_class;
39 |
40 | /**********************
41 | * GLOBAL PROTOTYPES
42 | **********************/
43 |
44 | /**
45 | * Create a switch object
46 | * @param parent pointer to an object, it will be the parent of the new switch
47 | * @return pointer to the created switch
48 | */
49 | lv_obj_t * lv_switch_create(lv_obj_t * parent);
50 |
51 | /**********************
52 | * MACROS
53 | **********************/
54 |
55 | #endif /*LV_USE_SWITCH*/
56 |
57 | #ifdef __cplusplus
58 | } /*extern "C"*/
59 | #endif
60 |
61 | #endif /*LV_SWITCH_H*/
62 |
--------------------------------------------------------------------------------
/clib/lvgl/src/widgets/lv_widgets.mk:
--------------------------------------------------------------------------------
1 | CSRCS += lv_arc.c
2 | CSRCS += lv_bar.c
3 | CSRCS += lv_btn.c
4 | CSRCS += lv_btnmatrix.c
5 | CSRCS += lv_canvas.c
6 | CSRCS += lv_checkbox.c
7 | CSRCS += lv_dropdown.c
8 | CSRCS += lv_img.c
9 | CSRCS += lv_label.c
10 | CSRCS += lv_line.c
11 | CSRCS += lv_roller.c
12 | CSRCS += lv_slider.c
13 | CSRCS += lv_switch.c
14 | CSRCS += lv_table.c
15 | CSRCS += lv_textarea.c
16 |
17 | DEPPATH += --dep-path $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/widgets
18 | VPATH += :$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/widgets
19 |
20 | CFLAGS += "-I$(LVGL_DIR)/$(LVGL_DIR_NAME)/src/widgets"
21 |
--------------------------------------------------------------------------------
/clib/lvgl_drv/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_H
10 | #define LV_PORT_DISP_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 | void lv_port_disp_init(int width, int height);
33 | void lv_port_disp_deinit(void);
34 | /**********************
35 | * MACROS
36 | **********************/
37 |
38 | #ifdef __cplusplus
39 | } /*extern "C"*/
40 | #endif
41 |
42 | #endif /*LV_PORT_DISP_H*/
43 |
44 | #endif /*Disable/Enable content*/
45 |
--------------------------------------------------------------------------------
/clib/lvgl_drv/lv_port_indev.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 1
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.h"
21 | #include "lvgl.h"
22 | #ifdef NXDK
23 | #include "SDL2/SDL.h"
24 | #else
25 | #include "SDL2/SDL.h"
26 | #endif
27 |
28 | /*********************
29 | * DEFINES
30 | *********************/
31 | typedef enum
32 | {
33 | LV_QUIT_NONE,
34 | LV_REBOOT,
35 | LV_SHUTDOWN,
36 | LV_QUIT,
37 | LV_QUIT_OTHER,
38 | } lv_quit_event_t;
39 | /**********************
40 | * TYPEDEFS
41 | **********************/
42 | typedef struct
43 | {
44 | SDL_GameControllerButton sdl_map;
45 | lv_key_t lvgl_map;
46 | } gamecontroller_map_t;
47 |
48 | typedef struct
49 | {
50 | SDL_Keycode sdl_map;
51 | lv_key_t lvgl_map;
52 | } keyboard_map_t;
53 |
54 | /**********************
55 | * GLOBAL PROTOTYPES
56 | **********************/
57 | void lv_port_indev_init(bool use_mouse_cursor);
58 | void lv_port_indev_deinit(void);
59 | void lv_set_quit(lv_quit_event_t event);
60 | lv_quit_event_t lv_get_quit(void);
61 | /**********************
62 | * MACROS
63 | **********************/
64 |
65 | #ifdef __cplusplus
66 | } /*extern "C"*/
67 | #endif
68 |
69 | #endif /*LV_PORT_INDEV_TEMPL_H*/
70 |
71 | #endif /*Disable/Enable content*/
72 |
--------------------------------------------------------------------------------
/clib/lvgl_drv/lv_sdl_disp.c:
--------------------------------------------------------------------------------
1 | //SPDX-License-Identifier: MIT
2 |
3 | #include
4 | #include "SDL2/SDL.h"
5 | #include "lv_port_disp.h"
6 | #include "lvgl.h"
7 |
8 | static void *fb1, *fb2;
9 | SDL_Window *window = NULL;
10 | SDL_Renderer *renderer = NULL;
11 | SDL_Texture *texture = NULL;
12 | static lv_disp_drv_t disp_drv;
13 | static lv_disp_draw_buf_t draw_buf;
14 | static int DISPLAY_WIDTH;
15 | static int DISPLAY_HEIGHT;
16 | #ifndef WINDOW_NAME
17 | #define WINDOW_NAME "LVGL"
18 | #endif
19 |
20 | static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
21 | {
22 | SDL_Rect r;
23 | r.x = area->x1;
24 | r.y = area->y1;
25 | r.w = area->x2 - area->x1 + 1;
26 | r.h = area->y2 - area->y1 + 1;
27 | SDL_UpdateTexture(texture, &r, color_p, r.w * ((LV_COLOR_DEPTH + 7) / 8));
28 | SDL_RenderCopy(renderer, texture, NULL, NULL);
29 | SDL_RenderPresent(renderer);
30 | lv_disp_flush_ready(disp_drv);
31 | }
32 |
33 | void lv_port_disp_init(int width, int height)
34 | {
35 | assert(LV_COLOR_DEPTH == 16 || LV_COLOR_DEPTH == 32);
36 | DISPLAY_WIDTH = width;
37 | DISPLAY_HEIGHT = height;
38 | SDL_InitSubSystem(SDL_INIT_VIDEO);
39 |
40 | window = SDL_CreateWindow(WINDOW_NAME,
41 | SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
42 | DISPLAY_WIDTH, DISPLAY_HEIGHT, 0);
43 |
44 | renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
45 |
46 | texture = SDL_CreateTexture(renderer,
47 | (LV_COLOR_DEPTH == 32) ? (SDL_PIXELFORMAT_ARGB8888) : (SDL_PIXELFORMAT_RGB565),
48 | SDL_TEXTUREACCESS_STREAMING,
49 | DISPLAY_WIDTH,
50 | DISPLAY_HEIGHT);
51 |
52 | fb1 = malloc(DISPLAY_WIDTH * DISPLAY_HEIGHT * ((LV_COLOR_DEPTH + 7) / 8));
53 | fb2 = malloc(DISPLAY_WIDTH * DISPLAY_HEIGHT * ((LV_COLOR_DEPTH + 7) / 8));
54 |
55 | lv_disp_draw_buf_init(&draw_buf, fb1, fb2, DISPLAY_WIDTH * DISPLAY_HEIGHT);
56 | lv_disp_drv_init(&disp_drv);
57 |
58 | disp_drv.hor_res = DISPLAY_WIDTH;
59 | disp_drv.ver_res = DISPLAY_HEIGHT;
60 | disp_drv.flush_cb = disp_flush;
61 | disp_drv.draw_buf = &draw_buf;
62 | disp_drv.full_refresh = 1;
63 | lv_disp_drv_register(&disp_drv);
64 | }
65 |
66 | void lv_port_disp_deinit()
67 | {
68 | free(fb1);
69 | free(fb2);
70 | SDL_DestroyTexture(texture);
71 | SDL_DestroyRenderer(renderer);
72 | SDL_DestroyWindow(window);
73 | SDL_QuitSubSystem(SDL_INIT_VIDEO);
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/clib/lvgl_drv/lv_xbox_disp.c:
--------------------------------------------------------------------------------
1 | //SPDX-License-Identifier: MIT
2 |
3 | #ifdef NXDK
4 | #include
5 | #include
6 | #include "lv_port_disp.h"
7 | #include "lvgl.h"
8 |
9 | static void *fb1, *fb2;
10 | static lv_disp_drv_t disp_drv;
11 | static lv_disp_draw_buf_t draw_buf;
12 | static int DISPLAY_WIDTH;
13 | static int DISPLAY_HEIGHT;
14 |
15 | static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
16 | {
17 | VIDEOREG(0x00600800) = (unsigned int)MmGetPhysicalAddress(color_p);
18 | XVideoFlushFB();
19 | lv_disp_flush_ready(disp_drv);
20 | }
21 |
22 | void lv_port_disp_init(int width, int height)
23 | {
24 | DISPLAY_WIDTH = width;
25 | DISPLAY_HEIGHT = height;
26 | XVideoSetMode(DISPLAY_WIDTH, DISPLAY_HEIGHT, LV_COLOR_DEPTH, REFRESH_DEFAULT);
27 |
28 | fb1 = MmAllocateContiguousMemoryEx(DISPLAY_WIDTH * DISPLAY_HEIGHT * ((LV_COLOR_DEPTH + 7) / 8),
29 | 0x00000000, 0x7FFFFFFF,
30 | 0x1000,
31 | PAGE_READWRITE |
32 | PAGE_WRITECOMBINE);
33 |
34 | fb2 = MmAllocateContiguousMemoryEx(DISPLAY_WIDTH * DISPLAY_HEIGHT * ((LV_COLOR_DEPTH + 7) / 8),
35 | 0x00000000, 0x7FFFFFFF,
36 | 0x1000,
37 | PAGE_READWRITE |
38 | PAGE_WRITECOMBINE);
39 |
40 | assert(fb1 != NULL);
41 | assert(fb2 != NULL);
42 |
43 | RtlZeroMemory(fb1, DISPLAY_WIDTH * DISPLAY_HEIGHT * ((LV_COLOR_DEPTH + 7) / 8));
44 | RtlZeroMemory(fb2, DISPLAY_WIDTH * DISPLAY_HEIGHT * ((LV_COLOR_DEPTH + 7) / 8));
45 | VIDEOREG(0x00600800) = (unsigned int)MmGetPhysicalAddress(fb1);
46 | XVideoFlushFB();
47 |
48 | lv_disp_draw_buf_init(&draw_buf, fb1, fb2, DISPLAY_WIDTH * DISPLAY_HEIGHT);
49 | lv_disp_drv_init(&disp_drv);
50 |
51 | disp_drv.hor_res = DISPLAY_WIDTH;
52 | disp_drv.ver_res = DISPLAY_HEIGHT;
53 | disp_drv.flush_cb = disp_flush;
54 | disp_drv.draw_buf = &draw_buf;
55 | disp_drv.full_refresh = 1;
56 | lv_disp_drv_register(&disp_drv);
57 | }
58 |
59 | void lv_port_disp_deinit()
60 | {
61 | MmFreeContiguousMemory(fb1);
62 | MmFreeContiguousMemory(fb2);
63 | }
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/include/pthread_signal.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2013-2016 mingw-w64 project
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a
5 | copy of this software and associated documentation files (the "Software"),
6 | to deal in the Software without restriction, including without limitation
7 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | and/or sell copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | DEALINGS IN THE SOFTWARE.
21 | */
22 |
23 | #ifndef WIN_PTHREADS_SIGNAL_H
24 | #define WIN_PTHREADS_SIGNAL_H
25 |
26 | /* Windows has rudimentary signals support. */
27 | #define pthread_sigmask(H, S1, S2) 0
28 |
29 | #endif /* WIN_PTHREADS_SIGNAL_H */
30 |
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/include/sched.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2011-2016 mingw-w64 project
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a
5 | copy of this software and associated documentation files (the "Software"),
6 | to deal in the Software without restriction, including without limitation
7 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | and/or sell copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | DEALINGS IN THE SOFTWARE.
21 | */
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | #include
32 |
33 | #ifndef WIN_PTHREADS_SCHED_H
34 | #define WIN_PTHREADS_SCHED_H
35 |
36 | #ifndef SCHED_OTHER
37 | /* Some POSIX realtime extensions, mostly stubbed */
38 | #define SCHED_OTHER 0
39 | #define SCHED_FIFO 1
40 | #define SCHED_RR 2
41 | #define SCHED_MIN SCHED_OTHER
42 | #define SCHED_MAX SCHED_RR
43 |
44 | struct sched_param {
45 | int sched_priority;
46 | };
47 |
48 | #ifdef __cplusplus
49 | extern "C" {
50 | #endif
51 |
52 | #if defined DLL_EXPORT && !defined (WINPTHREAD_EXPORT_ALL_DEBUG)
53 | #ifdef IN_WINPTHREAD
54 | #define WINPTHREAD_SCHED_API __declspec(dllexport)
55 | #else
56 | #define WINPTHREAD_SCHED_API __declspec(dllimport)
57 | #endif
58 | #else
59 | #define WINPTHREAD_SCHED_API
60 | #endif
61 |
62 | int WINPTHREAD_SCHED_API sched_yield(void);
63 | int WINPTHREAD_SCHED_API sched_get_priority_min(int pol);
64 | int WINPTHREAD_SCHED_API sched_get_priority_max(int pol);
65 | int WINPTHREAD_SCHED_API sched_getscheduler(pid_t pid);
66 | int WINPTHREAD_SCHED_API sched_setscheduler(pid_t pid, int pol, const struct sched_param *param);
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif
73 |
74 | #ifndef sched_rr_get_interval
75 | #define sched_rr_get_interval(_p, _i) \
76 | ( errno = ENOTSUP, (int) -1 )
77 | #endif
78 |
79 | #endif /* WIN_PTHREADS_SCHED_H */
80 |
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/include/semaphore.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2011-2016 mingw-w64 project
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a
5 | copy of this software and associated documentation files (the "Software"),
6 | to deal in the Software without restriction, including without limitation
7 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 | and/or sell copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 | DEALINGS IN THE SOFTWARE.
21 | */
22 |
23 | #ifndef WIN_PTHREADS_SEMAPHORE_H
24 | #define WIN_PTHREADS_SEMAPHORE_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | #if defined DLL_EXPORT && !defined (WINPTHREAD_EXPORT_ALL_DEBUG)
31 | #ifdef IN_WINPTHREAD
32 | #define WINPTHREAD_SEMA_API __declspec(dllexport)
33 | #else
34 | #define WINPTHREAD_SEMA_API __declspec(dllimport)
35 | #endif
36 | #else
37 | #define WINPTHREAD_SEMA_API
38 | #endif
39 |
40 | /* Set this to 0 to disable it */
41 | #define USE_SEM_CriticalSection_SpinCount 100
42 |
43 | #define SEM_VALUE_MAX INT_MAX
44 |
45 | #ifndef _MODE_T_
46 | #define _MODE_T_
47 | typedef unsigned short mode_t;
48 | #endif
49 |
50 | typedef void *sem_t;
51 |
52 | #define SEM_FAILED NULL
53 |
54 | int WINPTHREAD_SEMA_API sem_init(sem_t * sem, int pshared, unsigned int value);
55 |
56 | int WINPTHREAD_SEMA_API sem_destroy(sem_t *sem);
57 |
58 | int WINPTHREAD_SEMA_API sem_trywait(sem_t *sem);
59 |
60 | int WINPTHREAD_SEMA_API sem_wait(sem_t *sem);
61 |
62 | int WINPTHREAD_SEMA_API sem_timedwait(sem_t * sem, const struct timespec *t);
63 |
64 | int WINPTHREAD_SEMA_API sem_post(sem_t *sem);
65 |
66 | int WINPTHREAD_SEMA_API sem_post_multiple(sem_t *sem, int count);
67 |
68 | /* yes, it returns a semaphore (or SEM_FAILED) */
69 | sem_t * WINPTHREAD_SEMA_API sem_open(const char * name, int oflag, mode_t mode, unsigned int value);
70 |
71 | int WINPTHREAD_SEMA_API sem_close(sem_t * sem);
72 |
73 | int WINPTHREAD_SEMA_API sem_unlink(const char * name);
74 |
75 | int WINPTHREAD_SEMA_API sem_getvalue(sem_t * sem, int * sval);
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif /* WIN_PTHREADS_SEMAPHORE_H */
82 |
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/lib/libpthread.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/clib/mingw-w64-winpthreads/lib/libpthread.a
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/lib/libpthread.dll.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/clib/mingw-w64-winpthreads/lib/libpthread.dll.a
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/lib/libwinpthread.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/clib/mingw-w64-winpthreads/lib/libwinpthread.a
--------------------------------------------------------------------------------
/clib/mingw-w64-winpthreads/lib/libwinpthread.dll.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/clib/mingw-w64-winpthreads/lib/libwinpthread.dll.a
--------------------------------------------------------------------------------
/clib/quickjs/LICENSE:
--------------------------------------------------------------------------------
1 | QuickJS Javascript Engine
2 |
3 | Copyright (c) 2017-2021 Fabrice Bellard
4 | Copyright (c) 2017-2021 Charlie Gordon
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/clib/quickjs/hello.c:
--------------------------------------------------------------------------------
1 | /* File generated automatically by the QuickJS compiler. */
2 |
3 | #include "quickjs-libc.h"
4 |
5 | const uint32_t qjsc_hello_size = 78;
6 |
7 | const uint8_t qjsc_hello[78] = {
8 | 0x02, 0x04, 0x0e, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
9 | 0x6c, 0x65, 0x06, 0x6c, 0x6f, 0x67, 0x16, 0x48,
10 | 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72,
11 | 0x6c, 0x64, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
12 | 0x2e, 0x6a, 0x73, 0x0e, 0x00, 0x06, 0x00, 0xa0,
13 | 0x01, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x14,
14 | 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x38, 0xe1,
15 | 0x00, 0x00, 0x00, 0x42, 0xe2, 0x00, 0x00, 0x00,
16 | 0x04, 0xe3, 0x00, 0x00, 0x00, 0x24, 0x01, 0x00,
17 | 0xcd, 0x28, 0xc8, 0x03, 0x01, 0x00,
18 | };
19 |
20 | static JSContext *JS_NewCustomContext(JSRuntime *rt)
21 | {
22 | JSContext *ctx = JS_NewContextRaw(rt);
23 | if (!ctx)
24 | return NULL;
25 | JS_AddIntrinsicBaseObjects(ctx);
26 | JS_AddIntrinsicDate(ctx);
27 | JS_AddIntrinsicEval(ctx);
28 | JS_AddIntrinsicStringNormalize(ctx);
29 | JS_AddIntrinsicRegExp(ctx);
30 | JS_AddIntrinsicJSON(ctx);
31 | JS_AddIntrinsicProxy(ctx);
32 | JS_AddIntrinsicMapSet(ctx);
33 | JS_AddIntrinsicTypedArrays(ctx);
34 | JS_AddIntrinsicPromise(ctx);
35 | JS_AddIntrinsicBigInt(ctx);
36 | return ctx;
37 | }
38 |
39 | int main(int argc, char **argv)
40 | {
41 | JSRuntime *rt;
42 | JSContext *ctx;
43 | rt = JS_NewRuntime();
44 | js_std_set_worker_new_context_func(JS_NewCustomContext);
45 | js_std_init_handlers(rt);
46 | JS_SetModuleLoaderFunc(rt, NULL, js_module_loader, NULL);
47 | ctx = JS_NewCustomContext(rt);
48 | js_std_add_helpers(ctx, argc, argv);
49 | js_std_eval_binary(ctx, qjsc_hello, qjsc_hello_size, 0);
50 | js_std_loop(ctx);
51 | JS_FreeContext(ctx);
52 | JS_FreeRuntime(rt);
53 | return 0;
54 | }
55 |
--------------------------------------------------------------------------------
/clib/quickjs/libregexp-opcode.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Regular Expression Engine
3 | *
4 | * Copyright (c) 2017-2018 Fabrice Bellard
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | #ifdef DEF
26 |
27 | DEF(invalid, 1) /* never used */
28 | DEF(char, 3)
29 | DEF(char32, 5)
30 | DEF(dot, 1)
31 | DEF(any, 1) /* same as dot but match any character including line terminator */
32 | DEF(line_start, 1)
33 | DEF(line_end, 1)
34 | DEF(goto, 5)
35 | DEF(split_goto_first, 5)
36 | DEF(split_next_first, 5)
37 | DEF(match, 1)
38 | DEF(save_start, 2) /* save start position */
39 | DEF(save_end, 2) /* save end position, must come after saved_start */
40 | DEF(save_reset, 3) /* reset save positions */
41 | DEF(loop, 5) /* decrement the top the stack and goto if != 0 */
42 | DEF(push_i32, 5) /* push integer on the stack */
43 | DEF(drop, 1)
44 | DEF(word_boundary, 1)
45 | DEF(not_word_boundary, 1)
46 | DEF(back_reference, 2)
47 | DEF(backward_back_reference, 2) /* must come after back_reference */
48 | DEF(range, 3) /* variable length */
49 | DEF(range32, 3) /* variable length */
50 | DEF(lookahead, 5)
51 | DEF(negative_lookahead, 5)
52 | DEF(push_char_pos, 1) /* push the character position on the stack */
53 | DEF(bne_char_pos, 5) /* pop one stack element and jump if equal to the character
54 | position */
55 | DEF(prev, 1) /* go to the previous char */
56 | DEF(simple_greedy_quant, 17)
57 |
58 | #endif /* DEF */
59 |
--------------------------------------------------------------------------------
/clib/quickjs/quickjs-libc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * QuickJS C library
3 | *
4 | * Copyright (c) 2017-2018 Fabrice Bellard
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | #ifndef QUICKJS_LIBC_H
25 | #define QUICKJS_LIBC_H
26 |
27 | #include
28 | #include
29 |
30 | #include "quickjs.h"
31 |
32 | #ifdef __cplusplus
33 | extern "C" {
34 | #endif
35 |
36 | JSModuleDef *js_init_module_std(JSContext *ctx, const char *module_name);
37 | JSModuleDef *js_init_module_os(JSContext *ctx, const char *module_name);
38 | void js_std_add_helpers(JSContext *ctx, int argc, char **argv);
39 | void js_std_loop(JSContext *ctx);
40 | void js_std_init_handlers(JSRuntime *rt);
41 | void js_std_free_handlers(JSRuntime *rt);
42 | void js_std_dump_error(JSContext *ctx);
43 | uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
44 | int js_module_set_import_meta(JSContext *ctx, JSValueConst func_val,
45 | JS_BOOL use_realpath, JS_BOOL is_main);
46 | JSModuleDef *js_module_loader(JSContext *ctx,
47 | const char *module_name, void *opaque);
48 | void js_std_eval_binary(JSContext *ctx, const uint8_t *buf, size_t buf_len,
49 | int flags);
50 | void js_std_promise_rejection_tracker(JSContext *ctx, JSValueConst promise,
51 | JSValueConst reason,
52 | JS_BOOL is_handled, void *opaque);
53 | void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt));
54 |
55 | #ifdef __cplusplus
56 | } /* extern "C" { */
57 | #endif
58 |
59 | #endif /* QUICKJS_LIBC_H */
60 |
--------------------------------------------------------------------------------
/demo/app.jsx:
--------------------------------------------------------------------------------
1 | import { render, useState } from "fre"
2 |
3 | function App() {
4 | const [count, setCount] = useState(0)
5 | const add = () => {
6 | console.log('u clicked a button')
7 | setCount(count + 1)
8 | }
9 | return (
10 |
11 | {count}
12 |
13 | )
14 | }
15 | render(, document.body)
16 |
--------------------------------------------------------------------------------
/error.log:
--------------------------------------------------------------------------------
1 | error: expected type '*const fn(?*cimport.struct_JSContext, cimport.struct_JSValue, c_int, [*c]cimport.struct_JSValue) callconv(.C) cimport.struct_JSValue', found '*const fn(*cimport.struct_JSContext, cimport.struct_JSValue, c_int, [*c]cimport.struct_JSValue) callconv(.C) cimport.struct_JSValue'
--------------------------------------------------------------------------------
/jslib/build.mjs:
--------------------------------------------------------------------------------
1 | import { build } from "esbuild";
2 | async function buildA() {
3 | await build({
4 | entryPoints: ["demo/app.jsx"],
5 | outfile: "dist/app.js",
6 | bundle: true,
7 | format: "esm",
8 | treeShaking: false,
9 | jsxFactory:'h',
10 | inject: ['jslib/polyfill.mjs'],
11 | });
12 | }
13 |
14 | buildA();
15 |
--------------------------------------------------------------------------------
/jslib/demo.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "homo",
3 | "version": "0.0.0",
4 | "description": "",
5 | "main": "dom.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "build-js": "node ./jslib/build.mjs",
9 | "build-zig": "zig build",
10 | "build": "pnpm run build-js&&pnpm run build-zig"
11 | },
12 | "keywords": [],
13 | "author": "",
14 | "license": "ISC",
15 | "dependencies": {
16 | "esbuild": "^0.15.17",
17 | "fre": "^2.6.2"
18 | }
19 | }
--------------------------------------------------------------------------------
/src/asset/Sans.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/src/asset/Sans.ttf
--------------------------------------------------------------------------------
/src/component/button.zig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/src/component/button.zig
--------------------------------------------------------------------------------
/src/component/image.zig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/src/component/image.zig
--------------------------------------------------------------------------------
/src/component/input.zig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/src/component/input.zig
--------------------------------------------------------------------------------
/src/component/text.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 | const sdl = @import("../sdl.zig");
3 |
4 | const print = std.debug.print;
5 |
6 | pub fn drawFont(text: []const u8, x: i32, y: i32) void {
7 | var clearrect = sdl.SDL_Rect{ .x = 0, .y = 0, .w = 0, .h = 0 };
8 | clearrect.x = 0;
9 | clearrect.y = 0;
10 | clearrect.w = 100;
11 | clearrect.h = 100;
12 |
13 | _ = sdl.SDL_RenderFillRect(sdl.renderer, &clearrect);
14 |
15 | _ = sdl.TTF_Init();
16 | defer sdl.TTF_Quit();
17 |
18 | const font_file = @embedFile("../asset/Sans.ttf");
19 | const font_rw = sdl.SDL_RWFromConstMem(
20 | @as(*const anyopaque,@ptrCast(&font_file[0])),
21 | @as(c_int, @intCast(font_file.len)),
22 | );
23 | defer std.debug.assert(sdl.SDL_RWclose(font_rw) == 0);
24 |
25 | const font = sdl.TTF_OpenFontRW(font_rw, 0, 16);
26 | defer sdl.TTF_CloseFont(font);
27 |
28 | const font_surface = sdl.TTF_RenderUTF8_Blended(
29 | font,
30 | text.ptr,
31 | sdl.SDL_Color{
32 | .r = 0xFF,
33 | .g = 0xFF,
34 | .b = 0xFF,
35 | .a = 0xFF,
36 | },
37 | );
38 | defer sdl.SDL_FreeSurface(font_surface);
39 |
40 | const font_tex = sdl.SDL_CreateTextureFromSurface(sdl.renderer, font_surface);
41 | defer sdl.SDL_DestroyTexture(font_tex);
42 |
43 | var font_rect: sdl.SDL_Rect = .{
44 | .w = font_surface.*.w,
45 | .h = font_surface.*.h,
46 | .x = 0,
47 | .y = 0,
48 | };
49 |
50 | font_rect.x = x;
51 | font_rect.y = y;
52 |
53 | _ = sdl.SDL_RenderCopy(sdl.renderer, font_tex, null, &font_rect);
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/component/view.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 | const sdl = @import("../sdl.zig");
3 |
4 | const print = std.debug.print;
5 |
6 | pub fn drawView(x: i32, y: i32, w:i32, h:i32) void {
7 | var rect = sdl.SDL_Rect{ .x = 0, .y = 0, .w = 0, .h = 0 };
8 |
9 | rect.x = x;
10 | rect.y = y;
11 | rect.w = w;
12 | rect.h = h;
13 |
14 | _ = sdl.SDL_SetRenderDrawColor(sdl.renderer, 0xff, 0, 0, 0x10);
15 | _ = sdl.SDL_RenderFillRect(sdl.renderer, &rect);
16 | }
17 |
--------------------------------------------------------------------------------
/src/dummy.zig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/src/dummy.zig
--------------------------------------------------------------------------------
/src/flex.zig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yisar/homo/536a655d4c281aef3a048aaf36ebff8c22dc7d78/src/flex.zig
--------------------------------------------------------------------------------
/src/jsapi/fetch.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 |
3 | const print = std.debug.print;
4 | const qjs = @import("../qjs.zig");
5 |
6 | pub fn fetch(js_ctx: ?*qjs.JSContext, _: qjs.JSValue, _: c_int, args: [*c]qjs.JSValue) callconv(.C) qjs.JSValue {
7 | var url = qjs.JS_ToCString(js_ctx, args[0]);
8 | var urll = std.mem.span(url);
9 | print("{s}\n",.{urll});
10 |
11 | // TODO
12 | return qjs.JS_NewInt64(js_ctx, 1);
13 | }
--------------------------------------------------------------------------------
/src/lv.zig:
--------------------------------------------------------------------------------
1 | const lv = @import("./lvgl.zig");
2 | const std = @import("std");
3 |
4 | pub fn runLvgl() void {
5 | lv.lv_init();
6 | defer lv.lv_deinit();
7 |
8 | lv.lv_port_disp_init(640, 480);
9 | defer lv.lv_port_disp_deinit();
10 |
11 | lv.lv_port_indev_init(true);
12 | defer lv.lv_port_indev_deinit();
13 | _ = lv.lv_scr_act();
14 | lv.lv_obj_set_style_bg_color(lv.lv_scr_act(), lv.lv_color_hex(0x003a57), lv.LV_PART_MAIN);
15 | var label = lv.lv_label_create(lv.lv_scr_act());
16 | _ = lv.lv_label_set_text(label, "Hello world");
17 | _ = lv.lv_obj_set_style_text_color(lv.lv_scr_act(), lv.lv_color_hex(0xffffff), lv.LV_PART_MAIN);
18 | _ = lv.lv_obj_align(label, lv.LV_ALIGN_CENTER, 0, 0);
19 |
20 | var lastTick: i64 = std.time.milliTimestamp();
21 | while (true) {
22 | lv.lv_tick_inc(@as(u32, @intCast(std.time.milliTimestamp() - lastTick)));
23 | lastTick = std.time.milliTimestamp();
24 | _=lv.lv_task_handler();
25 | }
26 |
27 | // var lastTick: i64 = std.time.milliTimestamp();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/lvgl.zig:
--------------------------------------------------------------------------------
1 | pub usingnamespace @cImport({
2 | @cDefine("USE_SDL", "1");
3 | @cDefine("ZIG", "1");
4 | @cInclude("lvgl.h");
5 | @cInclude("lv_port_disp.h");
6 | @cInclude("lv_port_indev.h");
7 | });
--------------------------------------------------------------------------------
/src/main.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 |
3 | const print = std.debug.print;
4 | const sld = @import("./sdl.zig");
5 | const qjs = @import("./qjs.zig");
6 | const llv = @import("./lv.zig");
7 |
8 | const fs = std.fs;
9 | const mem = std.mem;
10 |
11 | pub fn main() !void {
12 | llv.runLvgl();
13 | // const allocator = std.heap.c_allocator;
14 | // var argIter = try std.process.argsWithAllocator(allocator);
15 | // _ = argIter.next();
16 | // const file = mem.span(argIter.next()) orelse return error.InvalidSource;
17 | // const src = try fs.cwd().readFileAlloc(allocator, file, 1024 * 1024);
18 | // defer allocator.free(src);
19 | // try qjs.runMicrotask(allocator, src);
20 | }
21 |
--------------------------------------------------------------------------------
/src/qjs.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 | const fetch = @import("./jsapi/fetch.zig");
3 | const sdl = @import("./sdl.zig");
4 | const qjs = @This();
5 |
6 | pub usingnamespace @cImport({
7 | @cInclude("quickjs-libc.h");
8 | });
9 |
10 | pub fn evalFile(allocator: std.mem.Allocator, src: []u8) ![]u8 {
11 | var js_src = std.ArrayList(u8).init(allocator);
12 | var js_wtr = js_src.writer();
13 | _ = try js_wtr.print("{s}\x00", .{src[0..src.len]});
14 | const srcs = js_src.toOwnedSlice();
15 | return srcs;
16 | }
17 |
18 | pub var js_ctx: ?*qjs.JSContext = null;
19 |
20 | pub fn runMicrotask(allocator: std.mem.Allocator, src: []u8) !void {
21 | const js_src = try qjs.evalFile(allocator, src);
22 |
23 | const load_std = "import * as std from 'std';import * as os from 'os';globalThis.std = std;globalThis.os = os;";
24 |
25 | var js_runtime: *qjs.JSRuntime = qjs.JS_NewRuntime().?;
26 | defer qjs.JS_FreeRuntime(js_runtime);
27 |
28 | js_ctx = qjs.JS_NewContext(js_runtime);
29 | defer qjs.JS_FreeContext(js_ctx);
30 |
31 | _ = qjs.js_init_module_std(js_ctx, "std");
32 | _ = qjs.js_init_module_os(js_ctx, "os");
33 |
34 | qjs.js_std_init_handlers(js_runtime);
35 | defer qjs.js_std_free_handlers(js_runtime);
36 |
37 | qjs.JS_SetModuleLoaderFunc(js_runtime, null, qjs.js_module_loader, null);
38 |
39 | qjs.js_std_add_helpers(js_ctx, 0, null);
40 |
41 | var global: qjs.JSValue = qjs.JS_GetGlobalObject(js_ctx);
42 |
43 | var sendfn: qjs.JSValue = qjs.JS_NewCFunction(js_ctx, fetch.fetch, "fetch", 1);
44 | defer qjs.JS_FreeValue(js_ctx, global);
45 | _ = qjs.JS_SetPropertyStr(js_ctx, global, "fetch", sendfn);
46 |
47 | const val = qjs.JS_Eval(js_ctx, load_std, load_std.len, "", qjs.JS_EVAL_TYPE_MODULE);
48 | if (qjs.JS_IsException(val) > 0) {
49 | qjs.js_std_dump_error(js_ctx);
50 | }
51 |
52 | const val2 = qjs.JS_Eval(js_ctx, js_src.ptr, js_src.len - 1, "", qjs.JS_EVAL_TYPE_GLOBAL);
53 | if (qjs.JS_IsException(val2) > 0) {
54 | qjs.js_std_dump_error(js_ctx);
55 | }
56 |
57 | qjs.js_std_loop(js_ctx);
58 | try sdl.runsdl();
59 | }
60 |
61 | pub fn js_call(fnname: []const u8, len: i32, args: [*c]qjs.JSValue ) []const u8 {
62 | var global = qjs.JS_GetGlobalObject(js_ctx);
63 | defer qjs.JS_FreeValue(js_ctx, global);
64 | var func = qjs.JS_GetPropertyStr(js_ctx, global, fnname.ptr);
65 | defer qjs.JS_FreeValue(js_ctx, func);
66 |
67 | var val = qjs.JS_Call(js_ctx, func, global, len, args);
68 |
69 | var j = qjs.JS_ToCString(js_ctx, val);
70 |
71 | var ret = std.mem.span(j);
72 | return ret;
73 | }
74 |
--------------------------------------------------------------------------------
/src/render.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 |
3 | const print = std.debug.print;
4 | const sdl = @import("./sdl.zig");
5 |
6 | const qjs = @import("./qjs.zig");
7 | const text = @import("./component/text.zig");
8 | const view = @import("./component/view.zig");
9 | // pub var myEventType: i32 = sdl.SDL_RegisterEvents(1);
10 |
11 | pub fn render(direct: []const u8) !void {
12 | const allocator = std.heap.page_allocator;
13 | var parser = std.json.Parser.init(allocator, false);
14 | defer parser.deinit();
15 |
16 | var tree = parser.parse(direct) catch |err| {
17 | std.debug.print("error: {s}", .{@errorName(err)});
18 | return;
19 | };
20 |
21 | var _type = tree.root.Object.get("type").?.String;
22 | var _x = tree.root.Object.get("x").?.String;
23 | var _y = tree.root.Object.get("y").?.String;
24 | var _w = tree.root.Object.get("w").?.String;
25 | var _h = tree.root.Object.get("h").?.String;
26 |
27 | const xx = try std.fmt.parseInt(i32, _x, 10);
28 | const yy = try std.fmt.parseInt(i32, _y, 10);
29 | const ww = try std.fmt.parseInt(i32, _w, 10);
30 | const hh = try std.fmt.parseInt(i32, _h, 10);
31 |
32 | if (std.mem.eql(u8, _type, "#text")) {
33 | var _data = tree.root.Object.get("data").?.String;
34 | const terminated = try allocator.dupeZ(u8, _data);
35 | defer allocator.free(terminated);
36 | text.drawFont(terminated[0..terminated.len], xx, yy);
37 | }
38 |
39 | if (std.mem.eql(u8, _type, "VIEW")) {
40 | view.drawView(xx, yy, ww, hh);
41 | }
42 |
43 | _ = sdl.SDL_RenderPresent(sdl.renderer);
44 |
45 |
46 | // print("{s}", .{_data});
47 | }
48 |
--------------------------------------------------------------------------------
/src/sdl.zig:
--------------------------------------------------------------------------------
1 | const std = @import("std");
2 | const sdl = @cImport({
3 | @cInclude("SDL.h");
4 | @cInclude("SDL_image.h");
5 | @cInclude("SDL_ttf.h");
6 | });
7 |
8 | const assert = @import("std").debug.assert;
9 | const text = @import("./component/text.zig");
10 | const print = std.debug.print;
11 | const qjs = @import("./qjs.zig");
12 | const r = @import("./render.zig");
13 |
14 | pub usingnamespace sdl;
15 |
16 | pub var window: ?*sdl.SDL_Window = null;
17 | pub var renderer: ?*sdl.SDL_Renderer = null;
18 |
19 | pub fn runsdl() anyerror!void {
20 | _ = sdl.SDL_Init(sdl.SDL_INIT_VIDEO | sdl.SDL_INIT_AUDIO);
21 | defer sdl.SDL_Quit();
22 |
23 | _ = sdl.SDL_CreateWindowAndRenderer(
24 | 640,
25 | 480,
26 | sdl.SDL_WINDOW_RESIZABLE | sdl.SDL_WINDOW_ALLOW_HIGHDPI,
27 | &window,
28 | &renderer,
29 | );
30 | defer sdl.SDL_DestroyWindow(window);
31 |
32 | _ = sdl.SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
33 | _ = sdl.SDL_RenderClear(renderer);
34 |
35 | eventloop: while (true) {
36 | var event: sdl.SDL_Event = undefined;
37 | while (sdl.SDL_PollEvent(&event) != 0) {
38 | switch (event.type) {
39 | sdl.SDL_QUIT => {
40 | break :eventloop;
41 | },
42 | sdl.SDL_KEYDOWN => {},
43 | sdl.SDL_MOUSEBUTTONDOWN => {
44 | var args = [_]qjs.JSValue{ qjs.JS_NewInt32(qjs.js_ctx, event.motion.x), qjs.JS_NewInt32(qjs.js_ctx, event.motion.y) };
45 | _ = qjs.js_call("bubblingClick", 2, &args);
46 | },
47 | else => {},
48 | }
49 | }
50 | var args = [_]qjs.JSValue{};
51 | var direct = qjs.js_call("getRenderQueue", 0, &args);
52 | if (!std.mem.eql(u8, direct, "null")) {
53 | try r.render(direct);
54 | } else {}
55 |
56 | sdl.SDL_Delay(1000 / 60);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------