This program consists of the software developed for the ELEC5870M Individual Project. It runs on the mbed LPC1768. It uses the mbed RTOS to perform the following tasks: - Implements intuitive GUI with buttons, LCD TFT Display and LEDs. - Serial Communication with the RPi - I2C communication with INA219 voltage current sensors - Power control at the USB ports
Dependencies: Adafruit_GFX Adafruit_ST7735 INA219 MODSERIAL MbedJSONValue mbed-rtos mbed
Screens/LogDurationScreen.h@3:7666de697752, 2017-02-04 (annotated)
- Committer:
- OHstin
- Date:
- Sat Feb 04 20:17:44 2017 +0000
- Revision:
- 3:7666de697752
This version before adding serial communication and pathways
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OHstin | 3:7666de697752 | 1 | #ifndef LOGDURATIONSCREEN_H |
OHstin | 3:7666de697752 | 2 | #define LOGDURATIONSCREEN_H |
OHstin | 3:7666de697752 | 3 | |
OHstin | 3:7666de697752 | 4 | #include "ListController.h" |
OHstin | 3:7666de697752 | 5 | |
OHstin | 3:7666de697752 | 6 | class LogDurationScreen:public Button <LogDurationScreen> |
OHstin | 3:7666de697752 | 7 | { |
OHstin | 3:7666de697752 | 8 | public: |
OHstin | 3:7666de697752 | 9 | LogDurationScreen(uint16_t backgroundColor); |
OHstin | 3:7666de697752 | 10 | int start(); |
OHstin | 3:7666de697752 | 11 | void buttonPressed(int button); |
OHstin | 3:7666de697752 | 12 | |
OHstin | 3:7666de697752 | 13 | private: |
OHstin | 3:7666de697752 | 14 | void drawLogDurationScreen(); |
OHstin | 3:7666de697752 | 15 | int changeScreen; |
OHstin | 3:7666de697752 | 16 | ListController *list; // manages the list controller |
OHstin | 3:7666de697752 | 17 | bool scroll; // updated when a scroll event occurs |
OHstin | 3:7666de697752 | 18 | bool enter; // updated when an enter event occurs |
OHstin | 3:7666de697752 | 19 | uint16_t bgColor; // stores the background color |
OHstin | 3:7666de697752 | 20 | |
OHstin | 3:7666de697752 | 21 | }; |
OHstin | 3:7666de697752 | 22 | |
OHstin | 3:7666de697752 | 23 | LogDurationScreen::LogDurationScreen(uint16_t backgroundColor) |
OHstin | 3:7666de697752 | 24 | { |
OHstin | 3:7666de697752 | 25 | bgColor = backgroundColor; |
OHstin | 3:7666de697752 | 26 | |
OHstin | 3:7666de697752 | 27 | } |
OHstin | 3:7666de697752 | 28 | |
OHstin | 3:7666de697752 | 29 | int LogDurationScreen::start() |
OHstin | 3:7666de697752 | 30 | { |
OHstin | 3:7666de697752 | 31 | |
OHstin | 3:7666de697752 | 32 | // draw the screen |
OHstin | 3:7666de697752 | 33 | drawLogDurationScreen(); |
OHstin | 3:7666de697752 | 34 | |
OHstin | 3:7666de697752 | 35 | // attach interrupts to buttons |
OHstin | 3:7666de697752 | 36 | Button<LogDurationScreen>::activateButtons(this); |
OHstin | 3:7666de697752 | 37 | |
OHstin | 3:7666de697752 | 38 | changeScreen = 0; |
OHstin | 3:7666de697752 | 39 | scroll = false; |
OHstin | 3:7666de697752 | 40 | enter = false; |
OHstin | 3:7666de697752 | 41 | |
OHstin | 3:7666de697752 | 42 | |
OHstin | 3:7666de697752 | 43 | while (changeScreen == 0) { |
OHstin | 3:7666de697752 | 44 | //updateTile(); |
OHstin | 3:7666de697752 | 45 | |
OHstin | 3:7666de697752 | 46 | // if scroll event occured |
OHstin | 3:7666de697752 | 47 | if (scroll) { |
OHstin | 3:7666de697752 | 48 | // perform scroll on list |
OHstin | 3:7666de697752 | 49 | list->scroll(); |
OHstin | 3:7666de697752 | 50 | // reset variable |
OHstin | 3:7666de697752 | 51 | scroll = false; |
OHstin | 3:7666de697752 | 52 | } |
OHstin | 3:7666de697752 | 53 | |
OHstin | 3:7666de697752 | 54 | // enter event occured |
OHstin | 3:7666de697752 | 55 | if (enter) { |
OHstin | 3:7666de697752 | 56 | // read the current option on the list |
OHstin | 3:7666de697752 | 57 | changeScreen = list->getCurrentOption(); |
OHstin | 3:7666de697752 | 58 | } |
OHstin | 3:7666de697752 | 59 | //wait_ms(200); |
OHstin | 3:7666de697752 | 60 | Thread::wait(200); |
OHstin | 3:7666de697752 | 61 | } |
OHstin | 3:7666de697752 | 62 | |
OHstin | 3:7666de697752 | 63 | // release the memory held by the list |
OHstin | 3:7666de697752 | 64 | delete list; |
OHstin | 3:7666de697752 | 65 | |
OHstin | 3:7666de697752 | 66 | // dettach interrupts to buttons |
OHstin | 3:7666de697752 | 67 | Button<LogDurationScreen>::deActivateButtons(); |
OHstin | 3:7666de697752 | 68 | |
OHstin | 3:7666de697752 | 69 | return changeScreen; |
OHstin | 3:7666de697752 | 70 | } |
OHstin | 3:7666de697752 | 71 | |
OHstin | 3:7666de697752 | 72 | void LogDurationScreen::drawLogDurationScreen() |
OHstin | 3:7666de697752 | 73 | { |
OHstin | 3:7666de697752 | 74 | |
OHstin | 3:7666de697752 | 75 | // construct the list |
OHstin | 3:7666de697752 | 76 | list = new ListController( 0, |
OHstin | 3:7666de697752 | 77 | 0, |
OHstin | 3:7666de697752 | 78 | "Duration", |
OHstin | 3:7666de697752 | 79 | "30 seconds", |
OHstin | 3:7666de697752 | 80 | "10 minutes", |
OHstin | 3:7666de697752 | 81 | "", |
OHstin | 3:7666de697752 | 82 | "", |
OHstin | 3:7666de697752 | 83 | bgColor, |
OHstin | 3:7666de697752 | 84 | 2); |
OHstin | 3:7666de697752 | 85 | |
OHstin | 3:7666de697752 | 86 | // draw the list |
OHstin | 3:7666de697752 | 87 | list->drawList(); |
OHstin | 3:7666de697752 | 88 | } |
OHstin | 3:7666de697752 | 89 | |
OHstin | 3:7666de697752 | 90 | void LogDurationScreen::buttonPressed(int button) |
OHstin | 3:7666de697752 | 91 | { |
OHstin | 3:7666de697752 | 92 | switch(button) { |
OHstin | 3:7666de697752 | 93 | |
OHstin | 3:7666de697752 | 94 | case BACKBUTTON: |
OHstin | 3:7666de697752 | 95 | // navigate to the previous screen |
OHstin | 3:7666de697752 | 96 | changeScreen = -1; |
OHstin | 3:7666de697752 | 97 | break; |
OHstin | 3:7666de697752 | 98 | |
OHstin | 3:7666de697752 | 99 | case SCROLLBUTTON: |
OHstin | 3:7666de697752 | 100 | // scroll to the next option |
OHstin | 3:7666de697752 | 101 | scroll = true; |
OHstin | 3:7666de697752 | 102 | break; |
OHstin | 3:7666de697752 | 103 | |
OHstin | 3:7666de697752 | 104 | case ENTERBUTTON: |
OHstin | 3:7666de697752 | 105 | // navigate to the selected option |
OHstin | 3:7666de697752 | 106 | enter = true; |
OHstin | 3:7666de697752 | 107 | break; |
OHstin | 3:7666de697752 | 108 | |
OHstin | 3:7666de697752 | 109 | default: |
OHstin | 3:7666de697752 | 110 | // do nothing |
OHstin | 3:7666de697752 | 111 | break; |
OHstin | 3:7666de697752 | 112 | } |
OHstin | 3:7666de697752 | 113 | } |
OHstin | 3:7666de697752 | 114 | |
OHstin | 3:7666de697752 | 115 | #endif |