From e71293e8ba2e674b03ca63abb31db346aea937cc Mon Sep 17 00:00:00 2001 From: FintasticMan Date: Tue, 12 Nov 2024 01:07:48 +0100 Subject: [PATCH] Fix build after temperature type changes --- InfiniTime | 2 +- main.cpp | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/InfiniTime b/InfiniTime index 57b6db8..f7c87a7 160000 --- a/InfiniTime +++ b/InfiniTime @@ -1 +1 @@ -Subproject commit 57b6db8b2a24e7303b79ea5439df655317af0196 +Subproject commit f7c87a700d2d9cd05469f1b5b2966a01808ce0e1 diff --git a/main.cpp b/main.cpp index f278b7f..4b7bbda 100644 --- a/main.cpp +++ b/main.cpp @@ -854,7 +854,7 @@ class Framework { void set_forecast( uint64_t timestamp, std::array< - Pinetime::Controllers::SimpleWeatherService::Forecast::Day, + std::optional, Pinetime::Controllers::SimpleWeatherService::MaxNbForecastDays> days) { std::array dataBuffer {}; @@ -871,10 +871,13 @@ class Framework { dataBuffer.at(10) = static_cast(days.size()); for (int i = 0; i < days.size(); i++) { - const Pinetime::Controllers::SimpleWeatherService::Forecast::Day &day = days.at(i); - write_int16(data.subspan(11+(i*5)), day.minTemperature); - write_int16(data.subspan(13+(i*5)), day.maxTemperature); - dataBuffer.at(15+(i*5)) = static_cast(day.iconId); + const std::optional &day = days.at(i); + if (!day.has_value()) { + continue; + } + write_int16(data.subspan(11+(i*5)), day->minTemperature.PreciseCelsius()); + write_int16(data.subspan(13+(i*5)), day->maxTemperature.PreciseCelsius()); + dataBuffer.at(15+(i*5)) = static_cast(day->iconId); } // send Forecast to SimpleWeatherService systemTask.nimble().weather().OnCommand(&ctxt); @@ -883,7 +886,7 @@ class Framework { void generate_weather_data(bool clear) { if (clear) { set_current_weather(0, 0, 0); - std::array days; + std::array, Pinetime::Controllers::SimpleWeatherService::MaxNbForecastDays> days; set_forecast(0, days); return; } @@ -895,10 +898,12 @@ class Framework { set_current_weather((uint64_t)timestamp, temperature, rand() % 9); // Generate forecast data - std::array days; + std::array, Pinetime::Controllers::SimpleWeatherService::MaxNbForecastDays> days; for (int i = 0; i < Pinetime::Controllers::SimpleWeatherService::MaxNbForecastDays; i++) { days[i] = Pinetime::Controllers::SimpleWeatherService::Forecast::Day { - (int16_t)(temperature - rand() % 10 * 100), (int16_t)(temperature + rand() % 10 * 100), Pinetime::Controllers::SimpleWeatherService::Icons(rand() % 9) + Pinetime::Controllers::SimpleWeatherService::Temperature(temperature - rand() % 10 * 100), + Pinetime::Controllers::SimpleWeatherService::Temperature(temperature + rand() % 10 * 100), + Pinetime::Controllers::SimpleWeatherService::Icons(rand() % 9), }; } set_forecast((uint64_t)timestamp, days);