Skip to main content
MMust.5
Senior
November 15, 2023
Solved

How to send an image located on a USB drive to the display?

  • November 15, 2023
  • 8 replies
  • 2632 views
The USB drive is connected to the STM32F407VGT6, this USB drive contains images, I need to send these images to the display.
 
I already know how to send to the display an array that is located on a USB drive.
I convert the image into an array, for example with the program Image2Lcd Ver3.2 
And I send this array to the display with the following code:

 

char line[100];
uint32_t Num;
while(f_gets(line, 2, &USBHFile))
{
if(line[0] == 'x' || line[0] == 'X')
 {
 char hex[10]={"0x"};
 f_gets(line, 3, &USBHFile);
 strcat(hex,line);
 Num=strtol(hex, NULL, 16);
 while(!(SPI1->SR & SPI_SR_TXE));
 SPI1->DR = Num;
 while(!(SPI1->SR & SPI_SR_TXE));
 }
}

 

I don't understand now how to send images to the display without conversion.
I need at least an algorithm of actions. I don’t understand what needs to be done in order to send an image to the display without converting the image to an array.
 
This topic has been closed for replies.
Best answer by Tesla DeLorean

The images will be an array of actual bytes, not hex encodings in ASCII, and might be in a graphics file format like JPEG or BMP.

A BMP file can describe several different bit/colour depths, and usually in a raster line format.

You'd read data with f_read(), or on a PC with fread(). Suggest you get a File View or File Manager were you can inspect and understand the byte level content as in the file, and as read directly into memory.

8 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
November 15, 2023

The images will be an array of actual bytes, not hex encodings in ASCII, and might be in a graphics file format like JPEG or BMP.

A BMP file can describe several different bit/colour depths, and usually in a raster line format.

You'd read data with f_read(), or on a PC with fread(). Suggest you get a File View or File Manager were you can inspect and understand the byte level content as in the file, and as read directly into memory.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MMust.5
MMust.5Author
Senior
November 15, 2023

If I now convert the image to an array then get this type of data in a text file:

0XC6,0X10,0XC6,0X10,0X86,0X10,0XC6,0X10,0XC6,0X10,0XC6,0X10,0XC7,0X10,0XC7,0X10, 0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,

I read a text file with the function

 f_gets(line, 2, &USBHFile)

I can also read the image using the f_gets function and get the same data type? 

0XC6,0X10,0XC6,0X10,0X86,0X10,0XC6,0X10,0XC6,0X10,0XC6,0X10,0XC7,0X10,0XC7,0X10, 0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,0XC7,0X10,
Pavel A.
November 15, 2023

You think a byte is 32 bits? Seriously?

 

MMust.5
MMust.5Author
Senior
November 15, 2023

uint32_t byte;

32 bits== 4 bytes

No, of course not, I didn't think so.

The variable name is probably just wrong.

If I thought so, I wouldn't shift the bits in the "byte" variable
SPI1->DR = byte>>24;

I only needed one byte from the "byte" variable, so I called it that.
My SPI1->DR register is 8 bit.

Pavel A.
November 15, 2023