Skip to content

Commit

Permalink
weather: Add functions for temperature in Fahrenheit
Browse files Browse the repository at this point in the history
  • Loading branch information
FintasticMan committed Jun 30, 2023
1 parent 5f3acfa commit f8100f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/components/ble/weather/WeatherService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,20 @@ namespace Pinetime {
return result;
}

int16_t WeatherService::GetTempFahrenheit(std::unique_ptr<WeatherData::Temperature>& temp) const {
if (temp->temperature == -32768) {
return -32768;
}
return temp->temperature * 9 / 5 + 3200;
}

int16_t WeatherService::GetDewPointFahrenheit(std::unique_ptr<WeatherData::Temperature>& 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);
Expand Down
12 changes: 12 additions & 0 deletions src/components/ble/weather/WeatherService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<WeatherData::Temperature>& 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<WeatherData::Temperature>& temp) const;

/*
* Management functions
*/
Expand Down

0 comments on commit f8100f2

Please sign in to comment.