From 08d7a1c123b40ed93fcd8e2dd2466959ae72d3ce Mon Sep 17 00:00:00 2001 From: cschwinne Date: Fri, 21 May 2021 22:23:12 +0200 Subject: [PATCH] Set Nixie contents via JSON API Elekstube mod support a subset of the cronixie display patterns --- .../EleksTube_IPS/usermod_elekstube_ips.h | 25 ++++++++++++++----- wled00/json.cpp | 4 +++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/usermods/EleksTube_IPS/usermod_elekstube_ips.h b/usermods/EleksTube_IPS/usermod_elekstube_ips.h index 242cea212..4f820c268 100644 --- a/usermods/EleksTube_IPS/usermod_elekstube_ips.h +++ b/usermods/EleksTube_IPS/usermod_elekstube_ips.h @@ -8,18 +8,31 @@ class ElekstubeIPSUsermod : public Usermod { private: TFTs tfts; void updateClockDisplay(TFTs::show_t show=TFTs::yes) { + bool set[6] = {false}; + for (uint8_t i = 0; i<6; i++) { + char c = cronixieDisplay[i]; + if (c >= '0' && c <= '9') { + tfts.setDigit(5-i, c - '0', show); set[i] = true; + } else if (c >= 'A' && c <= 'G') { + tfts.setDigit(5-i, c - 'A' + 10, show); set[i] = true; //10.bmp to 16.bmp static display + } else if (c == '-' || c == '_' || c == ' ') { + tfts.setDigit(5-i, 255, show); set[i] = true; //blank + } else { + set[i] = false; //display HHMMSS time + } + } uint8_t hr = hour(localTime); uint8_t hrTens = hr/10; uint8_t mi = minute(localTime); uint8_t mittens = mi/10; uint8_t s = second(localTime); uint8_t sTens = s/10; - tfts.setDigit(HOURS_TENS, hrTens, show); - tfts.setDigit(HOURS_ONES, hr - hrTens*10, show); - tfts.setDigit(MINUTES_TENS, mittens, show); - tfts.setDigit(MINUTES_ONES, mi - mittens*10, show); - tfts.setDigit(SECONDS_TENS, sTens, show); - tfts.setDigit(SECONDS_ONES, s - sTens*10, show); + if (!set[0]) tfts.setDigit(HOURS_TENS, hrTens, show); + if (!set[1]) tfts.setDigit(HOURS_ONES, hr - hrTens*10, show); + if (!set[2]) tfts.setDigit(MINUTES_TENS, mittens, show); + if (!set[3]) tfts.setDigit(MINUTES_ONES, mi - mittens*10, show); + if (!set[4]) tfts.setDigit(SECONDS_TENS, sTens, show); + if (!set[5]) tfts.setDigit(SECONDS_ONES, s - sTens*10, show); } unsigned long lastTime = 0; public: diff --git a/wled00/json.cpp b/wled00/json.cpp index 5bd76ec2e..a2cf126da 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -270,6 +270,10 @@ bool deserializeState(JsonObject root) } } + if (root["nx"].is()) { + strncpy(cronixieDisplay, root["nx"], 6); + } + usermods.readFromJsonState(root); int ps = root[F("psave")] | -1;