Pinky and the Brain / Mbed OS Clock

Dependencies:   SPI_TFT_ILI9341 TFT_fonts Adafruit_RTCLib RTC-DS1307 TSI

Revision:
11:80a6facfd9f1
Parent:
8:e7fce7d9ebdd
Child:
13:334c591a982b
--- a/utility.cpp	Wed May 24 09:07:13 2017 +0000
+++ b/utility.cpp	Wed May 24 09:53:03 2017 +0000
@@ -4,20 +4,23 @@
 TimeClass::TimeClass (int h, int m, float s)
     :   hour(h), minute(m), second(s) {}
 
-void TimeClass::inc(float i) {
-    second += i;
-    if (second >= 60) {
-        second = 0;
-        minute += 1;
+void TimeClass::inc(TimeClass *prev, float i) {
+    prev->second = this->second;
+    prev->minute = this->minute;
+    prev->hour = this->hour;
+    this->second += i;
+    if (this->second >= 60) {
+        this->second = 0;
+        this->minute += 1;
     }
     
-    if (minute == 60) {
-        minute = 0;
-        hour += 1;
+    if (this->minute == 60) {
+        this->minute = 0;
+        this->hour += 1;
     }
     
-    if (hour == 24)
-        hour = 0;
+    if (this->hour == 24)
+        this->hour = 0;
 }
 
 DateClass::DateClass(int d, int m, int y, int dow)
@@ -25,5 +28,5 @@
  
 WeatherClass::WeatherClass() {}
  
-StateClass::StateClass(TimeClass *t, WeatherClass *w, DateClass *d, TimeClass *a)
-    :   time(t), weather(w), date(d), alarm(a), screenState(0), screenActive(true) {}
\ No newline at end of file
+StateClass::StateClass(TimeClass *t, TimeClass *p, WeatherClass *w, DateClass *d, TimeClass *a)
+    :   time(t), prevTime(p), weather(w), date(d), alarm(a), screenState(0), screenActive(true) {}
\ No newline at end of file