| \ By saving a counter to the RTC, we can ignore some time-based wakeups |
| \ We can further save power by waking up with the RF system off, |
| \ but when we need to use the wifi, we can switch to RF-on wakeup |
| \ and schedule a new wakeup. |
| |
| #256 2 rshift constant rtc-user-offset |
| rtc-user-offset 0 2 rshift + rtc-time-offset |
| : rtc! ( n index -- ) |
| >r sp@ 4 swap rtc-user-offset r> + rtc-mem-write drop |
| ; |
| : rtc@ ( index -- n ) |
| >r 0 sp@ 4 swap rtc-user-offset r> + rtc-mem-read drop |
| ; |
| |
| \ Wakeup occurs on a positive pulse on RST. It can be generated by |
| \ D0 via the RTC or by an external logic signal. They can be OR'ed |
| \ together with external logic. |
| \ One simple approach with be to wake up every minute and check the |
| \ door switch. If its state has changed (save old value in RTC mem) |
| \ then schedule an RF-enabled wakeup and send a message. |
| \ reset-info c@ => |
| \ 0:poweron 1:hardwareWDT 2:fatalException |
| \ 3: softwareWDT 4: softwareReset 5: deepSleep 6: HardwareReset |