add auto turn off

master
Eggert Jung 4 years ago
parent 551b210656
commit bb1f68baab

@ -1,12 +1,10 @@
#include <avr/io.h> #include <avr/io.h>
#include <stdint.h> // has to be added to use uint8_t #include <avr/interrupt.h>
#include <avr/interrupt.h> // Needed to use interrupts
#include <avr/sleep.h> #include <avr/sleep.h>
#include <avr/eeprom.h> #include <avr/eeprom.h>
// 1 count = 0,065536 s #define ACTIVE_TIME 1 // minutes
#define ACTIVE_COUNT_MAX 13733 #define ANIMATION_INTERVALL 3 // counter increments (0.016 sec)
#define ANIMATION_INTERVALL 3
uint8_t EEMEM on_off_state; uint8_t EEMEM on_off_state;
volatile uint32_t leds = 0x00; volatile uint32_t leds = 0x00;
@ -111,9 +109,11 @@ ISR(TIMER0_OVF_vect){
{ {
count++; count++;
} }
if(active_count >= ACTIVE_COUNT_MAX){ if(active_count >= ACTIVE_TIME * 3662){
active_count=0; leds=0;
//leds_active = 0; write_leds();
//TODO maybe sleep here eeprom_write_byte(&on_off_state, 1);
set_sleep_mode(SLEEP_MODE_PWR_SAVE);
sleep_mode();
} }
} }

Loading…
Cancel
Save