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 LogScreen.h Source File

LogScreen.h

00001 #ifndef LOGSCREEN_H
00002 #define LOGSCREEN_H
00003 
00004 #include "ListController.h"
00005 
00006 class LogScreen: public Button <LogScreen>
00007 {
00008 public:
00009     LogScreen(uint16_t backgroundColor);
00010     int start();
00011     void buttonPressed(int button);
00012 
00013 private:
00014     void drawLogScreen();
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;   // stores the background color;
00020 };
00021 
00022 LogScreen::LogScreen(uint16_t backgroundColor)
00023 {
00024     bgColor = backgroundColor;
00025     
00026 }
00027 
00028 int LogScreen::start(){
00029     
00030     // draw the screen
00031     drawLogScreen();
00032     
00033     // attach interrupts to buttons
00034     Button<LogScreen>::activateButtons(this);
00035     
00036     changeScreen = 0;
00037     scroll = false;
00038     enter = false;
00039     
00040     
00041     while (changeScreen == 0){
00042  
00043         
00044         // scroll event occured
00045         if (scroll)
00046         {
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         {
00056             // read the current option on the list
00057             changeScreen = list->getCurrentOption();
00058         }
00059         //wait_ms(500);
00060         Thread::wait(200);    
00061     }
00062     
00063     // release the memory held by the list
00064     delete list;
00065     
00066     // dettach interrupts to buttons
00067     Button<LogScreen>::deActivateButtons();
00068     
00069     return changeScreen;
00070 }
00071 
00072 void LogScreen::drawLogScreen(){
00073        
00074     // construct the list
00075     list = new ListController( 0,
00076                      0,
00077                    "Logs",
00078                 "View Logs",
00079                 "New Logs",
00080                 "Delete Logs",
00081                 "",
00082                 bgColor,
00083                 3);
00084     
00085     // draw the list 
00086     list->drawList();   
00087 }
00088 
00089 void LogScreen::buttonPressed(int button)
00090 {
00091     switch(button){
00092         
00093         case BACKBUTTON:
00094             // navigate to the previous screen
00095             changeScreen = -1;
00096             break;
00097         
00098         case SCROLLBUTTON:
00099             // scroll to the next option
00100             scroll = true;
00101             break;
00102         
00103         case ENTERBUTTON:
00104             // navigate to the selected option
00105             enter = true;
00106             break;
00107             
00108         default:
00109             // do nothing
00110             break;    
00111     }
00112 }
00113 
00114 #endif