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/SolarGraphScreen.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 SOLARGRAPHSCREEN_H |
OHstin | 3:7666de697752 | 2 | #define SOLARGRAPHSCREEN_H |
OHstin | 3:7666de697752 | 3 | |
OHstin | 3:7666de697752 | 4 | #include "GraphController.h" |
OHstin | 3:7666de697752 | 5 | |
OHstin | 3:7666de697752 | 6 | class SolarGraphScreen:public GraphController, public Button <SolarGraphScreen> |
OHstin | 3:7666de697752 | 7 | { |
OHstin | 3:7666de697752 | 8 | public: |
OHstin | 3:7666de697752 | 9 | SolarGraphScreen(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 | int changeScreen; |
OHstin | 3:7666de697752 | 15 | }; |
OHstin | 3:7666de697752 | 16 | |
OHstin | 3:7666de697752 | 17 | SolarGraphScreen::SolarGraphScreen(uint16_t backgroundColor) |
OHstin | 3:7666de697752 | 18 | :GraphController( backgroundColor, |
OHstin | 3:7666de697752 | 19 | "Power[W] vs Time[s]") |
OHstin | 3:7666de697752 | 20 | { |
OHstin | 3:7666de697752 | 21 | |
OHstin | 3:7666de697752 | 22 | } |
OHstin | 3:7666de697752 | 23 | |
OHstin | 3:7666de697752 | 24 | int SolarGraphScreen::start(){ |
OHstin | 3:7666de697752 | 25 | |
OHstin | 3:7666de697752 | 26 | // draw the graph |
OHstin | 3:7666de697752 | 27 | GraphController::drawAxes(); |
OHstin | 3:7666de697752 | 28 | |
OHstin | 3:7666de697752 | 29 | // attach interrupts to buttons |
OHstin | 3:7666de697752 | 30 | Button<SolarGraphScreen>::activateButtons(this); |
OHstin | 3:7666de697752 | 31 | |
OHstin | 3:7666de697752 | 32 | changeScreen = 0; |
OHstin | 3:7666de697752 | 33 | |
OHstin | 3:7666de697752 | 34 | |
OHstin | 3:7666de697752 | 35 | while (changeScreen == 0){ |
OHstin | 3:7666de697752 | 36 | GraphController::plotData(); |
OHstin | 3:7666de697752 | 37 | //wait_ms(100); |
OHstin | 3:7666de697752 | 38 | Thread::wait(100); |
OHstin | 3:7666de697752 | 39 | } |
OHstin | 3:7666de697752 | 40 | |
OHstin | 3:7666de697752 | 41 | // dettach interrupts to buttons |
OHstin | 3:7666de697752 | 42 | Button<SolarGraphScreen>::deActivateButtons(); |
OHstin | 3:7666de697752 | 43 | |
OHstin | 3:7666de697752 | 44 | return changeScreen; |
OHstin | 3:7666de697752 | 45 | } |
OHstin | 3:7666de697752 | 46 | |
OHstin | 3:7666de697752 | 47 | void SolarGraphScreen::buttonPressed(int button) |
OHstin | 3:7666de697752 | 48 | { |
OHstin | 3:7666de697752 | 49 | switch(button){ |
OHstin | 3:7666de697752 | 50 | |
OHstin | 3:7666de697752 | 51 | case BACKBUTTON: |
OHstin | 3:7666de697752 | 52 | // navigate to the previous screen |
OHstin | 3:7666de697752 | 53 | changeScreen = -1; |
OHstin | 3:7666de697752 | 54 | break; |
OHstin | 3:7666de697752 | 55 | |
OHstin | 3:7666de697752 | 56 | case SCROLLBUTTON: |
OHstin | 3:7666de697752 | 57 | // scroll to the next option |
OHstin | 3:7666de697752 | 58 | //ListController::scroll(); |
OHstin | 3:7666de697752 | 59 | break; |
OHstin | 3:7666de697752 | 60 | |
OHstin | 3:7666de697752 | 61 | case ENTERBUTTON: |
OHstin | 3:7666de697752 | 62 | // navigate to the selected option |
OHstin | 3:7666de697752 | 63 | //changeScreen = ListController::getCurrentOption(); |
OHstin | 3:7666de697752 | 64 | |
OHstin | 3:7666de697752 | 65 | default: |
OHstin | 3:7666de697752 | 66 | // do nothing |
OHstin | 3:7666de697752 | 67 | break; |
OHstin | 3:7666de697752 | 68 | } |
OHstin | 3:7666de697752 | 69 | } |
OHstin | 3:7666de697752 | 70 | #endif |