【RT-Thread Software Package Application Works】Photo Album
[Copy link]
First of all, I would like to give a good review to this board that RT-THREAD cooperated with Zhengdian Atom. Not only does it have an integrated WIFI chip, but its programming is almost the same as that of the STM32 series.
It's just what I want. This chip is a SOC chip. It also has many integrated peripherals. It's really a must-have for learning RT-THREAD.
I have been thinking about this album for a while. I think I can handle it with my ability.
It involves two major aspects, one is reading files from the SD card and the other is displaying them.
The SD card involves adding a file system, whether it can be read smoothly from the SD card, what is read out, and whether it can be displayed on the screen.
Although it is simple, it is not easy to do. Alas! There is no free breakfast.
1. Prepare album pictures
Here is a photo of Taobao Dongjiyuan (Northeast Building Blocks Design Institute), which I cut into a 240*240 small picture:
Then, use the modulo software to modulo the file, and get it in 16-bit true color 565 format with the high bit first and no file header:
This is not the end. Then use C2B conversion assistant to convert it to BIN file, that is, convert the array into BIN file.
It’s not over yet. Prepare an SD card and a card reader and transfer all the files to the SD card.
2. Building the environment and programming
At first I didn't like the RT-THRAD environment. Is menuconfig the same as LINUX? I spent a lot of money back then.
I bought a development board and more than a dozen books to study LINUX, so I was a little unhappy when I saw the interface.
But after using it for a while, I found it good. I chose the FS example, but it didn't show anything, so I added the display.
As for the ENV environment, the official website also has it. I won’t say much here. Type menuconfig in ENV
The following is the FS file system. There are reference instructions on the Internet. I don’t want to say more.
Then save
Type in the ENV environment
pkgs --update
Then type
scons --mdk5
Then you can program
My procedure is as follows: (electronic photo album)
Let me first explain the idea, which is to use a cache, loop read BIN files, and then display them immediately.
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-05-16 yangjie first implementation
*/
#include <rtthread.h>
#include <dfs_fs.h>
#include <drv_lcd.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include <dfs_posix.h>
uint8_t buffer[115200];
int fd,size;
uint8_t iii;
int main(void)
{
rt_device_t sd_device = RT_NULL;
lcd_clear(WHITE);
#ifdef BSP_USING_TF_CARD
/* 挂载 TF 卡中的文件系统,参数 elm 表示挂载的文件系统类型为 elm-fat 文件系统*/
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
{
LOG_I("Filesystem initialized!");
}
else
{
LOG_E("Failed to initialize filesystem!");
}
#endif /*BSP_USING_TF_CARD*/
while(1)
{
if(iii == 0)
fd = open("/tt1.bin",O_RDONLY);
else if(iii == 1)
fd = open("/tt2.bin",O_RDONLY);
else if(iii == 2)
fd = open("/tt3.bin",O_RDONLY);
else if(iii == 3)
fd = open("/tt4.bin",O_RDONLY);
if(fd >=0 )
{
size = read(fd,buffer,sizeof(buffer));
close(fd);
if(size < 0)
return 0;
}
lcd_show_image(0, 0, 240, 239, buffer);
iii++;
if(iii >= 3)
iii = 0;
}
return 0;
}
3. Verification
Here is a video. When converting the third frame to BIN file, it prompts that there is illegal data. I think it is because the conversion software encountered something that it could not recognize. It has nothing to do with this program.
I'll wait for a chance to improve it. I think my development boards are gathering dust, but this small board can actually show the pictures I like. I have to take it out more often to look at it.
Here is the video link:
https://v.youku.com/v_show/id_XNDQ1NDI4ODYyMA==.html?spm=a2h3j.8428770.3416059.1
This content is originally created by EEWORLD forum user ddllxxrr . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source
|