From 6f83a3badef3e02a7f274aece8b99bdf017e54cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sat, 23 Dec 2023 17:22:32 +0100 Subject: [PATCH] Simple Weather Service Fix code formatting. --- src/components/ble/SimpleWeatherService.cpp | 30 +++++++------------ src/components/ble/SimpleWeatherService.h | 5 ++-- .../screens/WatchFacePineTimeStyle.cpp | 2 +- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/components/ble/SimpleWeatherService.cpp b/src/components/ble/SimpleWeatherService.cpp index 90adb926..8317aeab 100644 --- a/src/components/ble/SimpleWeatherService.cpp +++ b/src/components/ble/SimpleWeatherService.cpp @@ -29,31 +29,24 @@ namespace { enum class MessageType : uint8_t { CurrentWeather, Forecast, Unknown }; uint64_t ToUInt64(const uint8_t* data) { - return data[0] + - (data[1] << 8) + - (data[2] << 16) + - (data[3] << 24) + - (static_cast(data[4]) << 32) + - (static_cast(data[5]) << 48) + - (static_cast(data[6]) << 48) + - (static_cast(data[7]) << 56); + return data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24) + (static_cast(data[4]) << 32) + + (static_cast(data[5]) << 48) + (static_cast(data[6]) << 48) + (static_cast(data[7]) << 56); } int16_t ToInt16(const uint8_t* data) { - return data[0] + - (data[1] << 8); + return data[0] + (data[1] << 8); } SimpleWeatherService::CurrentWeather CreateCurrentWeather(const uint8_t* dataBuffer) { SimpleWeatherService::Location cityName; std::memcpy(cityName.data(), &dataBuffer[16], 32); cityName[32] = '\0'; - return SimpleWeatherService::CurrentWeather (ToUInt64(&dataBuffer[2]), + return SimpleWeatherService::CurrentWeather(ToUInt64(&dataBuffer[2]), ToInt16(&dataBuffer[10]), - ToInt16(&dataBuffer[12]), - ToInt16(&dataBuffer[14]), - SimpleWeatherService::Icons{dataBuffer[16 + 32]}, - std::move(cityName)); + ToInt16(&dataBuffer[12]), + ToInt16(&dataBuffer[14]), + SimpleWeatherService::Icons {dataBuffer[16 + 32]}, + std::move(cityName)); } SimpleWeatherService::Forecast CreateForecast(const uint8_t* dataBuffer) { @@ -63,10 +56,9 @@ namespace { const uint8_t nbDaysInBuffer = dataBuffer[10]; const uint8_t nbDays = std::min(SimpleWeatherService::MaxNbForecastDays, nbDaysInBuffer); for (int i = 0; i < nbDays; i++) { - days[i] = SimpleWeatherService::Forecast::Day { - ToInt16(&dataBuffer[11 + (i * 5)]), - ToInt16(&dataBuffer[13 + (i * 5)]), - SimpleWeatherService::Icons{dataBuffer[15 + (i * 5)]}}; + days[i] = SimpleWeatherService::Forecast::Day {ToInt16(&dataBuffer[11 + (i * 5)]), + ToInt16(&dataBuffer[13 + (i * 5)]), + SimpleWeatherService::Icons {dataBuffer[15 + (i * 5)]}}; } return SimpleWeatherService::Forecast {timestamp, nbDays, days}; } diff --git a/src/components/ble/SimpleWeatherService.h b/src/components/ble/SimpleWeatherService.h index 02a4c1e4..9b3a0e9c 100644 --- a/src/components/ble/SimpleWeatherService.h +++ b/src/components/ble/SimpleWeatherService.h @@ -61,7 +61,8 @@ namespace Pinetime { Unknown = 255 }; - using Location = std::array; // 32 char + \0 (end of string) + using Location = std::array; // 32 char + \0 (end of string) + struct CurrentWeather { CurrentWeather(uint64_t timestamp, int16_t temperature, @@ -74,7 +75,7 @@ namespace Pinetime { minTemperature {minTemperature}, maxTemperature {maxTemperature}, iconId {iconId}, - location{std::move(location)} { + location {std::move(location)} { } uint64_t timestamp; diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp index 9885bb42..caabbc11 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp +++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp @@ -543,7 +543,7 @@ void WatchFacePineTimeStyle::Refresh() { if (currentWeather.IsUpdated()) { auto optCurrentWeather = currentWeather.Get(); if (optCurrentWeather) { - lv_label_set_text_fmt(temperature, "%d°", (optCurrentWeather->temperature)/100); + lv_label_set_text_fmt(temperature, "%d°", (optCurrentWeather->temperature) / 100); lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId)); lv_obj_realign(temperature); lv_obj_realign(weatherIcon);