From 2a70b3a12ebf8a47000b083b551b01d410d72255 Mon Sep 17 00:00:00 2001 From: Nicolae Hodos Date: Sun, 29 Jan 2017 20:23:29 +0100 Subject: [PATCH] improve sleep based on lamp switch and add parameterized enableWdt --- libraries/TinyPower/TinyPower.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/TinyPower/TinyPower.h b/libraries/TinyPower/TinyPower.h index dd07161..5aac5a3 100644 --- a/libraries/TinyPower/TinyPower.h +++ b/libraries/TinyPower/TinyPower.h @@ -22,18 +22,26 @@ public: adc_disable(); sleep_enable(); // Sets the Sleep Enable bit in the MCUCR Register (SE BIT) + sleep_bod_disable(); sei(); // Enable interrupts sleep_cpu(); // sleep + sleep_disable(); // Clear SE bit cli(); // Disable interrupts PCMSK &= ~_BV(PCINT0); // Turn off PB0 as interrupt pin - sleep_disable(); // Clear SE bit adc_enable(); sei(); // Enable interrupts } + static void enableWdt(byte time) + { + MCUSR = 0x00; + WDTCR |= _BV(WDCE) | _BV(WDE); + WDTCR = _BV(WDIE) | time; + } + //enable the wdt for 8sec interrupt static void enableWdt() {