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