Question
How to transfer buffer to SPI LCD? This isn't it.
I'm really in need of some direction on how to get TouchGFX working on cheap LCD displays.
I'm using a SPI based LCD in a RGB565 format. I've tested the write commands with images, fonts, etc. but TouchGFX is not transferring correctly.
Here is my understanding of the engine and how to use it:
Implemented a flushFrameBuffer method to transfer the buffer to the display:
void TouchGFXHAL::flushFrameBuffer(const touchgfx::Rect& rect)
{
// Calling parent implementation of flushFrameBuffer(const touchgfx::Rect& rect).
//
// To overwrite the generated implementation, omit call to parent function
// and implemented needed functionality here.
// Please note, HAL::flushFrameBuffer(const touchgfx::Rect& rect) must
// be called to notify the touchgfx framework that flush has been performed.
// To calculate he start address of rect,
// use advanceFrameBufferToRect(uint8_t* fbPtr, const touchgfx::Rect& rect)
// defined in TouchGFXGeneratedHAL.cpp
uint8_t *fbPtr = reinterpret_cast<uint8_t*>(HAL::frameBuffer0);
fbPtr += rect.y * lcd().framebufferStride() + rect.x * 2;
ST7735_TouchFrameBuffer(rect.x, rect.y, rect.width, rect.height, fbPtr);
}The engine is being queued every 30ms.
extern "C"
void TE_Handler(void)
{
/* VSync has occurred, increment TouchGFX engine vsync counter */
touchgfx::HAL::getInstance()->vSync();
/* VSync has occurred, signal TouchGFX engine */
touchgfx::OSWrappers::signalVSync();
}Tried several different ideas on transferring the buffer. From the documentation, I've implemented the following:
void ST7735_TouchFrameBuffer(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint16_t *data)
{
__IO uint16_t* ptr;
uint32_t height;
ST7735_Select();
ST7735_SetAddressWindow(x, y, x + w - 1, y + h - 1);
for (height = 0; height < h ; height++)
{
ptr = data + x + (height + y) * 128;
ST7735_WriteData((uint8_t*) ptr, sizeof(uint16_t) * w);
}
ST7735_Unselect();
}And what I get is:
