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
Menu.h
00001 #ifndef MENU_H 00002 #define MENU_H 00003 00004 #include "mbed.h" 00005 #include "N5110.h" 00006 #include "Gamepad.h" 00007 #include "EngineController.h" 00008 00009 /** State for finite state machine struct */ 00010 struct State { 00011 int output; /**< Integer for output number. */ 00012 int next_state[4]; /**< Array of integers for next possible states. */ 00013 }; 00014 00015 /** Menu Class 00016 * @brief Class to control the overall state of the game 00017 * @author Lewis Wooltorton 00018 * @date April 2019 00019 00020 00021 @code 00022 00023 #include "N5110.h" 00024 #include "Gamepad.h" 00025 #include "mbed.h" 00026 #include "Menu.h" 00027 00028 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); 00029 Gamepad gamepad; 00030 Menu menu; 00031 00032 void init_game(); 00033 00034 int main() { 00035 gamepad.init(); 00036 menu.init(); 00037 lcd.init(); 00038 lcd.normalMode(); 00039 lcd.setBrightness(0.5); 00040 while(1) { 00041 00042 // clear, refresh lcd and run the menu. 00043 lcd.clear(); 00044 menu.run(lcd, gamepad); 00045 lcd.refresh(); 00046 wait(0.01); 00047 } 00048 } 00049 00050 @endcode 00051 */ 00052 00053 class Menu { 00054 public: 00055 // Constructor and Destructor. 00056 /** 00057 * @brief Constructor @details Non user specified. 00058 */ 00059 Menu(); 00060 /** 00061 * @brief Destructor @details Non user specified. 00062 */ 00063 ~Menu(); 00064 00065 // Mutators 00066 /** 00067 * @brief Initialises the Menu object. 00068 */ 00069 void init(); 00070 /** 00071 * @brief Runs the menu via a state machine. 00072 * @param &lcd @details The lcd object from the N5110 class 00073 * @param &gamepad @details The gamepad object from Gamepad class 00074 */ 00075 void run(N5110 &lcd, Gamepad &gamepad); 00076 00077 private: 00078 void set_input(bool start, bool back, bool x); 00079 void run_game(N5110 &lcd, Gamepad &gamepad); 00080 void display_menu(N5110 &lcd, Gamepad &gamepad); 00081 void display_controls(N5110 &lcd, Gamepad &gamepad); 00082 void output(N5110 &lcd, Gamepad &gamepad); 00083 void play_tone(Gamepad &gamepad); 00084 void play_chord_a(Gamepad &gamepad); 00085 void play_chord_b(Gamepad &gamepad); 00086 00087 int _menu_input; 00088 EngineController _controller; 00089 bool _button; 00090 int _state; 00091 int _output; 00092 bool _tone_flag; 00093 int _tone_counter; 00094 int _chord_counter; 00095 }; 00096 #endif
Generated on Mon Jul 18 2022 14:06:02 by
1.7.2