The Snooze Library seems to kill writing to EEPROM.
Is there any code for recovering Writing To EEProm after waking from sleep?
The code below demonstrates the problem.
Code:
#include <EEPROM.h>
#include <Snooze.h>
const int ledPin = 13;
int eeAddress = 0;
struct GPScord {
float flat;
float flon;
};
GPScord dummy;
int dummyInt = 0;
//SnoozeDigital digital;
SnoozeTimer timer;
SnoozeUSBSerial usb;
//SnoozeAlarm alarm;
SnoozeBlock config_teensy40(usb, timer);
void blink(int count)
{
int n=0;
while (n<count){
digitalWrite(ledPin,HIGH);
delay(500);
digitalWrite(ledPin,LOW);
delay(500);
n++;
}
}
void setup(){
Serial.begin(9600);
delay(4000);
pinMode(ledPin, OUTPUT);
timer.setTimer(10);
blink(4);
}
void loop() {
while (eeAddress < 1060) {
int who;
who = Snooze.deepSleep( config_teensy40 );
if (who == 36) { // rtc wakeup value
eeAddress += sizeof(dummyInt);
delay(5000);
usb.println(eeAddress);
usb.println("About to write to EEPROM");
EEPROM.write(eeAddress, dummyInt);
usb.println("Back from writing to EEPROM");// IT DOES NOT COME BACK!!!!
// EEPROM.put(eeAddress, dummy);
blink(1);
}
else {
blink(2);
usb.println(who);
}
}
}