Skip to content

Commit

Permalink
SimpleWeatherService: Add forecast operator overrides (#2011)
Browse files Browse the repository at this point in the history
Any screen that relies on DirtyValue to display up-to-date forecast data
would require the struct to provide an operator override for comparison.
  • Loading branch information
vkareh authored Feb 10, 2024
1 parent 44be356 commit 2db9205
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/ble/SimpleWeatherService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions src/components/ble/SimpleWeatherService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2db9205

Please sign in to comment.