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: MMA8452 N5110 PowerControl beep mbed
Menu.h
- Committer:
- stevenle93
- Date:
- 2015-05-05
- Revision:
- 5:c0a58a6916f2
- Parent:
- 3:1974db5993ef
- Child:
- 6:3e8ce3108702
File content as of revision 5:c0a58a6916f2:
/**
@file Menu.h
@brief This header file contains the project menu and using FSM
@brief Revision 1.0
@author Huynh Minh Tuan Le
@date April 2015
*/
#ifndef MENU_H
#define MENU_H
#include "mbed.h"
#include "MMA8452.h"
#include "N5110.h"
#include "Game.h"
/**
@namespace ButtonA
@brief Button A of interrupting service
*/
InterruptIn ButtonA(p16);
/**
@namespace ButtonB
@brief Button B of interrupting service
*/
InterruptIn ButtonB(p15);
/**
@namespace ButtonD
@brief Button Down of interrupting service
*/
InterruptIn ButtonD(p24);
/**
@namespace ButtonU
@brief Button Up of interrupting service
*/
InterruptIn ButtonU(p23);
int BuAFlag = 0;
int BuBFlag = 0;
int BuDFlag = 0;
int BuUFlag = 0;
int state = 0;
int substate = 0;
void BuAPress()
{
BuAFlag = 1; //Set flag for button A
}
void BuBPress()
{
BuBFlag = 1; //Set flag for button B
}
void BuDPress()
{
BuDFlag = 1; //Set flag for button Down
}
void BuUPress()
{
BuUFlag = 1; //Set flag for button Up
}
class Menu
{
public:
/**
Welcome function
* @brief It shows a welcome message on screen.
*/
void welcome();
/**
The first sub menu of Main menu.
@brief It has same factor of the Main menu which are Main menu title, Play and Score.
@brief It shows a cursor of circle pointing at "Play" factor.
*/
void main();
/**
The Highscore sector contains the highest score of player and the current score they have.
*/
void highscore();
/**
The Startgame sector contains options of game difficulty.
* @brief It allows player to choose which difficulty to play.
*/
void gameset();
/**
The Yourscore sector is a place showing your current score.
*/
void yourscore();
};
void Menu::welcome()
{
lcd.drawRect(0,0,84,3,1);
lcd.drawRect(0,43,84,3,1);
lcd.printString("Steve ninja",10,2);
wait(1.0);
lcd.printString("Present",25,3);
wait(0.5);
int i = 0;
while(i<5) {
lcd.inverseMode();
wait(0.2);
lcd.normalMode();
wait(0.2);
i++;
}
lcd.clear();
}
/**
The first sub menu of Main menu.
*/
void Menu::main()
{
lcd.printString("MAIN MENU",16,1);
lcd.printString("Play",31,3);
lcd.printString("Score",28,4);
}
void Menu::highscore()
{
lcd.printString("HIGH SCORE",13,1);
lcd.printString("Easy",31,2);
lcd.printString("Normal",25,3);
lcd.printString("Hard",31,4);
}
void Menu::yourscore()
{
lcd.printString("YOUR SCORE",13,1);
lcd.printString("Main menu",16,3);
lcd.printString("Reset",16,4);
}
void Menu::gameset()
{
lcd.printString("GAME MODE",15,1);
lcd.printString("Easy",31,2);
lcd.printString("Normal",25,3);
lcd.printString("Hard",31,4);
}
#endif