2023-01-15 01:41 PM
I am trying to implement this using an ILI9341 display, like here helentronica.com/2021/01/22/touchgfx-on-a-custom-made-low-cost-board-with-the-ili9341-controller-over-spi/
The article at support.touchgfx.com/4.21/docs/development/scenarios/lowering-memory-usage-with-partial-framebuffer does not provide sufficient details for implementing this strategy using the latest generated code (STM32CubeIDE 1.11.00). A few issues:
Is there an up-to date version of this article somewhere I'm missing? Or a complete functioning example?
Sorry for not linking, "new" members can't post links.
2023-01-15 10:03 PM
You maybe sleep, weak is exactly for override , and you place it in touchgfxhal.
All constants and help variables is based on your implement send rect. DMA is pref.
2023-01-15 10:11 PM
Appreciate the reply, but I can't really make sense of what you're saying.
My point is that yes, I can use the __weak prefix to override the default implementation, but that change is not recommended and will be overwritten by the code generator.
As for the article, it is incomplete because it uses a variable that is obviously defined and updated elsewhere, to implement a desired behavior that is, likewise, undocumented.
2023-01-15 10:38 PM
example from generated
__weak void FrameBufferAllocatorWaitOnTransfer()
{
/* NOTE: This function should not be modified, when the fuction is needed,
* FrameBufferAllocatorWaitOnTransfer should be implemented in the user file
*/
}
you leave here as is
and in your any file place
void FrameBufferAllocatorWaitOnTransfer()
{
...
}
and write partial code is your job , not generator
ex.
volatile uint8_t IsTransmittingBlock_;
void UNIMM_dmacallback(void)
{
IsTransmittingBlock_ = 0;
DisplayDriver_TransferCompleteCallback();
}
for details you open demo project in touchgfx for G071 board.
2023-01-15 11:00 PM
Thank you, appreciate the reply. The logic you're describing is the exact same as in the blog post I linked to. However, it does not correspond to the latest documentation, which includes the new variable blockIsTransferred. This new variable, as far as I can tell, is supposed to tell the frameBufferAllocator to wait for a transfer when there are no free blocks.
/**
* Called by FrameBufferAllocator to wait for a LCD Transfer, when the allocator has no free
* blocks. The LCD driver can use this function to synchronize the UI thread with the
* transfer logic.
*/
void FrameBufferAllocatorWaitOnTransfer();
/**
* Called by FrameBufferAllocator when a block is drawn and therefore ready for transfer. The
* LCD driver should use this method to start a transfer.
*/
void FrameBufferAllocatorSignalBlockDrawn();
This blockIsTransferred variable appears in the documentation article, but is not explained, nor is it defined anywhere in the generated code.
All I'm trying to ascertain is which version is the right one (generated code or documentation) to get a proper implementation.
2023-01-16 12:28 AM
I got a working solution: make the declaration of startNewTransfer in TouchGFXGeneratedHAL to __weak, and override it in TouchGFXHAL with the implementation shown in the documentation. The whole thing looks like this:
static volatile bool blockIsTransferred = false;
namespace touchgfx
{
void FrameBufferAllocatorWaitOnTransfer()
{
while(!blockIsTransferred);
}
void FrameBufferAllocatorSignalBlockDrawn()
{
blockIsTransferred = false;
}
// A user must call touchgfx::startNewTransfer(); once transmitFrameBufferBlock() has successfully sent a block.
void startNewTransfer()
{
FrameBufferAllocator* fba = HAL::getInstance()->getFrameBufferAllocator();
// Free the previous transmitted block, marking it ready for rendering
fba->freeBlockAfterTransfer();
blockIsTransferred = true;
if (fba->hasBlockReadyForTransfer())
{
touchgfx::Rect r;
// Get pointer to block buffer and coordinates of the rect
const uint8_t* pixels = fba->getBlockForTransfer(r);
// Start transmission of the block
touchgfxDisplayDriverTransmitBlock((uint8_t*)pixels, r.x, r.y, r.width, r.height);
}
}
}
extern "C"
void DisplayDriver_TransferCompleteCallback()
{
// After completed transmission start new transfer if blocks are ready.
blockIsTransferred = false;
touchgfx::startNewTransfer();
}
The documentation and generated code should be updated accordingly.