Rafael Zingler Posted May 2, 2019 Report Share Posted May 2, 2019 Hi, I'm currently using the frame buffer driver in a project with the LPC1788 microcontroller (which has an embedded LCD controller). I've implemented double buffering in the system, to eliminate the undesirable tear effect that appeared on the screen every time the driver put new content in the buffer. Thus, when the driver is pointing to buffer A, buffer B is being shown on the screen, and vice-versa. The operating system (enabled in gfxconf.h) I'm using is FreeRTOS. Another important thing was the need of a "policy" to decide when system must switch the buffers. For this, the option GDISP_NEED_AUTOFLUSH was set in the gfxconf.h file. In this way, I've implemented the board_flush() function, which starts a software timer. Thus, a little time after driver finishes writing, the timer callback function is called, and in the callback function the buffer switching is made (along with the data copy from the front to the back buffer). Basically, the idea is a "driver writing timeout", which makes the callback function be called, and inside it, the buffer switching. The problem I'm facing now is related to the moment on which the driver writes new data after finishing the last writing. If my callback function is still copying data from one buffer to the other and the driver writes new data, there is a data corruption in the "back buffer". I would like to know if anyone has an idea of how to solve this, or had been facing this same situation. Thanks in advance!! Link to comment Share on other sites More sharing options...
inmarket Posted May 5, 2019 Report Share Posted May 5, 2019 Your method of setting a timer is already an implemented option in ugfx. Check the flush options. You just need to implement the board_flush and set the option. Ugfx will then call your flush routine when and if needed. There are 2 ways to prevent corruption (after sing he inbuilt timer flush)... 1. Make the copy back a synchronous part of the flush routine, or 2. Start the copy back in the flush with a muted lock that is released when the copy back completes. Te driver pixel draw routine then needs to have a test to see if copy back is complete and if not wait until it is. Link to comment Share on other sites More sharing options...
Rafael Zingler Posted May 6, 2019 Author Report Share Posted May 6, 2019 Hi, thanks for the reply. It's already working with the GDISP_NEED_TIMERFLUSH enabled (100 ms). Very nice resource that I did'nt know yet!! Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now