mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
Merge f07699a4dd
into a2356f2f4a
This commit is contained in:
commit
99cda84d15
|
@ -62,12 +62,14 @@ namespace Pinetime {
|
|||
};
|
||||
|
||||
using Location = std::array<char, 33>; // 32 char + \0 (end of string)
|
||||
using PreciseTemp = int16_t;
|
||||
using DisplayTemp = int16_t;
|
||||
|
||||
struct CurrentWeather {
|
||||
CurrentWeather(uint64_t timestamp,
|
||||
int16_t temperature,
|
||||
int16_t minTemperature,
|
||||
int16_t maxTemperature,
|
||||
PreciseTemp temperature,
|
||||
PreciseTemp minTemperature,
|
||||
PreciseTemp maxTemperature,
|
||||
Icons iconId,
|
||||
Location&& location)
|
||||
: timestamp {timestamp},
|
||||
|
@ -79,9 +81,9 @@ namespace Pinetime {
|
|||
}
|
||||
|
||||
uint64_t timestamp;
|
||||
int16_t temperature;
|
||||
int16_t minTemperature;
|
||||
int16_t maxTemperature;
|
||||
PreciseTemp temperature;
|
||||
PreciseTemp minTemperature;
|
||||
PreciseTemp maxTemperature;
|
||||
Icons iconId;
|
||||
Location location;
|
||||
|
||||
|
@ -93,8 +95,8 @@ namespace Pinetime {
|
|||
uint8_t nbDays;
|
||||
|
||||
struct Day {
|
||||
int16_t minTemperature;
|
||||
int16_t maxTemperature;
|
||||
PreciseTemp minTemperature;
|
||||
PreciseTemp maxTemperature;
|
||||
Icons iconId;
|
||||
|
||||
bool operator==(const Day& other) const;
|
||||
|
@ -108,10 +110,14 @@ namespace Pinetime {
|
|||
std::optional<CurrentWeather> Current() const;
|
||||
std::optional<Forecast> GetForecast() const;
|
||||
|
||||
static int16_t CelsiusToFahrenheit(int16_t celsius) {
|
||||
static PreciseTemp CelsiusToFahrenheit(PreciseTemp celsius) {
|
||||
return celsius * 9 / 5 + 3200;
|
||||
}
|
||||
|
||||
static DisplayTemp Convert(PreciseTemp temp) {
|
||||
return temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
}
|
||||
|
||||
private:
|
||||
// 00050000-78fc-48fe-8e23-433b3a1942d0
|
||||
static constexpr ble_uuid128_t BaseUuid() {
|
||||
|
|
|
@ -174,14 +174,14 @@ void WatchFaceDigital::Refresh() {
|
|||
if (currentWeather.IsUpdated()) {
|
||||
auto optCurrentWeather = currentWeather.Get();
|
||||
if (optCurrentWeather) {
|
||||
int16_t temp = optCurrentWeather->temperature;
|
||||
Controllers::SimpleWeatherService::PreciseTemp preciseTemp = optCurrentWeather->temperature;
|
||||
char tempUnit = 'C';
|
||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||
preciseTemp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(preciseTemp);
|
||||
tempUnit = 'F';
|
||||
}
|
||||
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
|
||||
Controllers::SimpleWeatherService::DisplayTemp displayTemp = Controllers::SimpleWeatherService::Convert(preciseTemp);
|
||||
lv_label_set_text_fmt(temperature, "%d°%c", displayTemp, tempUnit);
|
||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||
} else {
|
||||
lv_label_set_text_static(temperature, "");
|
||||
|
|
|
@ -543,12 +543,12 @@ void WatchFacePineTimeStyle::Refresh() {
|
|||
if (currentWeather.IsUpdated()) {
|
||||
auto optCurrentWeather = currentWeather.Get();
|
||||
if (optCurrentWeather) {
|
||||
int16_t temp = optCurrentWeather->temperature;
|
||||
Controllers::SimpleWeatherService::PreciseTemp preciseTemp = optCurrentWeather->temperature;
|
||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||
preciseTemp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(preciseTemp);
|
||||
}
|
||||
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
lv_label_set_text_fmt(temperature, "%d°", temp);
|
||||
Controllers::SimpleWeatherService::DisplayTemp displayTemp = Controllers::SimpleWeatherService::Convert(preciseTemp);
|
||||
lv_label_set_text_fmt(temperature, "%d°", displayTemp);
|
||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||
} else {
|
||||
lv_label_set_text(temperature, "--");
|
||||
|
|
Loading…
Reference in a new issue