ThingPulse / espaper-weatherstation

WeatherStation for the 2.9" ESPaper modules
https://thingpulse.com/product-category/espaper-epaper-kits/
MIT License
89 stars 46 forks source link

Support night time icons #9

Closed marcelstoer closed 6 years ago

marcelstoer commented 6 years ago

It's really irritating to see a sun icon displayed when it's clearly dark outside (good thing is you might be asleep and not even notice 😜).

Unfortunately, WU doesn't clearly distinguish icon types at night in the API but they do use dedicated icons. Example:

"icon": "partlycloudy",
"icon_url": "http://icons.wxug.com/i/c/k/nt_partlycloudy.gif",

The nt_ prefix in the file name denotes a night icon (nt = night-time?). Even though WU has a complete set of night-time icons most likely one would only have to support two variations: http://icons.wxug.com/i/c/k/nt_partlycloudy.gif & http://icons.wxug.com/i/c/k/nt_clear.gif

Both could be mapped to Meteocons icons:

Plan:

marcelstoer commented 6 years ago

Part of https://github.com/ThingPulse/esp8266-weather-station-color/pull/45/commits/7429862d1bade8a3300d782d30e338c72a2feac8 can possibly be reused.

pilnikov commented 6 years ago

void WundergroundForecast::key(String key) { currentKey = String(key); if (currentKey == "simpleforecast") { isSimpleForecast = true; currentForecastPeriod = 1; //added for reset period in first pass, oterwise first period is 24 ShortTitleIndex = 0; // added as new value, also added in constructor (uint8_t) as private }

void WundergroundForecast::value(String value) { . . . //modifed (removed "nt_" from "night" icon names) if (currentKey == "icon" && !isSimpleForecast && currentForecastPeriod < maxForecasts) { #ifndef NIGHTICONS if (value.substring (0, 3) == "nt_") value.remove(0, 3); #endif forecasts[currentForecastPeriod].forecastIcon = value; } . . . if (isSimpleForecast) { //added int dailyForecastPeriod = (currentForecastPeriod - 1) * 2; //added for correct draw russian short weekday names, also modifed in sketch //String forecastTitleShort added in WGForecast struct if (currentKey == "weekday_short" && dailyForecastPeriod < maxForecasts) { forecasts[ShortTitleIndex].forecastTitleShort = value; ShortTitleIndex += 2; if (ShortTitleIndex >= 19) { ShortTitleIndex = 0; }
. . . }