![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
cbcx
Dependencies: DmTftLibrary mbed
Fork of LCD_Proj by
main.cpp@4:0d4286278f41, 2016-02-01 (annotated)
- Committer:
- TFuchsbichler
- Date:
- Mon Feb 01 13:08:54 2016 +0000
- Revision:
- 4:0d4286278f41
- Parent:
- 3:03c08a612220
dshshd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
TFuchsbichler | 0:dd55ca105ef3 | 1 | /********************************************************************************************** |
TFuchsbichler | 0:dd55ca105ef3 | 2 | Copyright (c) 2014 DisplayModule. All rights reserved. |
TFuchsbichler | 0:dd55ca105ef3 | 3 | |
TFuchsbichler | 0:dd55ca105ef3 | 4 | Redistribution and use of this source code, part of this source code or any compiled binary |
TFuchsbichler | 0:dd55ca105ef3 | 5 | based on this source code is permitted as long as the above copyright notice and following |
TFuchsbichler | 0:dd55ca105ef3 | 6 | disclaimer is retained. |
TFuchsbichler | 0:dd55ca105ef3 | 7 | |
TFuchsbichler | 0:dd55ca105ef3 | 8 | DISCLAIMER: |
TFuchsbichler | 0:dd55ca105ef3 | 9 | THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES |
TFuchsbichler | 0:dd55ca105ef3 | 10 | NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. |
TFuchsbichler | 0:dd55ca105ef3 | 11 | ********************************************************************************************/ |
TFuchsbichler | 0:dd55ca105ef3 | 12 | |
TFuchsbichler | 0:dd55ca105ef3 | 13 | /****************************************************************************** |
TFuchsbichler | 0:dd55ca105ef3 | 14 | * Tested on NUCLEO-F401RE, LPCXpresso11U68, LPCXpresso824-MAX platform. |
TFuchsbichler | 0:dd55ca105ef3 | 15 | *****************************************************************************/ |
TFuchsbichler | 0:dd55ca105ef3 | 16 | |
TFuchsbichler | 0:dd55ca105ef3 | 17 | #include "mbed.h" |
TFuchsbichler | 3:03c08a612220 | 18 | #include "bild.h" //Bilder mit einbinden |
TFuchsbichler | 4:0d4286278f41 | 19 | #include "as5047p.h" |
TFuchsbichler | 4:0d4286278f41 | 20 | #include "fuellstand.h" |
TFuchsbichler | 4:0d4286278f41 | 21 | |
TFuchsbichler | 0:dd55ca105ef3 | 22 | |
TFuchsbichler | 0:dd55ca105ef3 | 23 | #include "DmTftHX8353C.h" |
TFuchsbichler | 0:dd55ca105ef3 | 24 | #include "DmTftS6D0164.h" |
TFuchsbichler | 0:dd55ca105ef3 | 25 | #include "DmTftIli9325.h" |
TFuchsbichler | 0:dd55ca105ef3 | 26 | #include "DmTftIli9341.h" |
TFuchsbichler | 0:dd55ca105ef3 | 27 | #include "DmTftSsd2119.h" |
TFuchsbichler | 0:dd55ca105ef3 | 28 | #include "DmTftRa8875.h" |
TFuchsbichler | 0:dd55ca105ef3 | 29 | #include "DmTouch.h" |
TFuchsbichler | 0:dd55ca105ef3 | 30 | #include "DmTpFt6x06.h" |
TFuchsbichler | 0:dd55ca105ef3 | 31 | |
TFuchsbichler | 0:dd55ca105ef3 | 32 | /****************************************************************************** |
TFuchsbichler | 0:dd55ca105ef3 | 33 | * Typedefs and defines |
TFuchsbichler | 0:dd55ca105ef3 | 34 | *****************************************************************************/ |
TFuchsbichler | 0:dd55ca105ef3 | 35 | |
TFuchsbichler | 0:dd55ca105ef3 | 36 | /* Note that there are restrictions on which platforms that can use printf |
TFuchsbichler | 0:dd55ca105ef3 | 37 | in combinations with the DmTftLibrary. Some platforms (e.g. LPC1549 LPCXpresso) |
TFuchsbichler | 0:dd55ca105ef3 | 38 | use the same pins for USBRX/USBTX and display control. Printing will |
TFuchsbichler | 0:dd55ca105ef3 | 39 | cause the display to not work. Read more about this on the display's notebook |
TFuchsbichler | 0:dd55ca105ef3 | 40 | page. */ |
TFuchsbichler | 0:dd55ca105ef3 | 41 | //#define log(...) printf(__VA_ARGS__) |
TFuchsbichler | 0:dd55ca105ef3 | 42 | #define log(...) |
TFuchsbichler | 0:dd55ca105ef3 | 43 | |
TFuchsbichler | 0:dd55ca105ef3 | 44 | #if 1 |
TFuchsbichler | 0:dd55ca105ef3 | 45 | /* Displays without adapter */ |
TFuchsbichler | 0:dd55ca105ef3 | 46 | #define DM_PIN_SPI_MOSI p5 |
TFuchsbichler | 0:dd55ca105ef3 | 47 | #define DM_PIN_SPI_MISO p6 |
TFuchsbichler | 0:dd55ca105ef3 | 48 | #define DM_PIN_SPI_SCLK p7 |
Nikolas | 1:81d0d835991d | 49 | #define DM_PIN_CS_TOUCH p8 |
TFuchsbichler | 0:dd55ca105ef3 | 50 | #define DM_PIN_CS_TFT p21 |
Nikolas | 1:81d0d835991d | 51 | #define DM_PIN_CS_SDCARD p14 // 23 |
Nikolas | 1:81d0d835991d | 52 | #define DM_PIN_CS_FLASH p10 // 24 |
TFuchsbichler | 0:dd55ca105ef3 | 53 | #else |
TFuchsbichler | 0:dd55ca105ef3 | 54 | /* Displays with adapter */ |
TFuchsbichler | 0:dd55ca105ef3 | 55 | #define DM_PIN_SPI_MOSI p5 |
TFuchsbichler | 0:dd55ca105ef3 | 56 | #define DM_PIN_SPI_MISO p6 |
TFuchsbichler | 0:dd55ca105ef3 | 57 | #define DM_PIN_SPI_SCLK p7 |
Nikolas | 1:81d0d835991d | 58 | #define DM_PIN_CS_TOUCH p8 |
TFuchsbichler | 0:dd55ca105ef3 | 59 | #define DM_PIN_CS_TFT p21 |
Nikolas | 1:81d0d835991d | 60 | #define DM_PIN_CS_SDCARD p14 // 13 |
TFuchsbichler | 0:dd55ca105ef3 | 61 | #endif |
TFuchsbichler | 0:dd55ca105ef3 | 62 | |
TFuchsbichler | 0:dd55ca105ef3 | 63 | /****************************************************************************** |
TFuchsbichler | 0:dd55ca105ef3 | 64 | * Local variables |
TFuchsbichler | 0:dd55ca105ef3 | 65 | *****************************************************************************/ |
TFuchsbichler | 0:dd55ca105ef3 | 66 | |
TFuchsbichler | 4:0d4286278f41 | 67 | /********* Fuellstand *********/ |
TFuchsbichler | 4:0d4286278f41 | 68 | Fuellstand fst(75,p25, p26, p27, p28, p30); |
TFuchsbichler | 2:e1b98fac05ed | 69 | |
TFuchsbichler | 0:dd55ca105ef3 | 70 | /********* TFT DISPLAY INIT *********/ |
TFuchsbichler | 0:dd55ca105ef3 | 71 | DmTftIli9341 tft(p21, p22, p5, p6, p7); /* DmTftIli9341(PinName cs, PinName dc, PinName mosi, PinName miso, PinName clk) DM_TFT28_105 and DM_TFT28_116*/ |
TFuchsbichler | 0:dd55ca105ef3 | 72 | |
TFuchsbichler | 0:dd55ca105ef3 | 73 | /********* TOUCH PANEL INIT *********/ |
TFuchsbichler | 0:dd55ca105ef3 | 74 | |
TFuchsbichler | 0:dd55ca105ef3 | 75 | DmTouch touch(DmTouch::DM_TFT28_105, p5, p6, p7); |
TFuchsbichler | 0:dd55ca105ef3 | 76 | |
TFuchsbichler | 0:dd55ca105ef3 | 77 | DigitalInOut csTouch(DM_PIN_CS_TOUCH, PIN_OUTPUT, PullUp, 1); |
TFuchsbichler | 0:dd55ca105ef3 | 78 | DigitalInOut csDisplay(DM_PIN_CS_TFT, PIN_OUTPUT, PullUp, 1); |
TFuchsbichler | 0:dd55ca105ef3 | 79 | DigitalInOut csSDCard(DM_PIN_CS_SDCARD, PIN_OUTPUT, PullUp, 1); |
TFuchsbichler | 0:dd55ca105ef3 | 80 | #ifdef DM_PIN_CS_FLASH |
TFuchsbichler | 0:dd55ca105ef3 | 81 | DigitalInOut csFlash(DM_PIN_CS_FLASH, PIN_OUTPUT, PullUp, 1); |
TFuchsbichler | 0:dd55ca105ef3 | 82 | #endif |
TFuchsbichler | 0:dd55ca105ef3 | 83 | |
TFuchsbichler | 0:dd55ca105ef3 | 84 | /****************************************************************************** |
TFuchsbichler | 2:e1b98fac05ed | 85 | * Global variables |
TFuchsbichler | 0:dd55ca105ef3 | 86 | *****************************************************************************/ |
TFuchsbichler | 0:dd55ca105ef3 | 87 | |
TFuchsbichler | 2:e1b98fac05ed | 88 | uint16_t x = 0; |
TFuchsbichler | 2:e1b98fac05ed | 89 | uint16_t y = 0; |
TFuchsbichler | 2:e1b98fac05ed | 90 | uint16_t w = tft.width(); |
TFuchsbichler | 2:e1b98fac05ed | 91 | uint16_t h = tft.height(); |
TFuchsbichler | 2:e1b98fac05ed | 92 | |
TFuchsbichler | 2:e1b98fac05ed | 93 | bool down=false; |
TFuchsbichler | 2:e1b98fac05ed | 94 | time_t secondsSince1970; |
TFuchsbichler | 3:03c08a612220 | 95 | char timeString[20]; |
TFuchsbichler | 2:e1b98fac05ed | 96 | |
TFuchsbichler | 0:dd55ca105ef3 | 97 | /****************************************************************************** |
TFuchsbichler | 0:dd55ca105ef3 | 98 | * Local functions |
TFuchsbichler | 0:dd55ca105ef3 | 99 | *****************************************************************************/ |
TFuchsbichler | 0:dd55ca105ef3 | 100 | |
TFuchsbichler | 3:03c08a612220 | 101 | //Farben definieren |
Nikolas | 1:81d0d835991d | 102 | /* |
Nikolas | 1:81d0d835991d | 103 | #define RED 0xf800 |
Nikolas | 1:81d0d835991d | 104 | #define GREEN 0x07e0 |
Nikolas | 1:81d0d835991d | 105 | #define BLUE 0x001f |
Nikolas | 1:81d0d835991d | 106 | #define BLACK 0x0000 |
Nikolas | 1:81d0d835991d | 107 | #define YELLOW 0xffe0 |
Nikolas | 1:81d0d835991d | 108 | #define WHITE 0xffff |
Nikolas | 1:81d0d835991d | 109 | #define CYAN 0x07ff |
Nikolas | 1:81d0d835991d | 110 | #define BRIGHT_RED 0xf810 |
Nikolas | 1:81d0d835991d | 111 | #define GRAY1 0x8410 |
Nikolas | 1:81d0d835991d | 112 | #define GRAY2 0x4208 |
Nikolas | 1:81d0d835991d | 113 | */ |
Nikolas | 1:81d0d835991d | 114 | #define Navy 0x000F /* 0, 0, 128 */ |
Nikolas | 1:81d0d835991d | 115 | #define DarkGreen 0x03E0 /* 0, 128, 0 */ |
Nikolas | 1:81d0d835991d | 116 | #define DarkCyan 0x03EF /* 0, 128, 128 */ |
Nikolas | 1:81d0d835991d | 117 | #define Maroon 0x7800 /* 128, 0, 0 */ |
Nikolas | 1:81d0d835991d | 118 | #define Purple 0x780F /* 128, 0, 128 */ |
Nikolas | 1:81d0d835991d | 119 | #define Olive 0x7BE0 /* 128, 128, 0 */ |
Nikolas | 1:81d0d835991d | 120 | #define LightGrey 0xC618 /* 192, 192, 192 */ |
Nikolas | 1:81d0d835991d | 121 | #define DarkGrey 0x7BEF /* 128, 128, 128 */ |
Nikolas | 1:81d0d835991d | 122 | #define Magenta 0xF81F /* 255, 0, 255 */ |
Nikolas | 1:81d0d835991d | 123 | #define Orange 0xFD20 /* 255, 165, 0 */ |
Nikolas | 1:81d0d835991d | 124 | #define GreenYellow 0xAFE5 /* 173, 255, 47 */ |
Nikolas | 1:81d0d835991d | 125 | #define Pink 0xF81F |
Nikolas | 1:81d0d835991d | 126 | |
TFuchsbichler | 3:03c08a612220 | 127 | //Ticker initialisieren |
TFuchsbichler | 0:dd55ca105ef3 | 128 | Ticker Tick; |
TFuchsbichler | 0:dd55ca105ef3 | 129 | |
TFuchsbichler | 3:03c08a612220 | 130 | //Globale Variablen |
TFuchsbichler | 0:dd55ca105ef3 | 131 | float a; |
TFuchsbichler | 0:dd55ca105ef3 | 132 | int msek; |
TFuchsbichler | 0:dd55ca105ef3 | 133 | int sek; |
TFuchsbichler | 0:dd55ca105ef3 | 134 | int min; |
TFuchsbichler | 0:dd55ca105ef3 | 135 | int stund; |
TFuchsbichler | 3:03c08a612220 | 136 | int lsek; |
TFuchsbichler | 3:03c08a612220 | 137 | int lmin; |
TFuchsbichler | 3:03c08a612220 | 138 | int lstund; |
TFuchsbichler | 0:dd55ca105ef3 | 139 | bool mode; |
TFuchsbichler | 3:03c08a612220 | 140 | bool lhilf=false; |
TFuchsbichler | 0:dd55ca105ef3 | 141 | |
TFuchsbichler | 3:03c08a612220 | 142 | //Funktionsaufruf des Tickersinterrupts der Stoppuhr |
TFuchsbichler | 0:dd55ca105ef3 | 143 | void zaehl() |
TFuchsbichler | 0:dd55ca105ef3 | 144 | { |
TFuchsbichler | 0:dd55ca105ef3 | 145 | if(mode==true) { |
TFuchsbichler | 0:dd55ca105ef3 | 146 | msek++; |
TFuchsbichler | 3:03c08a612220 | 147 | //msek in sek |
TFuchsbichler | 0:dd55ca105ef3 | 148 | if(msek==100) { |
TFuchsbichler | 0:dd55ca105ef3 | 149 | sek++; |
TFuchsbichler | 0:dd55ca105ef3 | 150 | msek=0; |
TFuchsbichler | 0:dd55ca105ef3 | 151 | |
TFuchsbichler | 0:dd55ca105ef3 | 152 | } |
TFuchsbichler | 0:dd55ca105ef3 | 153 | |
TFuchsbichler | 3:03c08a612220 | 154 | //sek in min |
TFuchsbichler | 0:dd55ca105ef3 | 155 | if(sek==60) { |
TFuchsbichler | 0:dd55ca105ef3 | 156 | min++; |
TFuchsbichler | 0:dd55ca105ef3 | 157 | sek=0; |
TFuchsbichler | 0:dd55ca105ef3 | 158 | |
TFuchsbichler | 0:dd55ca105ef3 | 159 | } |
TFuchsbichler | 0:dd55ca105ef3 | 160 | |
TFuchsbichler | 3:03c08a612220 | 161 | //min in stund |
TFuchsbichler | 0:dd55ca105ef3 | 162 | if(min==60) { |
TFuchsbichler | 0:dd55ca105ef3 | 163 | stund++; |
TFuchsbichler | 0:dd55ca105ef3 | 164 | min=0; |
TFuchsbichler | 0:dd55ca105ef3 | 165 | } |
TFuchsbichler | 3:03c08a612220 | 166 | |
TFuchsbichler | 3:03c08a612220 | 167 | //stund reseten |
TFuchsbichler | 0:dd55ca105ef3 | 168 | if(stund==24) { |
TFuchsbichler | 0:dd55ca105ef3 | 169 | msek=0; |
TFuchsbichler | 0:dd55ca105ef3 | 170 | sek=0; |
TFuchsbichler | 0:dd55ca105ef3 | 171 | min=0; |
TFuchsbichler | 0:dd55ca105ef3 | 172 | stund=0; |
TFuchsbichler | 0:dd55ca105ef3 | 173 | } |
TFuchsbichler | 0:dd55ca105ef3 | 174 | |
TFuchsbichler | 0:dd55ca105ef3 | 175 | } |
TFuchsbichler | 0:dd55ca105ef3 | 176 | |
TFuchsbichler | 0:dd55ca105ef3 | 177 | } |
TFuchsbichler | 0:dd55ca105ef3 | 178 | |
TFuchsbichler | 3:03c08a612220 | 179 | //"Falsche" Zwischenzeit stoppen |
TFuchsbichler | 3:03c08a612220 | 180 | void lap() |
TFuchsbichler | 3:03c08a612220 | 181 | { |
TFuchsbichler | 3:03c08a612220 | 182 | |
TFuchsbichler | 3:03c08a612220 | 183 | tft.drawNumber(78,250,stund,2,1); |
TFuchsbichler | 3:03c08a612220 | 184 | tft.drawString(94, 250, ":"); |
TFuchsbichler | 3:03c08a612220 | 185 | tft.drawNumber(102,250,min,2,1); |
TFuchsbichler | 3:03c08a612220 | 186 | tft.drawString(118, 250, ":"); |
TFuchsbichler | 3:03c08a612220 | 187 | tft.drawNumber(126,250,sek,2,1); |
TFuchsbichler | 3:03c08a612220 | 188 | tft.drawString(142, 250, ":"); |
TFuchsbichler | 3:03c08a612220 | 189 | tft.drawNumber(150,250,msek,2,1); |
TFuchsbichler | 3:03c08a612220 | 190 | |
TFuchsbichler | 3:03c08a612220 | 191 | } |
TFuchsbichler | 3:03c08a612220 | 192 | |
TFuchsbichler | 3:03c08a612220 | 193 | //Stoppuhr reseten |
TFuchsbichler | 0:dd55ca105ef3 | 194 | void reset() |
TFuchsbichler | 0:dd55ca105ef3 | 195 | { |
TFuchsbichler | 0:dd55ca105ef3 | 196 | msek=0; |
TFuchsbichler | 0:dd55ca105ef3 | 197 | sek=0; |
TFuchsbichler | 0:dd55ca105ef3 | 198 | min=0; |
TFuchsbichler | 0:dd55ca105ef3 | 199 | stund=0; |
TFuchsbichler | 3:03c08a612220 | 200 | lap(); |
TFuchsbichler | 0:dd55ca105ef3 | 201 | } |
TFuchsbichler | 0:dd55ca105ef3 | 202 | |
TFuchsbichler | 3:03c08a612220 | 203 | //Startseite zeichnen |
TFuchsbichler | 2:e1b98fac05ed | 204 | void drawButtons() |
TFuchsbichler | 0:dd55ca105ef3 | 205 | { |
TFuchsbichler | 2:e1b98fac05ed | 206 | tft.clearScreen(BLACK); |
TFuchsbichler | 3:03c08a612220 | 207 | //Rectangles |
TFuchsbichler | 0:dd55ca105ef3 | 208 | tft.drawRectangle(25, 285, 74, 310,WHITE); |
TFuchsbichler | 0:dd55ca105ef3 | 209 | tft.drawRectangle(95, 285, 144, 310,WHITE); |
TFuchsbichler | 0:dd55ca105ef3 | 210 | tft.drawRectangle(165, 285,214, 310,WHITE); |
TFuchsbichler | 0:dd55ca105ef3 | 211 | tft.fillRectangle(26, 286, 73, 309, GREEN); |
TFuchsbichler | 0:dd55ca105ef3 | 212 | tft.fillRectangle(96, 286, 143, 309, RED); |
TFuchsbichler | 0:dd55ca105ef3 | 213 | //Text |
TFuchsbichler | 0:dd55ca105ef3 | 214 | tft.drawString(84, 30, "STOPWATCH"); |
Nikolas | 1:81d0d835991d | 215 | tft.setTextColor(GREEN, BLACK); |
TFuchsbichler | 0:dd55ca105ef3 | 216 | tft.drawString(30, 290, "START"); |
Nikolas | 1:81d0d835991d | 217 | tft.setTextColor(RED, BLACK); |
TFuchsbichler | 0:dd55ca105ef3 | 218 | tft.drawString(104, 290, "STOP"); |
Nikolas | 1:81d0d835991d | 219 | tft.setTextColor(BLACK, WHITE); |
TFuchsbichler | 0:dd55ca105ef3 | 220 | tft.drawString(170, 290, "RESET"); |
TFuchsbichler | 0:dd55ca105ef3 | 221 | touch.init(); |
TFuchsbichler | 2:e1b98fac05ed | 222 | |
TFuchsbichler | 2:e1b98fac05ed | 223 | tft.drawImage(208,0,32,32,zahnrad); |
TFuchsbichler | 4:0d4286278f41 | 224 | tft.drawImage(0,0,32,32,fuellstand); |
TFuchsbichler | 2:e1b98fac05ed | 225 | |
TFuchsbichler | 2:e1b98fac05ed | 226 | |
TFuchsbichler | 2:e1b98fac05ed | 227 | } |
TFuchsbichler | 3:03c08a612220 | 228 | |
TFuchsbichler | 3:03c08a612220 | 229 | |
TFuchsbichler | 3:03c08a612220 | 230 | //Einstellungen der RTC(Real Time Clock) |
TFuchsbichler | 2:e1b98fac05ed | 231 | void RTC_SETUP() |
TFuchsbichler | 2:e1b98fac05ed | 232 | { |
TFuchsbichler | 2:e1b98fac05ed | 233 | tft.clearScreen(BLACK); |
TFuchsbichler | 2:e1b98fac05ed | 234 | |
TFuchsbichler | 3:03c08a612220 | 235 | lhilf=true; |
TFuchsbichler | 3:03c08a612220 | 236 | |
TFuchsbichler | 2:e1b98fac05ed | 237 | tft.drawImage(176,0,64,32,accept); |
TFuchsbichler | 3:03c08a612220 | 238 | |
TFuchsbichler | 3:03c08a612220 | 239 | tft.drawImage(20,80,32,32,arrow_up); |
TFuchsbichler | 3:03c08a612220 | 240 | tft.drawImage(104,80,32,32,arrow_up); |
TFuchsbichler | 3:03c08a612220 | 241 | tft.drawImage(188,80,32,32,arrow_up); |
TFuchsbichler | 3:03c08a612220 | 242 | |
TFuchsbichler | 3:03c08a612220 | 243 | tft.drawImage(20,140,32,32,arrow_down); |
TFuchsbichler | 3:03c08a612220 | 244 | tft.drawImage(104,140,32,32,arrow_down); |
TFuchsbichler | 3:03c08a612220 | 245 | tft.drawImage(188,140,32,32,arrow_down); |
TFuchsbichler | 3:03c08a612220 | 246 | |
TFuchsbichler | 2:e1b98fac05ed | 247 | tft.drawString(84, 30, "SETTINGS"); |
TFuchsbichler | 3:03c08a612220 | 248 | |
TFuchsbichler | 2:e1b98fac05ed | 249 | while(1) { |
Nikolas | 1:81d0d835991d | 250 | secondsSince1970 = time(NULL); |
TFuchsbichler | 3:03c08a612220 | 251 | |
TFuchsbichler | 3:03c08a612220 | 252 | tft.drawNumber(28, 118,lstund,2,1); |
TFuchsbichler | 3:03c08a612220 | 253 | tft.drawNumber(112, 118, lmin,2,1); |
TFuchsbichler | 3:03c08a612220 | 254 | tft.drawNumber(196, 118, lsek,2,1); |
TFuchsbichler | 3:03c08a612220 | 255 | |
TFuchsbichler | 3:03c08a612220 | 256 | if(lstund==9&&lmin==1&&lsek==1&&lhilf==true) |
TFuchsbichler | 3:03c08a612220 | 257 | { |
TFuchsbichler | 3:03c08a612220 | 258 | //cages |
TFuchsbichler | 3:03c08a612220 | 259 | tft.drawImage(0,200,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 260 | tft.drawImage(60,200,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 261 | tft.drawImage(120,200,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 262 | tft.drawImage(180,200,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 263 | |
TFuchsbichler | 3:03c08a612220 | 264 | tft.drawImage(0,260,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 265 | tft.drawImage(60,260,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 266 | tft.drawImage(120,260,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 267 | tft.drawImage(180,260,60,60,cage); |
TFuchsbichler | 3:03c08a612220 | 268 | |
TFuchsbichler | 3:03c08a612220 | 269 | wait(2); |
TFuchsbichler | 3:03c08a612220 | 270 | |
TFuchsbichler | 3:03c08a612220 | 271 | tft.fillRectangle(0,200,240,320,BLACK); |
TFuchsbichler | 3:03c08a612220 | 272 | lhilf=false; |
TFuchsbichler | 3:03c08a612220 | 273 | } |
TFuchsbichler | 3:03c08a612220 | 274 | |
TFuchsbichler | 0:dd55ca105ef3 | 275 | touch.readTouchData(x, y, down); |
TFuchsbichler | 2:e1b98fac05ed | 276 | if(down==true&&x>=208&&x<=240&&y>=0&&y<=32) { |
TFuchsbichler | 2:e1b98fac05ed | 277 | wait(0.25); |
TFuchsbichler | 2:e1b98fac05ed | 278 | drawButtons(); |
TFuchsbichler | 2:e1b98fac05ed | 279 | return; |
TFuchsbichler | 2:e1b98fac05ed | 280 | } |
TFuchsbichler | 2:e1b98fac05ed | 281 | |
TFuchsbichler | 3:03c08a612220 | 282 | //Stunden Konfiguration |
TFuchsbichler | 3:03c08a612220 | 283 | if(down==true&&x>=20&&x<=52&&y>=80&&y<=112) { |
TFuchsbichler | 3:03c08a612220 | 284 | lstund++; |
TFuchsbichler | 3:03c08a612220 | 285 | if(lstund>=24) |
TFuchsbichler | 3:03c08a612220 | 286 | lstund=0; |
TFuchsbichler | 3:03c08a612220 | 287 | wait(0.25); |
TFuchsbichler | 3:03c08a612220 | 288 | } |
TFuchsbichler | 3:03c08a612220 | 289 | if(down==true&&x>=20&&x<=52&&y>=140&&y<=172) { |
TFuchsbichler | 3:03c08a612220 | 290 | lstund--; |
TFuchsbichler | 3:03c08a612220 | 291 | if(lstund<0) |
TFuchsbichler | 3:03c08a612220 | 292 | lstund=23; |
TFuchsbichler | 3:03c08a612220 | 293 | wait(0.25); |
TFuchsbichler | 3:03c08a612220 | 294 | } |
TFuchsbichler | 3:03c08a612220 | 295 | |
TFuchsbichler | 3:03c08a612220 | 296 | |
TFuchsbichler | 3:03c08a612220 | 297 | //Minuten Konfiguration |
TFuchsbichler | 3:03c08a612220 | 298 | if(down==true&&x>=104&&x<=136&y>=80&&y<=112) { |
TFuchsbichler | 3:03c08a612220 | 299 | lmin++; |
TFuchsbichler | 3:03c08a612220 | 300 | if(lmin>=60) |
TFuchsbichler | 3:03c08a612220 | 301 | lmin=0; |
TFuchsbichler | 3:03c08a612220 | 302 | wait(0.25); |
TFuchsbichler | 3:03c08a612220 | 303 | } |
TFuchsbichler | 3:03c08a612220 | 304 | if(down==true&&x>=104&&x<=136&&y>=140&&y<=172) { |
TFuchsbichler | 3:03c08a612220 | 305 | lmin--; |
TFuchsbichler | 3:03c08a612220 | 306 | if(lmin<0) |
TFuchsbichler | 3:03c08a612220 | 307 | lmin=59; |
TFuchsbichler | 3:03c08a612220 | 308 | wait(0.25); |
TFuchsbichler | 3:03c08a612220 | 309 | } |
TFuchsbichler | 3:03c08a612220 | 310 | |
TFuchsbichler | 3:03c08a612220 | 311 | |
TFuchsbichler | 3:03c08a612220 | 312 | //Sekunden Konfiguration |
TFuchsbichler | 3:03c08a612220 | 313 | if(down==true&&x>=188&&x<=220&&y>=80&&y<=112) { |
TFuchsbichler | 3:03c08a612220 | 314 | lsek++; |
TFuchsbichler | 3:03c08a612220 | 315 | if(lsek>=60) |
TFuchsbichler | 3:03c08a612220 | 316 | lsek=0; |
TFuchsbichler | 3:03c08a612220 | 317 | wait(0.25); |
TFuchsbichler | 3:03c08a612220 | 318 | } |
TFuchsbichler | 3:03c08a612220 | 319 | |
TFuchsbichler | 3:03c08a612220 | 320 | if(down==true&&x>=188&&x<=220&&y>=140&&y<=172) { |
TFuchsbichler | 3:03c08a612220 | 321 | lsek--; |
TFuchsbichler | 3:03c08a612220 | 322 | if(lsek<0) |
TFuchsbichler | 3:03c08a612220 | 323 | lsek=59; |
TFuchsbichler | 3:03c08a612220 | 324 | wait(0.25); |
TFuchsbichler | 3:03c08a612220 | 325 | } |
TFuchsbichler | 2:e1b98fac05ed | 326 | if(down==true&&x>=176&&x<=208&&y>=0&&y<=32) { |
TFuchsbichler | 3:03c08a612220 | 327 | struct tm t; |
TFuchsbichler | 3:03c08a612220 | 328 | t.tm_sec = lsek; // 0-59 |
TFuchsbichler | 3:03c08a612220 | 329 | t.tm_min = lmin; // 0-59 |
TFuchsbichler | 3:03c08a612220 | 330 | t.tm_hour = lstund; // 0-23 |
TFuchsbichler | 3:03c08a612220 | 331 | t.tm_mday = 29; // 1-31 |
TFuchsbichler | 3:03c08a612220 | 332 | t.tm_mon = 1; // 0-11 |
TFuchsbichler | 3:03c08a612220 | 333 | t.tm_year = 116; // year since 1900 |
TFuchsbichler | 3:03c08a612220 | 334 | |
TFuchsbichler | 3:03c08a612220 | 335 | |
TFuchsbichler | 3:03c08a612220 | 336 | // convert to timestamp |
TFuchsbichler | 3:03c08a612220 | 337 | time_t secondsSince1970 = mktime(&t); |
TFuchsbichler | 3:03c08a612220 | 338 | |
TFuchsbichler | 3:03c08a612220 | 339 | // Set time and start RTC |
TFuchsbichler | 3:03c08a612220 | 340 | set_time(secondsSince1970); |
TFuchsbichler | 3:03c08a612220 | 341 | |
TFuchsbichler | 2:e1b98fac05ed | 342 | wait(0.25); |
TFuchsbichler | 2:e1b98fac05ed | 343 | drawButtons(); |
TFuchsbichler | 2:e1b98fac05ed | 344 | return; |
TFuchsbichler | 2:e1b98fac05ed | 345 | } |
TFuchsbichler | 2:e1b98fac05ed | 346 | |
TFuchsbichler | 2:e1b98fac05ed | 347 | |
TFuchsbichler | 2:e1b98fac05ed | 348 | } |
TFuchsbichler | 2:e1b98fac05ed | 349 | |
TFuchsbichler | 2:e1b98fac05ed | 350 | |
TFuchsbichler | 2:e1b98fac05ed | 351 | } |
TFuchsbichler | 4:0d4286278f41 | 352 | |
TFuchsbichler | 4:0d4286278f41 | 353 | |
TFuchsbichler | 4:0d4286278f41 | 354 | void FReckt(int width, int x, int y, int percent) |
TFuchsbichler | 4:0d4286278f41 | 355 | { |
TFuchsbichler | 4:0d4286278f41 | 356 | tft.drawRectangle(x,y,x+width,y+100,WHITE); |
TFuchsbichler | 4:0d4286278f41 | 357 | tft.fillRectangle(x+1,y+1,x+width-2,y+98,BLACK); |
TFuchsbichler | 4:0d4286278f41 | 358 | |
TFuchsbichler | 4:0d4286278f41 | 359 | |
TFuchsbichler | 4:0d4286278f41 | 360 | |
TFuchsbichler | 4:0d4286278f41 | 361 | if(percent>=1&&percent<=25) |
TFuchsbichler | 4:0d4286278f41 | 362 | { |
TFuchsbichler | 4:0d4286278f41 | 363 | tft.fillRectangle(x+1,y+76,x+width-2,y+98,BLUE); |
TFuchsbichler | 4:0d4286278f41 | 364 | |
TFuchsbichler | 4:0d4286278f41 | 365 | } |
TFuchsbichler | 4:0d4286278f41 | 366 | |
TFuchsbichler | 4:0d4286278f41 | 367 | if(percent>=26&&percent<=50) |
TFuchsbichler | 4:0d4286278f41 | 368 | { |
TFuchsbichler | 4:0d4286278f41 | 369 | tft.fillRectangle(x+1,y+51,x+width-2,y+98,BLUE); |
TFuchsbichler | 4:0d4286278f41 | 370 | } |
TFuchsbichler | 4:0d4286278f41 | 371 | |
TFuchsbichler | 4:0d4286278f41 | 372 | if(percent>=51&&percent<=75) |
TFuchsbichler | 4:0d4286278f41 | 373 | { |
TFuchsbichler | 4:0d4286278f41 | 374 | tft.fillRectangle(x+1,y+26,x+width-2,y+98,BLUE); |
TFuchsbichler | 4:0d4286278f41 | 375 | } |
TFuchsbichler | 4:0d4286278f41 | 376 | |
TFuchsbichler | 4:0d4286278f41 | 377 | if(percent == 100) |
TFuchsbichler | 4:0d4286278f41 | 378 | { |
TFuchsbichler | 4:0d4286278f41 | 379 | tft.fillRectangle(x+1,y+1,x+width-2,y+98,BLUE); |
TFuchsbichler | 4:0d4286278f41 | 380 | } |
TFuchsbichler | 4:0d4286278f41 | 381 | |
TFuchsbichler | 4:0d4286278f41 | 382 | } |
TFuchsbichler | 4:0d4286278f41 | 383 | |
TFuchsbichler | 4:0d4286278f41 | 384 | void Fstand() |
TFuchsbichler | 4:0d4286278f41 | 385 | { |
TFuchsbichler | 4:0d4286278f41 | 386 | |
TFuchsbichler | 4:0d4286278f41 | 387 | tft.clearScreen(BLACK); |
TFuchsbichler | 4:0d4286278f41 | 388 | |
TFuchsbichler | 4:0d4286278f41 | 389 | |
TFuchsbichler | 4:0d4286278f41 | 390 | while(1) |
TFuchsbichler | 4:0d4286278f41 | 391 | { |
TFuchsbichler | 4:0d4286278f41 | 392 | FReckt(60, 30, 30, fst.wert()); |
TFuchsbichler | 4:0d4286278f41 | 393 | wait(0.5); |
TFuchsbichler | 4:0d4286278f41 | 394 | } |
TFuchsbichler | 4:0d4286278f41 | 395 | /* |
TFuchsbichler | 4:0d4286278f41 | 396 | while(1) |
TFuchsbichler | 4:0d4286278f41 | 397 | { |
TFuchsbichler | 4:0d4286278f41 | 398 | a=a+5; |
TFuchsbichler | 4:0d4286278f41 | 399 | wait(0.5); |
TFuchsbichler | 4:0d4286278f41 | 400 | FReckt(120,80,10,10,a); |
TFuchsbichler | 4:0d4286278f41 | 401 | if(a>=100) |
TFuchsbichler | 4:0d4286278f41 | 402 | { |
TFuchsbichler | 4:0d4286278f41 | 403 | a=100; |
TFuchsbichler | 4:0d4286278f41 | 404 | break; |
TFuchsbichler | 4:0d4286278f41 | 405 | } |
TFuchsbichler | 4:0d4286278f41 | 406 | |
TFuchsbichler | 4:0d4286278f41 | 407 | } |
TFuchsbichler | 4:0d4286278f41 | 408 | while(1) |
TFuchsbichler | 4:0d4286278f41 | 409 | { |
TFuchsbichler | 4:0d4286278f41 | 410 | a=a-5; |
TFuchsbichler | 4:0d4286278f41 | 411 | wait(0.5); |
TFuchsbichler | 4:0d4286278f41 | 412 | FReckt(120,80,10,10,a); |
TFuchsbichler | 4:0d4286278f41 | 413 | if(a<=0) |
TFuchsbichler | 4:0d4286278f41 | 414 | { |
TFuchsbichler | 4:0d4286278f41 | 415 | break; |
TFuchsbichler | 4:0d4286278f41 | 416 | } |
TFuchsbichler | 4:0d4286278f41 | 417 | } |
TFuchsbichler | 4:0d4286278f41 | 418 | */ |
TFuchsbichler | 4:0d4286278f41 | 419 | } |
TFuchsbichler | 4:0d4286278f41 | 420 | |
TFuchsbichler | 2:e1b98fac05ed | 421 | /****************************************************************************** |
TFuchsbichler | 2:e1b98fac05ed | 422 | * Main |
TFuchsbichler | 2:e1b98fac05ed | 423 | *****************************************************************************/ |
TFuchsbichler | 2:e1b98fac05ed | 424 | |
TFuchsbichler | 2:e1b98fac05ed | 425 | int main() |
TFuchsbichler | 2:e1b98fac05ed | 426 | { |
TFuchsbichler | 4:0d4286278f41 | 427 | fst.setboden(true); |
TFuchsbichler | 2:e1b98fac05ed | 428 | |
TFuchsbichler | 2:e1b98fac05ed | 429 | struct tm t; |
TFuchsbichler | 2:e1b98fac05ed | 430 | t.tm_sec = 00; // 0-59 |
TFuchsbichler | 2:e1b98fac05ed | 431 | t.tm_min = 12; // 0-59 |
TFuchsbichler | 2:e1b98fac05ed | 432 | t.tm_hour = 10; // 0-23 |
TFuchsbichler | 3:03c08a612220 | 433 | t.tm_mday = 29; // 1-31 |
TFuchsbichler | 3:03c08a612220 | 434 | t.tm_mon = 1; // 0-11 |
TFuchsbichler | 3:03c08a612220 | 435 | t.tm_year = 116; // year since 1900 |
TFuchsbichler | 2:e1b98fac05ed | 436 | |
TFuchsbichler | 2:e1b98fac05ed | 437 | // convert to timestamp |
TFuchsbichler | 2:e1b98fac05ed | 438 | time_t secondsSince1970 = mktime(&t); |
TFuchsbichler | 2:e1b98fac05ed | 439 | |
TFuchsbichler | 2:e1b98fac05ed | 440 | // Set time and start RTC |
TFuchsbichler | 2:e1b98fac05ed | 441 | set_time(secondsSince1970); |
TFuchsbichler | 2:e1b98fac05ed | 442 | |
TFuchsbichler | 2:e1b98fac05ed | 443 | log("init tft \r\n"); |
TFuchsbichler | 2:e1b98fac05ed | 444 | mode=false; |
TFuchsbichler | 2:e1b98fac05ed | 445 | tft.init(); |
TFuchsbichler | 2:e1b98fac05ed | 446 | Tick.attach(&zaehl, 0.01); |
TFuchsbichler | 2:e1b98fac05ed | 447 | |
TFuchsbichler | 2:e1b98fac05ed | 448 | drawButtons(); |
TFuchsbichler | 2:e1b98fac05ed | 449 | |
TFuchsbichler | 2:e1b98fac05ed | 450 | while (1) { |
TFuchsbichler | 2:e1b98fac05ed | 451 | secondsSince1970 = time(NULL); |
TFuchsbichler | 2:e1b98fac05ed | 452 | strftime(timeString, 20, "%H:%M:%S", localtime(&secondsSince1970)); |
TFuchsbichler | 2:e1b98fac05ed | 453 | tft.drawString(90, 50, timeString); |
TFuchsbichler | 2:e1b98fac05ed | 454 | |
TFuchsbichler | 2:e1b98fac05ed | 455 | touch.readTouchData(x, y, down); |
TFuchsbichler | 3:03c08a612220 | 456 | |
TFuchsbichler | 2:e1b98fac05ed | 457 | if(down==true&&x>=208&&x<=240&&y>=0&&y<=32) |
TFuchsbichler | 3:03c08a612220 | 458 | { |
TFuchsbichler | 3:03c08a612220 | 459 | strftime(timeString, 20, "%H", localtime(&secondsSince1970)); |
TFuchsbichler | 3:03c08a612220 | 460 | lstund=atoi(timeString); |
TFuchsbichler | 3:03c08a612220 | 461 | //atoi: Wandelt string in int um |
TFuchsbichler | 3:03c08a612220 | 462 | |
TFuchsbichler | 3:03c08a612220 | 463 | strftime(timeString, 20, "%M", localtime(&secondsSince1970)); |
TFuchsbichler | 3:03c08a612220 | 464 | lmin=atoi(timeString); |
TFuchsbichler | 2:e1b98fac05ed | 465 | |
TFuchsbichler | 3:03c08a612220 | 466 | strftime(timeString, 20, "%S", localtime(&secondsSince1970)); |
TFuchsbichler | 3:03c08a612220 | 467 | lsek=atoi(timeString); |
TFuchsbichler | 3:03c08a612220 | 468 | RTC_SETUP(); |
TFuchsbichler | 3:03c08a612220 | 469 | } |
TFuchsbichler | 3:03c08a612220 | 470 | |
TFuchsbichler | 3:03c08a612220 | 471 | //Start Stoppuhr |
TFuchsbichler | 3:03c08a612220 | 472 | if(down==true&&x>=25&&x<=74&&y>=285&&y<=310) { |
TFuchsbichler | 3:03c08a612220 | 473 | if(mode==true) { |
TFuchsbichler | 3:03c08a612220 | 474 | lap(); |
TFuchsbichler | 3:03c08a612220 | 475 | } |
TFuchsbichler | 0:dd55ca105ef3 | 476 | mode=true; |
TFuchsbichler | 3:03c08a612220 | 477 | } |
TFuchsbichler | 3:03c08a612220 | 478 | //Stop Stoppuhr |
TFuchsbichler | 0:dd55ca105ef3 | 479 | if(down==true&&x>=95&&x<=144&&y>=285&&y<=310) |
TFuchsbichler | 0:dd55ca105ef3 | 480 | mode=false; |
TFuchsbichler | 3:03c08a612220 | 481 | //Reset Stoppuhr |
TFuchsbichler | 0:dd55ca105ef3 | 482 | if(down==true&&x>=165&&x<=214&&y>=285&&y<=310) |
TFuchsbichler | 0:dd55ca105ef3 | 483 | reset(); |
TFuchsbichler | 4:0d4286278f41 | 484 | //Füllstand |
TFuchsbichler | 4:0d4286278f41 | 485 | if(down==true&&x>=0&&x<=32&&y>=0&&y<=32) |
TFuchsbichler | 4:0d4286278f41 | 486 | Fstand(); |
TFuchsbichler | 4:0d4286278f41 | 487 | |
TFuchsbichler | 2:e1b98fac05ed | 488 | |
TFuchsbichler | 3:03c08a612220 | 489 | tft.drawNumber(78,230,stund,2,1); |
TFuchsbichler | 3:03c08a612220 | 490 | tft.drawString(94, 230, ":"); |
TFuchsbichler | 3:03c08a612220 | 491 | tft.drawNumber(102,230,min,2,1); |
TFuchsbichler | 3:03c08a612220 | 492 | tft.drawString(118, 230, ":"); |
TFuchsbichler | 3:03c08a612220 | 493 | tft.drawNumber(126,230,sek,2,1); |
TFuchsbichler | 3:03c08a612220 | 494 | tft.drawString(142, 230, ":"); |
TFuchsbichler | 3:03c08a612220 | 495 | tft.drawNumber(150,230,msek,2,1); |
TFuchsbichler | 0:dd55ca105ef3 | 496 | |
TFuchsbichler | 0:dd55ca105ef3 | 497 | down=false; |
TFuchsbichler | 0:dd55ca105ef3 | 498 | } |
TFuchsbichler | 0:dd55ca105ef3 | 499 | |
TFuchsbichler | 0:dd55ca105ef3 | 500 | } |