OSWrappers
This class specifies OS wrappers for dealing with the framebuffer semaphore and the VSYNC signal.
Public Functions
void | giveFrameBufferSemaphore() |
Release the framebuffer semaphore. | |
void | giveFrameBufferSemaphoreFromISR() |
Release the framebuffer semaphore in a way that is safe in interrupt context. | |
void | initialize() |
Initialize framebuffer semaphore and queue/mutex for VSYNC signal. | |
bool | isVSyncAvailable() |
This function checks if a VSync occurred after last rendering. | |
void | signalRenderingDone() |
Signal that the rendering of the frame has completed. | |
void | signalVSync() |
Signal that a VSYNC has occurred. | |
void | takeFrameBufferSemaphore() |
Take the framebuffer semaphore. | |
void | taskDelay(uint16_t ms) |
A function that causes executing task to sleep for a number of milliseconds. | |
void | taskYield() |
A function that causes the executing task to yield control to another thread. | |
void | tryTakeFrameBufferSemaphore() |
Attempt to obtain the framebuffer semaphore. | |
void | waitForVSync() |
This function blocks until a VSYNC occurs. | |
Public Functions Documentation
giveFrameBufferSemaphore
static void giveFrameBufferSemaphore | ( | ) |
Release the framebuffer semaphore.
giveFrameBufferSemaphoreFromISR
static void giveFrameBufferSemaphoreFromISR | ( | ) |
Release the framebuffer semaphore in a way that is safe in interrupt context.
Called from ISR.
initialize
static void initialize | ( | ) |
Initialize framebuffer semaphore and queue/mutex for VSYNC signal.
isVSyncAvailable
static bool isVSyncAvailable | ( | ) |
This function checks if a VSync occurred after last rendering.
The function is used in systems that cannot wait in waitForVSync (because they are also checking other event sources.
True if VSync occurred.
Note
signalRenderingDone is typically used together with this function.
signalRenderingDone
static void signalRenderingDone | ( | ) |
Signal that the rendering of the frame has completed.
Used by some systems to avoid using any previous vsync.
signalVSync
static void signalVSync | ( | ) |
Signal that a VSYNC has occurred.
Should make the vsync queue/mutex available.
Note
This function is called from an ISR, and should (depending on OS) trigger a scheduling.
takeFrameBufferSemaphore
static void takeFrameBufferSemaphore | ( | ) |
Take the framebuffer semaphore.
Blocks until semaphore is available.
taskDelay
static void taskDelay | ( | uint16_t | ms | ) | |
A function that causes executing task to sleep for a number of milliseconds.
This function is OPTIONAL. It is only used by the TouchGFX in the case of a specific frame refresh strategy (REFRESH_STRATEGY_OPTIM_SINGLE_BUFFER_TFT_CTRL). Due to backwards compatibility, in order for this function to be usable by the HAL the function must be explicitly registered: hal.registerTaskDelayFunction(&OSWrappers::taskDelay)
ms | The number of milliseconds to sleep. |
taskYield
static void taskYield | ( | ) |
A function that causes the executing task to yield control to another thread.
This function is used by the framework when it is necessary to wait a little before continuing (e.g. drawing).
The implementation should typically request the operating system to change to another task of similar priority. When running without an operating system, the implementation can run a very short task and return.
tryTakeFrameBufferSemaphore
static void tryTakeFrameBufferSemaphore | ( | ) |
Attempt to obtain the framebuffer semaphore.
If semaphore is not available, do nothing.
Note
must return immediately! This function does not care who has the taken the semaphore, it only serves to make sure that the semaphore is taken by someone.
waitForVSync
static void waitForVSync | ( | ) |
This function blocks until a VSYNC occurs.
Note
This function must first clear the mutex/queue and then wait for the next one to occur.