Bug fix when exit sleep time when display was turned off.
parent
481936e599
commit
5f86c26e49
|
|
@ -30,7 +30,7 @@ SOFTWARE.
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#define VERSION "3.1"
|
#define VERSION "3.1.1"
|
||||||
|
|
||||||
#define HOSTNAME "PrintMon-"
|
#define HOSTNAME "PrintMon-"
|
||||||
#define CONFIG "/conf.txt"
|
#define CONFIG "/conf.txt"
|
||||||
|
|
@ -83,7 +83,8 @@ String lastMinute = "xx";
|
||||||
String lastSecond = "xx";
|
String lastSecond = "xx";
|
||||||
String lastReportStatus = "";
|
String lastReportStatus = "";
|
||||||
boolean displayOn = true;
|
boolean displayOn = true;
|
||||||
bool displaySleepOn = false;
|
boolean displaySleepOn = false;
|
||||||
|
boolean isSleepTime = false;
|
||||||
|
|
||||||
// Printer Client
|
// Printer Client
|
||||||
#if defined(USE_REPETIER_CLIENT)
|
#if defined(USE_REPETIER_CLIENT)
|
||||||
|
|
@ -1357,12 +1358,13 @@ void checkDisplay() {
|
||||||
// Enable or disable Display Sleep mode
|
// Enable or disable Display Sleep mode
|
||||||
checkSleepDisplay();
|
checkSleepDisplay();
|
||||||
if (!displayOn && DISPLAYCLOCK) {
|
if (!displayOn && DISPLAYCLOCK) {
|
||||||
if (displaySleepOn) {
|
if (isSleepTime && !displaySleepOn) {
|
||||||
|
enableSleepDisplay(true);
|
||||||
if (!DISPLAY_SLEEP_TURNOFF) { // Turn on display in brightness sleep mode, otherwise display stays off
|
if (!DISPLAY_SLEEP_TURNOFF) { // Turn on display in brightness sleep mode, otherwise display stays off
|
||||||
enableDisplay(true);
|
enableDisplay(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!isSleepTime) {
|
||||||
enableDisplay(true);
|
enableDisplay(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (displayOn && !printerClient.isPrinting() && !DISPLAYCLOCK) {
|
if (displayOn && !printerClient.isPrinting() && !DISPLAYCLOCK) {
|
||||||
|
|
@ -1394,32 +1396,34 @@ void checkDisplay() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (DISPLAYCLOCK) {
|
} else if (DISPLAYCLOCK) {
|
||||||
if (displayOn && (!printerClient.isPrinting() || printerClient.isPSUoff()) && displaySleepOn && DISPLAY_SLEEP_TURNOFF) {
|
if (displayOn && !displaySleepOn && isSleepTime && DISPLAY_SLEEP_TURNOFF && (!printerClient.isPrinting() || printerClient.isPSUoff())) {
|
||||||
isClockOn = true;
|
enableSleepDisplay(true);
|
||||||
display.clear();
|
display.clear();
|
||||||
display.display();
|
display.display();
|
||||||
display.setFont(ArialMT_Plain_16);
|
display.setFont(ArialMT_Plain_16);
|
||||||
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display.drawString(64, 5, "Printer Offline\nDisplay\nSleep Mode");
|
display.drawString(64, 5, "Printer Offline\nDisplay\nSleep Mode");
|
||||||
display.display();
|
display.display();
|
||||||
Serial.println("Printer Offline and Display Sleep mode on, going down to sleep..");
|
Serial.println("Printer Offline and Display Sleep mode on, going down to sleep...");
|
||||||
delay(5000);
|
delay(5000);
|
||||||
enableDisplay(false);
|
enableDisplay(false);
|
||||||
}
|
isClockOn = true; // Avoid set clock mode in display sleep with display off
|
||||||
if ((!printerClient.isPrinting() || printerClient.isPSUoff()) && !isClockOn) {
|
} else if (displayOn && !displaySleepOn && isSleepTime && !DISPLAY_SLEEP_TURNOFF) {
|
||||||
Serial.println("Clock Mode is turned on.");
|
enableSleepDisplay(true);
|
||||||
if (!DISPLAYWEATHER) {
|
} else if ((!printerClient.isPrinting() || printerClient.isPSUoff()) && !isClockOn) {
|
||||||
ui.disableAutoTransition();
|
Serial.println("Clock Mode is turned on.");
|
||||||
ui.setFrames(clockFrame, 1);
|
if (!DISPLAYWEATHER) {
|
||||||
clockFrame[0] = drawClock;
|
ui.disableAutoTransition();
|
||||||
} else {
|
ui.setFrames(clockFrame, 1);
|
||||||
ui.enableAutoTransition();
|
clockFrame[0] = drawClock;
|
||||||
ui.setFrames(clockFrame, 2);
|
} else {
|
||||||
clockFrame[0] = drawClock;
|
ui.enableAutoTransition();
|
||||||
clockFrame[1] = drawWeather;
|
ui.setFrames(clockFrame, 2);
|
||||||
}
|
clockFrame[0] = drawClock;
|
||||||
ui.setOverlays(clockOverlay, numberOfOverlays);
|
clockFrame[1] = drawWeather;
|
||||||
isClockOn = true;
|
}
|
||||||
|
ui.setOverlays(clockOverlay, numberOfOverlays);
|
||||||
|
isClockOn = true;
|
||||||
} else if (printerClient.isPrinting() && !printerClient.isPSUoff() && isClockOn) {
|
} else if (printerClient.isPrinting() && !printerClient.isPSUoff() && isClockOn) {
|
||||||
if (displaySleepOn && DISPLAY_SLEEP_TURNOFF) {
|
if (displaySleepOn && DISPLAY_SLEEP_TURNOFF) {
|
||||||
enableDisplay(true);
|
enableDisplay(true);
|
||||||
|
|
@ -1451,45 +1455,87 @@ void enableDisplay(boolean enable) {
|
||||||
}
|
}
|
||||||
display.displayOn();
|
display.displayOn();
|
||||||
Serial.println("Display was turned ON: " + timeClient.getFormattedTime());
|
Serial.println("Display was turned ON: " + timeClient.getFormattedTime());
|
||||||
|
Serial.println("enableDisplayOn displayOn: " + String(displayOn));
|
||||||
|
Serial.println("enableDisplayOn DISPLAYCLOCK: " + String(DISPLAYCLOCK));
|
||||||
|
Serial.println("enableDisplayOn isSleepTime: " + String(isSleepTime));
|
||||||
|
Serial.println("enableDisplayOn displaySleepOn: " + String(displaySleepOn));
|
||||||
|
Serial.println("enableDisplayOn DISPLAY_SLEEP_TURNOFF: " + String(DISPLAY_SLEEP_TURNOFF));
|
||||||
|
Serial.println("enableDisplayOn isClockOn: " + String(isClockOn));
|
||||||
|
Serial.println("enableDisplayOn printerClient.isPrinting(): " + String(printerClient.isPrinting()));
|
||||||
|
Serial.println("enableDisplayOn printerClient.isPSUoff(): " + String(printerClient.isPSUoff()));
|
||||||
} else {
|
} else {
|
||||||
display.displayOff();
|
display.displayOff();
|
||||||
Serial.println("Display was turned OFF: " + timeClient.getFormattedTime());
|
Serial.println("Display was turned OFF: " + timeClient.getFormattedTime());
|
||||||
displayOffEpoch = lastEpoch;
|
displayOffEpoch = lastEpoch;
|
||||||
|
Serial.println("enableDisplayOff displayOn: " + String(displayOn));
|
||||||
|
Serial.println("enableDisplayOff DISPLAYCLOCK: " + String(DISPLAYCLOCK));
|
||||||
|
Serial.println("enableDisplayOff isSleepTime: " + String(isSleepTime));
|
||||||
|
Serial.println("enableDisplayOff displaySleepOn: " + String(displaySleepOn));
|
||||||
|
Serial.println("enableDisplayOff DISPLAY_SLEEP_TURNOFF: " + String(DISPLAY_SLEEP_TURNOFF));
|
||||||
|
Serial.println("enableDisplayOff isClockOn: " + String(isClockOn));
|
||||||
|
Serial.println("enableDisplayOff printerClient.isPrinting(): " + String(printerClient.isPrinting()));
|
||||||
|
Serial.println("enableDisplayOff printerClient.isPSUoff(): " + String(printerClient.isPSUoff()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkSleepDisplay() {
|
void checkSleepDisplay() {
|
||||||
|
isSleepTime=checkSleepTime();
|
||||||
if (displaySleepOn) {
|
if (displaySleepOn) {
|
||||||
if(!enableSleepDisplay()) {
|
if(!isSleepTime) {
|
||||||
|
isClockOn=false;
|
||||||
|
enableSleepDisplay(false);
|
||||||
// Disable Sleep Display
|
// Disable Sleep Display
|
||||||
Serial.println("Display Sleep FINISH: " + timeClient.getFormattedTime());
|
Serial.println("Display Sleep FINISH: " + timeClient.getFormattedTime());
|
||||||
display.setBrightness(DISPLAY_BRIGHTNESS);
|
display.setBrightness(DISPLAY_BRIGHTNESS);
|
||||||
Serial.println("Display Brightness NORMAL: " + String(DISPLAY_BRIGHTNESS));
|
Serial.println("Display Brightness NORMAL: " + String(DISPLAY_BRIGHTNESS));
|
||||||
enableDisplay(true);
|
if (DISPLAY_SLEEP_TURNOFF) {
|
||||||
display.clear();
|
enableDisplay(true);
|
||||||
display.display();
|
display.clear();
|
||||||
display.setFont(ArialMT_Plain_16);
|
display.display();
|
||||||
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
display.setFont(ArialMT_Plain_16);
|
||||||
display.setContrast(255); // default is 255
|
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display.drawString(64, 5, "Display\nWake up...");
|
display.setContrast(255); // default is 255
|
||||||
display.display();
|
display.drawString(64, 5, "Display\nWake up...");
|
||||||
Serial.println("Display waking up...");
|
display.display();
|
||||||
delay(5000);
|
Serial.println("Display waking up...");
|
||||||
|
|
||||||
|
Serial.println("checkSleepDisplay Display Brightness SLEEP MODE: " + String(SLEEP_BRIGHTNESS));
|
||||||
|
Serial.println("checkSleepDisplay displayOn: " + String(displayOn));
|
||||||
|
Serial.println("checkSleepDisplay DISPLAYCLOCK: " + String(DISPLAYCLOCK));
|
||||||
|
Serial.println("checkSleepDisplay isSleepTime: " + String(isSleepTime));
|
||||||
|
Serial.println("checkSleepDisplay displaySleepOn: " + String(displaySleepOn));
|
||||||
|
Serial.println("checkSleepDisplay DISPLAY_SLEEP_TURNOFF: " + String(DISPLAY_SLEEP_TURNOFF));
|
||||||
|
Serial.println("checkSleepDisplay isClockOn: " + String(isClockOn));
|
||||||
|
Serial.println("checkSleepDisplay printerClient.isPrinting(): " + String(printerClient.isPrinting()));
|
||||||
|
Serial.println("checkSleepDisplay printerClient.isPSUoff(): " + String(printerClient.isPSUoff()));
|
||||||
|
delay(5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (enableSleepDisplay()) {
|
} else if (isSleepTime && !displaySleepOn) {
|
||||||
// Enable Sleep Display
|
// Enable Sleep Display
|
||||||
Serial.println("Display Sleep START: " + timeClient.getFormattedTime());
|
Serial.println("Display Sleep START: " + timeClient.getFormattedTime());
|
||||||
display.setBrightness(SLEEP_BRIGHTNESS);
|
display.setBrightness(SLEEP_BRIGHTNESS);
|
||||||
Serial.println("Display Brightness SLEEP MODE: " + String(SLEEP_BRIGHTNESS));
|
Serial.println("checkSleepDisplay Display Brightness SLEEP MODE: " + String(SLEEP_BRIGHTNESS));
|
||||||
|
Serial.println("checkSleepDisplay displayOn: " + String(displayOn));
|
||||||
|
Serial.println("checkSleepDisplay DISPLAYCLOCK: " + String(DISPLAYCLOCK));
|
||||||
|
Serial.println("checkSleepDisplay isSleepTime: " + String(isSleepTime));
|
||||||
|
Serial.println("checkSleepDisplay displaySleepOn: " + String(displaySleepOn));
|
||||||
|
Serial.println("checkSleepDisplay DISPLAY_SLEEP_TURNOFF: " + String(DISPLAY_SLEEP_TURNOFF));
|
||||||
|
Serial.println("checkSleepDisplay isClockOn: " + String(isClockOn));
|
||||||
|
Serial.println("checkSleepDisplay printerClient.isPrinting(): " + String(printerClient.isPrinting()));
|
||||||
|
Serial.println("checkSleepDisplay printerClient.isPSUoff(): " + String(printerClient.isPSUoff()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enableSleepDisplay() {
|
void enableSleepDisplay(boolean enable) {
|
||||||
displaySleepOn=isSleepTime(DISPLAY_SLEEP,BeginSleepHour,BeginSleepMin,EndSleepHour,EndSleepMin);
|
displaySleepOn=enable;
|
||||||
return displaySleepOn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSleepTime(bool DISPLAY_SLEEP,int BeginSleepHour,int BeginSleepMin,int EndSleepHour,int EndSleepMin) {
|
bool checkSleepTime() {
|
||||||
|
return SleepTime(DISPLAY_SLEEP,BeginSleepHour,BeginSleepMin,EndSleepHour,EndSleepMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SleepTime(bool DISPLAY_SLEEP,int BeginSleepHour,int BeginSleepMin,int EndSleepHour,int EndSleepMin) {
|
||||||
if (DISPLAY_SLEEP) {
|
if (DISPLAY_SLEEP) {
|
||||||
int curHour = timeClient.getHours().toInt();
|
int curHour = timeClient.getHours().toInt();
|
||||||
int curMin = timeClient.getMinutes().toInt();
|
int curMin = timeClient.getMinutes().toInt();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue