Added clock-halt handling and improved display.

This commit is contained in:
Dirk Jahnke
2018-11-14 11:12:36 +01:00
parent 9292826f72
commit 708aeb2e72
6 changed files with 51 additions and 17 deletions

View File

@@ -128,12 +128,18 @@ void Display::addLogMessage(const char *message) {
void Display::showDashboard(void) {
static unsigned long lastDisplayUpdate_ms = 0;
static unsigned long lastBlinkChange_ms = 0;
static bool blinkOnCycle = false; // toggles the on/off blinking phase
currentScreen = DashboardScreen;
// avoid flickering of the display:
if (millis() - lastDisplayUpdate_ms < TIME_BETWEEN_DISPLAY_UPDATES_ms) return;
lastDisplayUpdate_ms = millis();
if (lastDisplayUpdate_ms - lastBlinkChange_ms > BLINK_ON_OFF_TIME_ms) {
lastBlinkChange_ms = lastDisplayUpdate_ms;
blinkOnCycle = !blinkOnCycle;
}
u8g2.clearBuffer();
u8g2.setDrawColor(1);
@@ -143,26 +149,28 @@ void Display::showDashboard(void) {
u8g2.print(clockName);
// ****** speed *****
setNormalTextSize();
u8g2.setCursor(55, 2*getTextHeight()-1);
setSmallTextSize();
u8g2.setCursor(55, 2*getTextHeight());
u8g2.print(clockSpeed);
// ***** time *****
setLargeTextSize();
u8g2.setCursor(0, u8g2.getDisplayHeight()-1);
if (clockHour < 10) u8g2.print("0");
u8g2.print(clockHour);
u8g2.print(":");
if (clockMinute < 10) u8g2.print("0");
u8g2.print(clockMinute);
if (!clockHalted || blinkOnCycle) {
setLargeTextSize();
u8g2.setCursor(0, u8g2.getDisplayHeight()-1);
if (clockHour < 10) u8g2.print("0");
u8g2.print(clockHour);
u8g2.print(":");
if (clockMinute < 10) u8g2.print("0");
u8g2.print(clockMinute);
}
// ***** halt/go *****
if (clockHalted) {
setSmallTextSize();
u8g2.setDrawColor(1);
u8g2.drawBox(55, u8g2.getDisplayHeight() - 2*getTextHeight()-3, 5*4+2, getTextHeight());
u8g2.setDrawColor(0);
u8g2.setCursor(57, u8g2.getDisplayHeight() - getTextHeight()-3);
u8g2.setDrawColor(blinkOnCycle ? 1 : 0);
u8g2.drawBox(55, u8g2.getDisplayHeight() - 2*getTextHeight()-4, 4*u8g2.getMaxCharWidth()+3, getTextHeight()+1);
u8g2.setDrawColor(blinkOnCycle ? 0 : 1);
u8g2.setCursor(57, u8g2.getDisplayHeight() - getTextHeight()-4);
u8g2.print("HALT");
u8g2.setDrawColor(1);
}