Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jbaumann/attiny_daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaumann committed Nov 22, 2021
2 parents 2f634fa + f4e5deb commit a271944
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion firmware/ATTinyDaemon/ATTinyDaemon.h
Expand Up @@ -19,7 +19,7 @@
*/
static const uint32_t MAJOR = 2;
static const uint32_t MINOR = 13;
static const uint32_t PATCH = 14;
static const uint32_t PATCH = 15;

/*
Flash size definition
Expand Down
8 changes: 5 additions & 3 deletions firmware/ATTinyDaemon/ATTinyDaemon.ino
Expand Up @@ -135,15 +135,17 @@ void setup() {
ISR (PCINT0_vect) {

disable_watchdog();

if (seconds > timeout && primed != 1) {
primed = 1;
/*
if (seconds > timeout && primed == 0) {
primed = 2;
// could be set during the shutdown while the timeout has not yet been exceeded. We reset it.
should_shutdown = Shutdown_Cause::none;
} else {
// signal the Raspberry that the button has been pressed.
should_shutdown |= Shutdown_Cause::button;
}
*/
should_shutdown |= Shutdown_Cause::button;
}

void loop() {
Expand Down
2 changes: 2 additions & 0 deletions firmware/ATTinyDaemon/handleIO.ino
Expand Up @@ -269,4 +269,6 @@ void ups_on() {
push_switch(pulse_length_safe);
}
}
// we restart I2C since the RPi has just been turned on (again)
init_I2C();
}
11 changes: 8 additions & 3 deletions firmware/ATTinyDaemon/handleState.ino
Expand Up @@ -135,14 +135,19 @@ void act_on_state_change() {
init_I2C();
}
if (should_restart) {
if (primed == 1) {
if (primed > 0
|| (primed == 0 && (should_shutdown && Shutdown_Cause::button)) ) {
// RPi has not accessed the I2C interface for more than timeout seconds.
// We restart it. Signal restart by blinking ten times
blink_led(10, BLINK_TIME / 2);
restart_raspberry();
}

reset_counter_Safe();
// Primed has been set by the button press, we use the restart time
// for debouncing
should_shutdown &= ~Shutdown_Cause::button;

reset_counter_Safe();
}
}
}
}
Expand Down

0 comments on commit a271944

Please sign in to comment.