cbcx

Dependencies:   DmTftLibrary mbed

Fork of LCD_Proj by Tobias Fuchsbichler

Revision:
1:81d0d835991d
Parent:
0:dd55ca105ef3
Child:
2:e1b98fac05ed
--- a/main.cpp	Mon Dec 14 15:25:49 2015 +0000
+++ b/main.cpp	Mon Dec 21 12:37:40 2015 +0000
@@ -42,18 +42,18 @@
 #define DM_PIN_SPI_MOSI   p5
 #define DM_PIN_SPI_MISO   p6
 #define DM_PIN_SPI_SCLK   p7
-#define DM_PIN_CS_TOUCH   p25
+#define DM_PIN_CS_TOUCH   p8
 #define DM_PIN_CS_TFT     p21
-#define DM_PIN_CS_SDCARD  p23
-#define DM_PIN_CS_FLASH   p24
+#define DM_PIN_CS_SDCARD  p14   // 23
+#define DM_PIN_CS_FLASH   p10   // 24
 #else
 /* Displays with adapter */
 #define DM_PIN_SPI_MOSI   p5
 #define DM_PIN_SPI_MISO   p6
 #define DM_PIN_SPI_SCLK   p7
-#define DM_PIN_CS_TOUCH   p25
+#define DM_PIN_CS_TOUCH   p8
 #define DM_PIN_CS_TFT     p21
-#define DM_PIN_CS_SDCARD  p23
+#define DM_PIN_CS_SDCARD  p14   // 13
 #endif
 
 /******************************************************************************
@@ -74,6 +74,7 @@
 DigitalInOut csFlash(DM_PIN_CS_FLASH, PIN_OUTPUT, PullUp, 1);
 #endif
 
+PwmOut pwmRTC(p23); // RTC test PWM
 /******************************************************************************
  * Global variables 
  *****************************************************************************/
@@ -82,6 +83,31 @@
  * Local functions
  *****************************************************************************/
 
+/*
+#define RED     0xf800
+#define GREEN   0x07e0
+#define BLUE    0x001f
+#define BLACK   0x0000
+#define YELLOW  0xffe0
+#define WHITE   0xffff
+#define CYAN        0x07ff
+#define BRIGHT_RED  0xf810
+#define GRAY1       0x8410
+#define GRAY2       0x4208
+*/
+#define Navy            0x000F      /*   0,   0, 128 */
+#define DarkGreen       0x03E0      /*   0, 128,   0 */
+#define DarkCyan        0x03EF      /*   0, 128, 128 */
+#define Maroon          0x7800      /* 128,   0,   0 */
+#define Purple          0x780F      /* 128,   0, 128 */
+#define Olive           0x7BE0      /* 128, 128,   0 */
+#define LightGrey       0xC618      /* 192, 192, 192 */
+#define DarkGrey        0x7BEF      /* 128, 128, 128 */
+#define Magenta         0xF81F      /* 255,   0, 255 */
+#define Orange          0xFD20      /* 255, 165,   0 */
+#define GreenYellow     0xAFE5      /* 173, 255,  47 */
+#define Pink            0xF81F
+
 Ticker Tick;
 
 float a;
@@ -91,7 +117,6 @@
 int stund;
 bool mode;
 
-
 void zaehl()
 {
     if(mode==true) {
@@ -137,6 +162,24 @@
 
 int main()
 {
+    pwmRTC.write(0.4);
+    pwmRTC.period(0.0000263);
+    char timeString[20];
+    
+    struct tm t;
+    t.tm_sec = 00;    // 0-59
+    t.tm_min = 12;    // 0-59
+    t.tm_hour = 10;   // 0-23
+    t.tm_mday = 21;   // 1-31
+    t.tm_mon = 12;     // 0-11
+    t.tm_year = 115;  // year since 1900
+    
+    // convert to timestamp 
+    time_t secondsSince1970 = mktime(&t);
+
+    // Set time and start RTC
+    set_time(secondsSince1970);
+    
     log("init tft \r\n");
     mode=false;
     tft.init();
@@ -156,13 +199,18 @@
     tft.fillRectangle(96, 286, 143, 309, RED);
 //Text
     tft.drawString(84, 30, "STOPWATCH");
+    tft.setTextColor(GREEN, BLACK);
     tft.drawString(30, 290, "START");
+    tft.setTextColor(RED, BLACK);
     tft.drawString(104, 290, "STOP");
+    tft.setTextColor(BLACK, WHITE);
     tft.drawString(170, 290, "RESET");
-    
-    
     touch.init();
     while (1) {
+        secondsSince1970 = time(NULL);
+        strftime(timeString, 20, "%H:%M:%S", localtime(&secondsSince1970));
+        tft.drawString(50, 50, timeString);
+        
         touch.readTouchData(x, y, down);
         if(down==true&&x>=25&&x<=74&&y>=285&&y<=310)
             mode=true;
@@ -178,7 +226,8 @@
         tft.drawNumber(112,70,min,2,1);
         tft.drawString(128, 70, ":");
         tft.drawNumber(136,70,sek,2,1);
-        tft.drawNumber(136,86,msek,2,1);
+        tft.drawString(152, 70, ":");
+        tft.drawNumber(160,70,msek,2,1);
 
         down=false;
     }