diff options
author | Elena ``of Valhalla'' Grandi <elena.valhalla@gmail.com> | 2012-01-26 07:04:08 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <elena.valhalla@gmail.com> | 2012-01-26 07:04:08 +0100 |
commit | 0dc9cd95010ac7ae60141629367d60472084f132 (patch) | |
tree | a6bbdefd8e384e0ae438dc7e4125b5d097f7da76 /arduino_sketch | |
parent | e16a541a0442f2dd596d23ae6938e28a3a3feaa4 (diff) |
arduino sketch: fix loading of status after lack of power
Diffstat (limited to 'arduino_sketch')
-rw-r--r-- | arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde b/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde index 090f14e..1b5fd89 100644 --- a/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde +++ b/arduino_sketch/fuzzy_alarm_clock_ds1307/fuzzy_alarm_clock_ds1307.pde @@ -44,7 +44,7 @@ int st = 0; // alarm status (minutes from alarm - TIN) char alarms[NALARMS][5]; // alarm settings char cmin; // current minute -int a = -1; // current alarm +signed char a = -1; // current alarm char dbg = 0; // print debug informations bool ringing = false; // sound the alarm bool pressed = false; // stop button status @@ -88,10 +88,12 @@ void setup () { cmin = RTC.readData(0x0a); // This only works if the arduino had no power for a // "short" time. This is by design. :D - RTC.readClock(); - st = st + (RTC.getMinutes() - cmin) % 60; - cmin = RTC.getMinutes(); - save_status(); + if ( a >= 0 ) { + RTC.readClock(); + st = st + (RTC.getMinutes() - cmin) % 60; + cmin = RTC.getMinutes(); + save_status(); + } for ( int i = 0; i < NALARMS ; i ++ ) { for ( int j = 0; j < 5 ; j ++ ) { alarms[i][j] = RTC.readData(0x0b + i*5 + j); |