【AT-START-F425 Review】Reading USB files to achieve image reproduction
[Copy link]
This post was last edited by jinglixixi on 2022-4-21 13:39
Since the core chip used by AT-START-F425 is a USB-oriented microcontroller and provides corresponding USB flash drive reading and writing functions, it can realize two applications, namely, one is to use the file reading function to build a picture library or character library to expand the storage space, and the other is to use the file storage function to act as a data recording device.
Here we will first introduce its reading function to realize image reproduction. Of course, the premise is that the prepared image file has been stored in the U disk, and secondly, there is the support of a color display. The display used here is a 0.96-inch OLED color display.
For testing purposes, a monochrome image file is first stored in the file, and its display effect is shown in Figure 1.
Figure 1 Test effect
The statement to determine whether the specified file is opened is:
if(f_open(&file, "0: zsh.bmp", FA_READ) != FR_OK)
When the specified file is opened successfully, the display program is:
for(i=0;i<N;i++)
{
res = f_read(&file, read_datp, sizeof(read_datp), &len);
// 绘制一行彩线
for(j=0;j<80;j++)
{
LCD_WR_DATA8(gImage_cgq[j*2]);
LCD_WR_DATA8(gImage_cgq[j*2+1]);
}
}
From the test results, we can see that there is no problem in opening the *.BMP file, and its data can be read and displayed.
Next, a parameter picture display can be generated, and the effect is shown in Figure 2.
Figure 2 Display image
The program to display this effect is:
if(f_open(&file, "0:YX32.bin", FA_READ) != FR_OK)
{
USBH_DEBUG("Open AT32.txt failed");
}
else
{
for(i=0;i<80;i++)
{
res = f_read(&file, read_datp, sizeof(read_datp), &len);
for(j=0;j<160;j++)
{
LCD_WR_DATA8(read_datp[j*2]);
LCD_WR_DATA8(read_datp[j*2+1]);
}
}
if(res != FR_OK || len == 0)
{
USBH_DEBUG("Read AT32.txt failed");
}
else
{
USBH_DEBUG("Read AT32.txt Success");
}
f_close(&file);
}
f_mount(NULL, "", 0);
}
After completing the above basic tests, we can explore the reading of multiple files to realize the function of digital photo frame. The display effect is shown in Figures 3 and 4.
Figure 3 Digital photo frame effect 1
Figure 4 Digital photo frame effect 2
The program to implement this function is:
static usb_sts_type usbh_user_application(void)
{
usb_sts_type status = USB_OK;
FRESULT res;
int i,j,z;
uint32_t len;
res = f_mount(&fs, "", 0);
if(res == FR_OK)
{
for(z=0;z<3;z++)
{
if(z==0) f_open(&file, "0:YX32.bin", FA_READ);
if(z==1) f_open(&file, "0:HKTK.bin", FA_READ);
if(z==2) f_open(&file, "0:HY32.bin", FA_READ);
for(i=0;i<80;i++)
{
res = f_read(&file, read_datp, sizeof(read_datp), &len);
for(j=0;j<160;j++)
{
LCD_WR_DATA8(read_datp[j*2]);
LCD_WR_DATA8(read_datp[j*2+1]);
}
}
f_close(&file);
delay_ms(2000);
}
f_mount(NULL, "", 0);
}
return status;
}
From this we can see that the file reading function of the AT-START-F425 development board is still very powerful.
|