This post was last edited by Fillmore on 2020-4-10 13:50
I often forget things, such as what day it is today, what day of the week, and what I have to do on that day. Sometimes I write it down in a notebook, sometimes in WeChat, but sometimes I even forget where I wrote it down...
To deal with this situation, I made a desk calendar with a memo and put it on my workbench to remind myself of what I need to do.
Functional Description
Function list of the work : display the Gregorian calendar date, display the lunar calendar date, display the day of the week, display the anniversary, display the day's memo, display the daily selected sentences, click the touch button to select the date, mark the status of the to-do items, transfer the memo items to the cloud through MQTT, and connect the device to WIFI through the QR code.
List of software packages used by the work
1. EasyFlash software package
EasyFlash is an open source lightweight embedded Flash memory library that makes it easier for developers to develop common applications based on Flash memory.
Responsible for storing some configuration parameters.
2. fal software package
FAL (Flash Abstraction Layer) Flash abstraction layer is an abstraction layer for managing and operating Flash and Flash-based partitions, and unifies the Flash and partition operation APIs for the upper layer.
Parameter saving operations depend on this package.
3. airkissOpen software package
Tencent WiFi device one-click network configuration protocol can easily configure the device's WIFI network.
It helped me solve a series of networking troubles and allowed me to focus on completing business logic.
4. netutils package
A collection of all the network gadgets available in RT-Thread. I used the network time synchronization function. After the device is connected to the network, it will automatically synchronize the time, so I don't have to worry about whether the time is accurate.
5. pahomqtt software package
A set of MQTT client programs designed based on the Eclipse paho-mqtt source code package.
Communication with the server relies on this package, which allows me to easily communicate with my own MQTT server without having to worry about the implementation details and processes in the middle, and can focus more work on business processing.
6. cJSON package
A classic JSON format toolkit that can easily parse and encapsulate JSON data through API interfaces in C language.
All data transmitted via MQTT is processed through cJSON. The structured data is more concise and intuitive, allowing more attention to be paid to business logic.
7. u8g2-c software package
u8g2 is a monochrome screen driver, through which I successfully drove the ink screen. Using its rich API, I vividly displayed the data on the ink screen.
8. [New] lunar_calendar package
lunar_calendar is a package of tools for converting Gregorian dates to lunar dates.
There are two calendars for dates: the lunar calendar and the solar calendar. The software package repository does not have this software package, and as a desk calendar, it would be very incomplete without the lunar calendar. Therefore, I packaged the code for converting the solar calendar to the lunar calendar into a software package, which will also make it easier for more friends to convert the lunar calendar in the future.
9. [New] bs8116a software package
bs8116a is the interrupt software package for Hetai's bs8116a-3 touch key chip.
I used bs8116a-3 touch buttons in this project, but the button software package in the software warehouse could not perfectly meet my needs, so I implemented the related business myself. One of the features of this software package is that it can use multiple i2c channels at the same time to connect multiple bs8116 touch chips. And through the form of interrupts, the system resource consumption is reduced. By configuring the relevant parameters, the effect of low power consumption can be achieved.
The above software packages can be found at the following address (please copy and open in an external browser): http://packages.rt-thread.org/
Hardware Block Diagram
Software Design
Logical Flowchart
The general process is as above, which is mainly divided into power-on, network configuration, and button clicking. Each part is relatively simple in logic, so I will not go into details.
Architecture
My main code is placed here, a total of 11 files, 8 C files, 2 header files, and 1 compiled file.
1applications
2├──SConscript/*编译文件*/
3├──defines.h/*变量函数声明*/
4├──init.c/*初始化*/
5├──keyboard.c/*键盘相关处理*/
6├──logic.c/*逻辑处理*/
7├──main.c/*主函数*/
8├──mqtt.c/*MQTT操作相关*/
9├──network.c/*网络操作相关*/
10├──qrcode_array.h/*配网二维码数组*/
11├──screen.c/*屏幕操作相关*/
12└──timer.c/*计时器*/
defines.h
1#defineMAX_TODO_SIZE8
2typedefstruct{
3charcontent[64];
4shortstatus;
5}TODO;
6typedefstruct{
7chardate[16];
8TODOtodo_list[MAX_TODO_SIZE];
9charfestival[64];
10charwords[256];
11}CALENDAR;
12externCALENDARcalendar_data;
The structure of the data I transfer is defined here, and most of the data is stored in this structure.
init.c
1/*集中初始化*/
2voidinit_all(void){
3fal_init();
4easyflash_init();
5init_mq();
6init_sem();
7init_keyboard();
8hwtimer_init();
9}
This function puts the various parts together and initializes them one by one in order.
The corresponding source codes have been open sourced.
Web interface
Code address
bs8116a-latest Code address:
lunar_calendar-latest Code address:
Project code address:
This issue is shared by Li Shuo, the first prize winner of the RT-Thread Software Package Competition
|