This post was last edited by 灰太狼.1. Works display
The functions of the work can be seen in the following Bilibili video [Desktop Weather Station | Xiaoanpai FreeRTOS+LVGL Development Practice]
For the shell, please refer to the following post: [[Model Sharing] Xiaoanpai AiPi-Eyes-S1 Shell]
Open source program link: AiPi_HZY_Weather: A weather station program developed using XiaoAnPai eyes-s1 (gitee.com)
2. Description of the Work2.1 HardwareThe hardware uses the AiPi-Eye-S1 development board and a 3.5-inch 240*320 pixel capacitive touch screen. In daily use, the device is powered by a USB cable through the type-c interface on the development board. Use a USB to TTL tool to download the program.
① Development environment I use VSCode to develop projects in Windows environment. For the specific environment construction process, please refer to the post in the forum: [Zero-based construction of Xiaoanpai Windows development environment]
② UI design This project uses the LVGL graphics library and the corresponding auxiliary development tool SquareLine Studio for interface design and C code generation.
③ Weather information acquisition This project uses the free weather API provided by Yike Cloud Weather to obtain the basic seven-day weather and basic real-time weather in the current area. Since the user ID and key parameters are used when requesting data, account registration is required.
④Programming ideas This project program refers to the official weather station example ( AiPi-Open-Kits/AiPi-Eyes_weather at master · Ai-Thinker-Open/AiPi-Open-Kits · GitHub ), and its overall implementation ideas are as follows:
- System Initialization
- Create multiple tasks based on FreeRTOS
(1) wifi_mainWiFi running task;
(2) lvgl_taskRun LVGL to realize touch screen display and touch function. When the network connection condition is triggered, the WiFi name and password data will be sent to the queue;
(3) bl61x_show_heap_size_taskPrint memory usage through the serial port (set the baud rate to 2000000);
(4) queue_taskAnalyze and process the queue data and execute the corresponding program. The communication between tasks is based on the queue.
Currently, the queue data processed by this task includes the following 4 types:
a. WiFi name and password data -> data storage, WiFi connection, WiFi connection success data will be sent to the queue when WiFi connection is successful;
b. WiFi connection success data -> create https_get_weather_taska task to obtain time and weather information;
c. Weather data for the next seven days -> update the screen display content;
d. Basic real-time weather data -> update the screen display content.
(5) https_get_weather_taskObtain the weather for the next seven days and basic real-time weather through https. After successful acquisition, the corresponding data will be sent to the queue. The task uses a timer http_timersto set the frequency of data acquisition.
3. Instructions for use3.1 Firmware BurningThe following operations need to be performed after the environment configuration is completed.
① Program compilation
Open the terminal in the project root directory and enter "make"
If there are no errors, the following content will be displayed in the end
②Firmware burning
In the terminal, enter make flash COMX=COMxxxx where xx is the COM port number of the actual connected downloader. In the figure below, COM port is 20.
Press the reset button as prompted to burn
(1) Enter the WiFi name and password you want to connect to in the network configuration menu.
(2) Enter your personal appid and appsecret after registering for Yike Cloud Weather in the weather account menu.
(3) Click the Connect button. If the configuration is correct, you will be redirected to the following interface.
In the main interface, click the corresponding area shown in the figure below to switch to the corresponding interface.
In the sub-interface, touch the bottom button to switch to the main interface.
Comments
Please log in or sign up to comment.