Hi everyone after a long time missing as I was designing a PCB I am back on programming. I need to load images on a 320*240 screen. So far I managed to load pictures 320*240 big and any other pictures with 320*x size where x can be any number between 1 to 240. But if I change the width of the picture (ie the 320) becomes sort of torsion (look on images below, the background is red in order to highlight where the picture starts and where it ends the size of this picture is 120*240). I have been trying to understand why this is happening but with no success :/. Below is the functions used to paint the picture, any help would be greatly appreciated thanks.
LCD_BMP((uint8_t*) ImageBuffer); // Calling the paint function from main
void LCD_BMP(uint8_t *bitmap) // painting the picture
{
uint32_t size = 100 * 240; // 100 = width, 240 = length
uint16_t *bitmap_ptr = (u16 *)bitmap;
LCD_SetCursor(0x00, 0x00);
LCD_SetDisplayWindow(0, 0, 100, 240); // Setting the position to start painting the picture from 0,0 and the size of the picture to be painted is 100*240
LCD_WriteRAM_Prepare(); // Prepare to write GRAM
volatile uint32_t dlycnt;
for(uint32_t index = 0; index<(size); index++)
{
LCD_Data = *bitmap_ptr++;
}
}
void LCD_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t width, uint16_t Height) // Setting up the painting area
{
uint32_t value = 0;
LCD_WriteReg(SSD2119_H_RAM_START_REG, Xpos);
if ((Xpos+width) >= LCD_PIXEL_WIDTH) {
LCD_WriteReg(SSD2119_H_RAM_END_REG, LCD_PIXEL_WIDTH-1);
} else {
LCD_WriteReg(SSD2119_H_RAM_END_REG, Xpos+width);
}
if ((Ypos+Height) >= LCD_PIXEL_HEIGHT) {
value = (LCD_PIXEL_HEIGHT-1) << 8;
} else {
value = (Ypos+Height) << 8;
}
value |= Xpos;
LCD_WriteReg(SSD2119_V_RAM_POS_REG, value);
LCD_SetCursor(Xpos, Ypos);
}
If you require any additional code in order to detect the problem write it in the comment section, I pasted the parts of the code where I guess the trouble is. Thank you once again .
These images are photos taken of the LCD screen in operation.
Image 1: 100*240 resolution picture
Image 2: 320*144 resolution picture:
Image 3: 320*240 resolution picture (full screen):
<html><head><title>Jive SBS</title></head>
<body><font face="arial,helvetica,sans-serif">
<b>Error</b><br><font size="-1">
An general error occurred while processing your request.
</font></font></body></html>