diff options
| author | Victor Kareh <vkareh@redhat.com> | 2024-02-10 13:24:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 19:24:46 +0100 |
| commit | 2db920599eec192f794c96fcaeb7376ea3325adb (patch) | |
| tree | b36bd23f3bc78c2c47ddf26e052a6a8efaabd898 /src/components/ble | |
| parent | 44be356dc2dc6b4b7b0df8e3e12d41751cc315d3 (diff) | |
SimpleWeatherService: Add forecast operator overrides (#2011)
Any screen that relies on DirtyValue to display up-to-date forecast data
would require the struct to provide an operator override for comparison.
Diffstat (limited to 'src/components/ble')
| -rw-r--r-- | src/components/ble/SimpleWeatherService.cpp | 13 | ||||
| -rw-r--r-- | src/components/ble/SimpleWeatherService.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/components/ble/SimpleWeatherService.cpp b/src/components/ble/SimpleWeatherService.cpp index d545d45b..146152f8 100644 --- a/src/components/ble/SimpleWeatherService.cpp +++ b/src/components/ble/SimpleWeatherService.cpp @@ -158,3 +158,16 @@ bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature && std::strcmp(this->location.data(), other.location.data()) == 0; } + +bool SimpleWeatherService::Forecast::Day::operator==(const SimpleWeatherService::Forecast::Day& other) const { + return this->iconId == other.iconId && this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature; +} + +bool SimpleWeatherService::Forecast::operator==(const SimpleWeatherService::Forecast& other) const { + for (int i = 0; i < this->nbDays; i++) { + if (this->days[i] != other.days[i]) { + return false; + } + } + return this->timestamp == other.timestamp && this->nbDays == other.nbDays; +} diff --git a/src/components/ble/SimpleWeatherService.h b/src/components/ble/SimpleWeatherService.h index cec2bb8b..4bbefcfc 100644 --- a/src/components/ble/SimpleWeatherService.h +++ b/src/components/ble/SimpleWeatherService.h @@ -96,9 +96,13 @@ namespace Pinetime { int16_t minTemperature; int16_t maxTemperature; Icons iconId; + + bool operator==(const Day& other) const; }; std::array<Day, MaxNbForecastDays> days; + + bool operator==(const Forecast& other) const; }; std::optional<CurrentWeather> Current() const; |
