Contains the main execution of the clock uses headers to import functions

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

Revision:
29:684e2a3e17b5
Parent:
28:53a5429976e4
Child:
30:af38c80391cb
--- a/settings.h	Thu May 25 12:57:32 2017 +0000
+++ b/settings.h	Thu May 25 13:16:32 2017 +0000
@@ -118,16 +118,19 @@
 {
     int a_h, a_m, t_h, t_m,t_d,t_mo,t_y = 0;
     a_h = tm_a_hr;
-    a_m = tm_a_m;
+    a_m = tm_a_min;
     t_h = tm_c.hour;
     t_m = tm_c.min;
     t_d = tm_c.date;
-    t_mo = tm_c.month;
+    t_mo = tm_c.mon;
     t_y = tm_c.year;
-    int multiplier = 8
+    int multiplier = 8;
     int o_setting = 11;
+    drawsettingback();
     while (true){
+        drawsettinganimate(a_h, a_m,t_h,t_m,t_d,t_mo,t_y);
         int option = setting_press();
+        int newval = 0;
         if (option == 0 || option == 2) break;
         switch (option) {
             case (11):
@@ -154,7 +157,7 @@
         }
         switch (o_setting) {
             case(11):
-                newval = a_h + tsi.d() * multiplier;
+                newval = a_h + tsi_d() * multiplier;
                 while (newval < 0) {
                     newval += 24;
                 }
@@ -166,7 +169,7 @@
                 TFT.printf("%d", a_h);//Alarm_Hour
                 break;
             case(12):
-                newval = a_m + tsi.d() * multiplier;
+                newval = a_m + tsi_d() * multiplier;
                 while (newval < 0) {
                     newval += 60;
                 }
@@ -178,7 +181,7 @@
                 TFT.printf("%d", a_m);//Alarm_Min
                 break;
             case(13):   //set time hour
-                newval = t_h + tsi.d() * multiplier;
+                newval = t_h + tsi_d() * multiplier;
                 if (newval < 0) newval += 24;
                 t_h = newval % 25;
                 TFT.fillrect(90, 140, 150, 180, Black);
@@ -188,7 +191,7 @@
                 TFT.printf("%d",t_h); // Time_hour
                 break;
             case(14): //set time min
-                newval = t_m + tsi.d() * multiplier;
+                newval = t_m + tsi_d() * multiplier;
                 if (newval < 0) newval += 60;
                 t_m = newval % 60;
                 TFT.fillrect(200, 140, 300, 180, Black);
@@ -198,7 +201,7 @@
                 TFT.printf("%d",t_m);//Time Min
                 break;
             case(15): // set time date
-                newval = t_d + tsi.d() * multiplier;
+                newval = t_d + tsi_d() * multiplier;
                 if (newval < 0) newval += 31;
                 t_d = newval % 32;
                 TFT.fillrect(55, 202, 148, 238, Black);
@@ -208,7 +211,7 @@
                 TFT.printf("%d",t_d); //print date
                 break;
             case(16): // set time month
-                newval = a_h + tsi.d() * multiplier;
+                newval = a_h + tsi_d() * multiplier;
                 if (newval < 0) newval += 12;
                 a_h = newval % 13;
                 TFT.fillrect(148, 202, 263, 238, Black);
@@ -218,7 +221,7 @@
                 TFT.printf("%d",t_mo); //print month
                 break;
             case(17): //set time year
-                newval = a_h + tsi.d() * multiplier;
+                newval = a_h + tsi_d() * multiplier;
                 if (newval > 1970 && newval < 2700) a_h = newval;
                 TFT.fillrect(263, 202, 310, 238, Black);
                 TFT.foreground(Red);
@@ -230,12 +233,16 @@
         TFT.foreground(White);
         if (option == 1) {
             tm_a_hr = a_h;
-            tm_a_min == a_m;
-            &tm_c.min = t_m;
-            &tm_c.hour = t_h;
-            &tm_c.date = t_d;
-            &tm_c.month = t_mo;
-            &tm_c.year = t_y;
+            tm_a_min = a_m;
+            tm_c.min = t_m;
+            tm_c.hour = t_h;
+            tm_c.date = t_d;
+            tm_c.mon = t_mo;
+            tm_c.year = t_y;
+            while (!rtc.setTime(tm_c, true, false)) { //set the Time in RTC Param : ( Time container, Start Clock, Twelve Hour Clock)
+        //       n++;
+             }
+           // pc.printf("Tried to write %d times\n\r",n);
             break;
         }
     }