From ca3a64f5dc18ce8985b399afa116dc8d6126cbe6 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Wed, 24 Jul 2024 00:30:22 +0200 Subject: [PATCH] Add display of RSSI --- ThermoBeaconDisplay.ino | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/ThermoBeaconDisplay.ino b/ThermoBeaconDisplay.ino index 444ab4a..63df545 100644 --- a/ThermoBeaconDisplay.ino +++ b/ThermoBeaconDisplay.ino @@ -92,8 +92,8 @@ void dispbat(int oldv, int newv, int xpos, int yf, int yt) { if (olen < 0) olen = 0; if (olen > 30) olen = 30; int nlen = (newv - 230) * 30 / 80; - if (olen < 0) olen = 0; - if (olen > 30) olen = 30; + if (nlen < 0) nlen = 0; + if (nlen > 30) nlen = 30; dbgVal(olen, nlen, xpos, yf, yt, 0); if (olen == nlen) return; tft.setViewport(xpos * (tft.width() / 2) + 10, yf + 2, 40, yt - 2); @@ -104,6 +104,28 @@ void dispbat(int oldv, int newv, int xpos, int yf, int yt) { tft.resetViewport(); } + +void disprssi(int oldv, int newv, int xpos, int yf, int yt) { + dbgVal(oldv, newv, xpos, yf, yt, -8); + int olen = (oldv + 100) / 10; + if (olen < 0) olen = 0; + if (olen > 4) olen = 4; + int nlen = (newv + 100) / 10; + if (nlen < 0) nlen = 0; + if (nlen > 4) nlen = 4; + dbgVal(olen, nlen, xpos, yf, yt, -9); + if (olen == nlen) return; + tft.setViewport(xpos * (tft.width() / 2) + 70, yf + 2, 40, yt - 2); + tft.fillScreen(TFT_BLACK); + int colour = nlen > 1 ? TFT_GREEN : TFT_RED; + int maxy = tft.height() - 15; + for (int i = 0; i < nlen; i++) { + int h = (i + 1) * maxy / 5; + tft.fillRect(5 + i * 6, 10 + maxy - h, 3, h, colour); + } + tft.resetViewport(); +} + void dispel(int oldv, int newv, int xpos, int yf, int yt, int colour) { dbgVal(oldv, newv, xpos, yf, yt, colour); if (oldv == newv) return; @@ -136,6 +158,7 @@ void dispel(int oldv, int newv, int xpos, int yf, int yt, int colour) { void display(int pos, entry *oldval, entry *newval) { dispbat(FL(oldval, bat), FL(newval, bat), pos, 0, 30); + disprssi(FL(oldval, rssi), FL(newval, rssi), pos, 0, 30); dispel(FL(oldval, tmp), FL(newval, tmp), pos, 30, 50, TFT_YELLOW); dispel(FL(oldval, hum), FL(newval, hum), pos, 80, 50, TFT_CYAN); } -- 2.43.0