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.
lib/Options/Options.cpp
- Committer:
- Kern_EL17KJTF
- Date:
- 2019-05-07
- Revision:
- 11:b288d01533cc
- Parent:
- 10:28575a6eaa13
- Child:
- 23:ecb74e52163d
File content as of revision 11:b288d01533cc:
/*
ELEC2645 Project
Options.cpp
Class file for Options in Donkey Kong game.
*/
#include "Options.h"
Options::Options()
{
}
Options::~Options()
{
}
float opt_brightness = 0.5;
float opt_contrast = 0.396;
int opt_volume = 1;
void Options::options_run(Gamepad &pad, N5110 &lcd) {
wait_ms(250);
while (pad.check_event(Gamepad::BACK_PRESSED) == false) {
//printf("Options State");
lcd.clear();
lcd.printString("Options",21,0);
options_brightness(pad, lcd);
options_contrast(pad, lcd);
options_volume(pad, lcd);
lcd.refresh();
wait_ms(1.0f/24);
}
}
void Options::options_brightness(Gamepad &pad, N5110 &lcd) {
if (pad.check_event(Gamepad::B_PRESSED) == true) {
opt_brightness = 0;
}
if (pad.check_event(Gamepad::A_PRESSED) == true) {
opt_brightness = 0.5;
}
lcd.setBrightness(opt_brightness);
lcd.printString("A/B = BackLite",0,2);
}
void Options::options_contrast(Gamepad &pad, N5110 &lcd) {
opt_contrast = pad.read_pot();
lcd.setContrast(opt_contrast);
lcd.printString("Pot = Contrast",0,3);
printf("Contrast = %f", opt_contrast);
}
void Options::options_volume(Gamepad &pad, N5110 &lcd) {
if (pad.check_event(Gamepad::Y_PRESSED) == true) {
opt_volume = 0;
}
if (pad.check_event(Gamepad::X_PRESSED) == true) {
opt_volume = 1;
pad.tone(2400, 0.2);
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) {
lcd.printString("Off",36,5);
} else {
lcd.printString("On",36,5);
}
}