
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
Icons/SettingsIcon.h@6:196a63a3378d, 2017-04-30 (annotated)
- Committer:
- OHstin
- Date:
- Sun Apr 30 17:19:22 2017 +0000
- Revision:
- 6:196a63a3378d
- Parent:
- 3:7666de697752
Final Code for mbed operation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
OHstin | 2:104bec169fb6 | 1 | #ifndef SETTINGSICON_H |
OHstin | 2:104bec169fb6 | 2 | #define SETTINGSICON_H |
OHstin | 2:104bec169fb6 | 3 | |
OHstin | 2:104bec169fb6 | 4 | class SettingsIcon |
OHstin | 2:104bec169fb6 | 5 | { |
OHstin | 2:104bec169fb6 | 6 | public: |
OHstin | 2:104bec169fb6 | 7 | SettingsIcon(uint8_t xCoordinate, uint8_t yCoordinate, uint16_t backgroundColor ); |
OHstin | 2:104bec169fb6 | 8 | void drawSettingsIcon(); |
OHstin | 2:104bec169fb6 | 9 | |
OHstin | 2:104bec169fb6 | 10 | private: |
OHstin | 2:104bec169fb6 | 11 | uint8_t startingWidth; |
OHstin | 2:104bec169fb6 | 12 | uint8_t startingHeight; |
OHstin | 2:104bec169fb6 | 13 | uint16_t bgColor; |
OHstin | 2:104bec169fb6 | 14 | uint16_t drawColor; |
OHstin | 2:104bec169fb6 | 15 | }; |
OHstin | 2:104bec169fb6 | 16 | |
OHstin | 2:104bec169fb6 | 17 | SettingsIcon::SettingsIcon(uint8_t xCoordinate, uint8_t yCoordinate, uint16_t backgroundColor){ |
OHstin | 2:104bec169fb6 | 18 | |
OHstin | 2:104bec169fb6 | 19 | // set the centre of the big circle |
OHstin | 2:104bec169fb6 | 20 | startingWidth = xCoordinate + 23; |
OHstin | 2:104bec169fb6 | 21 | startingHeight = yCoordinate + 23; |
OHstin | 2:104bec169fb6 | 22 | |
OHstin | 2:104bec169fb6 | 23 | // set the backgroundColor |
OHstin | 2:104bec169fb6 | 24 | bgColor = backgroundColor; |
OHstin | 2:104bec169fb6 | 25 | |
OHstin | 2:104bec169fb6 | 26 | // determine the color of the lines on the solar panel |
OHstin | 2:104bec169fb6 | 27 | if (bgColor == ST7735_WHITE ) { |
OHstin | 2:104bec169fb6 | 28 | drawColor = ST7735_BLACK; |
OHstin | 2:104bec169fb6 | 29 | } else if (bgColor == ST7735_BLACK) { |
OHstin | 2:104bec169fb6 | 30 | drawColor = ST7735_WHITE; |
OHstin | 2:104bec169fb6 | 31 | } |
OHstin | 2:104bec169fb6 | 32 | |
OHstin | 2:104bec169fb6 | 33 | } |
OHstin | 2:104bec169fb6 | 34 | |
OHstin | 2:104bec169fb6 | 35 | void SettingsIcon::drawSettingsIcon(){ |
OHstin | 2:104bec169fb6 | 36 | |
OHstin | 2:104bec169fb6 | 37 | // radii of outer circles (background circles) |
OHstin | 2:104bec169fb6 | 38 | int outerRad = 7; |
OHstin | 2:104bec169fb6 | 39 | |
OHstin | 2:104bec169fb6 | 40 | // radius of inner circle (background circle) |
OHstin | 2:104bec169fb6 | 41 | int innerRad = 7; |
OHstin | 2:104bec169fb6 | 42 | |
OHstin | 2:104bec169fb6 | 43 | // radius of big circle |
OHstin | 2:104bec169fb6 | 44 | int rad = 23; |
OHstin | 2:104bec169fb6 | 45 | |
OHstin | 2:104bec169fb6 | 46 | // distance to radius of circles along the horizontal |
OHstin | 2:104bec169fb6 | 47 | // and vertical axis of the big circle |
OHstin | 2:104bec169fb6 | 48 | int horAndVar = 23; |
OHstin | 2:104bec169fb6 | 49 | |
OHstin | 2:104bec169fb6 | 50 | // distance to radius of circles at 45 degrees |
OHstin | 2:104bec169fb6 | 51 | // from the centre of the big circle |
OHstin | 2:104bec169fb6 | 52 | int sides = 16; |
OHstin | 2:104bec169fb6 | 53 | |
OHstin | 2:104bec169fb6 | 54 | |
OHstin | 2:104bec169fb6 | 55 | // draw big circle |
OHstin | 2:104bec169fb6 | 56 | tft.fillCircle(startingWidth, startingHeight, rad, drawColor); |
OHstin | 2:104bec169fb6 | 57 | |
OHstin | 2:104bec169fb6 | 58 | // draw inner small background circle |
OHstin | 2:104bec169fb6 | 59 | tft.fillCircle(startingWidth, startingHeight, innerRad, bgColor); |
OHstin | 2:104bec169fb6 | 60 | |
OHstin | 2:104bec169fb6 | 61 | // draw outer small background circles |
OHstin | 2:104bec169fb6 | 62 | |
OHstin | 2:104bec169fb6 | 63 | // along vertical and horizontal axis |
OHstin | 2:104bec169fb6 | 64 | tft.fillCircle(startingWidth, startingHeight-horAndVar, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 65 | tft.fillCircle(startingWidth, startingHeight+horAndVar, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 66 | |
OHstin | 2:104bec169fb6 | 67 | tft.fillCircle(startingWidth-horAndVar, startingHeight, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 68 | tft.fillCircle(startingWidth+horAndVar, startingHeight, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 69 | |
OHstin | 2:104bec169fb6 | 70 | // along 45 degrees |
OHstin | 2:104bec169fb6 | 71 | tft.fillCircle(startingWidth+sides, startingHeight-sides, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 72 | tft.fillCircle(startingWidth+sides, startingHeight+sides, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 73 | |
OHstin | 2:104bec169fb6 | 74 | tft.fillCircle(startingWidth-sides, startingHeight-sides, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 75 | tft.fillCircle(startingWidth-sides, startingHeight+sides, outerRad, bgColor); |
OHstin | 2:104bec169fb6 | 76 | } |
OHstin | 2:104bec169fb6 | 77 | #endif |