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

Committer:
OHstin
Date:
Sat Feb 04 20:17:44 2017 +0000
Revision:
3:7666de697752
Child:
6:196a63a3378d
This version before adding serial communication and pathways

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OHstin 3:7666de697752 1 #ifndef LOGSCREEN_H
OHstin 3:7666de697752 2 #define LOGSCREEN_H
OHstin 3:7666de697752 3
OHstin 3:7666de697752 4 #include "ListController.h"
OHstin 3:7666de697752 5
OHstin 3:7666de697752 6 class LogScreen: public Button <LogScreen>
OHstin 3:7666de697752 7 {
OHstin 3:7666de697752 8 public:
OHstin 3:7666de697752 9 LogScreen(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 drawLogScreen();
OHstin 3:7666de697752 15 int changeScreen;
OHstin 3:7666de697752 16 ListController *list; // manages the list
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 LogScreen::LogScreen(uint16_t backgroundColor)
OHstin 3:7666de697752 23 {
OHstin 3:7666de697752 24 bgColor = backgroundColor;
OHstin 3:7666de697752 25
OHstin 3:7666de697752 26 }
OHstin 3:7666de697752 27
OHstin 3:7666de697752 28 int LogScreen::start(){
OHstin 3:7666de697752 29
OHstin 3:7666de697752 30 // draw the screen
OHstin 3:7666de697752 31 drawLogScreen();
OHstin 3:7666de697752 32
OHstin 3:7666de697752 33 // attach interrupts to buttons
OHstin 3:7666de697752 34 Button<LogScreen>::activateButtons(this);
OHstin 3:7666de697752 35
OHstin 3:7666de697752 36 changeScreen = 0;
OHstin 3:7666de697752 37 scroll = false;
OHstin 3:7666de697752 38 enter = true;
OHstin 3:7666de697752 39
OHstin 3:7666de697752 40
OHstin 3:7666de697752 41 while (changeScreen == 0){
OHstin 3:7666de697752 42
OHstin 3:7666de697752 43
OHstin 3:7666de697752 44 // scroll event occured
OHstin 3:7666de697752 45 if (scroll)
OHstin 3:7666de697752 46 {
OHstin 3:7666de697752 47 // perform scroll on the list
OHstin 3:7666de697752 48 list->scroll();
OHstin 3:7666de697752 49 // reset variable
OHstin 3:7666de697752 50 scroll = false;
OHstin 3:7666de697752 51 }
OHstin 3:7666de697752 52
OHstin 3:7666de697752 53 // enter event occured
OHstin 3:7666de697752 54 if (enter)
OHstin 3:7666de697752 55 {
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(500);
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<LogScreen>::deActivateButtons();
OHstin 3:7666de697752 68
OHstin 3:7666de697752 69 return changeScreen;
OHstin 3:7666de697752 70 }
OHstin 3:7666de697752 71
OHstin 3:7666de697752 72 void LogScreen::drawLogScreen(){
OHstin 3:7666de697752 73
OHstin 3:7666de697752 74 // construct the list
OHstin 3:7666de697752 75 list = new ListController( 0,
OHstin 3:7666de697752 76 0,
OHstin 3:7666de697752 77 "Logs",
OHstin 3:7666de697752 78 "View Logs",
OHstin 3:7666de697752 79 "New Logs",
OHstin 3:7666de697752 80 "Delete Logs",
OHstin 3:7666de697752 81 "",
OHstin 3:7666de697752 82 bgColor,
OHstin 3:7666de697752 83 3);
OHstin 3:7666de697752 84
OHstin 3:7666de697752 85 // draw the list
OHstin 3:7666de697752 86 list->drawList();
OHstin 3:7666de697752 87 }
OHstin 3:7666de697752 88
OHstin 3:7666de697752 89 void LogScreen::buttonPressed(int button)
OHstin 3:7666de697752 90 {
OHstin 3:7666de697752 91 switch(button){
OHstin 3:7666de697752 92
OHstin 3:7666de697752 93 case BACKBUTTON:
OHstin 3:7666de697752 94 // navigate to the previous screen
OHstin 3:7666de697752 95 changeScreen = -1;
OHstin 3:7666de697752 96 break;
OHstin 3:7666de697752 97
OHstin 3:7666de697752 98 case SCROLLBUTTON:
OHstin 3:7666de697752 99 // scroll to the next option
OHstin 3:7666de697752 100 scroll = true;
OHstin 3:7666de697752 101 break;
OHstin 3:7666de697752 102
OHstin 3:7666de697752 103 case ENTERBUTTON:
OHstin 3:7666de697752 104 // navigate to the selected option
OHstin 3:7666de697752 105 enter = true;
OHstin 3:7666de697752 106
OHstin 3:7666de697752 107 default:
OHstin 3:7666de697752 108 // do nothing
OHstin 3:7666de697752 109 break;
OHstin 3:7666de697752 110 }
OHstin 3:7666de697752 111 }
OHstin 3:7666de697752 112
OHstin 3:7666de697752 113 #endif