Aiuto con millis

Sto guardando, ma non mi è facile seguirlo senza averlo sviluppato da zero piano piano...
Per renderlo più comprensibile, dato che silenzia() sta solo dentro alarm() lo metterei lì direttamente.

#include <OneWire.h>
#include <DallasTemperature.h>
#define Temp_Max_Stored 25.70
#define led_red D5
#define led_green D6
#define ONE_WIRE_BUS D4 // Data wire is plugged to arduino pin
#define buzzer D7 // buzzer to arduino pin D7
#define snoozeDuration 30000 // attesa 5 minuti (1000 millisecondi equivalgono ad un secondo)
#define pauseBetweenNotes 1000
#define noteDuration 1000
#define relay_pin D0

float tempDALLAS;
unsigned long previousMillisAlarm = 0;
unsigned long previousMillisSilenzia = 0;
boolean outputTone = false;                // Records current state
bool snoozed = false;
bool muto = false;
OneWire oneWire1(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire1);
unsigned long t = 0;

void setup()
{
  Serial.begin(115200);
  // set up LEDs
  pinMode (led_red, OUTPUT);    digitalWrite(led_red, LOW);
  pinMode (led_green, OUTPUT); digitalWrite(led_green, LOW);
  pinMode (relay_pin, OUTPUT);  digitalWrite(relay_pin, HIGH);
  Serial.println("");  Serial.println("ArduAcquario MALAWI ");
}


void temperature()
{

  if (millis() - t > 5000) // Una volta ogni 5 secondi:
  {
    t = millis();
    sensors.requestTemperatures();
    tempDALLAS = sensors.getTempCByIndex(0);   // Read temperature of Dallas sensor
  }
}


void loop()
{
  temperature();
  while (tempDALLAS > Temp_Max_Stored)
  {
    Serial.println("================= ALARM TIME! ================");
    Serial.print ("Temp_Max_Stored = "); Serial.println (Temp_Max_Stored);
    temperature();
    digitalWrite (led_green, LOW); //set the LED off
    digitalWrite (led_red, HIGH); //set the LED on
    Serial.println();  Serial.print ("Temperatura acqua troppo ALTA! ");
    Serial.println(tempDALLAS); Serial.println();
    alarm();
    digitalWrite(relay_pin, LOW);
    delay(500);
  }

  digitalWrite (led_green, HIGH ); //set the LED off
  digitalWrite (led_red, LOW); //set the LED on
  Serial.println("==============================================");
  Serial.print("Temperatura acqua coretta ");
  Serial.println(tempDALLAS);
  digitalWrite(relay_pin, HIGH);
  noTone(buzzer);
}



void alarm()
{
  unsigned long  currentMillis = millis();
  int Value = analogRead(0);
  int Btn = 0;

  if (Value > 5    &&  Value < 20)   Btn = 1; //enter
  if (Value > 240 &&  Value < 300) Btn = 2; //up
  if (Value > 400 &&  Value < 450) Btn = 3; //down
  if (Value > 500 &&  Value < 600) Btn = 4; //back
  if (Btn >= 1 && Btn <= 3)
  {
    if (currentMillis - previousMillisSilenzia < snoozeDuration)
    {
      noTone(buzzer);
      muto = true;
      Serial.println(); Serial.println();
      Serial.println(currentMillis - previousMillisSilenzia);
      Serial.println(snoozeDuration);
      previousMillisSilenzia = currentMillis;
      Serial.println("******************** IF SILENZIA******************** ");
    }

    else
    {
      Serial.print("button = ");
      Serial.println(Btn);
      Serial.println ("BUTTON PRESSED - ALLARM SNOOZED");
      muto = false;
      Serial.println("******************** ELSE SILENZIA******************** ");
    }
  if (!muto)
  {
    unsigned long currentMillis = millis();
    if (outputTone)
    {
      // We are currently outputting a tone
      // Check if it's been long enough and turn off if so
      if (currentMillis - previousMillisAlarm >= noteDuration)
      {
        previousMillisAlarm = currentMillis;
        noTone(buzzer);
        outputTone = false;
      }
    } // END if (outputTone)

    else
    {
      // We are currently in a pause
      // Check if it's been long enough and turn on if so
      if (currentMillis - previousMillisAlarm >= pauseBetweenNotes)
      {
        previousMillisAlarm = currentMillis;
        tone(buzzer, 1000);
        outputTone = true;
      }
    } // END else
  } // END if (outputTone)
} // END alarm()