FreeRTOS Emulator with SDL2 Based Graphics and Input Library  1.0
A POSIX wrapper to run FreeRTOS on an x86 machine with some basic input and output libraries aimed at making teaching FreeRTOS simpler.
draw.c File Reference

Example draw functions for drawing user objects. More...

#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semaphore.h"
#include "gfx_ball.h"
#include "gfx_font.h"
#include "gfx_event.h"
#include "gfx_utils.h"
#include "gfx_print.h"
#include "gfx_draw.h"
#include "buttons.h"
#include "draw.h"

Classes

struct  images
 
struct  animations
 

Macros

#define FPS_AVERAGE_COUNT   50
 
#define LOGO_FILENAME   "freertos.jpg"
 
#define CAVE_SIZE_X   SCREEN_WIDTH / 2
 
#define CAVE_SIZE_Y   SCREEN_HEIGHT / 2
 
#define CAVE_X   CAVE_SIZE_X / 2
 
#define CAVE_Y   CAVE_SIZE_Y / 2
 
#define CAVE_THICKNESS   25
 
#define TOTAL_NUMBER_OF_BALL_SPRITES   25
 
#define NUMBER_OF_BALL_FRAMES   24
 
#define BALL_FRAME_PERIOD_MS   40
 
#define MARIO_SEQUENCE_IMAGES   3
 
#define MARIO_START_IMAGE_X   12
 
#define MARIO_START_IMAGE_Y   204
 
#define MARIO_X_SPACING   4
 
#define MARIO_Y_SPACING   0
 
#define MARIO_WIDTH   15
 
#define MARIO_HEIGHT   16
 
#define MARIO_RUN_FRAME_PERIOD   200
 
#define BARREL_SEQUENCE_IMAGES   4
 
#define BARREL_START_IMAGE_X   245
 
#define BARREL_START_IMAGE_Y   76
 
#define BARREL_X_PADDING   2
 
#define BARREL_Y_PADDING   0
 
#define BARREL_WIDTH   12
 
#define BARREL_HEIGHT   12
 
#define BARREL_FRAME_PERIOD   100
 

Functions

void vCheckDraw (unsigned char status, const char *msg)
 
void vDrawClearScreen (void)
 Clears the screen to be white. More...
 
void vDrawCaveBoundingBox (void)
 
void vCreateWalls (wall_t **left_wall, wall_t **right_wall, wall_t **top_wall, wall_t **bottom_wall)
 Creates the four demo walls used. More...
 
void vDrawWalls (wall_t *left_wall, wall_t *right_wall, wall_t *top_wall, wall_t *bottom_wall)
 Draws the demo walls. More...
 
void vDrawBall (ball_t *ball)
 Draws a ball. More...
 
void vDrawMouseBallAndBoundingBox (unsigned char ball_color_inverted)
 Draws the ball moved by the mouse and its bounding box. More...
 
void vDrawHelpText (void)
 
void vDrawFPS (void)
 Draws the FPS value on the screen. More...
 
void vDrawLogo (void)
 
void vDrawStaticItems (void)
 Draws the help text and FreeRTOS logo on the screen. More...
 
void vDrawButtonText (void)
 Draws the status information of the button presses on the screen. More...
 
void vDrawInitImages (void)
 
void vDrawInitBallHorizontalAnimations (void)
 
void vDrawInitBallVerticalAnimations (void)
 
void vDrawInitMarioRunAnimation (gfx_image_handle_t donkey_kong_image)
 
void vDrawInitBarrelAnimation (gfx_image_handle_t donkey_kong_image)
 
void vDrawInitDonkeyKongAnimations (void)
 
void vDrawInitAnnimations (void)
 
void vDrawInitResources (void)
 Loads images, sprite sheets and creates the annimation sequences needed. More...
 
void vDrawSpriteStatic ()
 Draws the static sprite to the bottom right corner of the screen. More...
 
void vDrawSpriteResetDownwardSequence ()
 Resets the downward animation sequence for example purposes. More...
 
void vDrawSpriteAnimations (TickType_t xLastFrameTime)
 Draws the sprite annimation to the bottom right corner of the screen. More...
 

Variables

struct images my_images = { 0 }
 
struct animations my_animations = { 0 }
 

Detailed Description

Example draw functions for drawing user objects.

Author
Alex Hoffman
Date
23 January 2023
----------------------------------------------------------------------
Copyright (C) Alexander Hoffman, 2023
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
----------------------------------------------------------------------

Macro Definition Documentation

◆ BALL_FRAME_PERIOD_MS

#define BALL_FRAME_PERIOD_MS   40

◆ BARREL_FRAME_PERIOD

#define BARREL_FRAME_PERIOD   100

◆ BARREL_HEIGHT

#define BARREL_HEIGHT   12

◆ BARREL_SEQUENCE_IMAGES

#define BARREL_SEQUENCE_IMAGES   4

◆ BARREL_START_IMAGE_X

#define BARREL_START_IMAGE_X   245

◆ BARREL_START_IMAGE_Y

#define BARREL_START_IMAGE_Y   76

◆ BARREL_WIDTH

#define BARREL_WIDTH   12

◆ BARREL_X_PADDING

#define BARREL_X_PADDING   2

◆ BARREL_Y_PADDING

#define BARREL_Y_PADDING   0

◆ CAVE_SIZE_X

#define CAVE_SIZE_X   SCREEN_WIDTH / 2

◆ CAVE_SIZE_Y

#define CAVE_SIZE_Y   SCREEN_HEIGHT / 2

◆ CAVE_THICKNESS

#define CAVE_THICKNESS   25

◆ CAVE_X

#define CAVE_X   CAVE_SIZE_X / 2

◆ CAVE_Y

#define CAVE_Y   CAVE_SIZE_Y / 2

◆ FPS_AVERAGE_COUNT

#define FPS_AVERAGE_COUNT   50

◆ LOGO_FILENAME

#define LOGO_FILENAME   "freertos.jpg"

◆ MARIO_HEIGHT

#define MARIO_HEIGHT   16

◆ MARIO_RUN_FRAME_PERIOD

#define MARIO_RUN_FRAME_PERIOD   200

◆ MARIO_SEQUENCE_IMAGES

#define MARIO_SEQUENCE_IMAGES   3

◆ MARIO_START_IMAGE_X

#define MARIO_START_IMAGE_X   12

◆ MARIO_START_IMAGE_Y

#define MARIO_START_IMAGE_Y   204

◆ MARIO_WIDTH

#define MARIO_WIDTH   15

◆ MARIO_X_SPACING

#define MARIO_X_SPACING   4

◆ MARIO_Y_SPACING

#define MARIO_Y_SPACING   0

◆ NUMBER_OF_BALL_FRAMES

#define NUMBER_OF_BALL_FRAMES   24

◆ TOTAL_NUMBER_OF_BALL_SPRITES

#define TOTAL_NUMBER_OF_BALL_SPRITES   25

Function Documentation

◆ vCheckDraw()

void vCheckDraw ( unsigned char  status,
const char *  msg 
)

◆ vCreateWalls()

void vCreateWalls ( wall_t **  left_wall,
wall_t **  right_wall,
wall_t **  top_wall,
wall_t **  bottom_wall 
)

Creates the four demo walls used.

Parameters
left_wallDouble pointer to the wall handle for the left wall
right_wallDouble pointer to the wall handle for the right wall
top_wallDouble pointer to the wall handle for the top wall
bottom_wallDouble pointer to the wall handle for the bottom wall

◆ vDrawBall()

void vDrawBall ( ball_t ball)

Draws a ball.

Parameters
ballPointer to ball handle to be drawn

◆ vDrawButtonText()

void vDrawButtonText ( void  )

Draws the status information of the button presses on the screen.

◆ vDrawCaveBoundingBox()

void vDrawCaveBoundingBox ( void  )

◆ vDrawClearScreen()

void vDrawClearScreen ( void  )

Clears the screen to be white.

◆ vDrawFPS()

void vDrawFPS ( void  )

Draws the FPS value on the screen.

◆ vDrawHelpText()

void vDrawHelpText ( void  )

◆ vDrawInitAnnimations()

void vDrawInitAnnimations ( void  )

◆ vDrawInitBallHorizontalAnimations()

void vDrawInitBallHorizontalAnimations ( void  )

◆ vDrawInitBallVerticalAnimations()

void vDrawInitBallVerticalAnimations ( void  )

◆ vDrawInitBarrelAnimation()

void vDrawInitBarrelAnimation ( gfx_image_handle_t  donkey_kong_image)

◆ vDrawInitDonkeyKongAnimations()

void vDrawInitDonkeyKongAnimations ( void  )

◆ vDrawInitImages()

void vDrawInitImages ( void  )

◆ vDrawInitMarioRunAnimation()

void vDrawInitMarioRunAnimation ( gfx_image_handle_t  donkey_kong_image)

◆ vDrawInitResources()

void vDrawInitResources ( void  )

Loads images, sprite sheets and creates the annimation sequences needed.

◆ vDrawLogo()

void vDrawLogo ( void  )

◆ vDrawMouseBallAndBoundingBox()

void vDrawMouseBallAndBoundingBox ( unsigned char  ball_color_inverted)

Draws the ball moved by the mouse and its bounding box.

Parameters
ball_color_inverted

◆ vDrawSpriteAnimations()

void vDrawSpriteAnimations ( TickType_t  xLastFrameTime)

Draws the sprite annimation to the bottom right corner of the screen.

Parameters
xLastFrameTimeTicks since last frame

◆ vDrawSpriteResetDownwardSequence()

void vDrawSpriteResetDownwardSequence ( )

Resets the downward animation sequence for example purposes.

◆ vDrawSpriteStatic()

void vDrawSpriteStatic ( )

Draws the static sprite to the bottom right corner of the screen.

◆ vDrawStaticItems()

void vDrawStaticItems ( void  )

Draws the help text and FreeRTOS logo on the screen.

◆ vDrawWalls()

void vDrawWalls ( wall_t left_wall,
wall_t right_wall,
wall_t top_wall,
wall_t bottom_wall 
)

Draws the demo walls.

Parameters
left_wallPointer to the wall handle for the left wall
right_wallPointer to the wall handle for the right wall
top_wallPointer to the wall handle for the top wall
bottom_wallPointer to the wall handle for the bottom wall

Variable Documentation

◆ my_animations

struct animations my_animations = { 0 }

◆ my_images

struct images my_images = { 0 }