// LCD
byte customCharSun[8] = {0b00100, 0b10001, 0b01110, 0b11111, 0b11111, 0b01110, 0b10001, 0b00100};
byte customCharMoon[8] = {0b11000, 0b01110, 0b00110, 0b00111, 0b00111, 0b00110, 0b01110, 0b11000};
byte customCharArrowRight[8] = {0b00000, 0b00100, 0b00110, 0b11111, 0b11111, 0b00110, 0b00100, 0b00000};
//bool displayActive = false;
unsigned long displayLastOnMillis = 0;

//extern long lastDisplayUpdate;

void enableDisplay() {
  lcd.backlight();
  displayActive = true;
  displayLastOnMillis = millis();
}

void disableDisplay() {
  lcd.noBacklight();
  displayActive = false;
}

void extendDisplayTimeout() {
  displayLastOnMillis = millis();
}

void handleDisplayTimeout() {
  if (displayActive && (millis() - displayLastOnMillis) > displayTimeout) {
    disableDisplay();
  }
}

void updateDisplay() {
  lastDisplayUpdate = 0;
}

void initDisplay() {
  lcd.init();
  lcd.createChar(0, customCharMoon);
  lcd.createChar(1, customCharSun);
  lcd.createChar(2, customCharArrowRight);

  lcd.setCursor(0, 0);

  lcd.print("WiFi-Thermostat ");
  lcd.setCursor(0, 1);
  lcd.print("      by Flo Kra");

  //  for ( int i = 0; i < 3; i++) {
  //    lcd.backlight();
  //    delay(200);
  //    lcd.noBacklight();
  //    delay(200);
  //  }
  lcd.backlight();
  delay(1000);
  ///lcd.clear();
  displayActive = true;
  displayLastOnMillis = millis();
}

