Initial publish

Dependencies:   mbed

Fork of el17dg by Dmitrijs Griskovs

Revision:
30:d454d0cb72bc
Parent:
26:676874c42883
Child:
36:207ec7db8648
--- a/settings/settings.cpp	Mon Apr 15 12:59:51 2019 +0000
+++ b/settings/settings.cpp	Tue Apr 16 21:16:33 2019 +0000
@@ -2,17 +2,74 @@
 #include "menu.h"
 #include "constants.h"
 #include "settings.h"
+#include "gameobject.h"
 
 
+Settings::Settings() {                              
+    current_page = 0;                     
+}                                          
+
+GameObject settingsArrowLeft;
+GameObject settingsArrowRight;
+
 bool Settings::updateAndWriteSettings(){
-    //setContrast();
+    if(x_dir.read() > joy_threshold_max_x){
+        current_page -= 1;
+        wait_ms(time_delay);    
+    } 
+    else if (x_dir.read() < joy_threshold_min_x){
+        current_page += 1;
+        wait_ms(time_delay); 
+    }
+    if (current_page < 0) {
+        current_page += total_pages;
+    }
+    if (current_page >= total_pages) {
+        current_page -= total_pages;
+    }  
+
     
-    lcd.printString("Push B to Exit",0,5);
+    if (current_page == 0){ settingsPage0();}
+    else if (current_page == 1){ settingsPage1();}
     
+    drawArrowsAndExitButton();
+    //lcd.printString("Push B to Exit",0,5);
+    lcd.printString("Use the Pot",0,4);
     bool back_to_menu = false; 
     if (gamepad.check_event(gamepad.B_PRESSED)){
+        gamepad.check_event(gamepad.B_PRESSED);
         back_to_menu = true; 
     }
     return back_to_menu;  
+}
+
+
+void Settings::drawArrowsAndExitButton(){
+    char buffer[16];
+    sprintf(buffer,"page #%i", current_page);
+    lcd.printString(buffer,20,0);
     
-}
\ No newline at end of file
+    settingsArrowLeft.pos.x = 6;
+    settingsArrowLeft.pos.y = 0;
+    settingsArrowRight.pos.x = 66;
+    settingsArrowRight.pos.y = 0;
+  
+    drawSprite(settingsArrowRight.pos, tutorial_arrow_right_sprite);
+    drawSprite(settingsArrowLeft.pos, tutorial_arrow_left_sprite);
+    lcd.printString("Push B to Exit",0,5);
+}
+
+void Settings::settingsPage0(){
+    lcd.setBrightness(pot.read());
+    lcd.printString("Set Brightness ",0,1);
+    lcd.drawRect(3, 20, 70, 10, FILL_TRANSPARENT);
+    lcd.drawRect(3, 20, 70*pot.read(), 10, FILL_BLACK);
+}
+
+void Settings::settingsPage1(){
+    lcd.setContrast(pot.read());
+    lcd.printString("Set Contrast",0,1);
+    lcd.drawRect(3, 20, 70, 10, FILL_TRANSPARENT);
+    lcd.drawRect(3, 20, 70*pot.read(), 10, FILL_BLACK);
+}
+