From 59a0170b85a120af4fe83a989a3ab7250584fe88 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Wed, 14 Nov 2018 11:27:06 +0100 Subject: [PATCH] Client clock list displayed only, if clients are present. --- src/display.cpp | 24 +++++++++++++----------- src/display.h | 12 ++++++++++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index d6790ed..b4b9773 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -51,7 +51,7 @@ Display::Display() { setClockWeekday("Mon"); setClockHalted(true); setNumberKnownClients(0); - for (int i=0; i"); + u8g2.print(numberKnownClients); u8g2.print(" Clks"); // ***** client list ***** u8g2.drawVLine(79, 0, u8g2.getDisplayHeight()); for (int i=0; i<5; ++i) { - u8g2.setDrawColor(1); - u8g2.drawBox(81, i * getTextHeight(), 3*3+1, getTextHeight()); - u8g2.setCursor(82, (i+1) * getTextHeight()); - u8g2.setDrawColor(0); - if (i < 10) u8g2.print(0); - u8g2.print(i); - u8g2.setDrawColor(1); - u8g2.setCursor(82+3*3+1+1, (i+1) * getTextHeight()); - u8g2.print(clientName[i]); + if (clientName[i][0] != 0) { + u8g2.setDrawColor(1); + u8g2.drawBox(81, i * getTextHeight(), 3*3+1, getTextHeight()); + u8g2.setCursor(82, (i+1) * getTextHeight()); + u8g2.setDrawColor(0); + if (i < 10) u8g2.print(0); + u8g2.print(i); + u8g2.setDrawColor(1); + u8g2.setCursor(82+3*3+1+1, (i+1) * getTextHeight()); + u8g2.print(clientName[i]); + } } u8g2.sendBuffer(); } diff --git a/src/display.h b/src/display.h index 4676ad9..d711a51 100644 --- a/src/display.h +++ b/src/display.h @@ -23,12 +23,20 @@ public: void showDashboard(void); void setClockName(const char *name) { strncpy(clockName, name, MAX_CLOCK_NAME_LEN); }; void setClockSpeed(const char *speed) { strncpy(clockSpeed, speed, MAX_CLOCK_SPEED_LEN); }; - void setTime(int hour, int minute) { clockHour = hour; clockMinute = minute; Serial.print("display: new time "); Serial.print(clockHour); Serial.print(":"); Serial.println(clockMinute); } + void setTime(int hour, int minute) { + clockHour = hour; + clockMinute = minute; + Serial.print("display: new time "); Serial.print(clockHour); Serial.print(":"); Serial.println(clockMinute); + } //void setClockSpeed(int _msPerModelSecond) { msPerModelSecond = _msPerModelSecond; setClockSpeed("x"); }; void setClockWeekday(const char *weekday) { strncpy(clockWeekday, weekday, MAX_CLOCK_WEEKDAY_LEN); }; void setClockHalted(bool halted) { clockHalted = halted; }; void setNumberKnownClients(int _numberKnownClients) { numberKnownClients = _numberKnownClients; }; - void setClientName(int clientNumber, const char *name) { if (clientNumber < MAX_NUMBER_CLIENTS_DISPLAYED) { strncpy(clientName[clientNumber], name, MAX_CLIENT_NAME_LEN); }}; + void setClientName(int clientNumber, const char *name) { + if (clientNumber < MAX_NUMBER_CLIENTS_DISPLAYED) { + strncpy(clientName[clientNumber], name, MAX_CLIENT_NAME_LEN); + } + }; void addLogMessage(const char *message); void showLog(void); private: