Augustine Kizito / Mbed 2 deprecated Solar_Powered_Smart_Camera

Dependencies:   Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SettingsScreen.h Source File

SettingsScreen.h

00001 #ifndef SETTINGSSCREEN_H
00002 #define SETTINGSSCREEN_H
00003 
00004 #include "ListController.h"
00005 
00006 class SettingsScreen: public Button <SettingsScreen>
00007 {
00008 public:
00009     SettingsScreen(uint16_t backgroundColor);
00010     int start();
00011     void buttonPressed(int button);
00012 
00013 private:
00014     void drawSettingsScreen();
00015     int changeScreen;
00016     ListController *list;   // manages the list
00017     bool scroll;    // updated when a scroll event occurs
00018     bool enter;     // updated when an enter event occurs
00019     uint16_t bgColor;   // background color
00020 
00021 };
00022 
00023 SettingsScreen::SettingsScreen(uint16_t backgroundColor)
00024 {
00025 
00026     bgColor = backgroundColor;
00027 }
00028 
00029 int SettingsScreen::start()
00030 {
00031 
00032     // draw the screen
00033     drawSettingsScreen();
00034 
00035     // attach interrupts to buttons
00036     Button<SettingsScreen>::activateButtons(this);
00037 
00038     changeScreen = 0;
00039     scroll = false;
00040     enter = false;
00041 
00042 
00043     while (changeScreen == 0) {
00044         //updateTile();
00045         // scroll event occured
00046         if (scroll) {
00047             // perform scroll on the list
00048             list->scroll();
00049             // reset variable
00050             scroll = false;
00051         }
00052 
00053         // enter event occured
00054         if (enter) {
00055             // read the current option on the list
00056             changeScreen = list->getCurrentOption();
00057         }
00058         //wait_ms(500);
00059         Thread::wait(200);
00060     }
00061     
00062     // release memory occupied by list controller
00063     delete list;
00064 
00065     // dettach interrupts to buttons
00066     Button<SettingsScreen>::deActivateButtons();
00067 
00068     return changeScreen;
00069 }
00070 
00071 void SettingsScreen::drawSettingsScreen()
00072 {
00073 
00074     // construct the list
00075     
00076     /**
00077     list = new ListController( 0,
00078                                0,
00079                                "Settings",
00080                                "LCD Screen",
00081                                "Data Logs",
00082                                "",
00083                                "",
00084                                backgroundColor,
00085                                2);
00086                                
00087     **/
00088     
00089     list = new ListController( 0,
00090                                0,
00091                                "Settings",
00092                                "LCD Screen",
00093                                "",
00094                                "",
00095                                "",
00096                                backgroundColor,
00097                                1);
00098 
00099     // draw the list
00100     list->drawList();
00101 }
00102 
00103 void SettingsScreen::buttonPressed(int button)
00104 {
00105     switch(button) {
00106 
00107         case BACKBUTTON:
00108             // navigate to the previous screen
00109             changeScreen = -1;
00110             break;
00111 
00112         case SCROLLBUTTON:
00113             // scroll to the next option
00114             scroll = true;
00115             break;
00116 
00117         case ENTERBUTTON:
00118             // navigate to the selected option
00119             enter = true;
00120 
00121         default:
00122             // do nothing
00123             break;
00124     }
00125 }
00126 
00127 #endif