From 2db920599eec192f794c96fcaeb7376ea3325adb Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Sat, 10 Feb 2024 13:24:46 -0500 Subject: 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. --- src/components/ble/SimpleWeatherService.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/components/ble/SimpleWeatherService.cpp') 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; +} -- cgit v1.2.3-70-g09d2