From 9375e773e9325920cf4d0d5b27503e94105d1451 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 | 7 +++++++ src/components/ble/weather/WeatherService.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/components/ble/weather/WeatherService.cpp b/src/components/ble/weather/WeatherService.cpp index b9a6af556c..77f493a88a 100644 --- a/src/components/ble/weather/WeatherService.cpp +++ b/src/components/ble/weather/WeatherService.cpp @@ -606,6 +606,13 @@ namespace Pinetime { return result; } + int16_t WeatherService::GetTempFahrenheit(int16_t temp) const { + if (temp == -32768) { + return -32768; + } + return temp * 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..ee99fae69a 100644 --- a/src/components/ble/weather/WeatherService.h +++ b/src/components/ble/weather/WeatherService.h @@ -70,6 +70,12 @@ 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(int16_t temp) const; + /* * Management functions */