From eca64ee3c3c0073dfb6ea6965f3346fc1ba7f988 Mon Sep 17 00:00:00 2001 From: Skip Hansen Date: Mon, 3 Jun 2024 16:05:03 -0700 Subject: [PATCH] Change Fahrenheit/ mph /mm Units option to Fahrenheit / mph / in. --- ESP32_AP-Flasher/src/contentmanager.cpp | 21 +++++++++++++++------ ESP32_AP-Flasher/wwwroot/content_cards.json | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ESP32_AP-Flasher/src/contentmanager.cpp b/ESP32_AP-Flasher/src/contentmanager.cpp index 1aa42d90..3388ab7c 100644 --- a/ESP32_AP-Flasher/src/contentmanager.cpp +++ b/ESP32_AP-Flasher/src/contentmanager.cpp @@ -855,7 +855,7 @@ void drawWeather(String &filename, JsonObject &cfgobj, const tagRecord *taginfo, const String tz = cfgobj["#tz"]; String units = ""; if (cfgobj["units"] == "1") { - units += "&temperature_unit=fahrenheit&windspeed_unit=mph"; + units += "&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch"; } DynamicJsonDocument doc(1000); @@ -940,7 +940,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, const tagRecord *taginfo String tz = cfgobj["#tz"]; String units = ""; if (cfgobj["units"] == "1") { - units += "&temperature_unit=fahrenheit&windspeed_unit=mph"; + units += "&temperature_unit=fahrenheit&windspeed_unit=mph&precipitation_unit=inch"; } DynamicJsonDocument doc(2000); @@ -990,10 +990,19 @@ void drawForecast(String &filename, JsonObject &cfgobj, const tagRecord *taginfo } if (loc["rain"]) { - const int8_t rain = round(daily["precipitation_sum"][dag].as()); - if (rain > 0) { - drawString(spr, String(rain) + "mm", dag * column1 + loc["rain"][0].as(), loc["rain"][1], day[2], TC_DATUM, (rain > 10 ? imageParams.highlightColor : TFT_BLACK)); - } + if (cfgobj["units"] == "0") { + const int8_t rain = round(daily["precipitation_sum"][dag].as()); + if (rain > 0) { + drawString(spr, String(rain) + "mm", dag * column1 + loc["rain"][0].as(), loc["rain"][1], day[2], TC_DATUM, (rain > 10 ? imageParams.highlightColor : TFT_BLACK)); + } + } else { + double fRain = daily["precipitation_sum"][dag].as(); + fRain = round(fRain*100.0) / 100.0; + if (fRain > 0.0) { + // inch, display if > .01 inches + drawString(spr, String(fRain) + "in", dag * column1 + loc["rain"][0].as(), loc["rain"][1], day[2], TC_DATUM, (fRain > 0.5 ? imageParams.highlightColor : TFT_BLACK)); + } + } } drawString(spr, String(tmin) + " ", dag * column1 + day[0].as(), day[4], day[2], TR_DATUM, (tmin < 0 ? imageParams.highlightColor : TFT_BLACK)); diff --git a/ESP32_AP-Flasher/wwwroot/content_cards.json b/ESP32_AP-Flasher/wwwroot/content_cards.json index 490b4eea..0d75e93e 100644 --- a/ESP32_AP-Flasher/wwwroot/content_cards.json +++ b/ESP32_AP-Flasher/wwwroot/content_cards.json @@ -103,7 +103,7 @@ "type": "select", "options": { "0": "-Celcius / Beaufort / millimeters", - "1": "Fahrenheit / mph / millimeters" + "1": "Fahrenheit / mph / inches" } }, { @@ -144,7 +144,7 @@ "type": "select", "options": { "0": "-Celcius / Beaufort / millimeters", - "1": "Fahrenheit / mph / millimeters" + "1": "Fahrenheit / mph / inches" } }, {