   return temperature;
 }
 
+bool isTopButtonPressed(){
+  int upPressed = digitalRead(PIN_BUTTON_UP);
+
+  if(upPressed == LOW){
+    return buttonDebounceComplete();
+  } else {
+    return false;
+  }
+}
+
 bool isMiddleButtonPressed(){
-
   int enterPressed = digitalRead(PIN_BUTTON_ENTER);
 
   if(enterPressed == LOW){
-
-    static unsigned long lastPressedTime = 0;
-    unsigned long currentTime = millis();
-
-    if((currentTime - lastPressedTime) > BUTTON_DEBOUNCE){
-      lastPressedTime = currentTime;
-      return true;
-    } else {
-      return false;
-    }  
-
+    return buttonDebounceComplete();
   } else {
     return false;
   }
 }
 
+bool isBottomButtonPressed(){
+  int downPressed = digitalRead(PIN_BUTTON_DOWN);
+
+  if(downPressed == LOW){
+    return buttonDebounceComplete();
+  } else {
+    return false;
+  }
+}
+
+bool buttonDebounceComplete(){
+  static unsigned long lastPressedTime = 0;
+  unsigned long currentTime = millis();
+
+  if((currentTime - lastPressedTime) > BUTTON_DEBOUNCE){
+    lastPressedTime = currentTime;
+    return true;
+  } else {
+    return false;
+  }
+}
+
 void shortBeepXTimesNoDelay(int times){
-  beepsLeft = times;  
+  beepsLeft = times;
 }
 
 //We don't use delay from beeps to avoid holding up the controller

    if(currentState != STATE_WINDOW_WITHIN){
      shortBeepXTimesNoDelay(2);
    }
    
    currentState = STATE_WINDOW_BEFORE;
    Serial.println("Window Before");
  }

  updateDisplayBackLightSettingsForCertainModes();

  if(currentValue >= CURRENT_ENABLE_THRESHOLD){
    return STATE_WINDOW_WITHIN;
  }

  return STATE_WINDOW_BEFORE;
   
}

STATE enterWindowWithinMode(double currentValue){
  unsigned long currentTime = millis();

  static unsigned long enableWindowTime = 0;
  
  if(currentState != STATE_WINDOW_WITHIN){
    currentState = STATE_WINDOW_WITHIN;
    enableWindowTime = currentTime;


  //We remain in this mode until the temperature drops below TEMP_WARN to prevent oscillating into this mode and out
  if(temperature >= TEMP_WARN){
    return STATE_TEMP_MAX;
  } else {
    return STATE_WINDOW_BEFORE;
  }
}

void updateDisplayBackLightSettingsForCertainModes(){
  if(isMiddleButtonPressed()){
    isBacklightAlwaysOn = !isBacklightAlwaysOn;
    changeDisplayBacklight(isBacklightAlwaysOn);
  }
}

void updateCurrentThresholdForCertainModes(){
  float newThreshold = currentEnableThreshold;

  if(isTopButtonPressed()){
    changeEnableThreshold(currentEnableThreshold += 0.01);
  }

  if(isBottomButtonPressed()){
    changeEnableThreshold(currentEnableThreshold -= 0.01);
  }



}


