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.
Dependencies: mbed
Fork of el17dg by
settings.cpp
00001 #include "main.h" 00002 #include "menu.h" 00003 #include "constants.h" 00004 #include "settings.h" 00005 #include "gameobject.h" 00006 #include "models.h" 00007 00008 00009 Settings::Settings() { 00010 current_page = 0; 00011 } 00012 00013 GameObject settingsArrowLeft; 00014 GameObject settingsArrowRight; 00015 00016 bool Settings::updateAndWriteSettings(){ 00017 if(x_dir.read() > joy_threshold_max_x){ 00018 current_page -= 1; 00019 wait_ms(time_delay); 00020 } else if (x_dir.read() < joy_threshold_min_x){ 00021 current_page += 1; 00022 wait_ms(time_delay); 00023 } 00024 if (current_page < 0) { 00025 current_page += total_pages; 00026 } 00027 if (current_page >= total_pages) { 00028 current_page -= total_pages; 00029 } 00030 if (current_page == 0){ settingsPage0();} 00031 else if (current_page == 1){ settingsPage1();} 00032 00033 drawArrowsAndExitButton(); 00034 lcd.printString("Use the Pot",0,4); 00035 bool back_to_menu = false; 00036 if (gamepad.check_event(gamepad.B_PRESSED)){ 00037 //gamepad.check_event(gamepad.B_PRESSED); 00038 gamepad.check_event(gamepad.A_PRESSED); 00039 back_to_menu = true; 00040 } 00041 return back_to_menu; 00042 } 00043 00044 00045 void Settings::drawArrowsAndExitButton(){ 00046 char buffer[16]; 00047 sprintf(buffer,"page #%i", current_page); 00048 lcd.printString(buffer,20,0); 00049 00050 settingsArrowLeft.pos.x = 6; 00051 settingsArrowLeft.pos.y = 0; 00052 settingsArrowRight.pos.x = 66; 00053 settingsArrowRight.pos.y = 0; 00054 00055 drawSprite(settingsArrowRight.pos, tutorial_arrow_right_sprite); 00056 drawSprite(settingsArrowLeft.pos, tutorial_arrow_left_sprite); 00057 lcd.printString("Push B to Exit",0,5); 00058 } 00059 00060 void Settings::settingsPage0(){ 00061 lcd.setBrightness(pot.read()); 00062 lcd.printString("Set Brightness ",0,1); 00063 lcd.drawRect(3, 20, 70, 10, FILL_TRANSPARENT); 00064 lcd.drawRect(3, 20, 70*pot.read(), 10, FILL_BLACK); 00065 } 00066 00067 void Settings::settingsPage1(){ 00068 lcd.setContrast(pot.read()); 00069 lcd.printString("Set Contrast",0,1); 00070 lcd.drawRect(3, 20, 70, 10, FILL_TRANSPARENT); 00071 lcd.drawRect(3, 20, 70*pot.read(), 10, FILL_BLACK); 00072 } 00073
Generated on Thu Jul 14 2022 14:15:02 by
1.7.2
