ThingPulse / espaper-weatherstation

WeatherStation for the 2.9" ESPaper modules

Home Page:https://thingpulse.com/product-category/espaper-epaper-kits/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support night time icons

marcelstoer opened this issue · comments

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:

  • nt_clear -> icon C
  • nt_partlycloudy -> icon I

Plan:

  • add nt_clear and nt_partlycloudy to weathericons.h
  • pass icon_url to getMeteoconIcon with every invocation
  • in getMeteoconIcon do
    • check whether the icon equals "partlycloudy" or "clear"
    • if so, check whether icon_url contains "/nt_"
    • if so, adjust the internal icon type accordingly

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;
}
.
.
.
}