1. Product introduction

The intelligent electronic card Demo is an application developed based on the OpenHarmony system, which is mainly composed of a schedule information acquisition module, a real-time weather module, a time acquisition module, a timing reminder module and a UI display module. Through this device, we can not only check the schedule of the day at any time, set regular reminders, but also check the real-time weather conditions such as time, date, indoor and outdoor temperature and humidity, and air PM value.
1. Device running effect <br> Burn the firmware of OpenHarmony 1.0.1 on the Runhe Hi3516DV300 AI Camera development board, connect the development board to the network and install the smart electronic card application, then open the smart electronic card application, we can See the running effect diagram as follows:
图片
We can see the time, weather (left half of the screen) and schedule (right half of the screen) and other information obtained in real time, and can also select the reminder time by sliding the time selector in the upper right corner of the screen; the schedule information includes the start and end of the schedule Time, schedule name and schedule execution details, etc. When the schedule is received, it is as follows:
图片
2. Interaction between the device and the cloud
图片
After we update the schedule information in the digital housekeeper APP on the mobile phone, the corresponding information will be uploaded to the cloud, and the smart electronic card application we developed will actively obtain the schedule information in the cloud through the HTTP protocol and display and update it.
3. Description of the main functions of the smart electronic card<br>The smart electronic card can check the schedule of the day at any time after the network connection is configured. The schedule information includes the start and end time of the schedule, the schedule name and the execution details of the schedule; by setting the timing Reminder realizes fixed-point on-time reminder; you can also view real-time time, date, indoor and outdoor temperature and humidity, air PM value and other real-time weather conditions on the screen. Users can easily remember their own schedule through the user-friendly display service, and know whether the current weather conditions are suitable for outdoor sports. The user's life brings comfort and convenience.

2. Project process

The smart electronic card project relies on the OpenHarmony open source developer growth plan, and the advancement of the project is inseparable from the guidance and help of mentors. When I completed the project, I went through three stages: the construction of the development environment, the learning of the C++ language, and the development of the smart electronic card project.
Construction of the development environment <br>The source code compilation of this project is carried out in the Ubuntu environment. My development "equipment" only has a Windows computer, so if we want to carry out the next development and debugging, we must build a virtual environment in the Windows environment. machine, and then set up the corresponding compilation environment in the Ubuntu environment of the virtual machine. For the specific construction process, please refer to the development part of the smart electronic card.
C++ language learning <br>This device-side project is developed based on C++ language, but I only have C language foundation, so I realized C++ language learning with the help of online learning platforms and other learning platforms during the winter vacation. The UI components of this project There is no perfect development manual, so the project is officially rated as high development difficulty. The development of this project is inseparable from a lot of exploration, learning and practice. At the same time, the process of reading a large number of official library files has greatly improved my experience. proficiency in the C++ language.
The development of intelligent electronic card project <br>The logic diagram of the product of this project is as follows:
图片
The smart electronic card actively obtains the real-time time from the server through the sntp protocol; obtains the weather information in real time through the weather API, and gives some warm suggestions according to the weather conditions; actively obtains the information in the digital housekeeper of the mobile phone or tablet terminal through the http protocol on the HUAWEI CLOUD The set schedule shows the start and end time of the schedule, the schedule name and schedule details; by selecting the time in the time selector, it can play the role of regularly reminding the schedule.
I have compiled some understandings of the existing code during the development process in this article: Smart Electronic Cards - Device Side

3. Installation tutorial

In order to allow the small partners to run the code of the smart electronic card project on their own development boards, I will organize the tutorials for installing the project application as follows:
Hardware Preparation <br>PC with pre-installed Windows system; Hi3516DV300 IoT Camera development board; USB to serial cable, network cable (Windows workbench is connected to Hi3516DV300 development board through USB to serial cable and network cable). 1. After completing the construction of the development board environment (that is, completing the firmware burning and Ubuntu compilation environment construction, see the development of smart electronic cards for details), create a new team_x directory in the vendor directory of OpenHarmony:

 mkdir vendor/team_x

图片
2. Copy the code of the smart electronic card to the newly created team_x.
The code link that has been closed: electronic_board
https://gitee.com/openharmony-sig/knowledge_demo_smart_home/tree/master/dev/team_x/electronic_board_1
3. After that, the application can be compiled. There are two compilation instructions: hb set and hb build -f:
First enter in Terminal:

 hb set

Then use the up and down keys on the keyboard to select electronic_board, and then press Enter to select;
After full compilation, enter:
hb build -f
Success will be displayed when the compilation is complete.
4. After the compilation is completed, the libelectrBoard.so file in the out/hispark_taurus/electronic_board/libs/usr/ directory is our target application file. This file and the res and config.json files in the project directory are compressed and packaged into zip format ( The three files are directly compressed, and the folder cannot be compressed), and after changing the suffix name to hap, you can install the application by mounting NFS. For details, please refer to the "V. Document Directory" section below.

4. Project display

1. Code directory structure <br>The following is the directory structure of the core code on the device side:

 |—— BUILD.gn                              // 编译脚本
|—— res                                   // 图片资源文件
|—— config.json                           // 安装包所需要的json文件
|—— include
|       |—— electronic_board_ability.h   // 入口类的头文件
|       |—— electr_board_ability_slice.h // 主页面的头文件,包含了时间选择器
|       |—— shcedule_list_view.h          // 日程列表显示类的头文件
|       |—— weather_time_view.h           // 天气以及时间显示类的头文件
|       |—— native_base.h                 // 基类的头文件
|       |—— event_listener.h              // 事件定义及实现的类
|       |—— ui_config.h                   // 界面相关坐标定义的头文件
|       |—— schedule_server.h             // 日程服务相关定义的头文件
|       |—— schedule_info.h               // 日程内容类的头文件
|       |—— common.h                      // 天气获取相关定义的头文件
|       |—— sntp.h                        // 时间获取相关定义的头文件
|        |—— link_list.h                    // 链表相关定义函数的解释头文件
|        |—— schedule_net_status.h         // 获取与运行网络连接相关的头函数
|       |__ LinkList.h                    // 链表相关定义的头文件
|
|__ src
        |—— electronic_board_ability.cpp 
        |—— electr_board_ability_slice.cpp// 主页面相关实现
        |—— schedule_list_view.cpp        // 日程列表显示类的实现
        |—— weather_time_view.cpp         // 天气以及时间显示类的实现
        |—— common.c                      // 天气获取以及解析的实现
        |—— schedule_server.c             // 日程服务获取的显示
        |—— sntp.c                        // 网络实时时间获取的实现
        |—— schedule_net_status.c         // 获取与运行网络连接相关的实现
    |__ LinkList.c                        // 链表的实现

The code link that has been closed: electronic_board
https://gitee.com/openharmony-sig/knowledge_demo_smart_home/tree/master/dev/team_x/electronic_board_1
2. Result details demonstration <br>As shown in the figure below, the electronic card application function area is divided into three parts, the time and weather area on the left, the schedule area in the lower right area, and the timing setting area in the upper right area:
图片
In the time weather zone:
• The weather obtains the real-time weather information corresponding to the region through the API corresponding to the weather. • The real-time clock is obtained through the sntp protocol. name, start time and schedule content, as shown in the following figure:
图片
In the time selection area :
• Select the time to be reminded by sliding. When the real-time clock is the same as the time in the time selection area, a reminder message will appear. When the user receives the reminder message and resets the time in the time selection area, the reminder message will disappear, as shown in the following figure:
图片

5. Project experience

In fact, the project development process is not as boring as many people imagine. In my opinion, it is a very fulfilling thing to be able to develop a useful and valuable product. It is undeniable that learning a new language takes a lot of energy, but in the process of learning and project development, my ability is also improving rapidly. This feeling of learning and gaining is exactly what I am looking for.
The project was developed on the basis of the original code. The source code written by the teachers is very beautiful, and the language structure and construction method are worthy of my serious study. During the development process, I also encountered a lot of difficult things, because the boot of the first development board I got had a problem and could not complete the firmware burning. Later, I explored with my mentor for a while before finally replacing the development board. This problem has been solved, thanks to the help provided by the electronic enthusiasts official and tutors. Later, when building the compilation environment, there were also various problems. Thanks to the careful guidance of the tutor, Mr. Zhong, I finally solved all the problems.
It takes a long time to compile the source code once (20min+), so I am very cautious every time I modify the source code. After the application is mounted, there may be UI and functions that you are satisfied with, and various garbled characters may appear. There is no way to start the application, and this kind of debugging process similar to the "lottery" feeling is also unforgettable in retrospect.
All in all, I have learned a lot of new knowledge during the project development process. After seeing the expected functions developed and debugged, I am also full of a sense of accomplishment. I am grateful for the opportunity provided by the official and the careful teaching of the tutor.

6. Document directory

During the development process, I organized the ideas and so on into the following documents:
Note: If you only pursue the reproduction of the project content, just check the article "Development of Smart Electronic Cards" in "Development Documents".
The development of smart electronic cards https://blog.csdn.net/weixin_46836693/article/details/124312294?spm=1001.2014.3001.5501
1. Development documents <br>Development documents describe the specific development content and reproduction process of the development of intelligent electronic cards https://blog.csdn.net/weixin_46836693/article/details/124312294?spm=1001.2014.3001.5501
Smart electronic card - device side https://blog.csdn.net/weixin_46836693/article/details/124312456?spm=1001.2014.3001.5501
Smart Electronic Cards - Digital Butler https://blog.csdn.net/weixin_46836693/article/details/124312360?spm=1001.2014.3001.5501
2. Equipment debugging document The equipment debugging document introduces some problems encountered in the project development process and the corresponding solutions.
Hi3516DV300 development board firmware burning experiencehttps://blog.csdn.net/weixin_46836693/article/details/124312473?spm= 1001.2014.3001.5501
The experience of loading applications through NFC mount https://blog.csdn.net/weixin_46836693/article/details/124312536?spm=1001.2014.3001.5501
Experience in setting environment variables under Ubuntuhttps://blog.csdn.net/weixin_46836693/article/details/124312495?spm= 1001.2014.3001.5501
Smart Electronic Cards - The Use of Giteehttps://blog.csdn.net/weixin_46836693/article/details/124312569?spm= 1001.2014.3001.5501
Note: Mr. Zhong Luping's device-side development files have helped me a lot in the application development of smart electronic cards. The reference article links are as follows:
Intelligent electronic card application development file
https://gitee.com/openharmony-sig/knowledge_demo_smart_home/tree/master/dev/docs/electronic_borad#%E6%99%BA%E8%83%BD%E7%94%B5%E5%AD%90%E7 %89%8C%E7%AE%80%E4%BB%8B

图片


OpenHarmony开发者
160 声望1.1k 粉丝

OpenHarmony是由开放原子开源基金会(OpenAtom Foundation)孵化及运营的开源项目,