Skip to content

Commit

Permalink
round temperature, assign numbers to icon enum
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlich committed Dec 11, 2023
1 parent 82f9bec commit dee7e3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
12 changes: 7 additions & 5 deletions daemon/src/services/simpleweatherservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void SimpleWeatherService::sendWeather(CurrentWeather *weather)
<< QMetaEnum::fromType<SimpleWeatherService::WeatherIcons>().valueToKey(
(int)iconToEnum(weather->weatherIcon())
)
<< (int)iconToEnum(weather->weatherIcon())
// << weather->clouds()
// << weather->humidity()
// << weather->windDeg()
Expand All @@ -56,9 +57,9 @@ void SimpleWeatherService::sendWeather(CurrentWeather *weather)
weatherBytes += TypeConversion::fromInt8(0); // message type
weatherBytes += TypeConversion::fromInt8(0); // version information
weatherBytes += TypeConversion::fromInt64(weather->dateTime());
weatherBytes += TypeConversion::fromInt8( weather->temperature() - 273.15 );
weatherBytes += TypeConversion::fromInt8( weather->minTemperature() - 273.15 );
weatherBytes += TypeConversion::fromInt8( weather->maxTemperature() - 273.15 );
weatherBytes += TypeConversion::fromInt8( round(weather->temperature() - 273.15) );
weatherBytes += TypeConversion::fromInt8( round(weather->minTemperature() - 273.15) );
weatherBytes += TypeConversion::fromInt8( round(weather->maxTemperature() - 273.15) );
weatherBytes += cityNameBytes;
weatherBytes += TypeConversion::fromInt8( (int)iconToEnum(weather->weatherIcon()) );

Expand Down Expand Up @@ -102,10 +103,11 @@ void SimpleWeatherService::sendWeather(CurrentWeather *weather)
<< QMetaEnum::fromType<SimpleWeatherService::WeatherIcons>().valueToKey(
(int)iconToEnum(fc.weatherIcon())
)
<< (int)iconToEnum(fc.weatherIcon())
;

forecastBytes += TypeConversion::fromInt8( fc.minTemperature() - 273.15 );
forecastBytes += TypeConversion::fromInt8( fc.maxTemperature() - 273.15 );
forecastBytes += TypeConversion::fromInt8( round(fc.minTemperature() - 273.15) );
forecastBytes += TypeConversion::fromInt8( round(fc.maxTemperature() - 273.15) );
forecastBytes += TypeConversion::fromInt8( (int)iconToEnum(fc.weatherIcon()) );

}
Expand Down
20 changes: 10 additions & 10 deletions daemon/src/services/simpleweatherservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class SimpleWeatherService : public QBLEService
void sendWeather(CurrentWeather *weather);

enum class WeatherIcons {
ClearSky,
FewClouds,
ScatteredClouds,
BrokenClouds,
ShowerRain,
Rain,
Thunderstorm,
Snow,
Mist,
Unknown // for any icon not listed above
ClearSky = 0,
FewClouds = 1,
ScatteredClouds = 2,
BrokenClouds = 3,
ShowerRain = 4,
Rain = 5,
Thunderstorm = 6,
Snow = 7,
Mist = 8,
Unknown = 255 // for any icon not listed above
};

Q_ENUM(WeatherIcons)
Expand Down

0 comments on commit dee7e3b

Please sign in to comment.