FreeRTOS Tetris
Functions
GUI Module

Module handling the Graphical User Interface. More...

Collaboration diagram for GUI Module:

Functions

void vGUIDrawMainMenu (game_mode_t mode, player_mode_t playerMode, rotation_t rotationMode, bool isConnected)
 Draw the main menu. More...
 
bool bGUIDrawLevelScreen (uint8_t *currentLevel, const score_t highScores[])
 Draw the level selection & highscores screen. More...
 
void vGUIDrawStatic (const image_handle_t squares[], const score_t *score)
 Draw the wall, score, level & number of lines completed. More...
 
void vGUIDrawPauseMenu (bool isConnected)
 Draw the Pause Menu. More...
 
void vGUIDrawGameOverMenu (score_t *score, char *lastUserName)
 Draw the Game-Over Menu. More...
 
bool bGUIDrawPlayerModeSelection (player_mode_t *playerMode)
 Draw the player-mode selection in Main Menu. More...
 
bool bGUIDrawRotationSelection (rotation_t *rotationMode)
 Draw rotation-mode selection in Main Menu. More...
 
bool bGUIDrawLevelMenuSelection (void)
 Draws & let the player switch to the level selection/highscores screen. More...
 
void vGUIDrawTetromino (const tetromino_t *tetromino, const image_handle_t squares[])
 Draw the current Tetromino. More...
 
void vGUIDrawLanded (const color_t landed[ROWS][COLS], const image_handle_t squares[])
 Draw the array of landed tetrominos. More...
 
void vGUIDrawNextTetromino (const tetromino_t *tetromino, const image_handle_t squares[])
 Draw the upcoming Tetromino in the upper right corner. More...
 
void vGUIDrawFPS (void)
 Draw an FPS counter.
 
void vGUISetImageHandle (image_handle_t squares[])
 Takes an image_handle_t array & initializes it with the correct images. More...
 
static void checkDraw (uint8_t status, const char *msg)
 Check if drawing is possible. More...
 
static void drawUserNameSelection (score_t *score, char *lastUserName)
 Draw the User-Name selection. More...
 
static void drawHighScores (const score_t highScores[])
 Draw the three hightest scores. More...
 
static void drawGameModes (game_mode_t currentMode)
 Draw the available game modes. More...
 
static void drawText (char *str, int16_t x, int16_t y, uint32_t color)
 Draw text on the screen. More...
 

Widths & heights for the individual mode texts on the display.

#define MODE_EASY_WIDTH   60
 
#define MODE_FAIR_WIDTH   61
 
#define MODE_HARD_WIDTH   60
 
#define MODE_RANDOM_WIDTH   90
 
#define MODE_DETERMINISTIC_WIDTH   198
 
#define MODES_HEIGHT   500
 

Detailed Description

Module handling the Graphical User Interface.

This module handles all functionality related to drawing/displaying things on the screen. It uses the TUM Drawing API.

Authors
Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
Date
04.02.2021

Function Documentation

◆ bGUIDrawLevelMenuSelection()

bool bGUIDrawLevelMenuSelection ( void  )

#include <gui.h>

Draws & let the player switch to the level selection/highscores screen.

Returns
(bool): Whether the the button was pressed.

◆ bGUIDrawLevelScreen()

bool bGUIDrawLevelScreen ( uint8_t *  currentLevel,
const score_t  highScores[] 
)

#include <gui.h>

Draw the level selection & highscores screen.

Parameters
[in]currentLevel(uint8_t*): The currently selected level. If no level was selected, it is 0.
[in]highScores(const score_t): Array of the 3 highest scores.
Returns
(bool): Return true if the "Back to Main Menu"-button was clicked.

◆ bGUIDrawPlayerModeSelection()

bool bGUIDrawPlayerModeSelection ( player_mode_t playerMode)

#include <gui.h>

Draw the player-mode selection in Main Menu.

Parameters
[in]playerMode( player_mode_t *): Player mode object.
Returns
(bool): Whether the player-mode changed.

◆ bGUIDrawRotationSelection()

bool bGUIDrawRotationSelection ( rotation_t rotationMode)

#include <gui.h>

Draw rotation-mode selection in Main Menu.

Parameters
[in]rotationMode( rotation_t): Rotation mode object.
Returns
(bool): Whether the rotation-mode changed.

◆ checkDraw()

void checkDraw ( uint8_t  status,
const char *  msg 
)
static

#include <gui.c>

Check if drawing is possible.

Checks if tumDrawing functions return 0 (success) or 1 (failure) and sends and error message in case of failure.

Parameters
[in]status(uint8_t): Function to check.
[in]msg(const char *): Error message.

◆ drawGameModes()

void drawGameModes ( game_mode_t  currentMode)
static

#include <gui.c>

Draw the available game modes.

Parameters
[in]currentMode( game_mode_t): Currently selected game mode.

◆ drawHighScores()

void drawHighScores ( const score_t  highScores[])
static

#include <gui.c>

Draw the three hightest scores.

Parameters
[in]highScores(const score_t []): Sorted high-scores array.

◆ drawText()

void drawText ( char *  str,
int16_t  x,
int16_t  y,
uint32_t  color 
)
static

#include <gui.c>

Draw text on the screen.

Parameters
[in]str(char *): Text to draw.
[in]x(int16_t): X-coordinate.
[in]y(int16_t): Y-coordinate.
[in]color(uint32_t): Color (HEX).

◆ drawUserNameSelection()

void drawUserNameSelection ( score_t score,
char *  lastUserName 
)
static

#include <gui.c>

Draw the User-Name selection.

Function that draws & lets the player select one of 6 usernames. Usernames are defined in the Config module.

Parameters
[in,out]score(const score_t *): Scores to draw.
[in]lastUserName(char*): Selected User-Name.

◆ vGUIDrawGameOverMenu()

void vGUIDrawGameOverMenu ( score_t score,
char *  lastUserName 
)

#include <gui.h>

Draw the Game-Over Menu.

If no new Tetromino can be placed, the game is over. Display this menu in this case.

Parameters
[in]score( score_t): Score object that contains the score, level & amount of rows that were reached.
[in]lastUserName(char*): User-name that was last selected.

◆ vGUIDrawLanded()

void vGUIDrawLanded ( const color_t  landed[ROWS][COLS],
const image_handle_t  squares[] 
)

#include <gui.h>

Draw the array of landed tetrominos.

Parameters
[in]landed(const color_t [][]): Array of landed Tetrominos.
[in]squares(const image_handle_t []): Array containing the square images.

◆ vGUIDrawMainMenu()

void vGUIDrawMainMenu ( game_mode_t  mode,
player_mode_t  playerMode,
rotation_t  rotationMode,
bool  isConnected 
)

#include <gui.h>

Draw the main menu.

If in multi-player mode, draw available game modes.

Parameters
[in]mode( game_mode_t): Current game mode.
[in]playerMode( player_mode_t): Current player mode (either single or multi).
[in]rotationMode( rotation_t): Current rotation mode (either left or right) .
[in]isConnected(bool): Whether the opponent is connected in multi player mode.

◆ vGUIDrawNextTetromino()

void vGUIDrawNextTetromino ( const tetromino_t tetromino,
const image_handle_t  squares[] 
)

#include <gui.h>

Draw the upcoming Tetromino in the upper right corner.

Parameters
[in]tetromino(const tetromino_t *): Tetromino to draw.
[in]squares(const image_handle_t): Array containing the square images.

◆ vGUIDrawPauseMenu()

void vGUIDrawPauseMenu ( bool  isConnected)

#include <gui.h>

Draw the Pause Menu.

If the player pressed "Esc" while playing, this menu is shown.

Parameters
[in]isConnected(bool): If the connection was established in multi-player mode.

◆ vGUIDrawStatic()

void vGUIDrawStatic ( const image_handle_t  squares[],
const score_t score 
)

#include <gui.h>

Draw the wall, score, level & number of lines completed.

Parameters
[in]squares(const image_handle_t): Array containing the square images.
[in]score(const score_t): Score object

◆ vGUIDrawTetromino()

void vGUIDrawTetromino ( const tetromino_t tetromino,
const image_handle_t  squares[] 
)

#include <gui.h>

Draw the current Tetromino.

Iterate through the Tetrominos's shape array and draw each existing entry in the Tetromino's color.

Parameters
[in]tetromino(const tetromino_t *): Tetromino object to draw.
[in]squares(const image_handle_t []): Array containing the square images.

◆ vGUISetImageHandle()

void vGUISetImageHandle ( image_handle_t  squares[])

#include <gui.h>

Takes an image_handle_t array & initializes it with the correct images.

Parameters
[out]squares( image_handle_t []): Array to initialize