From f8100f27ce1928bbc413d7a0583cd2b77b897d03 Mon Sep 17 00:00:00 2001 From: Finlay Davidson Date: Thu, 29 Jun 2023 01:30:44 +0200 Subject: [PATCH] weather: Add functions for temperature in Fahrenheit --- src/components/ble/weather/WeatherService.cpp | 14 ++++++++++++++ src/components/ble/weather/WeatherService.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/components/ble/weather/WeatherService.cpp b/src/components/ble/weather/WeatherService.cpp index 513bb2a16b..e4e9027c05 100644 --- a/src/components/ble/weather/WeatherService.cpp +++ b/src/components/ble/weather/WeatherService.cpp @@ -597,6 +597,20 @@ namespace Pinetime { return result; } + int16_t WeatherService::GetTempFahrenheit(std::unique_ptr& temp) const { + if (temp->temperature == -32768) { + return -32768; + } + return temp->temperature * 9 / 5 + 3200; + } + + int16_t WeatherService::GetDewPointFahrenheit(std::unique_ptr& temp) const { + if (temp->dewPoint == -32768) { + return -32768; + } + return temp->dewPoint * 9 / 5 + 3200; + } + void WeatherService::CleanUpQcbor(QCBORDecodeContext* decodeContext) { QCBORDecode_ExitMap(decodeContext); QCBORDecode_Finish(decodeContext); diff --git a/src/components/ble/weather/WeatherService.h b/src/components/ble/weather/WeatherService.h index 609e8760d6..393b37dfa7 100644 --- a/src/components/ble/weather/WeatherService.h +++ b/src/components/ble/weather/WeatherService.h @@ -70,6 +70,18 @@ namespace Pinetime { */ int16_t GetTodayMinTemp() const; + /** + * Converts the temperature in degrees Celsius to degrees Fahrenheit + * @return -32768 if there's no data, degrees Fahrenheit times 100 otherwise + */ + int16_t GetTempFahrenheit(std::unique_ptr& temp) const; + + /** + * Converts the dew point in degrees Celsius to degrees Fahrenheit + * @return -32768 if there's no data, degrees Fahrenheit times 100 otherwise + */ + int16_t GetDewPointFahrenheit(std::unique_ptr& temp) const; + /* * Management functions */