Kern Fowler / Mbed 2 deprecated Donkey_Kong_Game

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Options.h Source File

Options.h

00001 #ifndef OPTIONS_H
00002 #define OPTIONS_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 
00008 /** External variables used inside and out of the class. */
00009 extern float opt_brightness;
00010 extern float opt_contrast;
00011 extern int opt_volume;
00012 
00013 /** Options Class
00014 *@brief This class is for the options menu screen.
00015 *@author Kern Fowler
00016 *@version 1.0
00017 *@date May 2019
00018 */
00019 
00020 class Options {
00021 
00022 public:
00023 /** Options Constructor 
00024 @brief Builds my default Options contructor.
00025 @details This does not have any setup. 
00026 */
00027 Options();
00028 /** Options Destructor 
00029 @brief Builds my default Options destructor.
00030 @details This does not have any setup. 
00031 */
00032 ~Options();
00033 // Mutators
00034 
00035 /** 
00036 *@brief Runs and controls all the options functions.
00037 *@param pad The Gamepad class is used.
00038 *@param lcd The N5110 class is used.
00039 *@return None.
00040 *@details Prints the options menu, and controls various functions within the menu.
00041 *@code
00042 void Options::options_run(Gamepad &pad, N5110 &lcd) {
00043     wait_ms(250);
00044     while (pad.check_event(Gamepad::BACK_PRESSED) == false) { // Continues to show this screen until BACK button pressed.
00045         //printf("Options State");
00046         lcd.clear();
00047         lcd.printString("Options",21,0);
00048         options_brightness(pad, lcd); // Calls brightness function within class.
00049         options_contrast(pad, lcd); // Calls contrast function within class.
00050         options_volume(pad, lcd); // Calls volume function within class.
00051         lcd.refresh(); // Reloads screen on every cycle, controlled by fps. Default set to 24.
00052         wait_ms(1.0f/24);
00053     }
00054 }
00055 @endcode
00056 */
00057 void options_run(Gamepad &pad, N5110 &lcd);
00058 /** 
00059 *@brief Controls the state of LCD backlight.
00060 *@param pad The Gamepad class is used.
00061 *@param lcd The N5110 class is used.
00062 *@return None.
00063 *@details Toggles the backlight on LCD screen, ON/OFF based on button inputs. 
00064 *@code
00065 void Options::options_brightness(Gamepad &pad, N5110 &lcd) {
00066     if (pad.check_event(Gamepad::B_PRESSED) == true) { // If B is pressed, will turn off backlight.
00067         opt_brightness = 0;
00068     }
00069     if (pad.check_event(Gamepad::A_PRESSED) == true) { // If A is pressed, will turn on backlight.
00070         opt_brightness = 0.5;
00071     }
00072     lcd.setBrightness(opt_brightness);
00073     lcd.printString("A/B = BackLite",0,2);
00074 }
00075 @endcode
00076 */
00077 void options_brightness(Gamepad &pad, N5110 &lcd);
00078 /** 
00079 *@brief Controls the LCD contrast.
00080 *@param pad The Gamepad class is used.
00081 *@param lcd The N5110 class is used.
00082 *@return None.
00083 *@details Controls the LCD screen contrast based on gamepad potentiometer value.
00084 *@code
00085 void Options::options_contrast(Gamepad &pad, N5110 &lcd) {
00086     opt_contrast = pad.read_pot(); // Gets potentiometer value from gamepad and assigns it to a value.
00087     lcd.setContrast(opt_contrast); // Uses set value to change actual LCD contrast.
00088     lcd.printString("Pot = Contrast",0,3);
00089     printf("Contrast = %f", opt_contrast);
00090 }
00091 @endcode
00092 */
00093 void options_contrast(Gamepad &pad, N5110 &lcd);
00094 /** 
00095 *@brief Controls the state of game volume.
00096 *@param pad The Gamepad class is used.
00097 *@param lcd The N5110 class is used.
00098 *@return None.
00099 *@details Toggles the volume for the game, ON/OFF based on button inputs.
00100 *@code
00101 void Options::options_volume(Gamepad &pad, N5110 &lcd) {
00102     if (pad.check_event(Gamepad::Y_PRESSED) == true) { // If Y is pressed, will disable volume.
00103         opt_volume = 0;
00104     }
00105     if (pad.check_event(Gamepad::X_PRESSED) == true) { // If X is press, will enable volume.
00106         opt_volume = 1;
00107         pad.tone(2400, 0.2); // Plays a set of beeps to confirm the volume is on. 
00108         wait_ms(200);
00109         pad.tone(2400, 0.2);
00110         wait_ms(200);
00111         pad.tone(2400, 0.2);
00112     }
00113     lcd.printString("X/Y = Volume",0,4);
00114     if (opt_volume == 0) { // Shows on screen the current volume state.
00115         lcd.printString("Off",36,5);
00116     } else {
00117         lcd.printString("On",36,5);
00118     }
00119 }
00120 @endcode
00121 */
00122 void options_volume(Gamepad &pad, N5110 &lcd);
00123 };
00124 
00125 #endif