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