Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I successfully installed the LCD library with STM32F103C8T6
https://github.com/martnak/STM32-ILI9341/blob/master/Src/ILI9341/ILI9341_Touchscreen.cHello!
- We don't know where this library comes from
- We don't have access to the wiring
- We don't have access to your LCD documentation.
- We don't know what "a problem with displaying the image" means.
-> Does it display anything? Is it completely black? Can you initialize it? Can you get a uniform background but nothing else?
Are you trying to display characters and they don't display well?
Etc, etc...
Dora.
with communication SPIFrom the SD card, I can display text on the LCD, but the image is displayed in a partially colored way.
rom the SD card, I can display text on the LCD,
but the image is displayed in a partially colored way.
Hello, have good timeHello!
I checked your lcd library.
You are aware that it's a library for the touch panel only, right?
I mean, you cannot write a character with this library, not even a white background, nothing.
You can just read the position of where you press on the screen.
Beside this, you were saying you have "installed" the library. What I see is plain C code,
there is nothing to install. What did you do exactly?
Where do you see text on the image you posted? Did you write the "YL / 16"?
Where do you see an image. What do you mean by "partially colored way"?
Beside this, before messing with the SD card, you should solve the LCD first. Then when
it works, add the SD card. Or the other way around. I would start with the LCD as it
allows you to write error messages.
Yes, you are right. This library is related to the touch LCD, but I made some changes and was able to display text.
Hi,Hello!
So what you are saying is that the code you posted does not correspond to the problem you have?
Beside this, what you are saying is a bit scary: you modified the LCD touch screen program to display something?
(I hope not).
You should NEVER do that. The touch.c (whatever the name) should NOT display anything. If you do that, nobody
is ever going to hire you.
Let's do thing in the right sequence:
- Can you display a white screen, or a screen of a uniform color?
- Can you write a dot of another color on that screen?
As long as you cannot say yes to both of these questions, don't write anything else, don't mess with images,
don't mess with the SD card. And don't write these functions in touch.c, but in display.c.
Dora.
FATFS fs; // file system
FIL file; // File
FILINFO fno;
FRESULT fresult; // result
UINT br, bw; // File read/write count
/**** capacity related *****/
FATFS *pfs;
DWORD fre_clust;
uint32_t total, free_space;
int displayImage(const char* fname) {
// UART_Printf("Openning %s...\r\n", fname);
FIL file;
FRESULT res = f_open(&file, fname, FA_READ);
if(res != FR_OK) {
LCD_ShowString(0,10,"f_open() failed, res = %d\r\n",RED,WHITE,16,0);
return -1;
}
LCD_ShowString(0,30,"File opened, reading...\r\n",RED,WHITE,16,0);
unsigned int bytesRead;
uint8_t header[34];
res = f_read(&file, header, sizeof(header), &bytesRead);
if(res != FR_OK) {
LCD_ShowString(0,50,"f_read() failed, res = %d\r\n",RED,WHITE,16,0);
f_close(&file);
return -2;
}
if((header[0] != 0x42) || (header[1] != 0x4D)) {
LCD_ShowString(0,90,"Wrong BMP signature: 0x%02X 0x%02X\r\n",RED,WHITE,16,0);
f_close(&file);
return -3;
}
uint32_t imageOffset = header[10] | (header[11] << 8) | (header[12] << 16) | (header[13] << 24);
uint32_t imageWidth = header[18] | (header[19] << 8) | (header[20] << 16) | (header[21] << 24);
uint32_t imageHeight = header[22] | (header[23] << 8) | (header[24] << 16) | (header[25] << 24);
uint16_t imagePlanes = header[26] | (header[27] << 8);
uint16_t imageBitsPerPixel = header[28] | (header[29] << 8);
uint32_t imageCompression = header[30] | (header[31] << 8) | (header[32] << 16) | (header[33] << 24);
snprintf(buff, sizeof(buff), "Pixels offset: %lu\r\n ", imageOffset);
LCD_ShowString(0,110,buff,RED,WHITE,16,0);
snprintf(buff, sizeof(buff), "WxH: %lux%lu\r\n ", imageWidth, imageHeight);
LCD_ShowString(0,130,buff,RED,WHITE,16,0);
snprintf(buff, sizeof(buff), "Planes: %d\r\n ", imagePlanes);
LCD_ShowString(0,150,buff,RED,WHITE,16,0);
snprintf(buff, sizeof(buff), "Bits per pixel: %d\r\n ", imageBitsPerPixel);
LCD_ShowString(0,170,buff,RED,WHITE,16,0);
snprintf(buff, sizeof(buff), "Compression: %ld\r\n ", imageCompression);
LCD_ShowString(0,190,buff,RED,WHITE,16,0);
if((imageWidth != LCD_H) || (imageHeight != LCD_W)) {
// UART_Printf("Wrong BMP size, %dx%d expected\r\n", ST7735_WIDTH, ST7735_HEIGHT);
LCD_ShowString(0,210,"Wrong BMP size, %dx%d expected\r\n",RED,WHITE,16,0);
f_close(&file);
return -4;
}
if((imagePlanes != 1) || (imageBitsPerPixel != 24) || (imageCompression != 0)) {
LCD_ShowString(0,230,"Unsupported image format\r\n",RED,WHITE,16,0);
f_close(&file);
return -5;
}
res = f_lseek(&file, imageOffset);
if(res != FR_OK) {
snprintf(buff, sizeof(buff), "f_lseek() failed, res = %d\r\n ", res);
LCD_ShowString(0,250,buff,RED,WHITE,16,0);
f_close(&file);
return -6;
}
// row size is aligned to 4 bytes
uint8_t imageRow[(LCD_H * 3 + 3) & ~3];
for(uint32_t y = 0; y < imageHeight; y++) {
uint32_t rowIdx = 0;
res = f_read(&file, imageRow, sizeof(imageRow), &bytesRead);
if(res != FR_OK) {
snprintf(buff, sizeof(buff), "f_read() failed, res = %d\r\n", res);
LCD_ShowString(0,270,buff,RED,WHITE,16,0);
f_close(&file);
return -7;
}
for(uint32_t x = 0; x < imageWidth; x++) {
uint8_t b = imageRow[rowIdx++];
uint8_t g = imageRow[rowIdx++];
uint8_t r = imageRow[rowIdx++];
uint16_t color565 = COLOR565(r, g, b);
LCD_DrawPoint(x,imageHeight - y - 1,color565);
}
}
res = f_close(&file);
if(res != FR_OK) {
// UART_Printf("f_close() failed, res = %d\r\n", res);
snprintf(buff, sizeof(buff), "f_close() failed, res = %d\r\n", res);
LCD_ShowString(0,290,buff,RED,WHITE,16,0);
return -8;
}
return 0;
}
LCD_Init();
LCD_Fill(0,0,240,320,WHITE);
FRESULT res = f_mount(&fs, "", 0);
if(res != FR_OK) {
// UART_Printf("f_mount() failed, res = %d\r\n", res);
snprintf(buff, sizeof(buff), "f_mount() failed, res = %d\r\n", res);
LCD_ShowString(0,310,buff,RED,WHITE,16,0);
return -2;
}
LCD_ShowString(0,330,"f_mount() done!\r\n",RED,WHITE,16,0);
while (1)
{
displayImage("1.bmp");
displayImage("2.bmp");
displayImage("3.bmp");
displayImage("4.bmp");
displayImage("11.bmp");
displayImage("22.bmp");
}