├── .gitmodules
├── LICENSE
├── Makefile
├── README.md
├── assets
├── icon
│ ├── 100ask_logo.png
│ ├── net.ask100.lvgl.About.png
│ ├── net.ask100.lvgl.Benchmark.png
│ ├── net.ask100.lvgl.Calc.png
│ ├── net.ask100.lvgl.FileManager.png
│ ├── net.ask100.lvgl.Game2048.png
│ ├── net.ask100.lvgl.GameMemory.png
│ ├── net.ask100.lvgl.LAN.png
│ ├── net.ask100.lvgl.Music.png
│ ├── net.ask100.lvgl.SetBrightness.png
│ ├── net.ask100.lvgl.SetTime.png
│ ├── net.ask100.lvgl.Snake.png
│ ├── net.ask100.lvgl.Tiles.png
│ ├── net.ask100.lvgl.WLAN.png
│ ├── net.ask100.lvgl.Widgets.png
│ └── net.ask100.lvgl.bg.png
└── services
│ ├── net.ask100.lvgl.About.service
│ ├── net.ask100.lvgl.Benchmark.service
│ ├── net.ask100.lvgl.Calc.service
│ ├── net.ask100.lvgl.FileManager.service
│ ├── net.ask100.lvgl.Game2048.service
│ ├── net.ask100.lvgl.GameMemory.service
│ ├── net.ask100.lvgl.LAN.service
│ ├── net.ask100.lvgl.Music.service
│ ├── net.ask100.lvgl.SetBrightness.service
│ ├── net.ask100.lvgl.SetTime.service
│ ├── net.ask100.lvgl.Snake.service
│ ├── net.ask100.lvgl.Tiles.service
│ ├── net.ask100.lvgl.WLAN.service
│ └── net.ask100.lvgl.Widgets.service
├── lv_100ask_app
├── CMakeLists.txt
├── README.md
├── library.properties
├── lv_100ask_app.h
├── lv_100ask_app.mk
├── lv_100ask_app_conf_template.h
└── src
│ ├── general_app
│ ├── general_2048_game
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── general_2048_game.c
│ │ │ └── general_2048_game.h
│ ├── general_about
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── about.c
│ │ │ └── about.h
│ ├── general_app.h
│ ├── general_benchmark
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ └── main.c
│ ├── general_calc
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── general_calc.c
│ │ │ └── general_calc.h
│ ├── general_file_manager
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── file_manager.c
│ │ │ └── file_manager.h
│ ├── general_game_memory
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── general_game_memory.c
│ │ │ └── general_game_memory.h
│ ├── general_game_snake
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── general_game_snake.c
│ │ │ └── general_game_snake.h
│ ├── general_game_tiles
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── general_game_tiles.c
│ │ │ └── general_game_tiles.h
│ ├── general_music_player
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── music_player.c
│ │ │ └── music_player.h
│ └── general_widgets
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ └── main.c
│ ├── imx6ull_app
│ ├── imx6ull_app.h
│ ├── imx6ull_set_lan
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── set_lan.c
│ │ │ └── set_lan.h
│ ├── imx6ull_set_lcd_brightness
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── set_lcd_brightness.c
│ │ │ └── set_lcd_brightness.h
│ ├── imx6ull_set_time
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ │ ├── hour.c
│ │ │ ├── minute.c
│ │ │ ├── second.c
│ │ │ ├── set_time.c
│ │ │ ├── set_time.h
│ │ │ └── watch_bg.c
│ └── imx6ull_set_wlan
│ │ ├── Makefile
│ │ ├── app_src.mk
│ │ ├── main.c
│ │ └── src
│ │ ├── set_wlan.c
│ │ └── set_wlan.h
│ └── lv_100ask_app.h
├── lv_100ask_app_conf.h
├── lv_100ask_demo_conf.h
├── lv_100ask_modules_conf.h
├── lv_conf.h
├── lv_demo_conf.h
├── lv_drv_conf.h
├── lv_lib_png
├── .gitignore
├── CMakeLists.txt
├── LICENSE
├── README.md
├── lodepng.c
├── lodepng.h
├── lv_lib_png.mk
├── lv_png.c
├── lv_png.h
├── png_decoder_test.c
└── png_decoder_test.png
└── main.c
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "lv_100ask_demos"]
2 | path = lv_100ask_demos
3 | url = https://github.com/100askTeam/lv_100ask_demos.git
4 | [submodule "lv_100ask_modules"]
5 | path = lv_100ask_modules
6 | url = https://github.com/100askTeam/lv_100ask_modules.git
7 | [submodule "lv_drivers"]
8 | path = lv_drivers
9 | url = https://github.com/lvgl/lv_drivers.git
10 | [submodule "lvgl"]
11 | path = lvgl
12 | url = https://github.com/lvgl/lvgl.git
13 | [submodule "lv_demos"]
14 | path = lv_demos
15 | url = https://github.com/lvgl/lv_demos.git
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2008-2021 Shenzhen Baiwenwang Technology Co., Ltd.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 | # ⭐全速编译命令: make clean && make -j$(nproc) RUN_JOBS=-j$(nproc)
5 |
6 | #CC ?= gcc
7 | export CC := arm-buildroot-linux-gnueabihf-gcc
8 | export LVGL_DIR_NAME ?= lvgl
9 | export LVGL_DIR ?= ${shell pwd}
10 | export CFLAGS ?= -O3 -g0 -I$(LVGL_DIR)/ -Wall -Wshadow -Wundef -Wmissing-prototypes -Wno-discarded-qualifiers -Wall -Wextra -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated -Wempty-body -Wtype-limits -Wshift-negative-value -Wstack-usage=2048 -Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual -Wmissing-prototypes -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wno-discarded-qualifiers -Wformat-security -Wno-ignored-qualifiers -Wno-sign-compare \
11 | -I ~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include -I ~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/dbus-1.0/include
12 | export LDFLAGS ?= -lm -ldbus-1 -lpthread
13 | BIN = 100ask_lvgl_Main
14 |
15 |
16 | # 从make传递的参数获取子应用的编译速度设置,示例:make -j16 RUN_JOBS=-j16
17 | RUN_JOBS =
18 |
19 | #Collect the files to compile
20 | MAINSRC = ./main.c
21 |
22 | include $(LVGL_DIR)/lvgl/lvgl.mk
23 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
24 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
25 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
26 | #include $(LVGL_DIR)/lv_100ask_app/lv_100ask_app.mk
27 |
28 |
29 | OBJEXT ?= .o
30 |
31 | AOBJS = $(ASRCS:.S=$(OBJEXT))
32 | COBJS = $(CSRCS:.c=$(OBJEXT))
33 |
34 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
35 |
36 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
37 | OBJS = $(AOBJS) $(COBJS)
38 |
39 | ## MAINOBJ -> OBJFILES
40 | # general app
41 | SRC_DIR += lv_100ask_app/src/general_app/general_file_manager\
42 | lv_100ask_app/src/general_app/general_2048_game\
43 | lv_100ask_app/src/general_app/general_game_memory\
44 | lv_100ask_app/src/general_app/general_game_snake\
45 | lv_100ask_app/src/general_app/general_game_tiles\
46 | lv_100ask_app/src/general_app/general_calc\
47 | lv_100ask_app/src/general_app/general_widgets\
48 | lv_100ask_app/src/general_app/general_benchmark\
49 | lv_100ask_app/src/general_app/general_music_player\
50 | lv_100ask_app/src/general_app/general_about
51 | # imx6ull app
52 | SRC_DIR += lv_100ask_app/src/imx6ull_app/imx6ull_set_lcd_brightness\
53 | lv_100ask_app/src/imx6ull_app/imx6ull_set_time\
54 | lv_100ask_app/src/imx6ull_app/imx6ull_set_wlan\
55 | lv_100ask_app/src/imx6ull_app/imx6ull_set_lan
56 |
57 |
58 | all: default
59 | $(foreach dir,$(SRC_DIR),make $(RUN_JOBS) -C $(dir);)
60 |
61 | %.o: %.c
62 | $(CC) $(CFLAGS) -c $< -o $@
63 | @echo "CC $<"
64 |
65 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
66 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
67 | mkdir -p $(LVGL_DIR)/obj $(LVGL_DIR)/bin
68 | mv *.o $(LVGL_DIR)/obj/
69 | mv $(BIN) $(LVGL_DIR)/bin/
70 |
71 | clean:
72 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./bin/* ./obj/*
73 | $(foreach dir,$(SRC_DIR),make -C $(dir) clean;)
74 |
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

2 |
3 | 100ASK Linux LVGL Desktop
4 |
5 | 100ASK Linux LVGL desktop 是一个 MIT 许可的开源项目。本项目主要目的是为大家提供一个嵌入式Linux GUI的参考解决方案:低内存占用、简洁美观的视觉效果、稳定且拓展性强的项目架构。
6 |
7 | # 介绍(Introduction)
8 |
9 | 100ASK Linux LVGL desktop 是一个 MIT 许可的开源项目。该项目由 [百问网团队](https://www.100ask.net) 研发、发布,目的是为 100ASK_IMX6ULL、100ASK_STM32MP157开发板提供提供一个基础GUI,使用Makefile组织管理源码、基于GCC编译。通过修改少量的配置便在其他Linux、Linux开发板上运行。
10 |
11 | 项目效果演示视频:[https://www.bilibili.com/video/BV1nT4y1R7rz](https://www.bilibili.com/video/BV1nT4y1R7rz)
12 |
13 | 
14 |
15 | ## 快速开始
16 |
17 | 如果使用的是[百问网IMX6ULL开发板](https://item.taobao.com/item.htm?id=610613585935),那么你可以通过直接更新固件,最快获得体验。
18 |
19 | 烧写工具及镜像获取:
20 |
21 | - 百度云:链接: [https://pan.baidu.com/s/17QWdasg3lcSb82JK4uUJuQ](https://pan.baidu.com/s/17QWdasg3lcSb82JK4uUJuQ) 提取码: root
22 | - 不限速下载地址: [https://download.csdn.net/download/qq_35181236/40774994](https://download.csdn.net/download/qq_35181236/40774994)
23 |
24 | 或者选择按照下面的章节按步骤开始。
25 |
26 | ### 编译项目
27 |
28 | 1. 配置开发环境
29 | 本项目的开发环境为:` VMware Workstation + Ubuntu` ,
30 | 如果是学习韦东山嵌入式Linux教程的小伙伴可以跳过这一步,
31 | 需要搭建开发环境的请点击连接查看详细教程:xxxxxx 。
32 | 2. 配置交叉编译环境。如果工具链没有配置正确,可能会导致编译不通过,即使编译通过了也不能在目标平台上运行,请注意检查运行环境,编译环境。
33 | 3. 项目用到了dbus库,但是由于工具链可能有问题(暂未解决),导致我们需要手动指定dbus的头文件路径,因此我们需要在工具链中进行一些操作:
34 |
35 | ```shell
36 |
37 | book@100ask:~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ ls dbus-
38 | dbus-1.0/ dbus-c++-1/
39 | book@100ask:~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ pwd
40 | /home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include
41 | book@100ask:~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ cp dbus-1.0/dbus/ -rfd .
42 | book@100ask:~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ sync
43 | book@100ask:~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ ls dbus
44 | dbus/ dbus-1.0/ dbus-c++-1/
45 | book@100ask:~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ ls dbus
46 |
47 | ```
48 |
49 | > 编译的时候如果报错: `fatal error: dbus/dbus.h No such file or directory` 应该回来看这里的操作,按照自己的sdk路径参考修改即可。
50 |
51 | 4. 先克隆主仓库:git clone xxxxxxxx
52 | 5. 克隆主仓库后,同步子仓库模块: git submodule update --init --recursive
53 | 6. 后续更新子仓库模块: git submodule update --remote
54 | 7. 进入仓库根目录 `xxxxx` ,执行 `make clean && make` 开始编译。
55 | 8. 提升编译速度。全速编译命令: `make clean && make -j$(nproc) RUN_JOBS=-j$(nproc)`
56 | "make -j$(nproc)" 的 **$(nproc)** 是指定编译 **主桌面程序** 的内核线程数,命令会自动获取系统支持最大的线程数,可以手动指定线程数,如: -j16 ,
57 | "RUN_JOBS=j$(nproc)"的 **$(nproc)** 是指定编译 **APP程序** 的内核线程数,命令会自动获取系统支持最大的线程数,可以手动指定线程数,如: -j16 ,
58 | Linux 下输入 `nproc` 命令返回的数字是你机器的线程数。
59 |
60 | #### 编译其他板子
61 |
62 | 配置好交叉编译工具链之后,只需要稍作修改便可以在 100ASK_IMX6ULL_MINI、100ASK_STM32MP157 开发板上运行:
63 | 1. 参考[上面](#编译项目)的第三步操作
64 | 2. 修改 Makefile 变量 `CFLAGS` 的这两个链接路径,指定为你的路径:
65 |
66 | ```shell
67 |
68 | -I ~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include -I ~/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/dbus-1.0/include
69 |
70 | ```
71 |
72 | ---------------
73 |
74 | 示例:比如使用 100ASK_IMX6ULL_MINI开发板,并且是按照韦东山教程配套的资料文档配置好了工具链之后这样操作:
75 |
76 | 1. 复制 dbus 库:
77 |
78 | ```shell
79 |
80 | book@100ask:~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ ls dbus-
81 | dbus-1.0/ dbus-c++-1/
82 | book@100ask:~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ pwd
83 | /home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include
84 | book@100ask:~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ cp dbus-1.0/dbus/ -rfd .
85 | book@100ask:~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ sync
86 | book@100ask:~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ ls dbus
87 | dbus/ dbus-1.0/ dbus-c++-1/
88 | book@100ask:~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include$ ls dbus
89 |
90 | ```
91 |
92 | 2. 修改 Makefile 变量 `CFLAGS` 的这两个链接路径,指定为你的路径:
93 |
94 | ```shell
95 |
96 | -I ~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/include -I ~/100ask_imx6ull-mini-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/dbus-1.0/include
97 |
98 | ```
99 |
100 |
101 | ### 如何运行
102 | 1. 编译出来的可执行程序会放在项目根目录的 `bin` 目录下,将里面的可执行文件全部传到开发板文件系统中(如家目录),
103 | 2. 将 `assets/icon` 的 **icon** 目录及其中的所有图片文件传到开发板的文件系统中( **icon** 目录必须和可执行程序在同一级目录)
104 | 3. 修改 `assets/services` 中的所有 `.services` 文件,假如你将可执行文件放在了家目录,那么就改成这样:
105 | ```shell
106 | [D-BUS Service]
107 | Name=net.ask100.lvgl.About
108 | Exec=~/general_About # 原来是这样的Exec=/usr/share/100ask_desktop/general_About
109 | ```
110 | 4. 将修改后 `assets/services` 中的所有 `.services` 文件,复制到开发板的 dbus 服务目录下,本项目的目录是: `/usr/share/dbus-1/services/`
111 | 5. 在执行之前初始化 dbus 运行环境,执行: export $(dbus-launch)
112 | 6. 修改可执行文件的权限: sudo chmod +x ~/*
113 | 7. 最后在可执行文件的目录下执行桌面程序: ./100ask_lvgl_Main
114 | 8. 尽情享受吧
115 |
116 | ## 仓库子模块说明
117 |
118 | - [x] lv_100ask_demos:百问网 LVGL 示例仓库 (平台无关,可以在支持LVGL的任意平台编译运行)
119 | - [x] lv_100ask_modules:百问网模块仓库 (此仓库为本项目而设,目的是为了提供一些通用的模块供本项目使用,并减少代码量和项目维护难度)
120 | - [ ] lv_demos:LVGL 官方的示例(LVGL官方仓库)
121 | - [x] lv_drivers:用于 LVGL 嵌入式 GUI 库的 TFT 和触摸板驱动程序(LVGL官方仓库)
122 | - [x] lvgl:LVGL库,项目基于此仓库(LVGL官方仓库)
123 |
124 | > 上面 √ 选上的是必选仓库,如果不需要可选仓库,请注意修改配置文件和 Makefile。
125 |
126 | # 项目架构
127 |
128 | ## 项目框图
129 |
130 | 
131 |
132 | ## 目录说明
133 | ``` shell
134 | ├── assets # 程序运行所需的资源,二次开发需要将里面的文件copy开发板的文件系统中
135 | │ ├── icon # 桌面背景和APP图标(默认存放位置:/usr/share/100ask_desktop/assets/icon)。需要将 assets/icon 文件夹复制到主桌面程序的同级目录(默认存放位置:/usr/share/100ask_desktop)下,背景、图标可以替换,注意名称要和之前的一样。
136 | │ └── services # DBus服务列表。增加APP后需要参考里面的格式新建服务文件,并将服务文件(不是整个文件夹)copy到dbus服务文件目录下: /usr/share/dbus-1/services/
137 | ├── lv_100ask_app # APP程序(二次开发新的APP主要在这里添加自己的APP)
138 | │ └── src
139 | │ ├── general_app # 平台无关的通用APP
140 | │ │ ├── general_2048_game # APP程序的目录
141 | │ │ │ ├── obj # 编译过程输出文件存放在这里(执行后 make clean 会清除),可执行文件放在项目根目录的 bin 目录下
142 | │ │ │ └── src # APP程序代码
143 | │ │ ├── .......
144 | │ └── imx6ull_app # 硬件相关的APP
145 | │ ├── imx6ull_set_lan # APP程序的目录
146 | │ ├── .......
147 | ├── lv_100ask_demos # 百问网平台无关的通用APP
148 | │ ├── docs
149 | │ └── src
150 | │ ├── lv_100ask_demo_2048
151 | │ ├── ......
152 | ├── lv_100ask_modules # 百问网模块仓库 (此仓库为本项目而设,目的是为了提供一些通用的模块供本项目使用,并减少代码量和项目维护难度)
153 | │ ├── docs
154 | │ └── src
155 | │ ├── lv_100ask_boot_animation # 开机动画模块
156 | │ ├── lv_100ask_dbus_handler # DBus消息处理模块
157 | │ ├── lv_100ask_dbus_message_dispatch # 消息分发模块(目前是桌面主程序专用)
158 | │ ├── lv_100ask_demo_assistive_touch # 辅助触摸悬浮球模块
159 | │ └── lv_100ask_demo_init_icon # 桌面图标初始化模块(桌面主程序专用)
160 | ├── lv_demos # LVGL 官方的示例(LVGL官方仓库)
161 | ├── lv_drivers # 用于 LVGL 嵌入式 GUI 库的 TFT 和触摸板驱动程序(LVGL官方仓库)
162 | ├── lvgl # LVGL库,项目基于此仓库(LVGL官方仓库)
163 | ├── lv_lib_png # 显示png图片库(LVGL官方仓库)
164 | ├── bin # 编译完成后,所有的可执行文件存放在这里(执行后 make clean 会清除)
165 | └── obj # 桌面程序的编译过程输出文件存放在这里(执行后 make clean 会清除),可执行文件放在项目根目录的 bin 目录下
166 | ```
167 |
168 | ## 如何添加自己的程序
169 |
170 | 参考 `lv_100ask_app/` 在原有基础上追加或创建自己的应用。
171 |
172 | 1. 参考 `lv_100ask_app/src` 目录创建新的目录
173 | 2. 修改 `lv_100ask_app/lv_100ask_app.h` 包含添加你的应用路径。
174 | 3. 最后需要修改项目根目录的Makefile文件,在 SRC_DIR 变量添加自己创建的应用
175 |
176 |
177 | # 文档(Documentation)
178 |
179 | LVGL 文档教程:[http://lvgl.100ask.net/](http://lvgl.100ask.net/)
180 |
181 | LVGL 视频教程: TODO
182 |
183 | # 技术支持(FAQs)
184 |
185 | 欢迎来论坛发帖交流:[http://bbs.100ask.net/](http://bbs.100ask.net/)
186 |
187 | # Issues
188 | TODO
189 | # Changelog
190 | TODO
191 |
192 | # License
193 | MIT
194 |
195 | Copyright © 2008-2020 深圳百问网科技有限公司 All Rights Reserved.
196 |
197 |
198 |
199 | # 关于作者
200 | - 百问网官网:[http://www.100ask.net](http://www.100ask.net)
201 | - 百问网官方wiki:[http://wiki.100ask.org](http://wiki.100ask.org)
202 | - 百问网官方论坛:[http://bbs.100ask.net](http://bbs.100ask.net)
203 | - 微信公众号:百问科技
204 | - CSDN:[https://edu.csdn.net/lecturer/90](https://edu.csdn.net/lecturer/90)
205 | - B站:[https://space.bilibili.com/275908810](https://space.bilibili.com/275908810)
206 | - 知乎:[https://www.zhihu.com/people/www.100ask/](https://www.zhihu.com/people/www.100ask/)
207 | - 微博:[https://weibo.com/888wds](https://weibo.com/888wds)
208 | - 电子发烧友学院:[http://t.elecfans.com/teacher/3.html](http://t.elecfans.com/teacher/3.html)
209 |
210 |
211 | 公司名称:深圳百问网科技有限公司
212 | - 电话: 0755-86200561
213 | - 技术支持邮箱: weidongshan@qq.com
214 | - 地 址: 广东省深圳市龙岗区布吉南湾街道平吉大道建昇大厦B座
215 | - 邮 编: 518114
216 |
217 |
--------------------------------------------------------------------------------
/assets/icon/100ask_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/100ask_logo.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.About.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.About.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Benchmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Benchmark.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Calc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Calc.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.FileManager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.FileManager.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Game2048.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Game2048.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.GameMemory.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.GameMemory.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.LAN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.LAN.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Music.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Music.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.SetBrightness.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.SetBrightness.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.SetTime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.SetTime.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Snake.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Snake.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Tiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Tiles.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.WLAN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.WLAN.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.Widgets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.Widgets.png
--------------------------------------------------------------------------------
/assets/icon/net.ask100.lvgl.bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/assets/icon/net.ask100.lvgl.bg.png
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.About.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.About
3 | Exec=/usr/share/100ask_desktop/general_About
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Benchmark.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Benchmark
3 | Exec=/usr/share/100ask_desktop/general_Benchmark
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Calc.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Calc
3 | Exec=/usr/share/100ask_desktop/general_Calc
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.FileManager.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.FileManager
3 | Exec=/usr/share/100ask_desktop/general_FileManager
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Game2048.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Game2048
3 | Exec=/usr/share/100ask_desktop/general_Game2048
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.GameMemory.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.GameMemory
3 | Exec=/usr/share/100ask_desktop/general_GameMemory
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.LAN.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.LAN
3 | Exec=/usr/share/100ask_desktop/imx6ull_LAN
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Music.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Music
3 | Exec=/usr/share/100ask_desktop/general_Music
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.SetBrightness.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.SetBrightness
3 | Exec=/usr/share/100ask_desktop/imx6ull_SetBrightness
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.SetTime.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.SetTime
3 | Exec=/usr/share/100ask_desktop/imx6ull_SetTime
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Snake.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Snake
3 | Exec=/usr/share/100ask_desktop/general_Snake
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Tiles.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Tiles
3 | Exec=/usr/share/100ask_desktop/general_Tiles
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.WLAN.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.WLAN
3 | Exec=/usr/share/100ask_desktop/imx6ull_WLAN
4 |
--------------------------------------------------------------------------------
/assets/services/net.ask100.lvgl.Widgets.service:
--------------------------------------------------------------------------------
1 | [D-BUS Service]
2 | Name=net.ask100.lvgl.Widgets
3 | Exec=/usr/share/100ask_desktop/general_Widgets
4 |
--------------------------------------------------------------------------------
/lv_100ask_app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | file(GLOB_RECURSE SOURCES src/*.c)
2 | add_library(lv_100ask_app STATIC ${SOURCES})
3 |
--------------------------------------------------------------------------------
/lv_100ask_app/README.md:
--------------------------------------------------------------------------------
1 | # 仓库说明
2 |
3 | 此仓库是[百问网](https://www.100ask.net/index) lvgl 应用仓库。
4 |
5 | ## 用法
6 |
7 | English
8 |
9 |
10 | 1. Clone this repository: `git clone xxxx`.
11 | 2. The `lv_100ask_app` directory should be next to the `lvgl` directory in your project.
12 |
13 | Similarly to `lv_conf.h` there is a configuration file for the examples too. It is called `lv_100ask_app_conf.h`.
14 | 1. Copy `lv_100ask_app/lv_100ask_app_conf_template.h` next to `lv_100ask_app` directory
15 | 2. Rename it to `lv_100ask_app_conf.h`
16 | 3. Change the first `#if 0` to `#if 1` to enable the file's content
17 | 4. Enable or Disable demos
18 |
19 |
20 |
21 |
22 | 1. 将此仓库克隆下来: `git clone xxxx`.
23 | 2. 克隆下来之后将`lv_100ask_app` 目录放在你的项目中的 `lvgl` 库目录的旁边。
24 |
25 | 与 `lv_conf.h` 类似,此仓库示例也有一个配置文件。它就是`lv_demo_conf.h`。
26 | 1. 将 `lv_100ask_apps/lv_100ask_app_conf_template.h` 复制到 `lv_100ask_app` 目录旁边
27 | 2. 将 `lv_100ask_app_conf_template.h` 重命名为 `lv_100ask_app_conf.h`
28 | 3. 将重命名之后的 `lv_100ask_app_conf.h` 中的第一个 `#if 0` 更改为 `#if 1` 以启用文件的内容
29 | 4. 启用或禁用具体示例
30 |
31 |
32 | # 公司简介
33 |
34 | 深圳百问网科技有限公司(百问网)是中国一个专注于嵌入式Linux培训视频的科技公司。
35 |
36 | 致力于提供“教材、答疑、开发板、仿真器”一站式嵌入式学习解决方案:
37 |
38 | - 嵌入式教育开拓者
39 | - 18年嵌入式专家
40 | - ST官方合作伙伴
41 | - 全志在线官方合作伙伴
42 | - 中兴通信资深BSP专家
43 | - 首批华为鸿蒙课程开发者
44 | - 鸿蒙Liteos-a教程提供者
45 | - RT-Thread深度合作伙伴
46 | - RT-Thread官方教程提供者
47 |
48 | # 联系方式
49 |
50 | - 百问网官网:[http://www.100ask.net](http://www.100ask.net/)
51 | - 百问网官方wiki:[http://wiki.100ask.org](http://wiki.100ask.org/)
52 | - 百问网官方论坛:[http://bbs.100ask.net](http://bbs.100ask.net/)
53 | - 微信公众号:百问科技
54 | - CSDN:https://edu.csdn.net/lecturer/90
55 | - B站:https://space.bilibili.com/275908810?from=search&seid=10505231074028238949
56 | - 知乎:https://www.zhihu.com/people/www.100ask/
57 | - 微博:https://weibo.com/888wds?topnav=1&wvr=6
58 | - 电子发烧友学院:http://t.elecfans.com/teacher/3.html
59 | - 淘宝: [https://100ask.taobao.com](https://100ask.taobao.com/)
60 | - 技术支持邮箱: [weidongshan@qq.com](mailto:weidongshan@qq.com)
61 | - 公司名称:深圳百问网科技有限公司
62 | - 电话: 0755-86200561
63 | - 地 址: 广东省深圳市龙岗区布吉南湾街道平吉大道建昇大厦B1505
64 | - 邮 编: 518114
65 |
--------------------------------------------------------------------------------
/lv_100ask_app/library.properties:
--------------------------------------------------------------------------------
1 | name=lv_100ask_app
2 | version=1.0.0
3 | author=100ask
4 | maintainer=100ask,zhouyuebiao
5 | sentence=Application for 100ASK LVGL project
6 | paragraph=Demos and examples to form the features of 100ASK LVGL project.
7 | category=Display
8 | url=https://100ask.net
9 | architectures=*
10 | includes=lv_100ask_app.h
11 | depends=lvgl
12 |
--------------------------------------------------------------------------------
/lv_100ask_app/lv_100ask_app.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_100ask_app.h
3 | *
4 | */
5 |
6 | #ifndef LV_100ASK_APP_H
7 | #define LV_100ASK_APP_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #if defined(LV_LVGL_H_INCLUDE_SIMPLE)
17 | #include "lvgl.h"
18 | #else
19 | #include "../lvgl/lvgl.h"
20 | #endif
21 |
22 | #if 0
23 | #if defined(LV_100ASK_APP_PATH)
24 | #define __LV_TO_STR_AUX(x) #x
25 | #define __LV_TO_STR(x) __LV_TO_STR_AUX(x)
26 | #include __LV_TO_STR(LV_100ASK_APP_PATH)
27 | #undef __LV_TO_STR_AUX
28 | #undef __LV_TO_STR
29 | #elif defined(LV_100ASK_APP_INCLUDE_SIMPLE)
30 | #include "lv_100ask_app_conf.h"
31 | #else
32 | #include "../lv_100ask_app_conf.h"
33 | #endif
34 | #endif
35 |
36 | #include "src/general_app/general_app.h"
37 | #include "src/imx6ull_app/imx6ull_app.h"
38 | //#include "stm32mp157_app/stm32mp157_app.h"
39 |
40 | /*********************
41 | * DEFINES
42 | *********************/
43 | /*Test lvgl version*/
44 | #if LV_VERSION_CHECK(8, 0, 0) == 0
45 | #error "lv_100ask_app: Wrong lvgl version"
46 | #endif
47 |
48 | /**********************
49 | * TYPEDEFS
50 | **********************/
51 |
52 | /**********************
53 | * GLOBAL PROTOTYPES
54 | **********************/
55 |
56 |
57 | /**********************
58 | * MACROS
59 | **********************/
60 |
61 |
62 | #ifdef __cplusplus
63 | } /* extern "C" */
64 | #endif
65 |
66 | #endif /* LV_100ASK_APP_H */
67 |
--------------------------------------------------------------------------------
/lv_100ask_app/lv_100ask_app.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L lv_100ask_app -name \*.c)
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/lv_100ask_app_conf_template.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_100ask_app_conf.h
3 | * Configuration file for v1.0.0
4 | *
5 | */
6 | /*
7 | * COPY THIS FILE AS lv_100ask_app_conf.h
8 | */
9 |
10 | /* clang-format off */
11 | #if 0 /*Set it to "1" to enable the content*/
12 |
13 | #ifndef LV_100ASK_APP_CONF_H
14 | #define LV_100ASK_APP_CONF_H
15 |
16 |
17 | /*******************
18 | * GENERAL SETTING
19 | *******************/
20 |
21 | /*********************
22 | * DEMO USAGE
23 | *********************/
24 |
25 | /******************** 通用APP **********************/
26 | /* [General] 计算器 */
27 | #define LV_USE_100ASK_APP_CALC 0
28 |
29 | /* [General] 2048小游戏 */
30 | #define LV_USE_100ASK_APP_2048 0
31 |
32 | /* [General] 数字对拼图小游戏 */
33 | #define LV_USE_100ASK_APP_MEMORY 0
34 |
35 |
36 | #endif /*LV_100ASK_APP_CONF_H*/
37 |
38 | #endif /*End of "Content enable"*/
39 |
40 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_2048_game/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 | include $(LVGL_DIR)/lv_100ask_demos/lv_100ask_demo.mk
11 |
12 | BIN = general_Game2048
13 |
14 |
15 | #Collect the files to compile
16 | MAINSRC = ./main.c
17 |
18 | OBJEXT ?= .o
19 |
20 | AOBJS = $(ASRCS:.S=$(OBJEXT))
21 | COBJS = $(CSRCS:.c=$(OBJEXT))
22 |
23 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
24 |
25 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
26 | OBJS = $(AOBJS) $(COBJS)
27 |
28 | ## MAINOBJ -> OBJFILES
29 |
30 | all: default
31 |
32 | %.o: %.c
33 | @$(CC) $(CFLAGS) -c $< -o $@
34 | @echo "CC $<"
35 |
36 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
37 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
38 | mkdir -p obj
39 | mv *.o ./obj/
40 | mv $(BIN) $(LVGL_DIR)/bin/
41 |
42 | clean:
43 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
44 |
45 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_2048_game/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_2048_game/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_100ask_demos/lv_100ask_demo.h"
12 | //#include "src/general_2048_game.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(3);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Game2048", "/net/ask100/lvgl/Game2048");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //general_2048_game();
65 | lv_100ask_demo_2048();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_2048_game/src/general_2048_game.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file general_2048_game.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-09-16
7 | * @brief 贪吃蛇小游戏
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-09-16 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_GAME_2048
28 |
29 | #include
30 | #include "general_2048_game.h"
31 |
32 | /*********************
33 | * DEFINES
34 | *********************/
35 |
36 |
37 | /**********************
38 | * STATIC VARIABLES
39 | **********************/
40 |
41 | void general_2048_game_init(void)
42 | {
43 |
44 | }
45 |
46 |
47 | #endif /* LV_USE_100ASK_DEMO_GAME_2048 */
48 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_2048_game/src/general_2048_game.h:
--------------------------------------------------------------------------------
1 | #ifndef GENERAL_2048_GAME_H
2 | #define GENERAL_2048_GAME_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void general_2048_game_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* GENERAL_2048_GAME_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_about/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 | include $(LVGL_DIR)/lv_100ask_demos/lv_100ask_demo.mk
11 | #include $(LVGL_DIR)/lv_demos/lv_demo.mk
12 |
13 | BIN = general_About
14 |
15 |
16 | #Collect the files to compile
17 | MAINSRC = ./main.c
18 |
19 | OBJEXT ?= .o
20 |
21 | AOBJS = $(ASRCS:.S=$(OBJEXT))
22 | COBJS = $(CSRCS:.c=$(OBJEXT))
23 |
24 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
25 |
26 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
27 | OBJS = $(AOBJS) $(COBJS)
28 |
29 | ## MAINOBJ -> OBJFILES
30 |
31 | all: default
32 |
33 | %.o: %.c
34 | @$(CC) $(CFLAGS) -c $< -o $@
35 | @echo "CC $<"
36 |
37 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
38 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
39 | mkdir -p obj
40 | mv *.o ./obj/
41 | mv $(BIN) $(LVGL_DIR)/bin/
42 |
43 | clean:
44 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
45 |
46 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_about/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_about/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_100ask_demos/lv_100ask_demo.h"
12 | //#include "src/about.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(2);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.About", "/net/ask100/lvgl/About");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //about_init();
65 | lv_100ask_demo_about();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_about/src/about.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file about.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-11-03
7 | * @brief 音乐播放器
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-11-03 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_ABOUT
28 |
29 | #include
30 | #include
31 | #include "about.h"
32 |
33 | #include "lvgl/lvgl.h"
34 |
35 | /*********************
36 | * DEFINES
37 | *********************/
38 |
39 | /**********************
40 | * TYPEDEFS
41 | **********************/
42 |
43 |
44 | /**********************
45 | * STATIC VARIABLES
46 | **********************/
47 |
48 | /**********************
49 | * STATIC PROTOTYPES
50 | **********************/
51 |
52 |
53 | void about_init(void)
54 | {
55 |
56 | }
57 |
58 | #endif /* LV_USE_100ASK_DEMO_MUSIC_PLAYER */
59 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_about/src/about.h:
--------------------------------------------------------------------------------
1 | #ifndef ABOUT_H
2 | #define ABOUT_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void about_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* ABOUT_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_app.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file general_app.h
3 | *
4 | */
5 |
6 | #ifndef GENERAL_APP_H
7 | #define GENERAL_APP_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../lv_100ask_app.h"
17 |
18 | #include "general_2048_game/src/general_2048_game.h"
19 | #include "general_calc/src/general_calc.h"
20 | #include "general_game_memory/src/general_game_memory.h"
21 | #include "general_file_manager/src/file_manager.h"
22 | #include "general_music_player/src/music_player.h"
23 |
24 |
25 | /*********************
26 | * DEFINES
27 | *********************/
28 |
29 | /**********************
30 | * TYPEDEFS
31 | **********************/
32 |
33 | /**********************
34 | * GLOBAL PROTOTYPES
35 | **********************/
36 |
37 |
38 | /**********************
39 | * MACROS
40 | **********************/
41 |
42 |
43 | #ifdef __cplusplus
44 | } /* extern "C" */
45 | #endif
46 |
47 | #endif /* GENERAL_APP_H */
48 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_benchmark/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | include $(LVGL_DIR)/lv_demos/lv_demo.mk
12 |
13 | BIN = general_Benchmark
14 |
15 |
16 | #Collect the files to compile
17 | MAINSRC = ./main.c
18 |
19 | OBJEXT ?= .o
20 |
21 | AOBJS = $(ASRCS:.S=$(OBJEXT))
22 | COBJS = $(CSRCS:.c=$(OBJEXT))
23 |
24 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
25 |
26 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
27 | OBJS = $(AOBJS) $(COBJS)
28 |
29 | ## MAINOBJ -> OBJFILES
30 |
31 | all: default
32 |
33 | %.o: %.c
34 | @$(CC) $(CFLAGS) -c $< -o $@
35 | @echo "CC $<"
36 |
37 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
38 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
39 | mkdir -p obj
40 | mv *.o ./obj/
41 | mv $(BIN) $(LVGL_DIR)/bin/
42 |
43 | clean:
44 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
45 |
46 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_benchmark/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_benchmark/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_demos/lv_demo.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(2);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Benchmark", "/net/ask100/lvgl/Benchmark");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | //music_player_init();
64 | lv_demo_benchmark();
65 |
66 | // 悬浮球控制初始化
67 | assistive_touch_init();
68 |
69 | while(1) {
70 | lv_task_handler();
71 | //lv_tick_inc(5*1000);
72 | usleep(5000);
73 | }
74 | return 0;
75 | }
76 |
77 |
78 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
79 | uint32_t custom_tick_get(void)
80 | {
81 | static uint64_t start_ms = 0;
82 | if(start_ms == 0) {
83 | struct timeval tv_start;
84 | gettimeofday(&tv_start, NULL);
85 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
86 | }
87 |
88 | struct timeval tv_now;
89 | gettimeofday(&tv_now, NULL);
90 | uint64_t now_ms;
91 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
92 |
93 | uint32_t time_ms = now_ms - start_ms;
94 | return time_ms;
95 | }
96 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_calc/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 | include $(LVGL_DIR)/lv_100ask_demos/lv_100ask_demo.mk
11 |
12 | BIN = general_Calc
13 |
14 |
15 | #Collect the files to compile
16 | MAINSRC = ./main.c
17 |
18 | OBJEXT ?= .o
19 |
20 | AOBJS = $(ASRCS:.S=$(OBJEXT))
21 | COBJS = $(CSRCS:.c=$(OBJEXT))
22 |
23 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
24 |
25 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
26 | OBJS = $(AOBJS) $(COBJS)
27 |
28 | ## MAINOBJ -> OBJFILES
29 |
30 | all: default
31 |
32 | %.o: %.c
33 | @$(CC) $(CFLAGS) -c $< -o $@
34 | @echo "CC $<"
35 |
36 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
37 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
38 | mkdir -p obj
39 | mv *.o ./obj/
40 | mv $(BIN) $(LVGL_DIR)/bin/
41 |
42 | clean:
43 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
44 |
45 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_calc/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_calc/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_100ask_demos/lv_100ask_demo.h"
12 | //#include "src/general_calc.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(3);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Calc", "/net/ask100/lvgl/Calc");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //general_calc_init();
65 | lv_100ask_demo_calc();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_calc/src/general_calc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file general_calc.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-10-17
7 | * @brief 计算器
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-10-17 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_CALC
28 |
29 |
30 | #include
31 | #include
32 | #include
33 | #include "general_calc.h"
34 |
35 | #include "lvgl/lvgl.h"
36 |
37 | /*********************
38 | * DEFINES
39 | *********************/
40 | // Calculation expression
41 | #define LV_100ASK_CALC_EXPR_LEN (128) // 允许表达式的最大长度
42 | #define LV_100ASK_CALC_MAX_NUM_LEN (5) // 允许运算数的最大长度
43 |
44 | // padding
45 | #define LV_100ASK_CALC_HISTORY_MAX_LINE (128)
46 | #define LV_100ASK_CALC_HISTORY_MAX_H ((LV_VER_RES/4) * 1)
47 | #define LV_100ASK_PANEL_CALC_MAX_H ((LV_VER_RES/4) * 3)
48 | #define LV_100ASK_COLOR_BLACK lv_color_hex(0x000000)
49 | #define LV_100ASK_COLOR_GREEN lv_color_hex(0xf5fffa)
50 |
51 | /**********************
52 | * TYPEDEFS
53 | **********************/
54 | // 标记符
55 | typedef enum {
56 | TOKENIZER_ERROR, // Error
57 | TOKENIZER_ENDOFINPUT, // End of input
58 | TOKENIZER_NUMBER, // number
59 | TOKENIZER_PLUS, // +
60 | TOKENIZER_MINUS, // -
61 | TOKENIZER_ASTR, // *
62 | TOKENIZER_SLASH, // /
63 | TOKENIZER_LPAREN, // (
64 | TOKENIZER_RPAREN, // )
65 | } token_t;
66 |
67 | // 错误代码
68 | typedef enum {
69 | no_error = 0, // no error
70 | syntax_error, // syntax error
71 | } error_t;
72 |
73 | // 错误代码与对应的消息
74 | typedef struct {
75 | error_t error_code;
76 | char *message;
77 | } error_table_t;
78 |
79 |
80 | /**********************
81 | * STATIC VARIABLES
82 | **********************/
83 | //static lv_obj_t * bg_calc; // 背景
84 | static lv_obj_t * g_calc_ta; // 文本编辑框
85 | static char *curr_char = NULL; // 表达式中当前分析到的字符
86 | static char *next_char = NULL; // 表达式中下一个字符
87 |
88 |
89 | static token_t current_token = TOKENIZER_ERROR; // 默认当前token
90 | static error_t error_code = no_error; // 默认错误值
91 |
92 |
93 | // 按键布局
94 | static const char * btnm_map[] = { "(", ")", "C", "<-", "\n",
95 | "7", "8", "9", "/", "\n",
96 | "4", "5", "6", "*", "\n",
97 | "1", "2", "3", "-", "\n",
98 | "0", ".", "=", "+", ""};
99 |
100 | // 错误表
101 | static const error_table_t error_table[] = {
102 | {.error_code = no_error, .message = "no error"},
103 | {.error_code = syntax_error, .message = "syntax error!"}
104 | };
105 |
106 |
107 | /**********************
108 | * STATIC PROTOTYPES
109 | **********************/
110 | static void lv_100ask_calc_init(void); // 界面初始化
111 | static void lv_100ask_calc_tokenizer_init(char *expr); // 词法分析器初始化
112 | static token_t lv_100ask_calc_siglechar(void); // 获取单字符token类型
113 | static token_t lv_100ask_calc_get_next_token(void); // 获取一个token
114 | static token_t lv_100ask_calc_tokenizer_token(void); // 得到当前token
115 | static void lv_100ask_calc_accept(token_t token); // 匹配token
116 | static void lv_100ask_calc_tokenizer_next(void); // 解析下一个token
117 | static bool lv_100ask_calc_tokenizer_finished(void); // token解析完成
118 | static void lv_100ask_calc_error(error_t err); // 错误处理
119 | static int lv_100ask_calc_tokenizer_num(void); // 将ASCII形式的数字转为数值
120 | static int lv_100ask_calc_factor(void); // 取得当前因子的值, 若当前因子(类似上式中的M)是一个表达式, 进行递归求值
121 | static int lv_100ask_calc_term(void); // 求第二级优先级(乘除)表达式的值
122 | static int lv_100ask_calc_expr(void); // 求第一级优先级(加减)表达式的值
123 | static void event_handler_btnmatrix(lv_event_t * e); // 按钮矩阵事件
124 |
125 |
126 | /**********************
127 | * GLOBAL FUNCTIONS
128 | **********************/
129 |
130 | /*
131 | * 函数名: void lv_100ask_demo_calc(void)
132 | * 输入参数: 无
133 | * 返回值: 无
134 | * 函数作用: 应用初始化入口
135 | */
136 | void general_calc_init(void)
137 | {
138 | //bg_calc = lv_obj_create(lv_scr_act());
139 | //lv_obj_set_size(bg_calc, LV_HOR_RES, LV_VER_RES);
140 | //lv_obj_set_y(bg_calc, 0);
141 | //lv_obj_set_style_radius(bg_calc, 0, 0); // 设置圆角
142 | //lv_obj_set_style_bg_color(bg_calc, LV_100ASK_COLOR_GREEN, 0); // 设置背景颜色
143 |
144 | lv_100ask_calc_init();
145 | }
146 |
147 |
148 |
149 | /**********************
150 | * STATIC FUNCTIONS
151 | **********************/
152 |
153 | /*
154 | * 函数名: static void lv_100ask_calc_init(void)
155 | * 输入参数: 无
156 | * 返回值: 无
157 | * 函数作用: 应用界面初始化
158 | */
159 | static void lv_100ask_calc_init(void)
160 | {
161 | /* 计算历史及计算结果 */
162 | g_calc_ta = lv_textarea_create(lv_scr_act());
163 | lv_obj_set_style_text_font(g_calc_ta, &lv_font_montserrat_34, 0); // text font
164 | lv_obj_set_style_bg_color(g_calc_ta, LV_100ASK_COLOR_BLACK, 0); // 设置背景颜色
165 | lv_obj_set_style_text_color(g_calc_ta, LV_100ASK_COLOR_GREEN, 0); // 设置背景颜色
166 | lv_obj_set_style_radius(g_calc_ta, 0, 0); // 设置圆角
167 | lv_textarea_set_max_length(g_calc_ta, LV_100ASK_CALC_HISTORY_MAX_LINE); // 设置文本区域的最大长度
168 | lv_obj_set_size(g_calc_ta, LV_HOR_RES, LV_100ASK_CALC_HISTORY_MAX_H); // 设置宽高
169 | //lv_textarea_set_text_align(g_calc_ta, LV_LABEL_ALIGN_RIGHT); // 设置文本方向
170 | lv_textarea_set_text(g_calc_ta, "");
171 | lv_textarea_set_placeholder_text(g_calc_ta, "CALC HISTORY");
172 | //lv_textarea_set_cursor_hidden(g_calc_ta, true);
173 | lv_obj_align(g_calc_ta, LV_ALIGN_TOP_MID, 0, 0); // 摆放位置
174 |
175 | /* 计算器输入面板 */
176 | lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
177 | lv_obj_set_style_text_font(btnm, &lv_font_montserrat_26, 0); // text font
178 | lv_obj_set_width(btnm, LV_HOR_RES);
179 | lv_obj_set_height(btnm, LV_100ASK_PANEL_CALC_MAX_H);
180 | lv_obj_set_style_radius(btnm, 0, 0); // 设置圆角
181 | lv_btnmatrix_set_map(btnm, btnm_map);
182 | //lv_obj_set_style_bg_color(btnm, lv_color_hex(0xf9f9f9), 0); // 设置背景颜色
183 | lv_obj_align(btnm, LV_ALIGN_BOTTOM_MID, 0, 0);
184 | lv_obj_add_event_cb(btnm, event_handler_btnmatrix, LV_EVENT_VALUE_CHANGED, NULL);
185 | }
186 |
187 |
188 |
189 | /*
190 | * 函数名: static void event_handler_btnmatrix(lv_obj_t * obj, lv_event_t event)
191 | * 输入参数: 触发事件的对象
192 | * 输入参数: 触发的事件类型
193 | * 返回值: 无
194 | * 函数作用: 按钮矩阵事件处理
195 | */
196 | static void event_handler_btnmatrix(lv_event_t *e)
197 | {
198 | lv_event_code_t code = lv_event_get_code(e);
199 |
200 | if(code == LV_EVENT_VALUE_CHANGED)
201 | {
202 | static char calc_exp[LV_100ASK_CALC_EXPR_LEN]; // 表达式
203 | static int count = 0; // 记录表达式位置
204 |
205 | lv_obj_t * obj = lv_event_get_target(e);
206 | uint32_t id = lv_btnmatrix_get_selected_btn(obj);
207 | const char * txt = lv_btnmatrix_get_btn_text(obj, id);
208 |
209 | if (strcmp(txt, "=") == 0) // 执行运算
210 | {
211 | char tmp_buff[32];
212 | int calc_results;
213 |
214 | lv_100ask_calc_tokenizer_init(calc_exp); // 词法分析器
215 |
216 | calc_results = lv_100ask_calc_expr(); // 求第一级优先级(加减)表达式的值
217 |
218 | if (error_code != no_error)
219 | {
220 | // 查找错误代码并打印对应消息
221 | for (int i = 0; i < sizeof(error_table); i++)
222 | {
223 | if (error_table[i].error_code == error_code)
224 | {
225 | lv_textarea_add_text(g_calc_ta, "\n");
226 | lv_textarea_add_text(g_calc_ta, error_table[i].message);
227 | lv_textarea_add_text(g_calc_ta, "\n");
228 | //printf("\n%s\n", error_table[i].message);
229 | }
230 | }
231 | error_code = no_error;
232 | }
233 | else
234 | {
235 | sprintf(tmp_buff, "=\n%d\n", calc_results);
236 | lv_textarea_add_text(g_calc_ta, tmp_buff);
237 | memset(calc_exp, '\0',sizeof(calc_exp)); // 清空表达式
238 | }
239 |
240 | }
241 | else if (strcmp(txt, "C") == 0) // 清空
242 | {
243 | lv_textarea_set_text(g_calc_ta, "");
244 | memset(calc_exp, '\0',sizeof(calc_exp)); // 清空表达式
245 | count = 0;
246 | }
247 |
248 | else if (strcmp(txt, "<-") == 0) // 删除
249 | {
250 | lv_textarea_del_char(g_calc_ta);
251 | calc_exp[count-1] = '\0';
252 | count--;
253 | }
254 |
255 | else // 追加内容
256 | {
257 | lv_textarea_add_text(g_calc_ta, txt);
258 | strcat(&calc_exp[0], txt);
259 | count++;
260 | }
261 | }
262 | }
263 |
264 |
265 | /*
266 | * 函数名: static token_t lv_100ask_calc_siglechar(void)
267 | * 输入参数: 无
268 | * 返回值: token类型
269 | * 函数作用: 获取单字符token类型
270 | */
271 | static token_t lv_100ask_calc_siglechar(void)
272 | {
273 | switch (*curr_char)
274 | {
275 | case '+':
276 | return TOKENIZER_PLUS;
277 | case '-':
278 | return TOKENIZER_MINUS;
279 | case '*':
280 | return TOKENIZER_ASTR;
281 | case '/':
282 | return TOKENIZER_SLASH;
283 | case '(':
284 | return TOKENIZER_LPAREN;
285 | case ')':
286 | return TOKENIZER_RPAREN;
287 | default:
288 | break;
289 | }
290 |
291 | return TOKENIZER_ERROR;
292 | }
293 |
294 |
295 | /*
296 | * 函数名: static token_t lv_100ask_calc_get_next_token(void)
297 | * 输入参数: 无
298 | * 返回值: token类型
299 | * 函数作用: 获取一个token
300 | */
301 | static token_t lv_100ask_calc_get_next_token(void)
302 | {
303 | int i;
304 |
305 | // 表达式结束
306 | if (curr_char == '\0')
307 | return TOKENIZER_ENDOFINPUT;
308 |
309 | if (isdigit(*curr_char))
310 | {
311 | // 不可超过允许数字长度
312 | for (i = 0; i <= LV_100ASK_CALC_MAX_NUM_LEN; i++)
313 | {
314 | // 数字结束
315 | if (!isdigit(*(curr_char + i)))
316 | {
317 | next_char = curr_char + i;
318 | return TOKENIZER_NUMBER;
319 | }
320 | }
321 | }
322 | // 分界符
323 | else if (lv_100ask_calc_siglechar())
324 | {
325 | next_char++;
326 | return lv_100ask_calc_siglechar();
327 | }
328 |
329 | return TOKENIZER_ERROR;
330 | }
331 |
332 |
333 |
334 | /*
335 | * 函数名: static token_t lv_100ask_calc_tokenizer_finished(void)
336 | * 输入参数: 无
337 | * 返回值: true - 无需要解析的token, false - 有需要解析的token
338 | * 函数作用: 判断是否token是否到达结尾
339 | */
340 | static bool lv_100ask_calc_tokenizer_finished(void)
341 | {
342 | return *curr_char == '\0' || current_token == TOKENIZER_ENDOFINPUT;
343 | }
344 |
345 |
346 | /*
347 | * 函数名: static void lv_100ask_calc_error(error_t err)
348 | * 输入参数: 错误类型
349 | * 返回值: 无
350 | * 函数作用: 错误处理
351 | */
352 | static void lv_100ask_calc_error(error_t err)
353 | {
354 | error_code = err;
355 |
356 | return;
357 | }
358 |
359 |
360 | /*
361 | * 函数名: static token_t lv_100ask_calc_tokenizer_next(void)
362 | * 输入参数: 无
363 | * 返回值: 无
364 | * 函数作用: 解析下一个token
365 | */
366 | static void lv_100ask_calc_tokenizer_next(void)
367 | {
368 | if (lv_100ask_calc_tokenizer_finished())
369 | return;
370 |
371 | curr_char = next_char;
372 | current_token = lv_100ask_calc_get_next_token();
373 |
374 | return;
375 | }
376 |
377 |
378 | /*
379 | * 函数名: static token_t lv_100ask_calc_tokenizer_token(void)
380 | * 输入参数: 无
381 | * 返回值: 无
382 | * 函数作用: 得到当前token
383 | */
384 | static token_t lv_100ask_calc_tokenizer_token(void)
385 | {
386 | return current_token;
387 | }
388 |
389 |
390 | /*
391 | * 函数名: static token_t lv_100ask_calc_tokenizer_num(void)
392 | * 输入参数: 无
393 | * 返回值: 无
394 | * 函数作用: 将ASCII形式的数字转为数值
395 | */
396 | static int lv_100ask_calc_tokenizer_num(void)
397 | {
398 | return atoi(curr_char);
399 | }
400 |
401 |
402 | /*
403 | * 函数名: static void lv_100ask_calc_accept(token_t token)
404 | * 输入参数: 需要匹配的token
405 | * 返回值: 无
406 | * 函数作用: 匹配token
407 | */
408 | static void lv_100ask_calc_accept(token_t token)
409 | {
410 | if (token != lv_100ask_calc_tokenizer_token())
411 | lv_100ask_calc_error(syntax_error);
412 |
413 | lv_100ask_calc_tokenizer_next();
414 | }
415 |
416 |
417 |
418 | /*
419 | * 函数名: static int lv_100ask_calc_factor(void)
420 | * 输入参数: 无
421 | * 返回值: 因子的值
422 | * 函数作用: 取得当前因子的值, 若当前因子(类似上式中的M)是一个表达式, 进行递归求值
423 | */
424 | static int lv_100ask_calc_factor(void)
425 | {
426 | int r;
427 |
428 | // 当前token的类型
429 | switch (lv_100ask_calc_tokenizer_token())
430 | {
431 | // 数字(终结符)
432 | case TOKENIZER_NUMBER:
433 | // 将其由ASCII转为数字值
434 | r = lv_100ask_calc_tokenizer_num();
435 | // 根据语法规则匹配当前token
436 | lv_100ask_calc_accept(TOKENIZER_NUMBER);
437 | break;
438 | // 左括号
439 | case TOKENIZER_LPAREN:
440 | lv_100ask_calc_accept(TOKENIZER_LPAREN);
441 | // 将括号里的值当作一个新的表达式, 递归计算(递归是从函数expr()开始的)
442 | r = lv_100ask_calc_expr();
443 | // 当括号里的表达式处理完毕后下一个token一定是右括号
444 | lv_100ask_calc_accept(TOKENIZER_RPAREN);
445 | break;
446 | // 除左括号和数字之外的其它token已经被上一级处理掉了
447 | // 若有其token, 一定是表达式语法错误
448 | default:
449 | lv_100ask_calc_error(syntax_error);
450 | }
451 |
452 | // 返回因子的值
453 | return r;
454 | }
455 |
456 |
457 | /*
458 | * 函数名: static int lv_100ask_calc_term(void)
459 | * 输入参数: 无
460 | * 返回值: 计算结果
461 | * 函数作用: 求第二级优先级(乘除)表达式的值
462 | */
463 | static int lv_100ask_calc_term(void)
464 | {
465 | int f1, f2;
466 | token_t op;
467 |
468 | // 获取左操作数(因子)
469 | f1 = lv_100ask_calc_factor();
470 | // 获取操作符
471 | op = lv_100ask_calc_tokenizer_token();
472 |
473 | // 操作符只能是乘或者除(同一优先级)
474 | while (op == TOKENIZER_ASTR || op == TOKENIZER_SLASH)
475 | {
476 | // 下一个token
477 | lv_100ask_calc_tokenizer_next();
478 | // 获取右操作数(因子)
479 | f2 = lv_100ask_calc_factor();
480 | switch ((int)op)
481 | {
482 | case TOKENIZER_ASTR:
483 | f1 = f1 * f2;
484 | break;
485 | case TOKENIZER_SLASH:
486 | f1 = f1 / f2;
487 | break;
488 | }
489 | // 上面计算完毕的这个值将做为左操作数
490 | op = lv_100ask_calc_tokenizer_token();
491 | }
492 |
493 | return f1;
494 | }
495 |
496 |
497 | /*
498 | * 函数名: static int lv_100ask_calc_expr(void)
499 | * 输入参数: 无
500 | * 返回值: 计算结果
501 | * 函数作用: 求第一级优先级(加减)表达式的值
502 | */
503 | static int lv_100ask_calc_expr(void)
504 | {
505 | int t1, t2 = 0;
506 | token_t op;
507 |
508 | // 第一个操作数
509 | t1 = lv_100ask_calc_term();
510 | // 获取运算符
511 | op = lv_100ask_calc_tokenizer_token();
512 |
513 | // 操作符只能是加或者减(同一优先级)
514 | while (op == TOKENIZER_PLUS || op == TOKENIZER_MINUS)
515 | {
516 | // 下一个token
517 | lv_100ask_calc_tokenizer_next();
518 | // 第二个操作数
519 | t2 = lv_100ask_calc_term();
520 | switch ((int)op)
521 | {
522 | case TOKENIZER_PLUS:
523 | t1 = t1 + t2;
524 | break;
525 | case TOKENIZER_MINUS:
526 | t1 = t1 - t2;
527 | break;
528 | }
529 | op = lv_100ask_calc_tokenizer_token();
530 | }
531 |
532 | return t1;
533 | }
534 |
535 |
536 | /*
537 | * 函数名: static int lv_100ask_calc_expr(void)
538 | * 输入参数: 输入的表达式字符串
539 | * 返回值: 无
540 | * 函数作用: 词法分析器初始化
541 | */
542 | static void lv_100ask_calc_tokenizer_init(char *expr)
543 | {
544 | curr_char = next_char = expr;
545 | current_token = lv_100ask_calc_get_next_token();
546 |
547 | return;
548 | }
549 |
550 |
551 | #endif /* LV_USE_100ASK_CALC */
552 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_calc/src/general_calc.h:
--------------------------------------------------------------------------------
1 | #ifndef GENERAL_CALC_H
2 | #define GENERAL_CALC_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void general_calc_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* GENERAL_CALC_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_file_manager/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | BIN = general_FileManager
12 |
13 |
14 | #Collect the files to compile
15 | MAINSRC = ./main.c
16 |
17 | OBJEXT ?= .o
18 |
19 | AOBJS = $(ASRCS:.S=$(OBJEXT))
20 | COBJS = $(CSRCS:.c=$(OBJEXT))
21 |
22 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
23 |
24 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
25 | OBJS = $(AOBJS) $(COBJS)
26 |
27 | ## MAINOBJ -> OBJFILES
28 |
29 | all: default
30 |
31 | %.o: %.c
32 | @$(CC) $(CFLAGS) -c $< -o $@
33 | @echo "CC $<"
34 |
35 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
36 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
37 | mkdir -p obj
38 | mv *.o ./obj/
39 | mv $(BIN) $(LVGL_DIR)/bin/
40 |
41 | clean:
42 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_file_manager/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_file_manager/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "src/file_manager.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(2);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.FileManager", "/net/ask100/lvgl/FileManager");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | file_manager_init();
64 |
65 | // 悬浮球控制初始化
66 | assistive_touch_init();
67 |
68 | while(1) {
69 | lv_task_handler();
70 | //lv_tick_inc(5*1000);
71 | usleep(5000);
72 | }
73 | return 0;
74 | }
75 |
76 |
77 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
78 | uint32_t custom_tick_get(void)
79 | {
80 | static uint64_t start_ms = 0;
81 | if(start_ms == 0) {
82 | struct timeval tv_start;
83 | gettimeofday(&tv_start, NULL);
84 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
85 | }
86 |
87 | struct timeval tv_now;
88 | gettimeofday(&tv_now, NULL);
89 | uint64_t now_ms;
90 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
91 |
92 | uint32_t time_ms = now_ms - start_ms;
93 | return time_ms;
94 | }
95 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_file_manager/src/file_manager.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file file_manager.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-11-03
7 | * @brief 文件管理器
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-11-03 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_FILE_MANAGER
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include "file_manager.h"
34 |
35 | #include "lvgl/lvgl.h"
36 |
37 | /*********************
38 | * DEFINES
39 | *********************/
40 | #define WIN_HEADER_HEIGHT (60)
41 | #define WIN_BTN_WIDTH (50)
42 |
43 |
44 | #define MENU_WIDTH (22)
45 | #define SHOW_WIDTH (100 - MENU_WIDTH)
46 |
47 | /**********************
48 | * TYPEDEFS
49 | **********************/
50 |
51 |
52 | /**********************
53 | * STATIC VARIABLES
54 | **********************/
55 | static lv_obj_t * g_path_label;
56 | static lv_obj_t * g_file_list;
57 | static char * file_browser_dir[256] = {0};
58 | /**********************
59 | * STATIC PROTOTYPES
60 | **********************/
61 | static void win_event_handler(lv_event_t * e);
62 | static void click_file_event_handler(lv_event_t * e);
63 | static void show_dir(char * path);
64 | static void strip_ext(char *fname);
65 | static void shell_opt_handle(const char * cmd, char * result);
66 | static void click_menu_item_event_handler(lv_event_t * e);
67 |
68 |
69 |
70 | /* 去除最后的换行符 */
71 | static void trim_string(char *str)
72 | {
73 | int len = strlen(str);
74 |
75 | //去掉最后的换行符
76 | if(str[len-1] == '\n')
77 | {
78 | len--; //字符串长度减一
79 | str[len] = 0; //给字符串最后一个字符赋0,即结束符
80 | }
81 | }
82 |
83 |
84 | // 去掉最后的后缀名
85 | static void strip_ext(char *fname)
86 | {
87 | char *end = fname + strlen(fname);
88 |
89 | while (end >= fname && *end != '/') {
90 | --end;
91 | }
92 |
93 | if (end > fname) {
94 | *end = '\0';
95 | }
96 | else if (end == fname) {
97 | *(end+1) = '\0';
98 | }
99 |
100 | }
101 |
102 |
103 | static void win_event_handler(lv_event_t * e)
104 | {
105 | lv_obj_t * obj = lv_event_get_target(e);
106 | LV_LOG_USER("Button %d clicked", (int)lv_obj_get_index(obj));
107 | }
108 |
109 | static void click_menu_item_event_handler(lv_event_t * e)
110 | {
111 | lv_event_code_t code = lv_event_get_code(e);
112 | char * buff = lv_event_get_user_data(e);
113 |
114 | if(code == LV_EVENT_CLICKED) {
115 | char * file_name[256];
116 |
117 | //LV_LOG_USER("Button %s clicked", buff);
118 | if((strcmp(buff, "..") == 0) && (strcmp(buff, "/") != 0))
119 | {
120 | strip_ext(file_browser_dir); // 去掉最后的 /路径
121 | lv_snprintf(file_name, sizeof(file_name), "%s", file_browser_dir);
122 | show_dir(file_name);
123 | }
124 | else show_dir(buff);
125 | }
126 | }
127 |
128 |
129 | static void click_file_event_handler(lv_event_t * e)
130 | {
131 | lv_event_code_t code = lv_event_get_code(e);
132 | lv_obj_t * obj = lv_event_get_target(e);
133 |
134 | if(code == LV_EVENT_CLICKED) {
135 | struct stat stat_buf;
136 | char * file_name[256];
137 |
138 | memset(file_name, 0, sizeof(file_name));
139 | //trim_string(file_browser_dir); // 去掉最后的 \n
140 | if((strcmp(lv_list_get_btn_text(g_file_list, obj), "..") == 0) && (strcmp(file_browser_dir, "/") != 0))
141 | {
142 | strip_ext(file_browser_dir); // 去掉最后的 /路径
143 | lv_snprintf(file_name, sizeof(file_name), "%s", file_browser_dir);
144 | }
145 | else
146 | {
147 | if (strcmp(file_browser_dir, "/") == 0)
148 | lv_snprintf(file_name, sizeof(file_name), "%s%s", file_browser_dir, lv_list_get_btn_text(g_file_list, obj));
149 | else
150 | lv_snprintf(file_name, sizeof(file_name), "%s/%s", file_browser_dir, lv_list_get_btn_text(g_file_list, obj));
151 | }
152 |
153 | if((stat(file_name, &stat_buf) == -1))
154 | {
155 | LV_LOG_USER("stat error");
156 | }
157 | if(S_ISDIR(stat_buf.st_mode))
158 | {
159 | show_dir(file_name);
160 | }
161 | }
162 | }
163 |
164 |
165 | static void shell_opt_handle(const char * cmd, char * result)
166 | {
167 | FILE * fp;
168 | char buffer[128] = {0};
169 | //char str_ret_buff[1024] = {0};
170 |
171 | fp=popen(cmd, "r");
172 | while (fgets(buffer, 128, fp) != NULL)
173 | {
174 | //printf("%s", buffer);
175 | strcat(result, buffer);
176 | }
177 |
178 | if (pclose(fp) == -1)
179 | {
180 | LV_LOG_USER("close failed!");
181 | return NULL;
182 | //exit(1); // return -1;
183 | }
184 | }
185 |
186 |
187 | static void show_dir(char * path)
188 | {
189 | //uint32_t i;
190 | lv_obj_t * btn;
191 | struct stat stat_buf;
192 | struct dirent **namelist;
193 | char str_file_path_name[256];
194 | int32_t file_n;
195 |
196 | file_n = scandir(path, &namelist, 0, alphasort);
197 | if (file_n < 0)
198 | {
199 | LV_LOG_USER("Not found!");
200 | return;
201 | }
202 | else
203 | lv_obj_clean(g_file_list); // 清空列表,删除对象的所有子项(但不是对象本身)
204 |
205 | for(uint16_t i = 0; i < file_n; i++) {
206 | // 获取文件的: 路径+名称
207 | memset(str_file_path_name, 0, sizeof(str_file_path_name));
208 | lv_snprintf(str_file_path_name, sizeof(str_file_path_name), "%s/%s", path, namelist[i]->d_name);
209 |
210 | if((stat(str_file_path_name, &stat_buf) == -1))
211 | {
212 | LV_LOG_USER("stat error");
213 | continue;
214 | }
215 |
216 | // 识别并展示文件
217 | if ((strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".png") == 0) || (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".PNG") == 0) ||\
218 | (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".jpg") == 0) || (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".JPG") == 0) ||\
219 | (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".bmp") == 0) || (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".BMP") == 0) ||\
220 | (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".gif") == 0) || (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".GIF") == 0))
221 | btn = lv_list_add_btn(g_file_list, LV_SYMBOL_IMAGE, namelist[i]->d_name);
222 | else if ((strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".mp3") == 0) || (strcmp((namelist[i]->d_name + (strlen(namelist[i]->d_name) - 4)) , ".MP3") == 0))
223 | btn = lv_list_add_btn(g_file_list, LV_SYMBOL_AUDIO, namelist[i]->d_name);
224 | else if(S_ISDIR(stat_buf.st_mode))
225 | btn = lv_list_add_btn(g_file_list, LV_SYMBOL_DIRECTORY, namelist[i]->d_name);
226 | else
227 | btn = lv_list_add_btn(g_file_list, LV_SYMBOL_FILE, namelist[i]->d_name);
228 |
229 | lv_obj_add_event_cb(btn, click_file_event_handler, LV_EVENT_CLICKED, NULL);
230 | }
231 | free(namelist);
232 |
233 | memset(file_browser_dir, 0, sizeof(file_browser_dir));
234 | strcpy(file_browser_dir, path);
235 |
236 | // 更新路径信息
237 | lv_label_set_text_fmt(g_path_label, LV_SYMBOL_EYE_OPEN" %s", path);
238 | }
239 |
240 |
241 | void file_manager_init(void)
242 | {
243 | // win风格样式
244 | static lv_style_t win_sytle;
245 | lv_style_init(&win_sytle);
246 | //lv_style_set_bg_opa(&win_sytle, 0);
247 | lv_style_set_radius(&win_sytle, 0);
248 | //lv_style_set_text_font(&win_sytle, &lv_font_montserrat_20);
249 | lv_style_set_bg_color(&win_sytle, lv_color_hex(0xff813f));
250 |
251 | // win中btn的风格样式
252 | static lv_style_t win_btn;
253 | lv_style_init(&win_btn);
254 | //lv_style_set_bg_opa(&win_btn, 0);
255 | lv_style_set_border_opa(&win_btn, 0);
256 | lv_style_set_outline_opa(&win_btn, 0);
257 | lv_style_set_radius(&win_btn, 12);
258 | lv_style_set_text_font(&win_btn, &lv_font_montserrat_20);
259 |
260 | // win展示区域风格样式
261 | static lv_style_t win_cont_style;
262 | lv_style_init(&win_cont_style);
263 | //lv_style_set_bg_opa(&win_cont_style, 0);
264 | //lv_style_set_border_opa(&win_cont_style, 0);
265 | //lv_style_set_text_color(&win_cont_style, lv_color_hex(0xffffff));
266 | lv_style_set_pad_column(&win_cont_style, 0);
267 | lv_style_set_pad_row(&win_cont_style, 0);
268 | lv_style_set_flex_flow(&win_cont_style, LV_FLEX_FLOW_ROW);
269 | lv_style_set_pad_all(&win_cont_style, 0);
270 | lv_style_set_layout(&win_cont_style, LV_LAYOUT_FLEX);
271 |
272 | // 左侧菜单的风格样式
273 | static lv_style_t list_menu_style;
274 | lv_style_init(&list_menu_style);
275 | lv_style_set_bg_color(&list_menu_style, lv_color_hex(0x222d36));
276 | lv_style_set_radius(&list_menu_style, 0);
277 | lv_style_set_pad_row(&list_menu_style, 5);
278 | lv_style_set_pad_all(&list_menu_style, 0);
279 | lv_style_set_text_font(&list_menu_style, &lv_font_montserrat_20);
280 | //lv_style_set_text_opa(&list_menu_style, 0);
281 |
282 | // 左侧菜单按钮的风格样式
283 | static lv_style_t list_menu_btn;
284 | lv_style_init(&list_menu_btn);
285 | lv_style_set_bg_opa(&list_menu_btn, 0);
286 | lv_style_set_border_opa(&list_menu_btn, 0);
287 | lv_style_set_text_color(&list_menu_btn, lv_color_hex(0xffffff));
288 |
289 | // 右侧文件浏览区域的样式风格
290 | static lv_style_t file_list_style;
291 | lv_style_init(&file_list_style);
292 | //lv_style_set_bg_opa(&file_list_style, 0);
293 | //lv_style_set_border_opa(&file_list_style, 0);
294 | lv_style_set_pad_all(&file_list_style, 0);
295 | lv_style_set_radius(&file_list_style, 0);
296 | lv_style_set_text_font(&file_list_style, &lv_font_montserrat_20);
297 | //lv_style_set_text_color(&file_list_style, lv_color_hex(0xffffff));
298 |
299 | // 顶部按钮
300 | lv_obj_t * win = lv_win_create(lv_scr_act(), WIN_HEADER_HEIGHT);
301 | lv_obj_add_style(win, &win_sytle, 0);
302 | lv_obj_t * btn;
303 | btn = lv_win_add_btn(win, LV_SYMBOL_LEFT, WIN_BTN_WIDTH);
304 | lv_obj_add_style(btn, &win_btn, 0);
305 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "..");
306 |
307 | btn = lv_win_add_btn(win, LV_SYMBOL_RIGHT, WIN_BTN_WIDTH);
308 | lv_obj_add_style(btn, &win_btn, 0);
309 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, ".");
310 |
311 | btn = lv_win_add_btn(win, LV_SYMBOL_UP, WIN_BTN_WIDTH);
312 | lv_obj_add_style(btn, &win_btn, 0);
313 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "..");
314 |
315 | btn = lv_win_add_btn(win, LV_SYMBOL_DOWN, WIN_BTN_WIDTH);
316 | lv_obj_add_style(btn, &win_btn, 0);
317 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, ".");
318 |
319 | // 当前路径
320 | g_path_label = lv_win_add_title(win, "Path://");
321 | lv_label_set_text(g_path_label, "Path://www.100ask.net");
322 |
323 | // 展示区域
324 | lv_obj_t * win_cont = lv_win_get_content(win); /*Content can be aded here*/
325 | lv_obj_add_style(win_cont, &win_cont_style, 0);
326 |
327 | // 左侧菜单
328 | lv_obj_t * list_menu = lv_list_create(win_cont);
329 | lv_obj_set_size(list_menu, LV_PCT(MENU_WIDTH), LV_PCT(100));
330 | lv_obj_add_style(list_menu, &list_menu_style, 0);
331 |
332 | lv_obj_set_style_bg_color(lv_list_add_text(list_menu, "DEVICE"), lv_palette_main(LV_PALETTE_ORANGE), 0);
333 | btn = lv_list_add_btn(list_menu, NULL, LV_SYMBOL_DRIVE" File System");
334 | lv_obj_add_style(btn, &list_menu_btn, 0);
335 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "/");
336 | btn = lv_list_add_btn(list_menu, NULL, LV_SYMBOL_DRIVE" Mnt");
337 | lv_obj_add_style(btn, &list_menu_btn, 0);
338 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "/mnt");
339 |
340 | lv_obj_set_style_bg_color(lv_list_add_text(list_menu, "PLACES"), lv_palette_main(LV_PALETTE_LIME), 0);
341 | btn = lv_list_add_btn(list_menu, NULL, LV_SYMBOL_HOME " HOME");
342 | lv_obj_add_style(btn, &list_menu_btn, 0);
343 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "/root");
344 | btn = lv_list_add_btn(list_menu, NULL, LV_SYMBOL_AUDIO " Music");
345 | lv_obj_add_style(btn, &list_menu_btn, 0);
346 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "/root/music");
347 | btn = lv_list_add_btn(list_menu, NULL, LV_SYMBOL_IMAGE " Pictures");
348 | lv_obj_add_style(btn, &list_menu_btn, 0);
349 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "/root/pictures");
350 | btn = lv_list_add_btn(list_menu, NULL, LV_SYMBOL_TRASH " Trash");
351 | lv_obj_add_style(btn, &list_menu_btn, 0);
352 | lv_obj_add_event_cb(btn, click_menu_item_event_handler, LV_EVENT_CLICKED, "/root");
353 |
354 | /* 展示区域 */
355 | g_file_list = lv_list_create(win_cont);
356 | lv_obj_set_size(g_file_list, LV_PCT(SHOW_WIDTH), LV_PCT(100));
357 | lv_obj_add_style(g_file_list, &file_list_style, 0);
358 | lv_list_add_btn(g_file_list, LV_SYMBOL_GPS, "www.100ask.net");
359 |
360 | // 默认打开家目录
361 | //shell_opt_handle("pwd ~", file_browser_dir);
362 | show_dir("/root");
363 | }
364 |
365 | #endif /* LV_USE_100ASK_DEMO_FILE_MANAGER */
366 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_file_manager/src/file_manager.h:
--------------------------------------------------------------------------------
1 | #ifndef FILE_MANAGER_MEMORY_H
2 | #define FILE_MANAGER_MEMORY_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void file_manager_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* FILE_MANAGER_MEMORY_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_memory/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 | include $(LVGL_DIR)/lv_100ask_demos/lv_100ask_demo.mk
11 |
12 | BIN = general_GameMemory
13 |
14 |
15 | #Collect the files to compile
16 | MAINSRC = ./main.c
17 |
18 | OBJEXT ?= .o
19 |
20 | AOBJS = $(ASRCS:.S=$(OBJEXT))
21 | COBJS = $(CSRCS:.c=$(OBJEXT))
22 |
23 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
24 |
25 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
26 | OBJS = $(AOBJS) $(COBJS)
27 |
28 | ## MAINOBJ -> OBJFILES
29 |
30 | all: default
31 |
32 | %.o: %.c
33 | @$(CC) $(CFLAGS) -c $< -o $@
34 | @echo "CC $<"
35 |
36 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
37 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
38 | mkdir -p obj
39 | mv *.o ./obj/
40 | mv $(BIN) $(LVGL_DIR)/bin/
41 |
42 | clean:
43 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
44 |
45 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_memory/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_memory/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_100ask_demos/lv_100ask_demo.h"
12 | //#include "src/general_game_memory.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(2);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.GameMemory", "/net/ask100/lvgl/GameMemory");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //general_game_memory_init();
65 | lv_100ask_demo_memory();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_memory/src/general_game_memory.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file general_game_memory.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-10-11
7 | * @brief 数字对拼图小游戏
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-10-11 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_GAME_MEMORY
28 |
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include "general_game_memory.h"
36 |
37 | #include "lvgl/lvgl.h"
38 |
39 | /*********************
40 | * DEFINES
41 | *********************/
42 | #define OBJ_COUNT_HOR (6)
43 | #define OBJ_COUNT_VER (6)
44 | #define OBJ_MAX_COUNT (OBJ_COUNT_HOR * OBJ_COUNT_VER)
45 | #define OBJ_COUNT (OBJ_MAX_COUNT / 2)
46 |
47 | /**********************
48 | * TYPEDEFS
49 | **********************/
50 |
51 |
52 | /**********************
53 | * STATIC VARIABLES
54 | **********************/
55 | static int list_number[OBJ_MAX_COUNT];
56 | static lv_obj_t * g_obj[OBJ_MAX_COUNT]; /* 方块 */
57 | static lv_obj_t * g_befObj;
58 |
59 | /**********************
60 | * STATIC PROTOTYPES
61 | **********************/
62 | static void list_rand_number(int arry[], int max_count, int count);
63 |
64 |
65 | // 生成个数为max_count的指定count范围内count个只重复一次的随机数的算法
66 | static void list_rand_number(int arry[], int max_count, int count)
67 | {
68 | int w, t;
69 |
70 | srand((unsigned)time(NULL));
71 | //srand(seed);
72 | for (int i = 0; i < max_count; i++)
73 | arry[i] = (i % count) + 1;
74 | for (int i = 0; i < max_count; i++)
75 | {
76 | w = rand() % (count - (i % count)) + i;
77 | t = arry[i];
78 | arry[i] = arry[w];
79 | arry[w] = t;
80 | }
81 | }
82 |
83 |
84 | static void event_handler(lv_event_t * e)
85 | {
86 | lv_event_code_t code = lv_event_get_code(e);
87 |
88 | if(code == LV_EVENT_CLICKED)
89 | {
90 | lv_obj_t *current_obj;
91 | if (NULL == g_befObj)
92 | {
93 | g_befObj = lv_event_get_target(e);
94 | lv_obj_set_style_text_opa(g_befObj, LV_OPA_100, 0);
95 | return;
96 | }
97 | else
98 | {
99 | current_obj = lv_event_get_target(e);
100 | if(current_obj == g_befObj) return;
101 | }
102 |
103 | if (strcmp(\
104 | lv_label_get_text(lv_obj_get_child(current_obj, 0)),\
105 | lv_label_get_text(lv_obj_get_child(g_befObj, 0))) == 0)
106 | {
107 | lv_obj_set_style_bg_opa(current_obj, LV_OPA_0, 0);
108 | lv_obj_set_style_text_opa(current_obj, LV_OPA_0, 0);
109 | lv_obj_set_style_border_opa(current_obj, LV_OPA_0, 0);
110 | lv_obj_set_style_shadow_opa(current_obj, LV_OPA_0, 0);
111 | lv_obj_clear_flag(current_obj, LV_OBJ_FLAG_CLICKABLE);
112 |
113 | lv_obj_set_style_bg_opa(g_befObj, LV_OPA_0, 0);
114 | lv_obj_set_style_text_opa(g_befObj, LV_OPA_0, 0);
115 | lv_obj_set_style_border_opa(g_befObj, LV_OPA_0, 0);
116 | lv_obj_set_style_shadow_opa(g_befObj, LV_OPA_0, 0);
117 | lv_obj_clear_flag(g_befObj, LV_OBJ_FLAG_CLICKABLE);
118 | }
119 | else
120 | {
121 | lv_obj_set_style_text_opa(current_obj, LV_OPA_100, 0);
122 | lv_obj_set_style_text_opa(g_befObj, LV_OPA_0, 0);
123 | }
124 |
125 | g_befObj = current_obj;
126 | }
127 | }
128 |
129 |
130 | void general_game_memory_init(void)
131 | {
132 | static lv_style_t cont_style;
133 | static lv_style_t obj_style;
134 |
135 | // 初始化随机数
136 | list_rand_number(list_number, OBJ_MAX_COUNT, OBJ_COUNT);
137 |
138 | // 使用PNG作为底图
139 | lv_obj_t * img = lv_img_create(lv_scr_act());
140 | lv_img_set_src(img, "./assets/general_game_memory.png");
141 | lv_obj_align(img, LV_ALIGN_CENTER, 0, 0);
142 |
143 | /* 整个容器的样式 */
144 | lv_style_init(&cont_style);
145 | lv_style_set_bg_opa(&cont_style, 0);
146 | lv_style_set_radius(&cont_style, 0);
147 | lv_style_set_pad_all(&cont_style, 0); // 铺满
148 |
149 | /* 方块的样式 */
150 | lv_style_init(&obj_style);
151 | lv_style_set_radius(&obj_style, 0);
152 | lv_style_set_border_width(&obj_style, 1);
153 | lv_style_set_border_color(&obj_style, lv_color_hex(0xffffff));
154 | lv_style_set_text_opa(&obj_style, LV_OPA_0);
155 | //lv_style_set_bg_color(&obj_style, lv_color_hex(0xefddd5));
156 | lv_style_set_text_font(&obj_style, &lv_font_montserrat_40);
157 |
158 | /* Create a container with flex */
159 | lv_obj_t * cont = lv_obj_create(lv_scr_act());
160 | lv_obj_set_style_base_dir(cont, LV_BASE_DIR_LTR, 0);
161 | lv_obj_set_style_pad_row(cont, 0, 0);
162 | lv_obj_set_style_pad_column(cont, 0, 0);
163 | lv_obj_set_size(cont, LV_HOR_RES, LV_VER_RES);
164 | lv_obj_align(cont, LV_ALIGN_TOP_MID, 0, 0);
165 | lv_obj_add_style(cont, &cont_style, 0);
166 | lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW_WRAP);
167 | //lv_obj_set_flex_align(cont, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
168 |
169 | uint32_t i;
170 | for(i = 0; i < OBJ_MAX_COUNT; i++) {
171 | g_obj[i] = lv_btn_create(cont);
172 | lv_obj_add_event_cb(g_obj[i], event_handler, LV_EVENT_CLICKED, NULL);
173 | lv_obj_set_size(g_obj[i], (LV_HOR_RES-4) / OBJ_COUNT_HOR, LV_VER_RES / OBJ_COUNT_VER);
174 | lv_obj_add_style(g_obj[i], &obj_style, 0);
175 |
176 | lv_obj_t * label = lv_label_create(g_obj[i]);
177 | lv_label_set_text_fmt(label, "%d", list_number[i]);
178 | lv_obj_center(label);
179 | }
180 | }
181 |
182 | #endif /* LV_USE_100ASK_DEMO_GAME_MEMORY */
183 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_memory/src/general_game_memory.h:
--------------------------------------------------------------------------------
1 | #ifndef GENERAL_GAME_MEMORY_H
2 | #define GENERAL_GAME_MEMORY_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void general_game_memory_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* GENERAL_GAME_MEMORY_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_snake/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 | include $(LVGL_DIR)/lv_100ask_demos/lv_100ask_demo.mk
11 |
12 | BIN = general_Snake
13 |
14 |
15 | #Collect the files to compile
16 | MAINSRC = ./main.c
17 |
18 | OBJEXT ?= .o
19 |
20 | AOBJS = $(ASRCS:.S=$(OBJEXT))
21 | COBJS = $(CSRCS:.c=$(OBJEXT))
22 |
23 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
24 |
25 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
26 | OBJS = $(AOBJS) $(COBJS)
27 |
28 | ## MAINOBJ -> OBJFILES
29 |
30 | all: default
31 |
32 | %.o: %.c
33 | @$(CC) $(CFLAGS) -c $< -o $@
34 | @echo "CC $<"
35 |
36 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
37 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
38 | mkdir -p obj
39 | mv *.o ./obj/
40 | mv $(BIN) $(LVGL_DIR)/bin/
41 |
42 | clean:
43 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
44 |
45 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_snake/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_snake/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_100ask_demos/lv_100ask_demo.h"
12 | //#include "src/general_2048_game.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(3);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Snake", "/net/ask100/lvgl/Snake");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //general_game_snake_init();
65 | lv_100ask_demo_snake();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_snake/src/general_game_snake.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file general_game_snake.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-11-08
7 | * @brief 贪吃蛇小游戏
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-11-08 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_GAME_SNAKE
28 |
29 | #include
30 | #include "general_game_snake.h"
31 |
32 | /*********************
33 | * DEFINES
34 | *********************/
35 |
36 |
37 | /**********************
38 | * STATIC VARIABLES
39 | **********************/
40 |
41 | void general_game_snake_init(void)
42 | {
43 |
44 | }
45 |
46 |
47 | #endif /* LV_USE_100ASK_DEMO_GAME_SNAKE */
48 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_snake/src/general_game_snake.h:
--------------------------------------------------------------------------------
1 | #ifndef GENERAL_GAME_SNAKE_H
2 | #define GENERAL_GAME_SNAKE_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void general_game_snake_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* GENERAL_GAME_SNAKE_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_tiles/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 | include $(LVGL_DIR)/lv_100ask_demos/lv_100ask_demo.mk
11 |
12 | BIN = general_Tiles
13 |
14 |
15 | #Collect the files to compile
16 | MAINSRC = ./main.c
17 |
18 | OBJEXT ?= .o
19 |
20 | AOBJS = $(ASRCS:.S=$(OBJEXT))
21 | COBJS = $(CSRCS:.c=$(OBJEXT))
22 |
23 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
24 |
25 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
26 | OBJS = $(AOBJS) $(COBJS)
27 |
28 | ## MAINOBJ -> OBJFILES
29 |
30 | all: default
31 |
32 | %.o: %.c
33 | @$(CC) $(CFLAGS) -c $< -o $@
34 | @echo "CC $<"
35 |
36 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
37 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
38 | mkdir -p obj
39 | mv *.o ./obj/
40 | mv $(BIN) $(LVGL_DIR)/bin/
41 |
42 | clean:
43 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
44 |
45 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_tiles/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_tiles/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_100ask_demos/lv_100ask_demo.h"
12 | //#include "src/general_2048_game.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(3);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Tron", "/net/ask100/lvgl/Tron");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //general_game_tiles_init();
65 | lv_100ask_demo_tiles();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_tiles/src/general_game_tiles.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file general_game_tiles.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-11-08
7 | * @brief 将数字滑动到位的拼图游戏
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-11-08 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_GAME_TRON
28 |
29 | #include
30 | #include "general_game_tiles.h"
31 |
32 | /*********************
33 | * DEFINES
34 | *********************/
35 |
36 |
37 | /**********************
38 | * STATIC VARIABLES
39 | **********************/
40 |
41 | void general_game_tiles_init(void)
42 | {
43 |
44 | }
45 |
46 |
47 | #endif /* LV_USE_100ASK_DEMO_GAME_TRON */
48 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_game_tiles/src/general_game_tiles.h:
--------------------------------------------------------------------------------
1 | #ifndef GENERAL_GAME_TILES_H
2 | #define GENERAL_GAME_TILES_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void general_game_tiles_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* GENERAL_GAME_TILES_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_music_player/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | include $(LVGL_DIR)/lv_demos/lv_demo.mk
12 |
13 | BIN = general_Music
14 |
15 |
16 | #Collect the files to compile
17 | MAINSRC = ./main.c
18 |
19 | OBJEXT ?= .o
20 |
21 | AOBJS = $(ASRCS:.S=$(OBJEXT))
22 | COBJS = $(CSRCS:.c=$(OBJEXT))
23 |
24 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
25 |
26 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
27 | OBJS = $(AOBJS) $(COBJS)
28 |
29 | ## MAINOBJ -> OBJFILES
30 |
31 | all: default
32 |
33 | %.o: %.c
34 | @$(CC) $(CFLAGS) -c $< -o $@
35 | @echo "CC $<"
36 |
37 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
38 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
39 | mkdir -p obj
40 | mv *.o ./obj/
41 | mv $(BIN) $(LVGL_DIR)/bin/
42 |
43 | clean:
44 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
45 |
46 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_music_player/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_music_player/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_demos/lv_demo.h"
12 | //#include "src/music_player.h"
13 |
14 | #define DISP_BUF_SIZE (1024 * 600)
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(2);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Music", "/net/ask100/lvgl/Music");
59 |
60 | // 让桌面暂停运行
61 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
62 |
63 | /*Create a Demo*/
64 | //music_player_init();
65 | lv_demo_music();
66 |
67 | // 悬浮球控制初始化
68 | assistive_touch_init();
69 |
70 | while(1) {
71 | lv_task_handler();
72 | //lv_tick_inc(5*1000);
73 | usleep(5000);
74 | }
75 | return 0;
76 | }
77 |
78 |
79 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
80 | uint32_t custom_tick_get(void)
81 | {
82 | static uint64_t start_ms = 0;
83 | if(start_ms == 0) {
84 | struct timeval tv_start;
85 | gettimeofday(&tv_start, NULL);
86 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
87 | }
88 |
89 | struct timeval tv_now;
90 | gettimeofday(&tv_now, NULL);
91 | uint64_t now_ms;
92 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
93 |
94 | uint32_t time_ms = now_ms - start_ms;
95 | return time_ms;
96 | }
97 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_music_player/src/music_player.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file music_player.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-11-03
7 | * @brief 音乐播放器
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-11-03 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_MUSIC_PLAYER
28 |
29 | #include
30 | #include
31 | #include "music_player.h"
32 |
33 | #include "lvgl/lvgl.h"
34 |
35 | /*********************
36 | * DEFINES
37 | *********************/
38 |
39 | /**********************
40 | * TYPEDEFS
41 | **********************/
42 |
43 |
44 | /**********************
45 | * STATIC VARIABLES
46 | **********************/
47 |
48 | /**********************
49 | * STATIC PROTOTYPES
50 | **********************/
51 |
52 |
53 | void music_player_init(void)
54 | {
55 |
56 | }
57 |
58 | #endif /* LV_USE_100ASK_DEMO_MUSIC_PLAYER */
59 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_music_player/src/music_player.h:
--------------------------------------------------------------------------------
1 | #ifndef MUSIC_PLAYER_MEMORY_H
2 | #define MUSIC_PLAYER_MEMORY_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../general_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void music_player_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* MUSIC_PLAYER_MEMORY_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_widgets/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | include $(LVGL_DIR)/lv_demos/lv_demo.mk
12 |
13 | BIN = general_Widgets
14 |
15 |
16 | #Collect the files to compile
17 | MAINSRC = ./main.c
18 |
19 | OBJEXT ?= .o
20 |
21 | AOBJS = $(ASRCS:.S=$(OBJEXT))
22 | COBJS = $(CSRCS:.c=$(OBJEXT))
23 |
24 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
25 |
26 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
27 | OBJS = $(AOBJS) $(COBJS)
28 |
29 | ## MAINOBJ -> OBJFILES
30 |
31 | all: default
32 |
33 | %.o: %.c
34 | @$(CC) $(CFLAGS) -c $< -o $@
35 | @echo "CC $<"
36 |
37 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
38 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
39 | mkdir -p obj
40 | mv *.o ./obj/
41 | mv $(BIN) $(LVGL_DIR)/bin/
42 |
43 | clean:
44 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
45 |
46 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_widgets/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/general_app/general_widgets/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "lv_demos/lv_demo.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(2);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Widgets", "/net/ask100/lvgl/Widgets");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | //music_player_init();
64 | lv_demo_widgets();
65 |
66 | // 悬浮球控制初始化
67 | assistive_touch_init();
68 |
69 | while(1) {
70 | lv_task_handler();
71 | //lv_tick_inc(5*1000);
72 | usleep(5000);
73 | }
74 | return 0;
75 | }
76 |
77 |
78 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
79 | uint32_t custom_tick_get(void)
80 | {
81 | static uint64_t start_ms = 0;
82 | if(start_ms == 0) {
83 | struct timeval tv_start;
84 | gettimeofday(&tv_start, NULL);
85 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
86 | }
87 |
88 | struct timeval tv_now;
89 | gettimeofday(&tv_now, NULL);
90 | uint64_t now_ms;
91 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
92 |
93 | uint32_t time_ms = now_ms - start_ms;
94 | return time_ms;
95 | }
96 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_app.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file imx6ull_app.h
3 | *
4 | */
5 |
6 | #ifndef IMXULL_APP_H
7 | #define IMXULL_APP_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 | #include "../lv_100ask_app.h"
17 |
18 | #include "imx6ull_set_lcd_brightness/src/set_lcd_brightness.h"
19 | #include "imx6ull_set_time/src/set_time.h"
20 | #include "imx6ull_set_wlan/src/set_wlan.h"
21 | #include "imx6ull_set_lan/src/set_lan.h"
22 |
23 |
24 | /*********************
25 | * DEFINES
26 | *********************/
27 |
28 | /**********************
29 | * TYPEDEFS
30 | **********************/
31 |
32 | /**********************
33 | * GLOBAL PROTOTYPES
34 | **********************/
35 |
36 |
37 | /**********************
38 | * MACROS
39 | **********************/
40 |
41 |
42 | #ifdef __cplusplus
43 | } /* extern "C" */
44 | #endif
45 |
46 | #endif /* IMXULL_APP_H */
47 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lan/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | BIN = imx6ull_LAN
12 |
13 |
14 | #Collect the files to compile
15 | MAINSRC = ./main.c
16 |
17 | OBJEXT ?= .o
18 |
19 | AOBJS = $(ASRCS:.S=$(OBJEXT))
20 | COBJS = $(CSRCS:.c=$(OBJEXT))
21 |
22 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
23 |
24 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
25 | OBJS = $(AOBJS) $(COBJS)
26 |
27 | ## MAINOBJ -> OBJFILES
28 |
29 | all: default
30 |
31 | %.o: %.c
32 | @$(CC) $(CFLAGS) -c $< -o $@
33 | @echo "CC $<"
34 |
35 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
36 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
37 | mkdir -p obj
38 | mv *.o ./obj/
39 | mv $(BIN) $(LVGL_DIR)/bin/
40 |
41 | clean:
42 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lan/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lan/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "src/set_lan.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(3);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.LAN", "/net/ask100/lvgl/LAN");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | imx6ull_set_lan_init();
64 |
65 | // 悬浮球控制初始化
66 | assistive_touch_init();
67 |
68 | while(1) {
69 | lv_task_handler();
70 | //lv_tick_inc(5*1000);
71 | usleep(5000);
72 | }
73 | return 0;
74 | }
75 |
76 |
77 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
78 | uint32_t custom_tick_get(void)
79 | {
80 | static uint64_t start_ms = 0;
81 | if(start_ms == 0) {
82 | struct timeval tv_start;
83 | gettimeofday(&tv_start, NULL);
84 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
85 | }
86 |
87 | struct timeval tv_now;
88 | gettimeofday(&tv_now, NULL);
89 | uint64_t now_ms;
90 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
91 |
92 | uint32_t time_ms = now_ms - start_ms;
93 | return time_ms;
94 | }
95 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lan/src/set_lan.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file set_lan.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-11-03
7 | * @brief 有线(LAN)网络设置
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-11-03 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1
28 |
29 | #include
30 | #include
31 | #include
32 | #include "set_lan.h"
33 |
34 | #include "lvgl/lvgl.h"
35 |
36 | // LAN信息结构体
37 | static struct Lan_info {
38 | char device[8]; // 网卡设备
39 | char cable[16]; // 连接状态
40 | char dhcp[8]; // DHCPC模式
41 | char mac[24]; // MAC地址
42 | char ipaddr[16]; // IP地址
43 | char gateway[16]; // 网关
44 | char netmask[16]; // 子网掩码
45 | } Lan_info = {"0", "0", "0", "0", "0", "0"};
46 |
47 | static lv_obj_t * g_btn_run_dhcp; // 刷新网卡句柄
48 | static lv_obj_t * g_table_lan_info; // LAN信息表格句柄
49 | static lv_timer_t * g_wifi_scan_task_handle; // 定时器任务句柄
50 |
51 | static bool get_lan_info(void); // 获取LAN信息
52 | static void set_cell_value(lv_obj_t * table); // 展示LAN信息
53 | static void run_dhcpc_event_handler(lv_event_t * e); // DHCPC按钮回调函数
54 | static void lv_task_lan_cable_scan(lv_timer_t * task); // 定时扫描连接状态任务
55 | static char * shell_exec_handle(const char * cmd, char * result); // shell命令执行函数
56 |
57 |
58 | static void run_dhcpc_event_handler(lv_event_t * e)
59 | {
60 | lv_event_code_t code = lv_event_get_code(e);
61 |
62 | if(code == LV_EVENT_CLICKED) {
63 | //LV_LOG_USER("Clicked");
64 | get_lan_info();
65 | set_cell_value(g_table_lan_info);
66 | }
67 | }
68 |
69 |
70 | // 定时扫描连接状态
71 | static void lv_task_lan_cable_scan(lv_timer_t * task)
72 | {
73 | get_lan_info();
74 | set_cell_value(g_table_lan_info);
75 | }
76 |
77 |
78 | static char * shell_exec_handle(const char * cmd, char * result)
79 | {
80 | FILE * fp;
81 | char buffer[128] = {0};
82 |
83 | fp=popen(cmd, "r");
84 | while (fgets(buffer, 128, fp) != NULL)
85 | {
86 | printf("%s", buffer);
87 | strcat(result, buffer);
88 | }
89 |
90 | if (pclose(fp) == -1)
91 | {
92 | printf("close failed!");
93 | //return NULL;
94 | }
95 | }
96 |
97 |
98 | static bool get_lan_info(void)
99 | {
100 | char cmd_buff[128];
101 | char result[128];
102 |
103 | // 检查网线连接状态
104 | memset(cmd_buff, 0, sizeof(cmd_buff));
105 | memset(result, 0, sizeof(result));
106 | lv_snprintf(cmd_buff, sizeof(cmd_buff), "ip link show | grep eth0: | awk '{print $9}'");
107 | shell_exec_handle(cmd_buff, result);
108 | lv_snprintf(Lan_info.cable, sizeof(Lan_info.cable), result);
109 | if (strstr(Lan_info.cable, "DOWN") != NULL)
110 | {
111 | memset(cmd_buff, 0, sizeof(cmd_buff));
112 | memset(result, 0, sizeof(result));
113 | lv_snprintf(cmd_buff, sizeof(cmd_buff), "ip link show | grep eth1: | awk '{print $9}'");
114 | shell_exec_handle(cmd_buff, result);
115 | lv_snprintf(Lan_info.cable, sizeof(Lan_info.cable), result);
116 | if (strstr(Lan_info.cable, "DOWN") != NULL)
117 | {
118 | LV_LOG_USER("Neither eth1 nor eth0 are connected!\n");
119 | memset(Lan_info.dhcp, 0, sizeof(Lan_info.dhcp));
120 | memset(Lan_info.mac, 0, sizeof(Lan_info.mac));
121 | memset(Lan_info.ipaddr, 0, sizeof(Lan_info.ipaddr));
122 | memset(Lan_info.gateway, 0, sizeof(Lan_info.gateway));
123 | memset(Lan_info.netmask, 0, sizeof(Lan_info.netmask));
124 | return 0;
125 | }
126 | else lv_snprintf(Lan_info.device, sizeof(Lan_info.device), "eth1");
127 | }
128 | else
129 | {
130 | lv_snprintf(Lan_info.device, sizeof(Lan_info.device), "eth0");
131 | }
132 |
133 | // 检查DHCP状态
134 | lv_snprintf(Lan_info.dhcp, sizeof(Lan_info.dhcp), "YES");
135 |
136 | // 获取MAC地址
137 | memset(cmd_buff, 0, sizeof(cmd_buff));
138 | memset(result, 0, sizeof(result));
139 | //lv_snprintf(cmd_buff, sizeof(cmd_buff), "ifconfig %s | grep \"ether \" | awk '{print $2}'", Lan_info.device);
140 | lv_snprintf(cmd_buff, sizeof(cmd_buff), "ifconfig %s | grep \"HWaddr \" | awk '{print $5}'", Lan_info.device); // ifconfig eth0 | grep "HWaddr " | awk '{print $5}'
141 | shell_exec_handle(cmd_buff, result);
142 | lv_snprintf(Lan_info.mac, sizeof(Lan_info.mac), result);
143 |
144 | // 获取IP地址
145 | memset(cmd_buff, 0, sizeof(cmd_buff));
146 | memset(result, 0, sizeof(result));
147 | //lv_snprintf(cmd_buff, sizeof(cmd_buff), "ifconfig %s | grep \"inet \" | awk '{print $2}'", Lan_info.device);
148 | lv_snprintf(cmd_buff, sizeof(cmd_buff), "ifconfig %s | grep \"inet \" | awk -F '[:]' '{print $2}' | awk '{print $1}'", Lan_info.device); // ifconfig eth0 | grep "inet " | awk -F '[:]' '{print $2}' | awk '{print $1}'
149 | shell_exec_handle(cmd_buff, result);
150 | lv_snprintf(Lan_info.ipaddr, sizeof(Lan_info.ipaddr), result);
151 |
152 | // 获取网关
153 | memset(cmd_buff, 0, sizeof(cmd_buff));
154 | memset(result, 0, sizeof(result));
155 | lv_snprintf(cmd_buff, sizeof(cmd_buff), "ip route show | grep \"default via \" | awk '{print $3}'"); // ip route show | grep "default via " | awk '{print $3}'
156 | shell_exec_handle(cmd_buff, result);
157 | lv_snprintf(Lan_info.gateway, sizeof(Lan_info.gateway), result);
158 |
159 | // 获取子网掩码
160 | memset(cmd_buff, 0, sizeof(cmd_buff));
161 | memset(result, 0, sizeof(result));
162 | //lv_snprintf(cmd_buff, sizeof(cmd_buff), "ifconfig %s | grep \"netmask \" | awk '{print $4}'", Lan_info.device);
163 | lv_snprintf(cmd_buff, sizeof(cmd_buff), "ifconfig %s | grep \"Mask\" | awk -F '[:]' '{print $4}'", Lan_info.device);// ifconfig eth0 | grep "Mask" | awk -F '[:]' '{print $4}'
164 | shell_exec_handle(cmd_buff, result);
165 | lv_snprintf(Lan_info.netmask, sizeof(Lan_info.netmask), result);
166 |
167 | memset(cmd_buff, 0, sizeof(cmd_buff));
168 | memset(result, 0, sizeof(result));
169 |
170 | return 1;
171 | }
172 |
173 |
174 | static void set_cell_value(lv_obj_t * table)
175 | {
176 | // Fill the first column
177 | lv_table_set_cell_value(table, 0, 0, "Cable");
178 | lv_table_set_cell_value(table, 1, 0, "DHCP");
179 | lv_table_set_cell_value(table, 2, 0, "MAC");
180 | lv_table_set_cell_value(table, 3, 0, "IP-address");
181 | lv_table_set_cell_value(table, 4, 0, "Gateway");
182 | lv_table_set_cell_value(table, 5, 0, "Netmask");
183 |
184 | // Fill the second column
185 | lv_table_set_cell_value(table, 0, 1, "Connected "LV_SYMBOL_OK); // LV_SYMBOL_OK LV_SYMBOL_WARNING
186 | lv_table_set_cell_value(table, 1, 1, Lan_info.dhcp);
187 | lv_table_set_cell_value(table, 2, 1, Lan_info.mac);
188 | lv_table_set_cell_value(table, 3, 1, Lan_info.ipaddr);
189 | lv_table_set_cell_value(table, 4, 1, Lan_info.gateway);
190 | lv_table_set_cell_value(table, 5, 1, Lan_info.netmask);
191 |
192 | if (strstr(Lan_info.cable, "DOWN") != NULL)
193 | {
194 | lv_obj_add_state(g_btn_run_dhcp, LV_STATE_DISABLED|LV_STATE_CHECKED);
195 | lv_label_set_text(lv_obj_get_child(g_btn_run_dhcp, 0), LV_SYMBOL_WARNING" The network cable is not connected!");
196 | lv_table_set_cell_value(table, 0, 1, "Not Connected "LV_SYMBOL_WARNING); // LV_SYMBOL_OK LV_SYMBOL_WARNING
197 | }
198 | else
199 | {
200 | lv_obj_clear_state(g_btn_run_dhcp, LV_STATE_DISABLED|LV_STATE_CHECKED);
201 | lv_label_set_text(lv_obj_get_child(g_btn_run_dhcp, 0), LV_SYMBOL_REFRESH" Retrieve IP address(DHCPC)");
202 | }
203 | }
204 |
205 | void imx6ull_set_lan_init(void)
206 | {
207 | lv_obj_t * obj_layout;
208 | static lv_style_t obj_layout_style; // 容器的样式
209 |
210 | get_lan_info(); // 先获取网络信息
211 |
212 | lv_style_init(&obj_layout_style);
213 | //lv_style_set_pad_all(&obj_layout_style, 0);
214 | //lv_style_set_bg_opa(&obj_layout_style, 0);
215 | //lv_style_set_shadow_opa(&obj_layout_style, 0);
216 | lv_style_set_pad_row(&obj_layout_style, 20);
217 | lv_style_set_border_opa(&obj_layout_style, 0);
218 |
219 | /* Layout Init */
220 | obj_layout = lv_obj_create(lv_scr_act());
221 | lv_obj_set_size(obj_layout, LV_PCT(100), LV_PCT(100));
222 | lv_obj_set_layout(obj_layout, LV_LAYOUT_FLEX);
223 | lv_obj_set_flex_flow(obj_layout, LV_FLEX_FLOW_COLUMN);
224 | lv_obj_center(obj_layout);
225 | lv_obj_add_style(obj_layout, &obj_layout_style, 0);
226 |
227 | /* Create title */
228 | lv_obj_t * label_title = lv_label_create(obj_layout);
229 | lv_obj_set_width(label_title, LV_PCT(100));
230 | lv_obj_set_style_text_font(label_title, &lv_font_montserrat_32, 0);
231 | lv_obj_set_style_text_align(label_title, LV_TEXT_ALIGN_CENTER, 0);
232 | //lv_label_set_recolor(label_title, true); /*Enable re-coloring by commands in the text*/
233 | lv_label_set_text(label_title, "LAN");
234 | lv_obj_align(label_title, LV_ALIGN_CENTER, 0, 0); //lv_obj_center(label_title);
235 |
236 | /* Get IP Address(DHCPC) Button */
237 | g_btn_run_dhcp = lv_btn_create(obj_layout);
238 | lv_obj_set_width(g_btn_run_dhcp, LV_PCT(100));
239 | lv_obj_add_event_cb(g_btn_run_dhcp, run_dhcpc_event_handler, LV_EVENT_CLICKED, NULL);
240 |
241 | lv_obj_t * label = lv_label_create(g_btn_run_dhcp);
242 | lv_label_set_text(label, LV_SYMBOL_REFRESH" Retrieve IP address(DHCPC)");
243 | lv_obj_center(label);
244 |
245 | /* NET info */
246 | g_table_lan_info = lv_table_create(obj_layout);
247 | lv_obj_set_width(g_table_lan_info, LV_PCT(100));
248 | lv_obj_set_style_pad_all(g_table_lan_info, 0, 0);
249 | lv_obj_set_style_border_opa(g_table_lan_info, 0, 0);
250 | //lv_obj_set_style_text_font(g_table_lan_info, &lv_font_simsun_16_cjk, 0); // 中文
251 |
252 | lv_table_set_col_width(g_table_lan_info, 0, 770); // 150
253 | lv_table_set_col_width(g_table_lan_info, 1, 200); // 800
254 |
255 | // Fill the table
256 | set_cell_value(g_table_lan_info);
257 |
258 | /*Add an event callback to to apply some custom drawing*/
259 | //lv_obj_add_event_cb(table, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
260 |
261 | g_wifi_scan_task_handle = lv_timer_create(lv_task_lan_cable_scan, 5000, NULL); // 10秒定时器任务
262 |
263 | }
264 |
265 | #endif /* LV_USE_100ASK_DEMO_GAME_2048 */
266 |
267 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lan/src/set_lan.h:
--------------------------------------------------------------------------------
1 | #ifndef IMX6ULL_SET_LAN_H
2 | #define IMX6ULL_SET_LAN_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../imx6ull_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void imx6ull_set_lan_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* IMX6ULL_SET_LAN_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lcd_brightness/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | BIN = imx6ull_SetBrightness
12 |
13 |
14 | #Collect the files to compile
15 | MAINSRC = ./main.c
16 |
17 | OBJEXT ?= .o
18 |
19 | AOBJS = $(ASRCS:.S=$(OBJEXT))
20 | COBJS = $(CSRCS:.c=$(OBJEXT))
21 |
22 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
23 |
24 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
25 | OBJS = $(AOBJS) $(COBJS)
26 |
27 | ## MAINOBJ -> OBJFILES
28 |
29 | all: default
30 |
31 | %.o: %.c
32 | @$(CC) $(CFLAGS) -c $< -o $@
33 | @echo "CC $<"
34 |
35 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
36 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
37 | mkdir -p obj
38 | mv *.o ./obj/
39 | mv $(BIN) $(LVGL_DIR)/bin/
40 |
41 | clean:
42 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lcd_brightness/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lcd_brightness/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "src/set_lcd_brightness.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(3);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.SetBrightness", "/net/ask100/lvgl/SetBrightness");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | imx6ull_set_lcd_brightness_init();
64 |
65 | // 悬浮球控制初始化
66 | assistive_touch_init();
67 |
68 | while(1) {
69 | lv_task_handler();
70 | //lv_tick_inc(5*1000);
71 | usleep(5000);
72 | }
73 | return 0;
74 | }
75 |
76 |
77 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
78 | uint32_t custom_tick_get(void)
79 | {
80 | static uint64_t start_ms = 0;
81 | if(start_ms == 0) {
82 | struct timeval tv_start;
83 | gettimeofday(&tv_start, NULL);
84 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
85 | }
86 |
87 | struct timeval tv_now;
88 | gettimeofday(&tv_now, NULL);
89 | uint64_t now_ms;
90 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
91 |
92 | uint32_t time_ms = now_ms - start_ms;
93 | return time_ms;
94 | }
95 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lcd_brightness/src/set_lcd_brightness.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file set_lcd_brightness.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-10-29
7 | * @brief IMX6ULL屏幕背光设置
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-10-29 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_GAME_2048
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include "set_lcd_brightness.h"
36 |
37 | #include "lvgl/lvgl.h"
38 | #include "lv_drivers/display/fbdev.h"
39 | #include "lv_drivers/indev/evdev.h"
40 |
41 | /*********************
42 | * DEFINES
43 | *********************/
44 |
45 | static void backlight_control(int32_t brightness)
46 | {
47 | char ch_led_state[2];
48 | char * led_brightness = "/sys/class/backlight/backlight/brightness";;
49 | FILE *p_led_control = NULL;
50 |
51 | if ((p_led_control = fopen(led_brightness, "r+")) != NULL)
52 | {
53 | // The specified LED's brightness file is open for reading and writing.
54 | // Convert led_state to a char, write the result to the brightness file,
55 | // and close the file.
56 |
57 | lv_snprintf(ch_led_state, sizeof(ch_led_state), "%d", brightness);
58 | fwrite(ch_led_state, sizeof(char), 1, p_led_control);
59 | fclose(p_led_control);
60 | }
61 | }
62 |
63 |
64 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
65 | static char get_backlight_brightenss(void)
66 | {
67 | char ch_led_state[2];
68 | char * led_brightness = "/sys/class/backlight/backlight/brightness";;
69 | FILE *p_led_control = NULL;
70 |
71 | if ((p_led_control = fopen(led_brightness, "r+")) != NULL)
72 | {
73 | size_t ret = fread(ch_led_state, sizeof(*ch_led_state), ARRAY_SIZE(ch_led_state), p_led_control);
74 | if (ret != ARRAY_SIZE(ch_led_state)) {
75 | fprintf(stderr, "fread() failed: %zu\n", ret);
76 | exit(EXIT_FAILURE);
77 | }
78 | fclose(p_led_control);
79 | }
80 |
81 | printf("%c\n", ch_led_state[0]);
82 |
83 | return ch_led_state[0];
84 | }
85 |
86 |
87 |
88 | #if 0
89 | static lv_obj_t * slider_label;
90 | static void slider_event_cb(lv_event_t * e)
91 | {
92 | lv_obj_t * slider = lv_event_get_target(e);
93 | char buf[8];
94 | lv_snprintf(buf, sizeof(buf), "%d", lv_slider_get_value(slider));
95 | lv_label_set_text(slider_label, buf);
96 | lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
97 | backlight_control(lv_slider_get_value(slider));
98 | }
99 | #endif
100 |
101 |
102 | static void slider_event_cb(lv_event_t * e)
103 | {
104 | lv_event_code_t code = lv_event_get_code(e);
105 | lv_obj_t * obj = lv_event_get_target(e);
106 |
107 | if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
108 | lv_coord_t *s = lv_event_get_param(e);
109 | *s = LV_MAX(*s, 60);
110 | } else if(code == LV_EVENT_DRAW_PART_END) {
111 | lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
112 | if(dsc->part == LV_PART_KNOB && lv_obj_has_state(obj, LV_STATE_PRESSED)) {
113 | char buf[8];
114 | lv_snprintf(buf, sizeof(buf), "%d", lv_slider_get_value(obj));
115 |
116 | lv_point_t text_size;
117 | lv_txt_get_size(&text_size, buf, &lv_font_montserrat_20, 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
118 |
119 | lv_area_t txt_area;
120 | txt_area.x1 = dsc->draw_area->x1 + lv_area_get_width(dsc->draw_area) / 2 - text_size.x / 2;
121 | txt_area.x2 = txt_area.x1 + text_size.x;
122 | txt_area.y2 = dsc->draw_area->y1 - 10;
123 | txt_area.y1 = txt_area.y2 - text_size.y;
124 |
125 | lv_area_t bg_area;
126 | bg_area.x1 = txt_area.x1 - LV_DPX(8);
127 | bg_area.x2 = txt_area.x2 + LV_DPX(8);
128 | bg_area.y1 = txt_area.y1 - LV_DPX(8);
129 | bg_area.y2 = txt_area.y2 + LV_DPX(8);
130 |
131 | lv_draw_rect_dsc_t rect_dsc;
132 | lv_draw_rect_dsc_init(&rect_dsc);
133 | rect_dsc.bg_color = lv_palette_darken(LV_PALETTE_GREY, 3);
134 | rect_dsc.radius = LV_DPX(5);
135 | lv_draw_rect(&bg_area, dsc->clip_area, &rect_dsc);
136 |
137 | lv_draw_label_dsc_t label_dsc;
138 | lv_draw_label_dsc_init(&label_dsc);
139 | label_dsc.color = lv_color_white();
140 | label_dsc.font = &lv_font_montserrat_20;
141 | lv_draw_label(&txt_area, dsc->clip_area, &label_dsc, buf, NULL);
142 |
143 | backlight_control(lv_slider_get_value(obj));
144 | }
145 | }
146 | }
147 |
148 |
149 | void imx6ull_set_lcd_brightness_init(void)
150 | {
151 | /*Create a transition*/
152 | static const lv_style_prop_t props[] = {LV_STYLE_BG_COLOR, 0};
153 | static lv_style_transition_dsc_t transition_dsc;
154 | lv_style_transition_dsc_init(&transition_dsc, props, lv_anim_path_linear, 300, 0, NULL);
155 |
156 | static lv_style_t style_main;
157 | static lv_style_t style_indicator;
158 | static lv_style_t style_knob;
159 | static lv_style_t style_pressed_color;
160 | lv_style_init(&style_main);
161 | lv_style_set_bg_opa(&style_main, LV_OPA_COVER);
162 | lv_style_set_bg_color(&style_main, lv_palette_main(LV_PALETTE_GREY));
163 | lv_style_set_radius(&style_main, LV_RADIUS_CIRCLE);
164 | lv_style_set_pad_ver(&style_main, -2); /*Makes the indicator larger*/
165 |
166 | lv_style_init(&style_indicator);
167 | lv_style_set_bg_opa(&style_indicator, LV_OPA_COVER);
168 | lv_style_set_bg_color(&style_indicator, lv_palette_main(LV_PALETTE_ORANGE));
169 | lv_style_set_radius(&style_indicator, LV_RADIUS_CIRCLE);
170 | lv_style_set_transition(&style_indicator, &transition_dsc);
171 |
172 | lv_style_init(&style_knob);
173 | lv_style_set_bg_opa(&style_knob, LV_OPA_COVER);
174 | lv_style_set_bg_color(&style_knob, lv_palette_main(LV_PALETTE_ORANGE));
175 | lv_style_set_border_color(&style_knob, lv_palette_darken(LV_PALETTE_ORANGE, 3));
176 | lv_style_set_border_width(&style_knob, 2);
177 | lv_style_set_radius(&style_knob, LV_RADIUS_CIRCLE);
178 | lv_style_set_pad_all(&style_knob, 6); /*Makes the knob larger*/
179 | lv_style_set_transition(&style_knob, &transition_dsc);
180 |
181 | lv_style_init(&style_pressed_color);
182 | lv_style_set_bg_color(&style_pressed_color, lv_palette_darken(LV_PALETTE_ORANGE, 2));
183 |
184 | /*Create a slider and add the style*/
185 | lv_obj_t * slider = lv_slider_create(lv_scr_act());
186 | lv_obj_remove_style_all(slider); /*Remove the styles coming from the theme*/
187 | //lv_obj_set_size(slider, (LV_HOR_RES / 4 * 3), (LV_VER_RES / 20));
188 | lv_obj_set_width(slider, LV_PCT(60)); // lv_pct(x) can be used to set the size and position in percentage
189 | lv_bar_set_range(slider, 0, 8);
190 | lv_slider_set_value(slider, (get_backlight_brightenss() - '0'), LV_ANIM_ON);
191 | //lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
192 | lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_ALL, NULL);
193 |
194 | lv_obj_add_style(slider, &style_main, LV_PART_MAIN);
195 | lv_obj_add_style(slider, &style_indicator, LV_PART_INDICATOR);
196 | lv_obj_add_style(slider, &style_pressed_color, LV_PART_INDICATOR | LV_STATE_PRESSED);
197 | lv_obj_add_style(slider, &style_knob, LV_PART_KNOB);
198 | lv_obj_add_style(slider, &style_pressed_color, LV_PART_KNOB | LV_STATE_PRESSED);
199 |
200 | lv_obj_center(slider);
201 |
202 | lv_obj_t * title_label = lv_label_create(lv_scr_act());
203 | lv_obj_set_style_text_font(title_label, &lv_font_montserrat_40, 0);
204 | lv_label_set_text(title_label, "BRIGHTNESS");
205 | lv_obj_align_to(title_label, slider, LV_ALIGN_OUT_TOP_LEFT, 0, -10);
206 | }
207 |
208 |
209 | #endif /* LV_USE_100ASK_DEMO_GAME_2048 */
210 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_lcd_brightness/src/set_lcd_brightness.h:
--------------------------------------------------------------------------------
1 | #ifndef IMX6ULL_SET_LCD_BRIGHTNESS_H
2 | #define IMX6ULL_SET_LCD_BRIGHTNESS_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../imx6ull_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void imx6ull_set_lcd_brightness_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* IMX6ULL_SET_LCD_BRIGHTNESS_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_time/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | BIN = imx6ull_SetTime
12 |
13 |
14 | #Collect the files to compile
15 | MAINSRC = ./main.c
16 |
17 | OBJEXT ?= .o
18 |
19 | AOBJS = $(ASRCS:.S=$(OBJEXT))
20 | COBJS = $(CSRCS:.c=$(OBJEXT))
21 |
22 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
23 |
24 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
25 | OBJS = $(AOBJS) $(COBJS)
26 |
27 | ## MAINOBJ -> OBJFILES
28 |
29 | all: default
30 |
31 | %.o: %.c
32 | @$(CC) $(CFLAGS) -c $< -o $@
33 | @echo "CC $<"
34 |
35 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
36 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
37 | mkdir -p obj
38 | mv *.o ./obj/
39 | mv $(BIN) $(LVGL_DIR)/bin/
40 |
41 | clean:
42 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_time/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_time/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "src/set_time.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(3);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.SetTime", "/net/ask100/lvgl/SetTime");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | imx6ull_set_time_init();
64 |
65 | // 悬浮球控制初始化
66 | assistive_touch_init();
67 |
68 | while(1) {
69 | lv_task_handler();
70 | //lv_tick_inc(5*1000);
71 | usleep(5000);
72 | }
73 | return 0;
74 | }
75 |
76 |
77 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
78 | uint32_t custom_tick_get(void)
79 | {
80 | static uint64_t start_ms = 0;
81 | if(start_ms == 0) {
82 | struct timeval tv_start;
83 | gettimeofday(&tv_start, NULL);
84 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
85 | }
86 |
87 | struct timeval tv_now;
88 | gettimeofday(&tv_now, NULL);
89 | uint64_t now_ms;
90 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
91 |
92 | uint32_t time_ms = now_ms - start_ms;
93 | return time_ms;
94 | }
95 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_time/src/set_time.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file set_time.c
4 | * @author 百问科技
5 | * @version V1.0
6 | * @date 2021-10-29
7 | * @brief IMX6ULL屏幕背光设置
8 | ******************************************************************************
9 | * Change Logs:
10 | * Date Author Notes
11 | * 2021-10-29 zhouyuebiao First version
12 | ******************************************************************************
13 | * @attention
14 | *
15 | * Copyright (C) 2008-2021 深圳百问网科技有限公司
16 | * All rights reserved
17 | *
18 | ******************************************************************************
19 | */
20 |
21 |
22 | /*********************
23 | * INCLUDES
24 | *********************/
25 | //#include "../../lv_100ask_demo.h"
26 |
27 | #if 1 //LV_USE_100ASK_DEMO_GAME_2048
28 |
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include "set_time.h"
36 |
37 | #include "lvgl/lvgl.h"
38 | #include "lv_drivers/display/fbdev.h"
39 | #include "lv_drivers/indev/evdev.h"
40 |
41 | /*********************
42 | * DEFINES
43 | *********************/
44 | #include
45 |
46 | LV_IMG_DECLARE(watch_bg);
47 | LV_IMG_DECLARE(hour);
48 | LV_IMG_DECLARE(minute);
49 | LV_IMG_DECLARE(second);
50 |
51 | lv_obj_t * lvMinute;
52 | lv_obj_t * lvHour;
53 | lv_obj_t * lvSecond ;
54 |
55 | lv_obj_t * g_obj_hour;
56 | lv_obj_t * g_obj_minute;
57 |
58 | uint8_t Minute = 24;
59 | uint8_t Hour = 8;
60 | uint8_t Second= 2 ;
61 |
62 |
63 | ///////////////////////////// 日历
64 | static lv_obj_t * g_calendar;
65 |
66 | static void date_event_cb(lv_event_t * e);
67 | static void calendar_event_cb(lv_event_t * e);
68 |
69 |
70 | static void update_time_value(void)
71 | {
72 | time_t rawtime;
73 | struct tm *info;
74 |
75 | time( &rawtime );
76 | info = localtime( &rawtime );
77 |
78 | Hour = info->tm_hour;
79 | Minute = info->tm_min;
80 | Second = info->tm_sec;
81 |
82 | lv_img_set_angle(lvHour, (Hour * 300 + Minute / 12 % 12 * 60)); // Set Hour angle
83 | lv_img_set_angle(lvMinute, (Minute*60)); // Set Minute angles
84 | lv_img_set_angle(lvSecond, (Second * 60)); // Set second angle
85 | }
86 |
87 | static void update_time(void *arg)
88 | {
89 | char buf[4];
90 | char strftime_buf[64];
91 |
92 | if(Second++>60)
93 | {
94 | Second=0;
95 | if(Minute++>60)
96 | {
97 | Minute=0;
98 | if(Hour++>12) Hour=0;
99 | }
100 | }
101 | if(lvHour !=NULL)
102 | {
103 |
104 | // Hour,Minute,Second;
105 | lv_img_set_angle( lvHour, Hour*30*10);
106 | lv_img_set_angle( lvMinute, Minute*6*10);
107 | lv_img_set_angle( lvSecond, Second*6*10);
108 | }
109 |
110 | lv_snprintf(buf, sizeof(buf), "%02d", Hour);
111 | lv_textarea_set_text(g_obj_hour, buf); // 在文本区域展示日期信息
112 |
113 | lv_snprintf(buf, sizeof(buf), "%02d", Minute);
114 | lv_textarea_set_text(g_obj_minute, buf); // 在文本区域展示日期信息
115 | }
116 |
117 |
118 | void analog(lv_obj_t *parent)
119 | {
120 | lv_obj_t * img = lv_img_create(parent);
121 | //lv_obj_center(img);
122 | lv_img_set_src(img, &watch_bg);
123 | lv_obj_set_size(img, 200, 200);
124 | lv_obj_set_align(img, LV_ALIGN_CENTER);
125 |
126 | // Hour
127 | lvHour = lv_img_create(img);
128 | lv_img_set_src(lvHour, &hour);
129 | lv_obj_set_align(lvHour, LV_ALIGN_CENTER);
130 | lv_img_set_angle(lvHour, (Hour * 300 + Minute / 12 % 12 * 60)); // Set Hour angle
131 |
132 | // Minute
133 | lvMinute = lv_img_create(img);
134 | lv_img_set_src(lvMinute, &minute);
135 | lv_obj_set_align(lvMinute, LV_ALIGN_CENTER);
136 | lv_img_set_angle(lvMinute, (Minute*60)); // Set Minute angle
137 |
138 | // Second
139 | lvSecond = lv_img_create(img);
140 | lv_img_set_src( lvSecond, &second);
141 | lv_obj_set_align(lvSecond, LV_ALIGN_CENTER);
142 | lv_img_set_angle(lvSecond, (Second * 60)); // Set second angle
143 |
144 | lv_timer_t * timer = lv_timer_create(update_time, 1000, NULL); // Update clock timer
145 | lv_timer_ready(timer);
146 | }
147 |
148 |
149 | // 获取时分秒命令,安度可单独获取:时、分、秒
150 | // date -d today +%Y%m%d%H%M%S
151 | static void clock_init(lv_obj_t *parent)
152 | {
153 | time_t rawtime;
154 | struct tm *info;
155 |
156 | time( &rawtime );
157 | info = localtime( &rawtime );
158 |
159 | Hour = info->tm_hour;
160 | Minute = info->tm_min;
161 | Second = info->tm_sec;
162 |
163 | #if 0
164 | lv_obj_t * tim = lv_obj_create(lv_scr_act());
165 |
166 | lv_obj_add_flag(tim, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
167 | lv_obj_set_size(tim, LV_PCT(100), LV_PCT(100));
168 | lv_obj_center(tim);
169 | //lv_obj_set_height(tim, LV_PCT(100));
170 | //lv_obj_set_style_max_height(tim, 300, 0);
171 |
172 | lv_obj_set_flex_flow(tim, LV_FLEX_FLOW_COLUMN);
173 | lv_obj_set_flex_grow(tim, 1);
174 | lv_obj_add_flag(tim, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
175 | #endif
176 |
177 | analog(parent);
178 | }
179 |
180 |
181 | static void date_event_cb(lv_event_t * e)
182 | {
183 | lv_event_code_t code = lv_event_get_code(e);
184 | lv_obj_t * ta = lv_event_get_target(e);
185 |
186 | if(code == LV_EVENT_FOCUSED) {
187 | if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_POINTER) {
188 | if(g_calendar == NULL) {
189 | // 获取系统时间
190 | time_t rawtime;
191 | struct tm *info;
192 | time( &rawtime );
193 | info = localtime( &rawtime );
194 |
195 | lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 使能 lv_layer_top 点击
196 | g_calendar = lv_calendar_create(lv_layer_top()); // 在 lv_layer_top 层上创建日历对象
197 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_50, 0); // 设置对象透明度
198 | lv_obj_set_style_bg_color(lv_layer_top(), lv_palette_main(LV_PALETTE_GREY), 0); // 设置对象颜色
199 | lv_obj_set_size(g_calendar, 300, 300); // 设置对象大小
200 | lv_calendar_set_today_date(g_calendar, (info->tm_year + 2000 - 100), (info->tm_mon + 1), info->tm_mday); // 设置今天的日期
201 | lv_calendar_set_showed_date(g_calendar, (info->tm_year + 2000 - 100), (info->tm_mon + 1)); // 给日历的指定打开时显示的日期
202 | lv_obj_align(g_calendar, LV_ALIGN_CENTER, 0, 30); // 设置对象对齐、偏移
203 | lv_obj_add_event_cb(g_calendar, calendar_event_cb, LV_EVENT_VALUE_CHANGED, ta); // 给对象分配事件
204 | lv_obj_add_event_cb(lv_layer_top(), calendar_event_cb, LV_EVENT_CLICKED, ta); // 给对象分配事件(lv_layer_top层分配点击回调处理函数)
205 |
206 | lv_calendar_header_dropdown_create(g_calendar); // 创建一个包含 2 个下拉列表的标题:一个用于年份,另一个用于月份。
207 | }
208 | }
209 | }
210 | }
211 |
212 |
213 | static void calendar_event_cb(lv_event_t * e)
214 | {
215 | lv_event_code_t code = lv_event_get_code(e); // 获取事件代码
216 | lv_obj_t * ta = lv_event_get_user_data(e); // 获取在对象上注册事件时传递的 user_data
217 | lv_obj_t * obj = lv_event_get_current_target(e);
218 |
219 | // 判断事件类型
220 | if(code == LV_EVENT_VALUE_CHANGED) {
221 | char buf[32];
222 | char cmd_buf[64];
223 | lv_calendar_date_t d;
224 | lv_calendar_get_pressed_date(obj, &d); // 获取当前选中的日期
225 |
226 | memset(buf, 0, sizeof(buf));
227 | lv_snprintf(buf, sizeof(buf), "%02d-%02d-%d", d.year, d.month, d.day);
228 | lv_textarea_set_text(ta, buf); // 在文本区域展示日期信息
229 |
230 | lv_snprintf(cmd_buf, sizeof(cmd_buf), "date -s %s && hwclock -w && hwclock -w", buf);
231 | printf("%s\n", cmd_buf);
232 | system(cmd_buf); // TODO
233 | update_time_value();
234 |
235 | lv_obj_del(g_calendar); // 删除对象及其所有子对象
236 | lv_obj_remove_event_cb(lv_layer_top(), calendar_event_cb); // 删除对象的事件处理函数(lv_layer_top层)
237 | g_calendar = NULL;
238 | lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 清除标志(lv_layer_top层)
239 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); // 设置透明度(lv_layer_top层)
240 | }
241 | else if ((code == LV_EVENT_CLICKED))
242 | {
243 | lv_obj_del(g_calendar); // 删除对象及其所有子对象
244 | lv_obj_remove_event_cb(lv_layer_top(), calendar_event_cb); // 删除对象的事件处理函数(lv_layer_top层)
245 | g_calendar = NULL;
246 | lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 清除标志(lv_layer_top层)
247 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); // 设置透明度(lv_layer_top层)
248 | }
249 | }
250 |
251 |
252 | // 日期
253 | static void date_init(lv_obj_t *parent)
254 | {
255 | // 获取系统时间
256 | char buf[32];
257 | time_t rawtime;
258 | struct tm *info;
259 | time(&rawtime);
260 | info = localtime(&rawtime);
261 |
262 | // 日期标题
263 | lv_obj_t * date_label = lv_label_create(parent);
264 | lv_obj_set_width(date_label, 250); // lv_obj_get_width(parent)
265 | lv_label_set_text(date_label, "DATE"); // 为标签设置新文本
266 | lv_obj_set_style_text_opa(date_label, LV_OPA_50, 0);
267 |
268 | lv_obj_t * date = lv_textarea_create(parent);
269 | lv_textarea_set_one_line(date, true); // 单行模式
270 | lv_snprintf(buf, sizeof(buf), "%02d-%02d-%d", (info->tm_year + 2000 - 100), (info->tm_mon + 1), info->tm_mday);
271 | lv_textarea_set_text(date, buf); // 在文本区域展示日期信息
272 | //lv_obj_align(date, LV_ALIGN_TOP_MID, 0, 120); // 更改对象的对齐方式并设置新坐标
273 | lv_obj_add_event_cb(date, date_event_cb, LV_EVENT_ALL, NULL); // 为对象分配事件及其处理函数
274 |
275 | //lv_obj_align_to(date_label, date, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
276 | }
277 |
278 | // 时
279 | static void set_hour_event_cb(lv_event_t * e)
280 | {
281 | lv_event_code_t code = lv_event_get_code(e); // 获取事件代码
282 | lv_obj_t * obj = lv_event_get_target(e); // 获取触发事件的对象
283 | lv_obj_t * ta = lv_event_get_user_data(e); // 获取在对象上注册事件时传递的 user_data
284 |
285 | // 判断事件类型
286 | if(code == LV_EVENT_SHORT_CLICKED) {
287 | char hour_buf[4];
288 | char cmd_buf[64];
289 | lv_roller_get_selected_str(obj, hour_buf, sizeof(hour_buf)); // 获取当前选中的时间(hour)
290 |
291 | lv_textarea_set_text(ta, hour_buf); // 在文本区域展示日期信息
292 |
293 | lv_obj_del(obj); // 删除对象及其所有子对象
294 | lv_obj_remove_event_cb(lv_layer_top(), set_hour_event_cb); // 删除对象的事件处理函数(lv_layer_top层)
295 | obj = NULL;
296 | lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 清除标志(lv_layer_top层)
297 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); // 设置透明度(lv_layer_top层)
298 |
299 | lv_snprintf(cmd_buf, sizeof(cmd_buf), "date -s %s:00:01 && hwclock -w && hwclock -w", hour_buf);
300 | printf("%s\n", cmd_buf);
301 | system(cmd_buf);
302 | update_time_value();
303 | }
304 | else if ((code == LV_EVENT_CLICKED))
305 | {
306 | lv_obj_del(obj); // 删除对象及其所有子对象
307 | lv_obj_remove_event_cb(lv_layer_top(), set_hour_event_cb); // 删除对象的事件处理函数(lv_layer_top层)
308 | obj = NULL;
309 | lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 清除标志(lv_layer_top层)
310 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); // 设置透明度(lv_layer_top层)
311 | }
312 |
313 | }
314 |
315 |
316 | static void opt_hour_event_cb(lv_event_t * e)
317 | {
318 | lv_event_code_t code = lv_event_get_code(e);
319 | lv_obj_t * ta = lv_event_get_target(e);
320 |
321 | if(code == LV_EVENT_FOCUSED) {
322 | if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_POINTER) {
323 | if(g_calendar == NULL) {
324 | const char * opts = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24";
325 | uint16_t selected = atoi(lv_label_get_text(lv_obj_get_child(ta, 0))) - 1; // 获取当前时间,并设为默认选中项
326 |
327 | // 制造对话框效果
328 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_50, 0);
329 | lv_obj_set_style_bg_color(lv_layer_top(), lv_palette_main(LV_PALETTE_GREY), 0);
330 |
331 | lv_obj_t *roller= lv_roller_create(lv_layer_top());
332 | lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL); // 设置选中的选项 TODO
333 | lv_roller_set_visible_row_count(roller, 8);
334 | lv_obj_set_width(roller, 80);
335 | lv_obj_set_style_text_font(roller, &lv_font_montserrat_22, 0);
336 | lv_obj_align_to(roller, ta, LV_ALIGN_CENTER, 0, 0);
337 | lv_roller_set_selected(roller, selected, LV_ANIM_OFF);
338 |
339 | lv_obj_add_event_cb(roller, set_hour_event_cb, LV_EVENT_SHORT_CLICKED, ta); // 给对象分配事件
340 | lv_obj_add_event_cb(lv_layer_top(), set_hour_event_cb, LV_EVENT_CLICKED, ta); // 给对象分配事件(lv_layer_top层分配点击回调处理函数)
341 |
342 | }
343 | }
344 | }
345 | }
346 |
347 |
348 | // 分
349 | static void set_minute_event_cb(lv_event_t * e)
350 | {
351 | lv_event_code_t code = lv_event_get_code(e); // 获取事件代码
352 | lv_obj_t * obj = lv_event_get_target(e); // 获取触发事件的对象
353 | lv_obj_t * ta = lv_event_get_user_data(e); // 获取在对象上注册事件时传递的 user_data
354 |
355 | // 判断事件类型
356 | if(code == LV_EVENT_SHORT_CLICKED) {
357 | char min_buf[4];
358 | char cmd_buf[64];
359 | lv_roller_get_selected_str(obj, min_buf, sizeof(min_buf)); // 获取当前选中的时间(hour)
360 |
361 | lv_textarea_set_text(ta, min_buf); // 在文本区域展示日期信息
362 |
363 | lv_obj_del(obj); // 删除对象及其所有子对象
364 | lv_obj_remove_event_cb(lv_layer_top(), set_minute_event_cb); // 删除对象的事件处理函数(lv_layer_top层)
365 | obj = NULL;
366 | lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 清除标志(lv_layer_top层)
367 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); // 设置透明度(lv_layer_top层)
368 |
369 | lv_snprintf(cmd_buf, sizeof(cmd_buf), "date -s 01:%s:01 && hwclock -w && hwclock -w", min_buf);
370 | printf("%s\n", cmd_buf);
371 | system(cmd_buf);
372 | update_time_value();
373 | }
374 | else if ((code == LV_EVENT_CLICKED))
375 | {
376 | lv_obj_del(obj); // 删除对象及其所有子对象
377 | lv_obj_remove_event_cb(lv_layer_top(), set_minute_event_cb); // 删除对象的事件处理函数(lv_layer_top层)
378 | obj = NULL;
379 | lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); // 清除标志(lv_layer_top层)
380 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_TRANSP, 0); // 设置透明度(lv_layer_top层)
381 | }
382 |
383 | }
384 |
385 | static void opt_minute_event_cb(lv_event_t * e)
386 | {
387 | lv_event_code_t code = lv_event_get_code(e);
388 | lv_obj_t * ta = lv_event_get_target(e);
389 |
390 | if(code == LV_EVENT_FOCUSED) {
391 | if(lv_indev_get_type(lv_indev_get_act()) == LV_INDEV_TYPE_POINTER) {
392 | if(g_calendar == NULL) {
393 | const char * opts = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n\
394 | 21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n\
395 | 41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59";
396 | uint16_t selected = atoi(lv_label_get_text(lv_obj_get_child(ta, 0))) - 1; // 获取当前时间,并设为默认选中项
397 |
398 | // 制造对话框效果
399 | lv_obj_set_style_bg_opa(lv_layer_top(), LV_OPA_50, 0);
400 | lv_obj_set_style_bg_color(lv_layer_top(), lv_palette_main(LV_PALETTE_GREY), 0);
401 |
402 | lv_obj_t *roller= lv_roller_create(lv_layer_top());
403 | lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL); // 设置选中的选项 TODO
404 | lv_roller_set_visible_row_count(roller, 8);
405 | lv_obj_set_width(roller, 80);
406 | lv_obj_set_style_text_font(roller, &lv_font_montserrat_22, 0);
407 | lv_obj_align_to(roller, ta, LV_ALIGN_CENTER, 0, 0);
408 | lv_roller_set_selected(roller, selected, LV_ANIM_OFF);
409 |
410 | lv_obj_add_event_cb(roller, set_minute_event_cb, LV_EVENT_SHORT_CLICKED, ta); // 给对象分配事件
411 | lv_obj_add_event_cb(lv_layer_top(), set_minute_event_cb, LV_EVENT_CLICKED, ta); // 给对象分配事件(lv_layer_top层分配点击回调处理函数)
412 |
413 | }
414 | }
415 | }
416 | }
417 |
418 | // 时间
419 | static void time_init(lv_obj_t *parent)
420 | {
421 | // 获取系统时间
422 | char buf[32];
423 | time_t rawtime;
424 | struct tm *info;
425 | time(&rawtime);
426 | info = localtime(&rawtime);
427 |
428 | // 时标题
429 | lv_obj_t * hour_label = lv_label_create(parent);
430 | lv_obj_set_width(hour_label, 250); // lv_obj_get_width(parent)
431 | lv_label_set_text(hour_label, "HOUR"); // 为标签设置新文本
432 | lv_obj_set_style_text_opa(hour_label, LV_OPA_50, 0);
433 |
434 | g_obj_hour = lv_textarea_create(parent);
435 | lv_textarea_set_one_line(g_obj_hour, true); // 单行模式
436 | lv_snprintf(buf, sizeof(buf), "%02d", info->tm_hour);
437 | lv_textarea_set_text(g_obj_hour, buf); // 在文本区域展示日期信息
438 | lv_obj_add_event_cb(g_obj_hour, opt_hour_event_cb, LV_EVENT_ALL, NULL); // 为对象分配事件及其处理函数
439 |
440 | // 分标题
441 | lv_obj_t * minute_label = lv_label_create(parent);
442 | lv_obj_set_width(minute_label, 250); // lv_obj_get_width(parent)
443 | lv_label_set_text(minute_label, "MINUTE"); // 为标签设置新文本
444 | lv_obj_set_style_text_opa(minute_label, LV_OPA_50, 0);
445 |
446 | g_obj_minute = lv_textarea_create(parent);
447 | lv_textarea_set_one_line(g_obj_minute, true); // 单行模式
448 | lv_snprintf(buf, sizeof(buf), "%02d", info->tm_min);
449 | lv_textarea_set_text(g_obj_minute, buf); // 在文本区域展示日期信息
450 | lv_obj_add_event_cb(g_obj_minute, opt_minute_event_cb, LV_EVENT_ALL, NULL); // 为对象分配事件及其处理函数
451 | }
452 |
453 |
454 |
455 | // 布局初始化
456 | static lv_obj_t * layout_init(void)
457 | {
458 | lv_obj_t * layout_obj;
459 | static lv_style_t cont_style; // 容器的样式
460 |
461 | /* 设置容器的样式 */
462 | lv_style_init(&cont_style);
463 | lv_style_set_flex_flow(&cont_style, LV_FLEX_FLOW_ROW_WRAP);
464 | lv_style_set_flex_main_place(&cont_style, LV_FLEX_ALIGN_SPACE_EVENLY);
465 | lv_style_set_layout(&cont_style, LV_LAYOUT_FLEX);
466 | //lv_style_set_bg_opa(&cont_style, 0);
467 | lv_style_set_border_opa(&cont_style, 0);
468 |
469 | layout_obj = lv_obj_create(lv_scr_act());
470 | lv_obj_set_size(layout_obj, 500, 500);
471 | lv_obj_center(layout_obj);
472 | lv_obj_add_style(layout_obj, &cont_style, 0);
473 |
474 | return layout_obj;
475 | }
476 |
477 |
478 | void imx6ull_set_time_init(void)
479 | {
480 | lv_obj_t * layout_obj = layout_init();
481 | clock_init(layout_obj);
482 | date_init(layout_obj);
483 | time_init(layout_obj);
484 | }
485 |
486 |
487 | #endif /* LV_USE_100ASK_DEMO_GAME_2048 */
488 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_time/src/set_time.h:
--------------------------------------------------------------------------------
1 | #ifndef IMX6ULL_SET_TIME_H
2 | #define IMX6ULL_SET_TIME_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../imx6ull_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void imx6ull_set_time_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* IMX6ULL_SET_TIME_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_wlan/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # Makefile
3 | #
4 |
5 | include ./app_src.mk
6 | include $(LVGL_DIR)/lvgl/lvgl.mk
7 | include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
8 | include $(LVGL_DIR)/lv_lib_png/lv_lib_png.mk
9 | include $(LVGL_DIR)/lv_100ask_modules/lv_100ask_modules.mk
10 |
11 | BIN = imx6ull_WLAN
12 |
13 |
14 | #Collect the files to compile
15 | MAINSRC = ./main.c
16 |
17 | OBJEXT ?= .o
18 |
19 | AOBJS = $(ASRCS:.S=$(OBJEXT))
20 | COBJS = $(CSRCS:.c=$(OBJEXT))
21 |
22 | MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
23 |
24 | SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
25 | OBJS = $(AOBJS) $(COBJS)
26 |
27 | ## MAINOBJ -> OBJFILES
28 |
29 | all: default
30 |
31 | %.o: %.c
32 | @$(CC) $(CFLAGS) -c $< -o $@
33 | @echo "CC $<"
34 |
35 | default: $(AOBJS) $(COBJS) $(MAINOBJ)
36 | $(CC) -o $(BIN) $(MAINOBJ) $(AOBJS) $(COBJS) $(LDFLAGS)
37 | mkdir -p obj
38 | mv *.o ./obj/
39 | mv $(BIN) $(LVGL_DIR)/bin/
40 |
41 | clean:
42 | rm -f $(BIN) $(AOBJS) $(COBJS) $(MAINOBJ) ./obj/*
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_wlan/app_src.mk:
--------------------------------------------------------------------------------
1 | CSRCS += $(shell find -L ./src/ -name "*.c")
2 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_wlan/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "lvgl/lvgl.h"
6 | #include "lv_drivers/display/fbdev.h"
7 | #include "lv_drivers/indev/evdev.h"
8 | #include "lv_lib_png/lv_png.h"
9 | #include "lv_100ask_modules/lv_100ask_modules.h"
10 |
11 | #include "src/set_wlan.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 | int main(void)
16 | {
17 | /*LittlevGL init*/
18 | lv_init();
19 |
20 | /*Linux frame buffer device init*/
21 | fbdev_init();
22 |
23 | /*A small buffer for LittlevGL to draw the screen's content*/
24 | static lv_color_t buf[DISP_BUF_SIZE];
25 |
26 | /*Initialize a descriptor for the buffer*/
27 | static lv_disp_draw_buf_t disp_buf;
28 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
29 |
30 | /*Initialize and register a display driver*/
31 | static lv_disp_drv_t disp_drv;
32 | lv_disp_drv_init(&disp_drv);
33 | disp_drv.draw_buf = &disp_buf;
34 | disp_drv.flush_cb = fbdev_flush;
35 | disp_drv.hor_res = 1024;
36 | disp_drv.ver_res = 600;
37 | lv_disp_drv_register(&disp_drv);
38 |
39 | /* Linux input device init */
40 | evdev_init();
41 |
42 | /* Initialize and register a display input driver */
43 | lv_indev_drv_t indev_drv;
44 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
45 |
46 | indev_drv.type = LV_INDEV_TYPE_POINTER;
47 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
48 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
49 |
50 | // 支持png
51 | lv_png_init();
52 |
53 | // Set Image Cache size
54 | lv_img_cache_set_size(3);
55 |
56 | // 调用进程间通信管理初始化函数
57 | lv_100ask_dbus_handler_init("net.ask100.lvgl.WLAN", "/net/ask100/lvgl/WLAN");
58 |
59 | // 让桌面暂停运行
60 | dbus_method_call("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main", "net.ask100.lvgl.Main", "states", 0, 0);
61 |
62 | /*Create a Demo*/
63 | imx6ull_set_wlan_init();
64 |
65 | // 悬浮球控制初始化
66 | assistive_touch_init();
67 |
68 | while(1) {
69 | lv_task_handler();
70 | //lv_tick_inc(5*1000);
71 | usleep(5000);
72 | }
73 | return 0;
74 | }
75 |
76 |
77 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
78 | uint32_t custom_tick_get(void)
79 | {
80 | static uint64_t start_ms = 0;
81 | if(start_ms == 0) {
82 | struct timeval tv_start;
83 | gettimeofday(&tv_start, NULL);
84 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
85 | }
86 |
87 | struct timeval tv_now;
88 | gettimeofday(&tv_now, NULL);
89 | uint64_t now_ms;
90 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
91 |
92 | uint32_t time_ms = now_ms - start_ms;
93 | return time_ms;
94 | }
95 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/imx6ull_app/imx6ull_set_wlan/src/set_wlan.h:
--------------------------------------------------------------------------------
1 | #ifndef IMX6ULL_SET_WLAN_H
2 | #define IMX6ULL_SET_WLAN_H
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 |
9 | /*********************
10 | * INCLUDES
11 | *********************/
12 | #include "../../imx6ull_app.h"
13 |
14 |
15 | /*********************
16 | * DEFINES
17 | *********************/
18 |
19 | /**********************
20 | * TYPEDEFS
21 | **********************/
22 |
23 | /**********************
24 | * GLOBAL PROTOTYPES
25 | **********************/
26 | void imx6ull_set_wlan_init(void);
27 |
28 |
29 |
30 | /**********************
31 | * MACROS
32 | **********************/
33 |
34 | #ifdef __cplusplus
35 | } /* extern "C" */
36 | #endif
37 |
38 | #endif /* IMX6ULL_SET_WLAN_H */
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/lv_100ask_app/src/lv_100ask_app.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_100ask_app.h
3 | * This file exists only to be compatible with Arduino's library structure
4 | */
5 |
6 | #ifndef LV_100ASK_APP_H
7 | #define LV_100ASK_APP_H
8 |
9 | #ifdef __cplusplus
10 | extern "C" {
11 | #endif
12 |
13 | /*********************
14 | * INCLUDES
15 | *********************/
16 |
17 | #include "../lv_100ask_app.h"
18 |
19 | /*********************
20 | * DEFINES
21 | *********************/
22 |
23 | /**********************
24 | * TYPEDEFS
25 | **********************/
26 |
27 | /**********************
28 | * GLOBAL PROTOTYPES
29 | **********************/
30 |
31 | /**********************
32 | * MACROS
33 | **********************/
34 |
35 |
36 | #ifdef __cplusplus
37 | } /* extern "C" */
38 | #endif
39 |
40 | #endif /* LV_100ASK_APP_H */
41 |
--------------------------------------------------------------------------------
/lv_100ask_app_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_100ask_app_conf.h
3 | * Configuration file for v1.0.0
4 | *
5 | */
6 | /*
7 | * COPY THIS FILE AS lv_100ask_app_conf.h
8 | */
9 |
10 | /* clang-format off */
11 | #if 1 /*Set it to "1" to enable the content*/
12 |
13 | #ifndef LV_100ASK_APP_CONF_H
14 | #define LV_100ASK_APP_CONF_H
15 |
16 |
17 | /*******************
18 | * GENERAL SETTING
19 | *******************/
20 |
21 | /*********************
22 | * DEMO USAGE
23 | *********************/
24 |
25 | /******************** 通用APP **********************/
26 | /* [General] 计算器 */
27 | #define LV_USE_100ASK_APP_CALC 0
28 |
29 | /* [General] 2048小游戏 */
30 | #define LV_USE_100ASK_APP_2048 0
31 |
32 | /* [General] 数字对拼图小游戏 */
33 | #define LV_USE_100ASK_APP_MEMORY 0
34 |
35 |
36 | #endif /*LV_100ASK_APP_CONF_H*/
37 |
38 | #endif /*End of "Content enable"*/
39 |
40 |
--------------------------------------------------------------------------------
/lv_100ask_demo_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_100ask_demo_conf.h
3 | * Configuration file for v8.1.0-dev
4 | *
5 | */
6 | /*
7 | * COPY THIS FILE AS lv_100ask_demo_conf.h
8 | */
9 |
10 | /* clang-format off */
11 | #if 1 /*Set it to "1" to enable the content*/
12 |
13 | #ifndef LV_100ASK_DEMO_CONF_H
14 | #define LV_100ASK_DEMO_CONF_H
15 |
16 |
17 | /*******************
18 | * GENERAL SETTING
19 | *******************/
20 |
21 | /*********************
22 | * DEMO USAGE
23 | *********************/
24 |
25 | /*Show some widget*/
26 |
27 | /* [Info] About us 1024x600*/
28 | #define LV_USE_100ASK_DEMO_ABOUT_US 1
29 | #if LV_USE_100ASK_DEMO_ABOUT_US
30 | #define LV_100ASK_IMX6ULL_PRO 1
31 | #define LV_100ASK_IMX6ULL_MINI 0
32 | #define LV_100ASK_STM32MP157_PRO 0
33 | #endif
34 |
35 | /* [Game] Memory game demo, optimized for 1024x600*/
36 | #define LV_USE_100ASK_DEMO_GAME_MEMORY 1
37 |
38 | /* [Game] 2048 game demo, optimized for 1024x600*/
39 | #define LV_USE_100ASK_DEMO_GAME_2048 1
40 |
41 | /* [Game] Snake game demo, optimized for 1024x600*/
42 | #define LV_USE_100ASK_DEMO_GAME_SNAKE 1
43 |
44 | /* [Game] Tron game demo, optimized for 1024x600*/
45 | #define LV_USE_100ASK_DEMO_GAME_TILES 1
46 |
47 | /* [Efficiency] Calculator demo, optimized for 1024x600*/
48 | #define LV_USE_100ASK_DEMO_EFF_CALC 1
49 |
50 | /* [Efficiency(Linux only)] Weather overview 1024x600*/
51 | #define LV_USE_100ASK_DEMO_WEATHER 0
52 |
53 |
54 |
55 | #endif /*LV_100ASK_DEMO_CONF_H*/
56 |
57 | #endif /*End of "Content enable"*/
58 |
59 |
--------------------------------------------------------------------------------
/lv_100ask_modules_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_100ask_modules_conf.h
3 | * Configuration file for v1.0.0
4 | *
5 | */
6 | /*
7 | * COPY THIS FILE AS lv_100ask_modules_conf.h
8 | */
9 |
10 | /* clang-format off */
11 | #if 1 /*Set it to "1" to enable the content*/
12 |
13 | #ifndef LV_100ASK_MODULES_CONF_H
14 | #define LV_100ASK_MODULES_CONF_H
15 |
16 |
17 | /*******************
18 | * GENERAL SETTING
19 | *******************/
20 |
21 | /*********************
22 | * DEMO USAGE
23 | *********************/
24 |
25 | /* [General] APP通用初始化组件 */
26 | #define LV_USE_100ASK_APP_GENERAL_TEMPLATE 0
27 |
28 | /* [General] 通用DBus 通信组件 */
29 | #define LV_USE_100ASK_DBUS_HANDLER 1
30 |
31 | /* [General] APP通用辅助触控组件 */
32 | #define LV_USE_100ASK_DEMO_ASSISTIVE_TOUCH 1
33 |
34 | /* [Main desktop usage] 开机动画 */
35 | #define LV_USE_100ASK_BOOT_ANIMATION 1
36 |
37 | /* [Main desktop usage] 主桌面初始化组件 */
38 | #define LV_USE_100ASK_DEMO_INIT_ICON 1
39 |
40 | /* [Main desktop usage] 主桌面消息分发组件 */
41 | #define LV_USE_100ASK_DEMO_MSG_DISP 1
42 |
43 |
44 | #endif /*LV_100ASK_MODULES_CONF_H*/
45 |
46 | #endif /*End of "Content enable"*/
47 |
48 |
--------------------------------------------------------------------------------
/lv_demo_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_demo_conf.h
3 | * Configuration file for v8.1.0-dev
4 | *
5 | */
6 | /*
7 | * COPY THIS FILE AS lv_demo_conf.h
8 | */
9 |
10 | #if 1 /*Set it to "1" to enable the content*/
11 |
12 | #ifndef LV_DEMO_CONF_H
13 | #define LV_DEMO_CONF_H
14 |
15 |
16 | /*******************
17 | * GENERAL SETTING
18 | *******************/
19 | #define LV_EX_PRINTF 0 /*Enable printf-ing data in demoes and examples*/
20 | #define LV_EX_KEYBOARD 0 /*Add PC keyboard support to some examples (`lv_drivers` repository is required)*/
21 | #define LV_EX_MOUSEWHEEL 0 /*Add 'encoder' (mouse wheel) support to some examples (`lv_drivers` repository is required)*/
22 |
23 | /*********************
24 | * DEMO USAGE
25 | *********************/
26 |
27 | /*Show some widget*/
28 | #define LV_USE_DEMO_WIDGETS 1
29 | #if LV_USE_DEMO_WIDGETS
30 | #define LV_DEMO_WIDGETS_SLIDESHOW 0
31 | #endif
32 |
33 | /*Printer demo, optimized for 800x480*/
34 | #define LV_USE_DEMO_PRINTER 0
35 |
36 | /*Demonstrate the usage of encoder and keyboard*/
37 | #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
38 |
39 | /*Benchmark your system*/
40 | #define LV_USE_DEMO_BENCHMARK 1
41 |
42 | /*Stress test for LVGL*/
43 | #define LV_USE_DEMO_STRESS 0
44 |
45 | /*Music player demo*/
46 | #define LV_USE_DEMO_MUSIC 1
47 | #if LV_USE_DEMO_MUSIC
48 | # define LV_DEMO_MUSIC_SQUARE 0
49 | # define LV_DEMO_MUSIC_LANDSCAPE 0
50 | # define LV_DEMO_MUSIC_ROUND 0
51 | # define LV_DEMO_MUSIC_LARGE 0
52 | # define LV_DEMO_MUSIC_AUTO_PLAY 0
53 | #endif
54 |
55 | #endif /*LV_DEMO_CONF_H*/
56 |
57 | #endif /*End of "Content enable"*/
--------------------------------------------------------------------------------
/lv_drv_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_drv_conf.h
3 | * Configuration file for v8.1.0-dev
4 | */
5 |
6 | /*
7 | * COPY THIS FILE AS lv_drv_conf.h
8 | */
9 |
10 | #if 1 /*Set it to "1" to enable the content*/
11 |
12 | #ifndef LV_DRV_CONF_H
13 | #define LV_DRV_CONF_H
14 |
15 | #include "lv_conf.h"
16 |
17 | // 100ask change begin
18 | #define USE_EVDEV 1
19 |
20 | // 100ask change end
21 |
22 | /*********************
23 | * DELAY INTERFACE
24 | *********************/
25 | #define LV_DRV_DELAY_INCLUDE /*Dummy include by default*/
26 | #define LV_DRV_DELAY_US(us) /*delay_us(us)*/ /*Delay the given number of microseconds*/
27 | #define LV_DRV_DELAY_MS(ms) /*delay_ms(ms)*/ /*Delay the given number of milliseconds*/
28 |
29 | /*********************
30 | * DISPLAY INTERFACE
31 | *********************/
32 |
33 | /*------------
34 | * Common
35 | *------------*/
36 | #define LV_DRV_DISP_INCLUDE /*Dummy include by default*/
37 | #define LV_DRV_DISP_CMD_DATA(val) /*pin_x_set(val)*/ /*Set the command/data pin to 'val'*/
38 | #define LV_DRV_DISP_RST(val) /*pin_x_set(val)*/ /*Set the reset pin to 'val'*/
39 |
40 | /*---------
41 | * SPI
42 | *---------*/
43 | #define LV_DRV_DISP_SPI_CS(val) /*spi_cs_set(val)*/ /*Set the SPI's Chip select to 'val'*/
44 | #define LV_DRV_DISP_SPI_WR_BYTE(data) /*spi_wr(data)*/ /*Write a byte the SPI bus*/
45 | #define LV_DRV_DISP_SPI_WR_ARRAY(adr, n) /*spi_wr_mem(adr, n)*/ /*Write 'n' bytes to SPI bus from 'adr'*/
46 |
47 | /*------------------
48 | * Parallel port
49 | *-----------------*/
50 | #define LV_DRV_DISP_PAR_CS(val) /*par_cs_set(val)*/ /*Set the Parallel port's Chip select to 'val'*/
51 | #define LV_DRV_DISP_PAR_SLOW /*par_slow()*/ /*Set low speed on the parallel port*/
52 | #define LV_DRV_DISP_PAR_FAST /*par_fast()*/ /*Set high speed on the parallel port*/
53 | #define LV_DRV_DISP_PAR_WR_WORD(data) /*par_wr(data)*/ /*Write a word to the parallel port*/
54 | #define LV_DRV_DISP_PAR_WR_ARRAY(adr, n) /*par_wr_mem(adr,n)*/ /*Write 'n' bytes to Parallel ports from 'adr'*/
55 |
56 | /***************************
57 | * INPUT DEVICE INTERFACE
58 | ***************************/
59 |
60 | /*----------
61 | * Common
62 | *----------*/
63 | #define LV_DRV_INDEV_INCLUDE /*Dummy include by default*/
64 | #define LV_DRV_INDEV_RST(val) /*pin_x_set(val)*/ /*Set the reset pin to 'val'*/
65 | #define LV_DRV_INDEV_IRQ_READ 0 /*pn_x_read()*/ /*Read the IRQ pin*/
66 |
67 | /*---------
68 | * SPI
69 | *---------*/
70 | #define LV_DRV_INDEV_SPI_CS(val) /*spi_cs_set(val)*/ /*Set the SPI's Chip select to 'val'*/
71 | #define LV_DRV_INDEV_SPI_XCHG_BYTE(data) 0 /*spi_xchg(val)*/ /*Write 'val' to SPI and give the read value*/
72 |
73 | /*---------
74 | * I2C
75 | *---------*/
76 | #define LV_DRV_INDEV_I2C_START /*i2c_start()*/ /*Make an I2C start*/
77 | #define LV_DRV_INDEV_I2C_STOP /*i2c_stop()*/ /*Make an I2C stop*/
78 | #define LV_DRV_INDEV_I2C_RESTART /*i2c_restart()*/ /*Make an I2C restart*/
79 | #define LV_DRV_INDEV_I2C_WR(data) /*i2c_wr(data)*/ /*Write a byte to the I1C bus*/
80 | #define LV_DRV_INDEV_I2C_READ(last_read) 0 /*i2c_rd()*/ /*Read a byte from the I2C bud*/
81 |
82 |
83 | /*********************
84 | * DISPLAY DRIVERS
85 | *********************/
86 |
87 | /*-------------------
88 | * Monitor of PC
89 | *-------------------*/
90 | #ifndef USE_MONITOR
91 | # define USE_MONITOR 0
92 | #endif
93 |
94 | #if USE_MONITOR
95 | # define MONITOR_HOR_RES 480
96 | # define MONITOR_VER_RES 320
97 |
98 | /* Scale window by this factor (useful when simulating small screens) */
99 | # define MONITOR_ZOOM 1
100 |
101 | /* Used to test true double buffering with only address changing.
102 | * Use 2 draw buffers, bith with MONITOR_HOR_RES x MONITOR_VER_RES size*/
103 | # define MONITOR_DOUBLE_BUFFERED 0
104 |
105 | /*Eclipse: Visual Studio: */
106 | # define MONITOR_SDL_INCLUDE_PATH
107 |
108 | /*Open two windows to test multi display support*/
109 | # define MONITOR_DUAL 0
110 | #endif
111 |
112 | /*-----------------------------------
113 | * Native Windows (including mouse)
114 | *----------------------------------*/
115 | #ifndef USE_WINDOWS
116 | # define USE_WINDOWS 0
117 | #endif
118 |
119 | #if USE_WINDOWS
120 | # define WINDOW_HOR_RES 480
121 | # define WINDOW_VER_RES 320
122 | #endif
123 |
124 | /*----------------------------
125 | * Native Windows (win32drv)
126 | *---------------------------*/
127 | #ifndef USE_WIN32DRV
128 | # define USE_WIN32DRV 0
129 | #endif
130 |
131 | #if USE_WIN32DRV
132 | /* Scale window by this factor (useful when simulating small screens) */
133 | # define WIN32DRV_MONITOR_ZOOM 1
134 | #endif
135 |
136 | /*----------------------------------------
137 | * GTK drivers (monitor, mouse, keyboard
138 | *---------------------------------------*/
139 | #ifndef USE_GTK
140 | # define USE_GTK 0
141 | #endif
142 |
143 | /*----------------------------------------
144 | * Wayland drivers (monitor, mouse, keyboard, touchscreen)
145 | *---------------------------------------*/
146 | #ifndef USE_WAYLAND
147 | # define USE_WAYLAND 0
148 | #endif
149 |
150 | #if USE_WAYLAND
151 | # define WAYLAND_HOR_RES 480
152 | # define WAYLAND_VER_RES 320
153 | # define WAYLAND_SURF_TITLE "LVGL"
154 | #endif
155 |
156 | /*----------------
157 | * SSD1963
158 | *--------------*/
159 | #ifndef USE_SSD1963
160 | # define USE_SSD1963 0
161 | #endif
162 |
163 | #if USE_SSD1963
164 | # define SSD1963_HOR_RES LV_HOR_RES
165 | # define SSD1963_VER_RES LV_VER_RES
166 | # define SSD1963_HT 531
167 | # define SSD1963_HPS 43
168 | # define SSD1963_LPS 8
169 | # define SSD1963_HPW 10
170 | # define SSD1963_VT 288
171 | # define SSD1963_VPS 12
172 | # define SSD1963_FPS 4
173 | # define SSD1963_VPW 10
174 | # define SSD1963_HS_NEG 0 /*Negative hsync*/
175 | # define SSD1963_VS_NEG 0 /*Negative vsync*/
176 | # define SSD1963_ORI 0 /*0, 90, 180, 270*/
177 | # define SSD1963_COLOR_DEPTH 16
178 | #endif
179 |
180 | /*----------------
181 | * R61581
182 | *--------------*/
183 | #ifndef USE_R61581
184 | # define USE_R61581 0
185 | #endif
186 |
187 | #if USE_R61581
188 | # define R61581_HOR_RES LV_HOR_RES
189 | # define R61581_VER_RES LV_VER_RES
190 | # define R61581_HSPL 0 /*HSYNC signal polarity*/
191 | # define R61581_HSL 10 /*HSYNC length (Not Implemented)*/
192 | # define R61581_HFP 10 /*Horitontal Front poarch (Not Implemented)*/
193 | # define R61581_HBP 10 /*Horitontal Back poarch (Not Implemented */
194 | # define R61581_VSPL 0 /*VSYNC signal polarity*/
195 | # define R61581_VSL 10 /*VSYNC length (Not Implemented)*/
196 | # define R61581_VFP 8 /*Vertical Front poarch*/
197 | # define R61581_VBP 8 /*Vertical Back poarch */
198 | # define R61581_DPL 0 /*DCLK signal polarity*/
199 | # define R61581_EPL 1 /*ENABLE signal polarity*/
200 | # define R61581_ORI 0 /*0, 180*/
201 | # define R61581_LV_COLOR_DEPTH 16 /*Fix 16 bit*/
202 | #endif
203 |
204 | /*------------------------------
205 | * ST7565 (Monochrome, low res.)
206 | *-----------------------------*/
207 | #ifndef USE_ST7565
208 | # define USE_ST7565 0
209 | #endif
210 |
211 | #if USE_ST7565
212 | /*No settings*/
213 | #endif /*USE_ST7565*/
214 |
215 | /*------------------------------
216 | * GC9A01 (color, low res.)
217 | *-----------------------------*/
218 | #ifndef USE_GC9A01
219 | # define USE_GC9A01 0
220 | #endif
221 |
222 | #if USE_GC9A01
223 | /*No settings*/
224 | #endif /*USE_GC9A01*/
225 |
226 | /*------------------------------------------
227 | * UC1610 (4 gray 160*[104|128])
228 | * (EA DOGXL160 160x104 tested)
229 | *-----------------------------------------*/
230 | #ifndef USE_UC1610
231 | # define USE_UC1610 0
232 | #endif
233 |
234 | #if USE_UC1610
235 | # define UC1610_HOR_RES LV_HOR_RES
236 | # define UC1610_VER_RES LV_VER_RES
237 | # define UC1610_INIT_CONTRAST 33 /* init contrast, values in [%] */
238 | # define UC1610_INIT_HARD_RST 0 /* 1 : hardware reset at init, 0 : software reset */
239 | # define UC1610_TOP_VIEW 0 /* 0 : Bottom View, 1 : Top View */
240 | #endif /*USE_UC1610*/
241 |
242 | /*-------------------------------------------------
243 | * SHARP memory in pixel monochrome display series
244 | * LS012B7DD01 (184x38 pixels.)
245 | * LS013B7DH03 (128x128 pixels.)
246 | * LS013B7DH05 (144x168 pixels.)
247 | * LS027B7DH01 (400x240 pixels.) (tested)
248 | * LS032B7DD02 (336x536 pixels.)
249 | * LS044Q7DH01 (320x240 pixels.)
250 | *------------------------------------------------*/
251 | #ifndef USE_SHARP_MIP
252 | # define USE_SHARP_MIP 0
253 | #endif
254 |
255 | #if USE_SHARP_MIP
256 | # define SHARP_MIP_HOR_RES LV_HOR_RES
257 | # define SHARP_MIP_VER_RES LV_VER_RES
258 | # define SHARP_MIP_SOFT_COM_INVERSION 0
259 | # define SHARP_MIP_REV_BYTE(b) /*((uint8_t) __REV(__RBIT(b)))*/ /*Architecture / compiler dependent byte bits order reverse*/
260 | #endif /*USE_SHARP_MIP*/
261 |
262 | /*-------------------------------------------------
263 | * ILI9341 240X320 TFT LCD
264 | *------------------------------------------------*/
265 | #ifndef USE_ILI9341
266 | # define USE_ILI9341 0
267 | #endif
268 |
269 | #if USE_ILI9341
270 | # define ILI9341_HOR_RES LV_HOR_RES
271 | # define ILI9341_VER_RES LV_VER_RES
272 | # define ILI9341_GAMMA 1
273 | # define ILI9341_TEARING 0
274 | #endif /*USE_ILI9341*/
275 |
276 | /*-----------------------------------------
277 | * Linux frame buffer device (/dev/fbx)
278 | *-----------------------------------------*/
279 | #ifndef USE_FBDEV
280 | # define USE_FBDEV 1
281 | #endif
282 |
283 | #if USE_FBDEV
284 | # define FBDEV_PATH "/dev/fb0"
285 | #endif
286 |
287 | /*-----------------------------------------
288 | * FreeBSD frame buffer device (/dev/fbx)
289 | *.........................................*/
290 | #ifndef USE_BSD_FBDEV
291 | # define USE_BSD_FBDEV 0
292 | #endif
293 |
294 | #if USE_BSD_FBDEV
295 | # define FBDEV_PATH "/dev/fb0"
296 | #endif
297 |
298 | /*-----------------------------------------
299 | * DRM/KMS device (/dev/dri/cardX)
300 | *-----------------------------------------*/
301 | #ifndef USE_DRM
302 | # define USE_DRM 0
303 | #endif
304 |
305 | #if USE_DRM
306 | # define DRM_CARD "/dev/dri/card0"
307 | # define DRM_CONNECTOR_ID -1 /* -1 for the first connected one */
308 | #endif
309 |
310 | /*********************
311 | * INPUT DEVICES
312 | *********************/
313 |
314 | /*--------------
315 | * XPT2046
316 | *--------------*/
317 | #ifndef USE_XPT2046
318 | # define USE_XPT2046 0
319 | #endif
320 |
321 | #if USE_XPT2046
322 | # define XPT2046_HOR_RES 480
323 | # define XPT2046_VER_RES 320
324 | # define XPT2046_X_MIN 200
325 | # define XPT2046_Y_MIN 200
326 | # define XPT2046_X_MAX 3800
327 | # define XPT2046_Y_MAX 3800
328 | # define XPT2046_AVG 4
329 | # define XPT2046_X_INV 0
330 | # define XPT2046_Y_INV 0
331 | # define XPT2046_XY_SWAP 0
332 | #endif
333 |
334 | /*-----------------
335 | * FT5406EE8
336 | *-----------------*/
337 | #ifndef USE_FT5406EE8
338 | # define USE_FT5406EE8 0
339 | #endif
340 |
341 | #if USE_FT5406EE8
342 | # define FT5406EE8_I2C_ADR 0x38 /*7 bit address*/
343 | #endif
344 |
345 | /*---------------
346 | * AD TOUCH
347 | *--------------*/
348 | #ifndef USE_AD_TOUCH
349 | # define USE_AD_TOUCH 0
350 | #endif
351 |
352 | #if USE_AD_TOUCH
353 | /*No settings*/
354 | #endif
355 |
356 |
357 | /*---------------------------------------
358 | * Mouse or touchpad on PC (using SDL)
359 | *-------------------------------------*/
360 | #ifndef USE_MOUSE
361 | # define USE_MOUSE 0
362 | #endif
363 |
364 | #if USE_MOUSE
365 | /*No settings*/
366 | #endif
367 |
368 | /*-------------------------------------------
369 | * Mousewheel as encoder on PC (using SDL)
370 | *------------------------------------------*/
371 | #ifndef USE_MOUSEWHEEL
372 | # define USE_MOUSEWHEEL 0
373 | #endif
374 |
375 | #if USE_MOUSEWHEEL
376 | /*No settings*/
377 | #endif
378 |
379 | /*-------------------------------------------------
380 | * Touchscreen as libinput interface (for Linux based systems)
381 | *------------------------------------------------*/
382 | #ifndef USE_LIBINPUT
383 | # define USE_LIBINPUT 0
384 | #endif
385 |
386 | #if USE_LIBINPUT
387 | # define LIBINPUT_NAME "/dev/input/event1" /*You can use the "evtest" Linux tool to get the list of devices and test them*/
388 | #endif /*USE_LIBINPUT*/
389 |
390 | /*-------------------------------------------------
391 | * Mouse or touchpad as evdev interface (for Linux based systems)
392 | *------------------------------------------------*/
393 | #ifndef USE_EVDEV
394 | # define USE_EVDEV 0
395 | #endif
396 |
397 | #ifndef USE_BSD_EVDEV
398 | # define USE_BSD_EVDEV 0
399 | #endif
400 |
401 | #if USE_EVDEV || USE_BSD_EVDEV
402 | # define EVDEV_NAME "/dev/input/event1" /*You can use the "evtest" Linux tool to get the list of devices and test them*/
403 | # define EVDEV_SWAP_AXES 0 /*Swap the x and y axes of the touchscreen*/
404 |
405 | # define EVDEV_CALIBRATE 0 /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/
406 |
407 | # if EVDEV_CALIBRATE
408 | # define EVDEV_HOR_MIN 0 /*to invert axis swap EVDEV_XXX_MIN by EVDEV_XXX_MAX*/
409 | # define EVDEV_HOR_MAX 4096 /*"evtest" Linux tool can help to get the correct calibraion values>*/
410 | # define EVDEV_VER_MIN 0
411 | # define EVDEV_VER_MAX 4096
412 | # endif /*EVDEV_CALIBRATE*/
413 | #endif /*USE_EVDEV*/
414 |
415 | /*-------------------------------
416 | * Keyboard of a PC (using SDL)
417 | *------------------------------*/
418 | #ifndef USE_KEYBOARD
419 | # define USE_KEYBOARD 0
420 | #endif
421 |
422 | #if USE_KEYBOARD
423 | /*No settings*/
424 | #endif
425 |
426 | #endif /*LV_DRV_CONF_H*/
427 |
428 | #endif /*End of "Content enable"*/
429 |
--------------------------------------------------------------------------------
/lv_lib_png/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.d
--------------------------------------------------------------------------------
/lv_lib_png/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | project(lv_lib_png
2 | HOMEPAGE_URL https://github.com/lvgl/lv_lib_png
3 | )
4 |
5 | file(GLOB_RECURSE SOURCES *.c)
6 | add_library(${CMAKE_PROJECT_NAME} STATIC ${SOURCES})
7 |
8 | if("${LIB_INSTALL_DIR}" STREQUAL "")
9 | set(LIB_INSTALL_DIR "lib")
10 | endif()
11 |
12 | if("${INC_INSTALL_DIR}" STREQUAL "")
13 | set(INC_INSTALL_DIR "include/lvgl/${CMAKE_PROJECT_NAME}")
14 | endif()
15 |
16 | file(GLOB LV_DRIVERS_PUBLIC_HEADERS
17 | "${CMAKE_SOURCE_DIR}/lv_png.h"
18 | "${CMAKE_SOURCE_DIR}/lodepng.h"
19 | )
20 |
21 | set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
22 | OUTPUT_NAME ${CMAKE_PROJECT_NAME}
23 | ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
24 | PUBLIC_HEADER "${LV_DRIVERS_PUBLIC_HEADERS}"
25 | )
26 |
27 | install(TARGETS ${CMAKE_PROJECT_NAME}
28 | ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
29 | PUBLIC_HEADER DESTINATION "${INC_INSTALL_DIR}"
30 | )
31 |
--------------------------------------------------------------------------------
/lv_lib_png/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 LittlevGL
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/lv_lib_png/README.md:
--------------------------------------------------------------------------------
1 | # PNG decoder for LVGL
2 |
3 | **This repository is merged into the lvgl repository. See https://docs.lvgl.io/master/libs/png.html**
4 |
5 | Allow the use of PNG images in LVGL. This implementation uses [lodepng](https://github.com/lvandeve/lodepng) library.
6 |
7 | ## Get started
8 | - Download or clone this repository
9 | - [Download from GitHub](https://github.com/littlevgl/lv_lib_lodepng/archive/master.zip)
10 | - Clone: `git clone https://github.com/littlevgl/lv_lib_png.git`
11 | - Include the library: `#include "lv_lib_png/lv_png.h"`
12 | - Initalize the decocer with `lv_png_init()`
13 | - Test with the following code:
14 | ```c
15 | LV_IMG_DECLARE(png_decoder_test);
16 | lv_obj_t * img = lv_img_create(lv_scr_act());
17 | lv_img_set_src(img, &png_decoder_test);
18 | ```
19 |
20 | ## Use PNG images from file
21 | By deafult `lodepng` uses C file IO API (e.g. `fopen`) and images can be opened like this:
22 | ```c
23 | lv_img_set_src(img, "./lv_lib_png/png_decoder_test.png");
24 | ```
25 |
26 | If you want to make `lodepng` to use LVGL's file system API add `#define LV_PNG_USE_LV_FILESYSTEM 1` to the end of your`lv_conf.h`.
27 | In this case you need to [register a driver](https://docs.lvgl.io/latest/en/html/overview/file-system.html) fo LVGL. The following functions are required:
28 | - `open_cb()`
29 | - `read_cb()`
30 | - `close_cb()`
31 | - `size_cb()`
32 |
33 | After that fiels can be opened like this:
34 | ```c
35 | lv_img_set_src(img, "P:lv_lib_lodepng/png_decoder_test.png");
36 | ```
37 |
38 |
39 | Note that the path of the file might be different.
40 |
41 | ## Use PNG images from flash
42 | To store a PNG image in flash it needs to be converted to C array with [Online Image converter](https://lvgl.io/tools/imageconverter). Choose `Raw with alpha` Color format and `C array` Output format. Copy the result C array to your project and use it like this:
43 | ```c
44 | LV_IMG_DECLARE(my_test_img);
45 | lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
46 | lv_img_set_src(img, &my_test_img);
47 | ```
48 |
49 | ## Learn more
50 | To learn more about the PNG decoder itself read [this blog post](https://blog.littlevgl.com/2018-10-05/png_converter)
51 |
52 | To learn more about the Image decoder interface of LittlevGL read the realevant part of the [documentation](https://docs.littlevgl.com/en/html/overview/image.html#image-decoder).
53 |
--------------------------------------------------------------------------------
/lv_lib_png/lv_lib_png.mk:
--------------------------------------------------------------------------------
1 | LV_LIB_PNG_DIR_NAME ?= lv_lib_png
2 |
3 | CSRCS += $(wildcard $(LVGL_DIR)/$(LV_LIB_PNG_DIR_NAME)/*.c)
4 |
--------------------------------------------------------------------------------
/lv_lib_png/lv_png.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file lv_png.c
3 | *
4 | */
5 |
6 | /*********************
7 | * INCLUDES
8 | *********************/
9 | #if defined(LV_LVGL_H_INCLUDE_SIMPLE)
10 | #include "lvgl.h"
11 | #else
12 | #include "lvgl/lvgl.h"
13 | #endif
14 |
15 | #include "lv_png.h"
16 | #include "lodepng.h"
17 | #include
18 | #include
19 |
20 | /*********************
21 | * DEFINES
22 | *********************/
23 |
24 | /**********************
25 | * TYPEDEFS
26 | **********************/
27 |
28 | /**********************
29 | * STATIC PROTOTYPES
30 | **********************/
31 | static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header);
32 | static lv_res_t decoder_open(lv_img_decoder_t * dec, lv_img_decoder_dsc_t * dsc);
33 | static void decoder_close(lv_img_decoder_t * dec, lv_img_decoder_dsc_t * dsc);
34 | static void convert_color_depth(uint8_t * img, uint32_t px_cnt);
35 |
36 | /**********************
37 | * STATIC VARIABLES
38 | **********************/
39 |
40 | /**********************
41 | * MACROS
42 | **********************/
43 |
44 | /**********************
45 | * GLOBAL FUNCTIONS
46 | **********************/
47 |
48 | /**
49 | * Register the PNG decoder functions in LittlevGL
50 | */
51 | void lv_png_init(void)
52 | {
53 | lv_img_decoder_t * dec = lv_img_decoder_create();
54 | lv_img_decoder_set_info_cb(dec, decoder_info);
55 | lv_img_decoder_set_open_cb(dec, decoder_open);
56 | lv_img_decoder_set_close_cb(dec, decoder_close);
57 | }
58 |
59 | /**********************
60 | * STATIC FUNCTIONS
61 | **********************/
62 |
63 | /**
64 | * Get info about a PNG image
65 | * @param src can be file name or pointer to a C array
66 | * @param header store the info here
67 | * @return LV_RES_OK: no error; LV_RES_INV: can't get the info
68 | */
69 | static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
70 | {
71 | (void) decoder; /*Unused*/
72 | lv_img_src_t src_type = lv_img_src_get_type(src); /*Get the source type*/
73 |
74 | /*If it's a PNG file...*/
75 | if(src_type == LV_IMG_SRC_FILE) {
76 | const char * fn = src;
77 | if(!strcmp(&fn[strlen(fn) - 3], "png")) { /*Check the extension*/
78 |
79 | /* Read the width and height from the file. They have a constant location:
80 | * [16..23]: width
81 | * [24..27]: height
82 | */
83 | uint32_t size[2];
84 | #if LV_PNG_USE_LV_FILESYSTEM
85 | lv_fs_file_t f;
86 | lv_fs_res_t res = lv_fs_open(&f, fn, LV_FS_MODE_RD);
87 | if(res != LV_FS_RES_OK) return LV_RES_INV;
88 | lv_fs_seek(&f, 16, LV_FS_SEEK_SET);
89 | uint32_t rn;
90 | lv_fs_read(&f, &size, 8, &rn);
91 | if(rn != 8) return LV_RES_INV;
92 | lv_fs_close(&f);
93 | #else
94 | FILE* file;
95 | file = fopen(fn, "rb" );
96 | if(!file) return LV_RES_INV;
97 | fseek(file, 16, SEEK_SET);
98 | size_t rn = fread(size, 1 , 8, file);
99 | fclose(file);
100 | if(rn != 8) return LV_RES_INV;
101 | #endif
102 | /*Save the data in the header*/
103 | header->always_zero = 0;
104 | header->cf = LV_IMG_CF_RAW_ALPHA;
105 | /*The width and height are stored in Big endian format so convert them to little endian*/
106 | header->w = (lv_coord_t) ((size[0] & 0xff000000) >> 24) + ((size[0] & 0x00ff0000) >> 8);
107 | header->h = (lv_coord_t) ((size[1] & 0xff000000) >> 24) + ((size[1] & 0x00ff0000) >> 8);
108 |
109 | return LV_RES_OK;
110 | }
111 | }
112 | /*If it's a PNG file in a C array...*/
113 | else if(src_type == LV_IMG_SRC_VARIABLE) {
114 | const lv_img_dsc_t * img_dsc = src;
115 | header->always_zero = 0;
116 | header->cf = img_dsc->header.cf; /*Save the color format*/
117 | header->w = img_dsc->header.w; /*Save the color width*/
118 | header->h = img_dsc->header.h; /*Save the color height*/
119 | return LV_RES_OK;
120 | }
121 |
122 | return LV_RES_INV; /*If didn't succeeded earlier then it's an error*/
123 | }
124 |
125 |
126 | /**
127 | * Open a PNG image and return the decided image
128 | * @param src can be file name or pointer to a C array
129 | * @param style style of the image object (unused now but certain formats might use it)
130 | * @return pointer to the decoded image or `LV_IMG_DECODER_OPEN_FAIL` if failed
131 | */
132 | static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc)
133 | {
134 |
135 | (void) decoder; /*Unused*/
136 | uint32_t error; /*For the return values of PNG decoder functions*/
137 |
138 | uint8_t * img_data = NULL;
139 |
140 | /*If it's a PNG file...*/
141 | if(dsc->src_type == LV_IMG_SRC_FILE) {
142 | const char * fn = dsc->src;
143 |
144 | if(!strcmp(&fn[strlen(fn) - 3], "png")) { /*Check the extension*/
145 |
146 | /*Load the PNG file into buffer. It's still compressed (not decoded)*/
147 | unsigned char * png_data; /*Pointer to the loaded data. Same as the original file just loaded into the RAM*/
148 | size_t png_data_size; /*Size of `png_data` in bytes*/
149 |
150 | error = lodepng_load_file(&png_data, &png_data_size, fn); /*Load the file*/
151 | if(error) {
152 | printf("error %u: %s\n", error, lodepng_error_text(error));
153 | return LV_RES_INV;
154 | }
155 |
156 | /*Decode the PNG image*/
157 | uint32_t png_width; /*Will be the width of the decoded image*/
158 | uint32_t png_height; /*Will be the width of the decoded image*/
159 |
160 | /*Decode the loaded image in ARGB8888 */
161 | error = lodepng_decode32(&img_data, &png_width, &png_height, png_data, png_data_size);
162 | free(png_data); /*Free the loaded file*/
163 | if(error) {
164 | printf("error %u: %s\n", error, lodepng_error_text(error));
165 | return LV_RES_INV;
166 | }
167 |
168 | /*Convert the image to the system's color depth*/
169 | convert_color_depth(img_data, png_width * png_height);
170 | dsc->img_data = img_data;
171 | return LV_RES_OK; /*The image is fully decoded. Return with its pointer*/
172 | }
173 | }
174 | /*If it's a PNG file in a C array...*/
175 | else if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
176 | const lv_img_dsc_t * img_dsc = dsc->src;
177 | uint32_t png_width; /*No used, just required by he decoder*/
178 | uint32_t png_height; /*No used, just required by he decoder*/
179 |
180 | /*Decode the image in ARGB8888 */
181 | error = lodepng_decode32(&img_data, &png_width, &png_height, img_dsc->data, img_dsc->data_size);
182 |
183 | if(error) {
184 | return LV_RES_INV;
185 | }
186 |
187 | /*Convert the image to the system's color depth*/
188 | convert_color_depth(img_data, png_width * png_height);
189 |
190 | dsc->img_data = img_data;
191 | return LV_RES_OK; /*Return with its pointer*/
192 | }
193 |
194 | return LV_RES_INV; /*If not returned earlier then it failed*/
195 | }
196 |
197 | /**
198 | * Free the allocated resources
199 | */
200 | static void decoder_close(lv_img_decoder_t *decoder, lv_img_decoder_dsc_t *dsc)
201 | {
202 | (void)decoder; /*Unused*/
203 | if (dsc->img_data) {
204 | free((uint8_t *)dsc->img_data);
205 | dsc->img_data = NULL;
206 | }
207 | }
208 |
209 | /**
210 | * If the display is not in 32 bit format (ARGB888) then covert the image to the current color depth
211 | * @param img the ARGB888 image
212 | * @param px_cnt number of pixels in `img`
213 | */
214 | static void convert_color_depth(uint8_t * img, uint32_t px_cnt)
215 | {
216 | #if LV_COLOR_DEPTH == 32
217 | lv_color32_t * img_argb = (lv_color32_t*)img;
218 | lv_color_t c;
219 | lv_color_t * img_c = (lv_color_t *) img;
220 | uint32_t i;
221 | for(i = 0; i < px_cnt; i++) {
222 | c = lv_color_make(img_argb[i].ch.red, img_argb[i].ch.green, img_argb[i].ch.blue);
223 | img_c[i].ch.red = c.ch.blue;
224 | img_c[i].ch.blue = c.ch.red;
225 | }
226 | #elif LV_COLOR_DEPTH == 16
227 | lv_color32_t * img_argb = (lv_color32_t*)img;
228 | lv_color_t c;
229 | uint32_t i;
230 | for(i = 0; i < px_cnt; i++) {
231 | c = lv_color_make(img_argb[i].ch.blue, img_argb[i].ch.green, img_argb[i].ch.red);
232 | img[i*3 + 2] = img_argb[i].ch.alpha;
233 | img[i*3 + 1] = c.full >> 8;
234 | img[i*3 + 0] = c.full & 0xFF;
235 | }
236 | #elif LV_COLOR_DEPTH == 8
237 | lv_color32_t * img_argb = (lv_color32_t*)img;
238 | lv_color_t c;
239 | uint32_t i;
240 | for(i = 0; i < px_cnt; i++) {
241 | c = lv_color_make(img_argb[i].red, img_argb[i].green, img_argb[i].blue);
242 | img[i*2 + 1] = img_argb[i].alpha;
243 | img[i*2 + 0] = c.full
244 | }
245 | #endif
246 | }
247 |
248 |
249 |
250 |
--------------------------------------------------------------------------------
/lv_lib_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 |
17 | /*********************
18 | * DEFINES
19 | *********************/
20 |
21 | /**********************
22 | * TYPEDEFS
23 | **********************/
24 |
25 | /**********************
26 | * GLOBAL PROTOTYPES
27 | **********************/
28 |
29 | /**
30 | * Register the PNG decoder functions in LittlevGL
31 | */
32 | void lv_png_init(void);
33 |
34 | /**********************
35 | * MACROS
36 | **********************/
37 |
38 |
39 | #ifdef __cplusplus
40 | } /* extern "C" */
41 | #endif
42 |
43 | #endif /*LV_PNG_H*/
44 |
--------------------------------------------------------------------------------
/lv_lib_png/png_decoder_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/100askTeam/lv_100ask_linux_desktop/a5aae9f1ebef8857c1c99cd6089d31f9da8720f2/lv_lib_png/png_decoder_test.png
--------------------------------------------------------------------------------
/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #include "lvgl/lvgl.h"
7 | #include "lv_drivers/display/fbdev.h"
8 | #include "lv_drivers/indev/evdev.h"
9 | #include "lv_lib_png/lv_png.h"
10 |
11 | #include "lv_100ask_modules/lv_100ask_modules.h"
12 |
13 | #define DISP_BUF_SIZE (1024 * 600)
14 |
15 |
16 | int main(void)
17 | {
18 | /*LittlevGL init*/
19 | lv_init();
20 |
21 | /*Linux frame buffer device init*/
22 | fbdev_init();
23 |
24 | /*A small buffer for LittlevGL to draw the screen's content*/
25 | static lv_color_t buf[DISP_BUF_SIZE];
26 |
27 | /*Initialize a descriptor for the buffer*/
28 | static lv_disp_draw_buf_t disp_buf;
29 | lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
30 |
31 | /*Initialize and register a display driver*/
32 | static lv_disp_drv_t disp_drv;
33 | lv_disp_drv_init(&disp_drv);
34 | disp_drv.draw_buf = &disp_buf;
35 | disp_drv.flush_cb = fbdev_flush;
36 | disp_drv.hor_res = 1024;
37 | disp_drv.ver_res = 600;
38 | lv_disp_drv_register(&disp_drv);
39 |
40 | /* Linux input device init */
41 | evdev_init();
42 |
43 | /* Initialize and register a display input driver */
44 | lv_indev_drv_t indev_drv;
45 | lv_indev_drv_init(&indev_drv); /*Basic initialization*/
46 |
47 | indev_drv.type = LV_INDEV_TYPE_POINTER;
48 | indev_drv.read_cb = evdev_read; //lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
49 | lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
50 |
51 | // 支持png
52 | lv_png_init();
53 |
54 | // Set Image Cache size
55 | lv_img_cache_set_size(32);
56 |
57 | // 调用进程间通信管理初始化函数
58 | lv_100ask_dbus_handler_init("net.ask100.lvgl.Main", "/net/ask100/lvgl/Main");
59 |
60 | /* 初始化桌面环境 */
61 | //lv_100ask_boot_animation(lv_100ask_demo_init_icon, 1500); //开机动画
62 | lv_100ask_demo_init_icon();
63 |
64 | while(1) {
65 | if (1 == is_app_fore_ground())
66 | {
67 | lv_task_handler();
68 | //lv_tick_inc(5*1000);
69 | usleep(5000);
70 | }
71 | else
72 | {
73 | wait_for_become_front_ground();
74 | lv_100ask_demo_init_icon();
75 | }
76 | }
77 | return 0;
78 | }
79 |
80 |
81 | /*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
82 | uint32_t custom_tick_get(void)
83 | {
84 | static uint64_t start_ms = 0;
85 | if(start_ms == 0) {
86 | struct timeval tv_start;
87 | gettimeofday(&tv_start, NULL);
88 | start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
89 | }
90 |
91 | struct timeval tv_now;
92 | gettimeofday(&tv_now, NULL);
93 | uint64_t now_ms;
94 | now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
95 |
96 | uint32_t time_ms = now_ms - start_ms;
97 | return time_ms;
98 | }
99 |
--------------------------------------------------------------------------------