Kern Fowler / Mbed 2 deprecated Donkey_Kong_Game

Dependencies:   mbed

Revision:
10:28575a6eaa13
Child:
11:b288d01533cc
diff -r e6832bf222b7 -r 28575a6eaa13 lib/Options/Options.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/Options/Options.cpp	Tue May 07 22:49:13 2019 +0000
@@ -0,0 +1,76 @@
+/*
+ELEC2645 Project
+Options.cpp
+Class file for Options in Donkey Kong game.
+*/
+
+#include "Options.h"
+
+Options::Options()
+{
+
+}
+
+Options::~Options()
+{
+
+}
+
+void Options::options_init() {
+    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);
+    }
+    
+}
\ No newline at end of file