weatherstatus: Display hourglass if we could not fetch new data.
This commit is contained in:
parent
f24a23e5e5
commit
0c094f9f55
|
@ -39,6 +39,7 @@ struct weather
|
||||||
{
|
{
|
||||||
float temperature{-273.15};
|
float temperature{-273.15};
|
||||||
std::string icon{"❗"};
|
std::string icon{"❗"};
|
||||||
|
bool old{true};
|
||||||
} __attribute__((aligned(64))) weather; // NOLINT(cert-err58-cpp)
|
} __attribute__((aligned(64))) weather; // NOLINT(cert-err58-cpp)
|
||||||
std::mutex mutex_weather;
|
std::mutex mutex_weather;
|
||||||
|
|
||||||
|
@ -137,9 +138,14 @@ bool fetch_weather()
|
||||||
weather.temperature = json[0]["main"]["temp"].get<float>();
|
weather.temperature = json[0]["main"]["temp"].get<float>();
|
||||||
weather.icon = map_icon(
|
weather.icon = map_icon(
|
||||||
json[0]["weather"][0]["icon"].get<std::string_view>());
|
json[0]["weather"][0]["icon"].get<std::string_view>());
|
||||||
return true;
|
weather.old = false;
|
||||||
}
|
}
|
||||||
return false;
|
else
|
||||||
|
{
|
||||||
|
weather.old = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_weather()
|
void print_weather()
|
||||||
|
@ -164,8 +170,9 @@ void print_weather()
|
||||||
return "#66ff66";
|
return "#66ff66";
|
||||||
}()};
|
}()};
|
||||||
|
|
||||||
std::cout << format(R"({0:s} <span color="{1:s}">{2:.1f}°C</span>)",
|
std::cout << format(R"({0:s} <span color="{1:s}">{2:.1f}°C</span>{3:s})",
|
||||||
weather.icon, color, weather.temperature)
|
weather.icon, color, weather.temperature,
|
||||||
|
weather.old ? R"( <span color="red">⏳</span>)" : "")
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue