 }
 
 /**
-   Wait for the RPi to shutdown properly, while disabling interrupts so to
-   avoid new touch events from being registered.
+   Wait for the RPi to shutdown properly. In the future more logic might be added here.
 */
 void waitForRPiShutdown() {
-  noInterrupts();
   delay(shutdownTime);
-  interrupts();
 }
 
 void setup() {
   Serial.begin(9600); // The Universal ATtinyCore library by Spence Konde uses PB0 as TX and PB1 as RX
   pinMode(rpiPwrPin, OUTPUT);
   pinMode(touchSensorPin, INPUT);
-  turnRPiPowerOff(); // When starting up, make sure the power to the RPi is off
   // Setup pin change interrupt for D2
   PCMSK |= bit (PCINT2); // want pin D2 (PB2)
   GIFR |= bit (PCIF); // clear any outstanding interrupts

   - Sleep state where the microcontroller is in deep sleep and the power to the RPi is OFF.
   - Operation state where the microcontroller is triggering the relay to power on the RPi and
   can communication to it via UART.

   ==== CURRENT FUNCTIONALITY ====
   Upon starting up, the microcontroller goes in deep sleep which can be interrupted by a HIGH


volatile unsigned long timeToSleep = 0;
const unsigned long awakePeriod = 600000; // Time in milliseconds to remain awake on every new touch
const unsigned long shutdownTime = 12000; // Time in milliseconds to wait for the RPi to shutdown

enum PowerState {
  SLEEP,
  OPERATION,
  SHUTDOWN
};
PowerState currentState = SLEEP; // Begin in a deep sleep state

/**
   The change interrupt callback
*/
ISR (PCINT0_vect) {
  // We register a touch event only when the signal from the touchSensor is rising
  // Ignore touch events while in shutdown state
  if (currentState != SHUTDOWN && digitalRead(touchSensorPin) == HIGH) {
    timeToSleep = millis() + awakePeriod;
  }
}
