This post was last edited by jinglixixi on 2020-10-19 16:26
Ever since I got my first CH554 development board, I have been looking forward to having a development board that can read USB flash drives. Later, the CH579M EVT development board came out, but unfortunately it did not work as I wished, so I focused my efforts on the CH579M- R1 development board.
Although the peripherals of CH579M-R1 are much different from those of CH579M EVT , it is still possible to use it to read and write data on a USB flash drive.
Since the functions provided by the routine are not very complete, I invested a lot of time and energy in this aspect, but there was not much progress. It was not until recent days that I finally completed the expected goal, combining the color OLED screen with the USB flash drive reading and writing functions to realize a mini version of the digital photo frame.
During this period, the following experiences were experienced:
1. Read the information in the USB flash drive and display its contents on the OLED screen
1 ) First create a new file " CH579HFT.TXT ", and then write the string " CH579M-R1 OK " and other information into it as shown in Figure 1 .
Figure 1 Create a new file
2 ) The read content is displayed through serial communication, as shown in Figure 2. The statement TotalCount = 12; is used to limit the length of the bytes read.
Figure 2 shows the read content
3 ) Add OLED screen display program, through the statement OLED_ShowString(0,0,mCmdParam.ByteRead.mByteBuffer,16);
To display the read content, see Figure 3 .
Figure 3 OLED screen display
2. Read the fonts in the USB flash drive and display Chinese characters on the OLED screen
Based on the previous character reading and writing, we can transform it to read byte data, so as to build a soft character library with a USB flash drive, and realize the display of Chinese characters through the OLED screen and display function.
1 ) Taking the 10 Chinese characters of "海存挚友天涯若比邻" as an example, first use font extraction software to extract its fonts, as shown in Figure 4 .
Figure 4 Extracting fonts
2 ) Arrange the files generated by the font template into the format required by the conversion software, and then convert them to obtain the binary file storing the font template, as shown in Figure 5 .
Figure 5 Data format conversion
3 ) The data was reviewed through the tool software, as shown in Figure 6. After review, the contents of the two were consistent, but the data types were different.
Figure 6 Review BIN file
4 ) The character mold is read in batches through serial communication, 32 bytes each time. The result is shown in Figure 7. It is determined that the reading is correct.
Figure 7 Reading the font
5 ) Configure the corresponding Chinese character display function to realize the reading and writing of the font and the reproduction of Chinese characters, as shown in Figure 8 .
Figure 8 Chinese characters reproduced by soft font library
3. Read the BMP file in the USB flash drive and display the image on the OLED color screen
We can regard each Chinese character as a black and white picture. With the foundation of Chinese character display, we can try to display pictures with a color OLED screen.
- The tool software is used to prepare an image file for display on the OLED screen. The length and width of the image are 160*80 pixels, and its content is shown in FIG9 .
Figure 9 Image processing
- Modify the image display function and split it up to integrate it into the data reading process. The effect after running is shown in Figure 10 .
Figure 10 Image display
4. Realization of digital photo frame functions
With the image display function, we can use the large capacity of the USB flash drive to manage a large number of files to realize the function of a digital photo frame. The basic implementation is that after displaying each picture, another picture file is opened after a delay to read and display it. The effect is shown in Figures 11 to 13 .
Figure 11 Cartoon picture
Figure 12 Landscape picture
Figure 13 shows the details
The goal of reading USB flash disk on CH579M-R1 development board has been achieved, and it has the function of digital photo frame. CH579M is a very powerful chip. I sincerely hope to get a CH579M EVT development board to further explore the SD card reading and writing functions to unleash its greater potential.
|