summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAvamander <avamander@gmail.com>2021-12-01 01:15:11 +0200
committerAvamander <avamander@gmail.com>2021-12-04 22:03:40 +0200
commit06b022fc4dd6c2b1e5145e111f5c1f32e4729eab (patch)
tree4b8e4279247e2af10f1e527da4ee41bd2ab39f56 /src
parentc870f8ed302823e12018aa196d87937c92966d06 (diff)
Improved UI and fixed a bug
Diffstat (limited to 'src')
-rw-r--r--src/components/ble/weather/WeatherService.cpp21
-rw-r--r--src/displayapp/screens/Weather.cpp20
2 files changed, 31 insertions, 10 deletions
diff --git a/src/components/ble/weather/WeatherService.cpp b/src/components/ble/weather/WeatherService.cpp
index 4ec57d00..250b36ab 100644
--- a/src/components/ble/weather/WeatherService.cpp
+++ b/src/components/ble/weather/WeatherService.cpp
@@ -29,6 +29,7 @@ namespace Pinetime {
WeatherService::WeatherService(System::SystemTask& system, DateTime& dateTimeController)
: system(system), dateTimeController(dateTimeController) {
nullHeader = &nullTimelineheader;
+ nullTimelineheader->timestamp = 0;
}
void WeatherService::Init() {
@@ -211,7 +212,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Clouds>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Clouds>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Obscuration>& WeatherService::GetCurrentObscuration() {
@@ -222,7 +223,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Obscuration>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Obscuration>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Precipitation>& WeatherService::GetCurrentPrecipitation() {
@@ -233,7 +234,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Precipitation>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Precipitation>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Wind>& WeatherService::GetCurrentWind() {
@@ -244,7 +245,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Wind>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Wind>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Temperature>& WeatherService::GetCurrentTemperature() {
@@ -255,7 +256,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Temperature>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Temperature>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Humidity>& WeatherService::GetCurrentHumidity() {
@@ -266,7 +267,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Humidity>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Humidity>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Pressure>& WeatherService::GetCurrentPressure() {
@@ -277,7 +278,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Pressure>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Pressure>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::Location>& WeatherService::GetCurrentLocation() {
@@ -288,7 +289,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::Location>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::Location>&>(*this->nullHeader);
}
std::unique_ptr<WeatherData::AirQuality>& WeatherService::GetCurrentQuality() {
@@ -299,7 +300,7 @@ namespace Pinetime {
}
}
- return reinterpret_cast<std::unique_ptr<WeatherData::AirQuality>&>(this->nullHeader);
+ return reinterpret_cast<std::unique_ptr<WeatherData::AirQuality>&>(*this->nullHeader);
}
size_t WeatherService::GetTimelineLength() const {
@@ -330,7 +331,7 @@ namespace Pinetime {
timeline.erase(std::remove_if(std::begin(timeline),
std::end(timeline),
[&](std::unique_ptr<WeatherData::TimelineHeader> const& header) {
- return isEventStillValid(header, timeCurrent);
+ return !isEventStillValid(header, timeCurrent);
}),
std::end(timeline));
diff --git a/src/displayapp/screens/Weather.cpp b/src/displayapp/screens/Weather.cpp
index 132bee71..0854c74a 100644
--- a/src/displayapp/screens/Weather.cpp
+++ b/src/displayapp/screens/Weather.cpp
@@ -74,6 +74,16 @@ std::unique_ptr<Screen> Weather::CreateScreenTemperature() {
std::unique_ptr<Controllers::WeatherData::Temperature>& current = weatherService.GetCurrentTemperature();
if (current->timestamp == 0) {
// Do not use the data, it's invalid
+ lv_label_set_text_fmt(label,
+ "#FFFF00 Temperature#\n\n"
+ "#444444 %d#\n\n"
+ "#444444 %d#\n\n"
+ "%d\n"
+ "%d\n",
+ 0,
+ 0,
+ 0,
+ 0);
} else {
lv_label_set_text_fmt(label,
"#FFFF00 Temperature#\n\n"
@@ -97,6 +107,16 @@ std::unique_ptr<Screen> Weather::CreateScreenAir() {
std::unique_ptr<Controllers::WeatherData::AirQuality>& current = weatherService.GetCurrentQuality();
if (current->timestamp == 0) {
// Do not use the data, it's invalid
+ lv_label_set_text_fmt(label,
+ "#FFFF00 Air quality#\n\n"
+ "#444444 %s#\n"
+ "#444444 %d#\n\n"
+ "%d\n"
+ "%d\n",
+ "",
+ 0,
+ 0,
+ 0);
} else {
lv_label_set_text_fmt(label,
"#FFFF00 Air quality#\n\n"