-
-
Notifications
You must be signed in to change notification settings - Fork 104
Minimal Demo
Alex Hoffman edited this page Apr 21, 2020
·
1 revision
The minimal demo does a few basic things. It creates a single task that gets the time from the Linux kernel and displays it on the screen. The things to note are:
- The task needs to check if 'q' has been pressed so it knows to exit. To do so it has to do a few things
- Each tick the task first calls
fetchEvents
which triggers the TUM Event library to poll the SDL backend for any new events. -
inputQueue
then provides a fresh buttons lookup table from the TUM Events library. - The buttons mutex is taken to allow for safe access to the buttons lookup table
- The buttons lookup table is queried to see if Q was pressed. This is done using the macro
#define KEYCODE(CHAR) SDL_SCANCODE_##CHAR
as all key scancodes are actually the SDL library scancodes. More information on them can be found here.
- Each tick the task first calls
- The task then wants to draw a string on the screen. To do this a few things are required.
- It must call
vBindDrawing
which bind the OpenGL Context to that thread, allowing it to draw using the TUM Draw API. This is the only drawing task and as such the task only calls this in its init code. - The Linux kernel is then queried for the REALTIME clock value, done using the
struct timespec
variablethe_time
and the syscallclock_gettime
. This returns the time in the format that is detailed here. - A string is formatted using
sprintf
which is then queried for its size usingtumGetTextSize
that will place the text's size in the variableour_time_strings_width
and return0
on success. - If
0
was returned then we have obtained the string's theoretical width on the screen and we can then draw it in the middle of the screen using a call totumDrawText
. - To show the newly drawn text on the screen we must trigger the screen to be updated, such that all changes can be drawn to the screen. This is done by calling
vDrawUpdateScreen
.
- It must call
- Finally the task sleeps for 1000 milliseconds (1 second) using
vTaskDelay
.
Authors: Philipp van Kempen, Alex Hoffman