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.
Options Class Reference
#include <Options.h>
Public Member Functions | |
| Options () | |
| Options Constructor. | |
| ~Options () | |
| Options Destructor. | |
| void | options_run (Gamepad &pad, N5110 &lcd) |
| Runs and controls all the options functions. | |
| void | options_brightness (Gamepad &pad, N5110 &lcd) |
| Controls the state of LCD backlight. | |
| void | options_contrast (Gamepad &pad, N5110 &lcd) |
| Controls the LCD contrast. | |
| void | options_volume (Gamepad &pad, N5110 &lcd) |
| Controls the state of game volume. | |
Detailed Description
Options Class.
This class is for the options menu screen.
- Version:
- 1.0
- Date:
- May 2019
Definition at line 20 of file Options.h.
Constructor & Destructor Documentation
| Options | ( | ) |
Options Constructor.
Builds my default Options contructor.
This does not have any setup.
Definition at line 10 of file Options.cpp.
| ~Options | ( | ) |
Options Destructor.
Builds my default Options destructor.
This does not have any setup.
Definition at line 16 of file Options.cpp.
Member Function Documentation
Controls the state of LCD backlight.
- Returns:
- None.
Toggles the backlight on LCD screen, ON/OFF based on button inputs.
void Options::options_brightness(Gamepad &pad, N5110 &lcd) { if (pad.check_event(Gamepad::B_PRESSED) == true) { // If B is pressed, will turn off backlight. opt_brightness = 0; } if (pad.check_event(Gamepad::A_PRESSED) == true) { // If A is pressed, will turn on backlight. opt_brightness = 0.5; } lcd.setBrightness(opt_brightness); lcd.printString("A/B = BackLite",0,2); }
Definition at line 42 of file Options.cpp.
Controls the LCD contrast.
- Returns:
- None.
Controls the LCD screen contrast based on gamepad potentiometer value.
void Options::options_contrast(Gamepad &pad, N5110 &lcd) { opt_contrast = pad.read_pot(); // Gets potentiometer value from gamepad and assigns it to a value. lcd.setContrast(opt_contrast); // Uses set value to change actual LCD contrast. lcd.printString("Pot = Contrast",0,3); printf("Contrast = %f", opt_contrast); }
Definition at line 54 of file Options.cpp.
Runs and controls all the options functions.
- Returns:
- None.
Prints the options menu, and controls various functions within the menu.
void Options::options_run(Gamepad &pad, N5110 &lcd) { wait_ms(250); while (pad.check_event(Gamepad::BACK_PRESSED) == false) { // Continues to show this screen until BACK button pressed. //printf("Options State"); lcd.clear(); lcd.printString("Options",21,0); options_brightness(pad, lcd); // Calls brightness function within class. options_contrast(pad, lcd); // Calls contrast function within class. options_volume(pad, lcd); // Calls volume function within class. lcd.refresh(); // Reloads screen on every cycle, controlled by fps. Default set to 24. wait_ms(1.0f/24); } }
Definition at line 27 of file Options.cpp.
Controls the state of game volume.
- Returns:
- None.
Toggles the volume for the game, ON/OFF based on button inputs.
void Options::options_volume(Gamepad &pad, N5110 &lcd) { if (pad.check_event(Gamepad::Y_PRESSED) == true) { // If Y is pressed, will disable volume. opt_volume = 0; } if (pad.check_event(Gamepad::X_PRESSED) == true) { // If X is press, will enable volume. opt_volume = 1; pad.tone(2400, 0.2); // Plays a set of beeps to confirm the volume is on. wait_ms(200); pad.tone(2400, 0.2); wait_ms(200); pad.tone(2400, 0.2); } lcd.printString("X/Y = Volume",0,4); if (opt_volume == 0) { // Shows on screen the current volume state. lcd.printString("Off",36,5); } else { lcd.printString("On",36,5); } }
Definition at line 62 of file Options.cpp.
Generated on Tue Jul 12 2022 18:21:51 by
1.7.2