Open FintasticMan opened 4 months ago
Build size and comparison to main: | Section | Size | Difference |
---|---|---|---|
text | 373224B | -16B | |
data | 940B | 0B | |
bss | 63516B | 0B |
You could use structs of one int to make the types really safe.
I'm ok with the current state. I however thought about another option.
SimpleWeatherService would define a Temperature type : PineTime::Controllers::SimpleWeatherService::Temperature
. It's the internal representation of a temperature in the SompleWeatherService expressed in "°C * 100"
struct Temperature {
int16_t temperature;
}
Somewhere under DisplayApp, we would define another Temperature type : Pinetime::Applications::Temperature
. It represent the temperature for the UI side of InfiniTime as an std::variant
(TODO : check that the overhead of std::variant is negligible)
struct TemperatureCelsius {
int16_t temperature;
}
struct TemperatureFahrenheit {
int16_t temperature;
}
using Temperature = std::variant<TemperatureCelsius, TemperatureFahrenheit temperature
Then, also under DisplayApp, we define a function that converts from SimpleWeatherService Temperature to "display" temperature :
Pinetime::Applications::Temperature Convert(PineTime::Controllers::SimpleWeatherService::Temperature, Controllers::Settings::WeatherFormat format);
This way, all the "temperature" types are strongly typed and it's impossible to implicitly convert from one to another. Also SimpleWeatherService does not have any code related to the UI anymore.
Handles rounding correctly.