Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FATFileSystem
Menu/Menu.h
- Committer:
- ellisbhastroud
- Date:
- 2019-05-09
- Revision:
- 16:c8d68cbd1ae2
- Parent:
- 14:08ac9aaa34c3
File content as of revision 16:c8d68cbd1ae2:
#ifndef MENU_H
#define MENU_H
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "SDFileSystem.h"
#include <algorithm>
/** Enum for wall types */
enum MenuChoice {
START, /**< start screen */
HIGHSCORES, /**< highscores screen */
SETTINGS, /**< settings screen */
};
/** Menu Class
* @brief Library for navigating menu options
* @author Ellis Blackford Stroud
* @date May, 2018
*/
class Menu
{
public:
/** Constructor */
Menu();
/** Destructor */
~Menu();
/** Sets class variables initial values */
void init();
/**Enters welcome screen loop */
void welcome_loop(Gamepad &pad, N5110 &lcd);
/** Enters menu screen loop */
void menu_loop(Gamepad &pad, N5110 &lcd);
/** Enters start screen loop */
void start_loop(Gamepad &pad, N5110 &lcd);
/** Enters highscores screen loop */
void highscores_loop(Gamepad &pad, N5110 &lcd, SDFileSystem &sd);
/** Enters settings screen loop */
void settings_loop(Gamepad &pad, N5110 &lcd);
/** Returns frame rate
* @returns the current frame rate
*/
int get_frame_rate();
/** Returns brightness
* @returns the current brightness
*/
float get_brightness();
/** Returns start game flag state
* @returns the start game flag state
*/
bool get_start_game_flag();
/** Resets start game flag */
void reset_start_game_flag();
/** Returns the current menu screen
* @returns the current menu screen
*/
MenuChoice get_screen();
private:
void read_input(Gamepad &pad);
void sd_read(SDFileSystem &sd);
void change_screen();
void drawSettings(N5110 &lcd);
void drawSettingsBars(N5110 &lcd);
void move_cursor(N5110 &lcd);
void cursor_pos_0();
void cursor_pos_1();
void cursor_pos_2();
void drawCursor(N5110 &lcd);
MenuChoice _screen;
bool _start_game_flag;
int _cursor_pos;
float _pot;
float _contrast;
float _brightness;
int _frame_rate;
int *_highscores_array;
int _n;
Direction _joy_direction;
};
const int mini_logo[15][60] = { //"MINI" from logo shown on welcome screen
{ 0,0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0 },
{ 0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0 },
{ 0,0,0,1,1,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0 },
{ 0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0 },
{ 0,0,0,1,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0 },
{ 0,0,0,1,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0 },
{ 0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0 },
{ 0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,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