Relation between frame buffer and display width
Hello everyone,
I am using STM32L4R9AII with my custom board.
When i start to develop my project, cubemx didn't support my MCU. So, I got discovery board project from Touchgfx and changed a lots of things to adapt it to my custom board.
Now cubemx supports my MCU. I started to pass my project to cubemx project. My screen resolution is 400x400px via MIPI dsi. When i established my project from cubemx, it didnt work well. I put a box on screen, i could see the box color but every lines were different places.
I digged down deep:
I passed display width as 400px to cubemx. So, Touchgfx passed BlitOp.nSteps=400 to DMA2D.
But GFXMMU module knows evey line has 1024px, but display is 400px. BlitOp.nSteps must be 1024. When i check my old project and discovery board project from new version of cubemx, i found code below to fix it:
#define BSP_LCD_IMAGE_WIDTH (3072 / 2)
#ifndef GUI_FRAME_BUFFER_WIDTH
#define GUI_FRAME_BUFFER_WIDTH BSP_LCD_IMAGE_WIDTH
void TouchGFXHAL::setFrameBufferStartAddresses(void* frameBuffer, void* doubleBuffer, void* animationStorage)
{
bool useDoubleBuffering = (doubleBuffer != 0);
bool useAnimationStorage = (animationStorage != 0);
uint8_t* buffer = static_cast<uint8_t*>(frameBuffer);
frameBuffer0 = reinterpret_cast<uint16_t*>(buffer);
if (useDoubleBuffering)
{
buffer += GUI_FRAME_BUFFER_SIZE;
frameBuffer1 = reinterpret_cast<uint16_t*>(buffer);
}
else
{
frameBuffer1 = 0;
}
if (useAnimationStorage)
{
buffer += GUI_FRAME_BUFFER_SIZE;
frameBuffer2 = reinterpret_cast<uint16_t*>(buffer);
}
else
{
frameBuffer2 = 0;
}
USE_DOUBLE_BUFFERING = useDoubleBuffering;
USE_ANIMATION_STORAGE = useAnimationStorage;
FRAME_BUFFER_WIDTH = GUI_FRAME_BUFFER_WIDTH; //gui_frame_buffer_width is 1024
FRAME_BUFFER_HEIGHT = GUI_FRAME_BUFFER_HEIGHT;
// Make note of whether we are using double buffering.
doubleBufferingEnabled = useDoubleBuffering;
currFbBase = frameBuffer0;
}as you can see FRAME_BUFFER_WIDTH was changed with GUI_FRAME_BUFFER_WIDTH. GUI_FRAMEBUFFER_WIDTH came from GFXMMU that is (3072/3) 1024. So everything is OK.
the frame buffer was calculated and allocated memory according to 400x400px. But we said to toucghgfx, FRAME_BUFFER_WIDTH is 1024. At that moment i confused.
Depending on code above, do i need allocate extra memory for frame buffer? If no need, how can touchgfx deal with?
Best regards,
Murat
