Skip to content

Commit d9c7c83

Browse files
committed
SimpleWeatherService: Add forecast operator overrides
Any screen that relies on DirtyValue to display up-to-date forecast data would require the struct to provide an operator override for comparison.
1 parent 44be356 commit d9c7c83

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/components/ble/SimpleWeatherService.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,16 @@ bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService
158158
this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature &&
159159
std::strcmp(this->location.data(), other.location.data()) == 0;
160160
}
161+
162+
bool SimpleWeatherService::Forecast::Day::operator==(const SimpleWeatherService::Forecast::Day& other) const {
163+
return this->iconId == other.iconId && this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature;
164+
}
165+
166+
bool SimpleWeatherService::Forecast::operator==(const SimpleWeatherService::Forecast& other) const {
167+
for (int i = 0; i < this->nbDays; i++) {
168+
if (this->days[i] != other.days[i]) {
169+
return false;
170+
}
171+
}
172+
return this->timestamp == other.timestamp && this->nbDays == other.nbDays;
173+
}

src/components/ble/SimpleWeatherService.h

+4
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ namespace Pinetime {
9696
int16_t minTemperature;
9797
int16_t maxTemperature;
9898
Icons iconId;
99+
100+
bool operator==(const Day& other) const;
99101
};
100102

101103
std::array<Day, MaxNbForecastDays> days;
104+
105+
bool operator==(const Forecast& other) const;
102106
};
103107

104108
std::optional<CurrentWeather> Current() const;

0 commit comments

Comments
 (0)