7 #ifndef __RESETONBOOT_H__
8 #define __RESETONBOOT_H__
10 #define BOOT_STATE_NORMAL 0x00
11 #define BOOT_STATE_PRE_RESET 0x01
12 #define BOOT_STATE_RESET 0x02
18 template <
class DEVTYPE>
25 ResetOnBoot (DEVTYPE& d) :
Alarm(0), dev(d), cnt(0), ms(200) { async(
true); }
28 void setBootState(uint8_t state) {
30 sc.setByte(CONFIG_BOOTSTATE, state);
35 uint8_t getBootState() {
38 return sc.getByte(CONFIG_BOOTSTATE);
43 setBootState(BOOT_STATE_NORMAL);
46 virtual void trigger (__attribute__ ((unused))
AlarmClock& clock) {
47 if (cnt < (4000 / ms)) {
49 cnt % 2 == 0 ? led(
true) : led(
false);
50 tick = millis2ticks(ms);
57 virtual void led(
bool on) {
58 on ==
true ? dev.led().ledOn() : dev.led().ledOff();
62 if (getBootState() == BOOT_STATE_RESET) {
63 DPRINT(F(
"Activated RESET ON BOOT"));
66 }
else if (getBootState() == BOOT_STATE_PRE_RESET) {
67 setBootState(BOOT_STATE_RESET);
69 }
else if (getBootState() == BOOT_STATE_NORMAL) {
70 setBootState(BOOT_STATE_PRE_RESET);
72 set(millis2ticks(ms));