cbcx

Dependencies:   DmTftLibrary mbed

Fork of LCD_Proj by Tobias Fuchsbichler

Revision:
2:e1b98fac05ed
Parent:
1:81d0d835991d
Child:
3:03c08a612220
diff -r 81d0d835991d -r e1b98fac05ed main.cpp
--- a/main.cpp	Mon Dec 21 12:37:40 2015 +0000
+++ b/main.cpp	Mon Dec 21 15:22:03 2015 +0000
@@ -15,6 +15,7 @@
  *****************************************************************************/
 
 #include "mbed.h"
+#include "bild.h"
 
 #include "DmTftHX8353C.h"
 #include "DmTftS6D0164.h"
@@ -60,6 +61,7 @@
  * Local variables
  *****************************************************************************/
 
+
 /*********  TFT DISPLAY INIT *********/
 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*/
 
@@ -76,9 +78,19 @@
 
 PwmOut pwmRTC(p23); // RTC test PWM
 /******************************************************************************
- * Global variables 
+ * Global variables
  *****************************************************************************/
 
+uint16_t x = 0;
+uint16_t y = 0;
+uint16_t w = tft.width();
+uint16_t h = tft.height();
+
+bool down=false;
+
+time_t secondsSince1970;
+ char timeString[20];
+
 /******************************************************************************
  * Local functions
  *****************************************************************************/
@@ -156,42 +168,11 @@
     stund=0;
 }
 
-/******************************************************************************
- * Main
- *****************************************************************************/
 
-int main()
+void drawButtons()
 {
-    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();
-    Tick.attach(&zaehl, 0.01);
-
-    uint16_t x = 0;
-    uint16_t y = 0;
-    uint16_t w = tft.width();
-    uint16_t h = tft.height();
-
-    bool down=false;
-//Rectangles
+    tft.clearScreen(BLACK);
+    //Rectangles
     tft.drawRectangle(25, 285, 74, 310,WHITE);
     tft.drawRectangle(95, 285, 144, 310,WHITE);
     tft.drawRectangle(165, 285,214, 310,WHITE);
@@ -206,28 +187,97 @@
     tft.setTextColor(BLACK, WHITE);
     tft.drawString(170, 290, "RESET");
     touch.init();
-    while (1) {
+
+    tft.drawImage(208,0,32,32,zahnrad);
+
+
+}
+void RTC_SETUP()
+{
+    tft.clearScreen(BLACK);
+
+    tft.drawImage(176,0,64,32,accept);
+    tft.drawString(84, 30, "SETTINGS");
+    
+    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>=208&&x<=240&&y>=0&&y<=32) {
+            wait(0.25);
+            drawButtons();
+            return;
+        }
+
+        if(down==true&&x>=176&&x<=208&&y>=0&&y<=32) {
+            wait(0.25);
+            drawButtons();
+            return;
+        }
+
+
+    }
+
+
+}
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+
+int main()
+{
+    pwmRTC.write(0.4);
+    pwmRTC.period(0.0000263);
+   
+
+    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();
+    Tick.attach(&zaehl, 0.01);
+
+    drawButtons();
+
+    while (1) {
+        secondsSince1970 = time(NULL);
+        strftime(timeString, 20, "%H:%M:%S", localtime(&secondsSince1970));
+        tft.drawString(90, 50, timeString);
+
+        touch.readTouchData(x, y, down);
+        if(down==true&&x>=208&&x<=240&&y>=0&&y<=32)
+            RTC_SETUP();
+
         if(down==true&&x>=25&&x<=74&&y>=285&&y<=310)
             mode=true;
 
         if(down==true&&x>=95&&x<=144&&y>=285&&y<=310)
             mode=false;
-            
+
         if(down==true&&x>=165&&x<=214&&y>=285&&y<=310)
             reset();
-       
-        tft.drawNumber(88,70,stund,2,1);
-        tft.drawString(104, 70, ":");
-        tft.drawNumber(112,70,min,2,1);
-        tft.drawString(128, 70, ":");
-        tft.drawNumber(136,70,sek,2,1);
-        tft.drawString(152, 70, ":");
-        tft.drawNumber(160,70,msek,2,1);
+
+        tft.drawNumber(78,250,stund,2,1);
+        tft.drawString(94, 250, ":");
+        tft.drawNumber(102,250,min,2,1);
+        tft.drawString(118, 250, ":");
+        tft.drawNumber(126,250,sek,2,1);
+        tft.drawString(142, 250, ":");
+        tft.drawNumber(150,250,msek,2,1);
 
         down=false;
     }