Switch to simpler temperature interface
This commit is contained in:
parent
29ad09f4ef
commit
e247bd7019
|
@ -398,7 +398,6 @@ list(APPEND SOURCE_FILES
|
||||||
displayapp/screens/Styles.cpp
|
displayapp/screens/Styles.cpp
|
||||||
displayapp/screens/WeatherSymbols.cpp
|
displayapp/screens/WeatherSymbols.cpp
|
||||||
displayapp/Colors.cpp
|
displayapp/Colors.cpp
|
||||||
displayapp/Weather.cpp
|
|
||||||
displayapp/widgets/Counter.cpp
|
displayapp/widgets/Counter.cpp
|
||||||
displayapp/widgets/PageIndicator.cpp
|
displayapp/widgets/PageIndicator.cpp
|
||||||
displayapp/widgets/DotIndicator.cpp
|
displayapp/widgets/DotIndicator.cpp
|
||||||
|
@ -607,7 +606,6 @@ set(INCLUDE_FILES
|
||||||
displayapp/screens/ApplicationList.h
|
displayapp/screens/ApplicationList.h
|
||||||
displayapp/screens/CheckboxList.h
|
displayapp/screens/CheckboxList.h
|
||||||
displayapp/Apps.h
|
displayapp/Apps.h
|
||||||
displayapp/Weather.h
|
|
||||||
displayapp/screens/Notifications.h
|
displayapp/screens/Notifications.h
|
||||||
displayapp/screens/HeartRate.h
|
displayapp/screens/HeartRate.h
|
||||||
displayapp/screens/Metronome.h
|
displayapp/screens/Metronome.h
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace {
|
||||||
std::memcpy(cityName.data(), &dataBuffer[16], 32);
|
std::memcpy(cityName.data(), &dataBuffer[16], 32);
|
||||||
cityName[32] = '\0';
|
cityName[32] = '\0';
|
||||||
return SimpleWeatherService::CurrentWeather(ToUInt64(&dataBuffer[2]),
|
return SimpleWeatherService::CurrentWeather(ToUInt64(&dataBuffer[2]),
|
||||||
SimpleWeatherService::Temperature {ToInt16(&dataBuffer[10])},
|
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[10])),
|
||||||
SimpleWeatherService::Temperature {ToInt16(&dataBuffer[12])},
|
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[12])),
|
||||||
SimpleWeatherService::Temperature {ToInt16(&dataBuffer[14])},
|
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[14])),
|
||||||
SimpleWeatherService::Icons {dataBuffer[16 + 32]},
|
SimpleWeatherService::Icons {dataBuffer[16 + 32]},
|
||||||
std::move(cityName));
|
std::move(cityName));
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,8 @@ namespace {
|
||||||
const uint8_t nbDaysInBuffer = dataBuffer[10];
|
const uint8_t nbDaysInBuffer = dataBuffer[10];
|
||||||
const uint8_t nbDays = std::min(SimpleWeatherService::MaxNbForecastDays, nbDaysInBuffer);
|
const uint8_t nbDays = std::min(SimpleWeatherService::MaxNbForecastDays, nbDaysInBuffer);
|
||||||
for (int i = 0; i < nbDays; i++) {
|
for (int i = 0; i < nbDays; i++) {
|
||||||
days[i] = SimpleWeatherService::Forecast::Day {SimpleWeatherService::Temperature {ToInt16(&dataBuffer[11 + (i * 5)])},
|
days[i] = SimpleWeatherService::Forecast::Day {SimpleWeatherService::Temperature(ToInt16(&dataBuffer[11 + (i * 5)])),
|
||||||
SimpleWeatherService::Temperature {ToInt16(&dataBuffer[13 + (i * 5)])},
|
SimpleWeatherService::Temperature(ToInt16(&dataBuffer[13 + (i * 5)])),
|
||||||
SimpleWeatherService::Icons {dataBuffer[15 + (i * 5)]}};
|
SimpleWeatherService::Icons {dataBuffer[15 + (i * 5)]}};
|
||||||
}
|
}
|
||||||
return SimpleWeatherService::Forecast {timestamp, nbDays, days};
|
return SimpleWeatherService::Forecast {timestamp, nbDays, days};
|
||||||
|
@ -98,9 +98,9 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) {
|
||||||
currentWeather = CreateCurrentWeather(dataBuffer);
|
currentWeather = CreateCurrentWeather(dataBuffer);
|
||||||
NRF_LOG_INFO("Current weather :\n\tTimestamp : %d\n\tTemperature:%d\n\tMin:%d\n\tMax:%d\n\tIcon:%d\n\tLocation:%s",
|
NRF_LOG_INFO("Current weather :\n\tTimestamp : %d\n\tTemperature:%d\n\tMin:%d\n\tMax:%d\n\tIcon:%d\n\tLocation:%s",
|
||||||
currentWeather->timestamp,
|
currentWeather->timestamp,
|
||||||
currentWeather->temperature,
|
currentWeather->temperature.PreciseCelsius(),
|
||||||
currentWeather->minTemperature,
|
currentWeather->minTemperature.PreciseCelsius(),
|
||||||
currentWeather->maxTemperature,
|
currentWeather->maxTemperature.PreciseCelsius(),
|
||||||
currentWeather->iconId,
|
currentWeather->iconId,
|
||||||
currentWeather->location.data());
|
currentWeather->location.data());
|
||||||
}
|
}
|
||||||
|
@ -112,8 +112,8 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) {
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
NRF_LOG_INFO("\t[%d] Min: %d - Max : %d - Icon : %d",
|
NRF_LOG_INFO("\t[%d] Min: %d - Max : %d - Icon : %d",
|
||||||
i,
|
i,
|
||||||
forecast->days[i].minTemperature,
|
forecast->days[i].minTemperature.PreciseCelsius(),
|
||||||
forecast->days[i].maxTemperature,
|
forecast->days[i].maxTemperature.PreciseCelsius(),
|
||||||
forecast->days[i].iconId);
|
forecast->days[i].iconId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,13 @@ std::optional<SimpleWeatherService::Forecast> SimpleWeatherService::GetForecast(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService::CurrentWeather& other) const {
|
bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService::CurrentWeather& other) const {
|
||||||
return this->iconId == other.iconId && this->temperature.temp == other.temperature.temp && this->timestamp == other.timestamp &&
|
return this->iconId == other.iconId && this->temperature == other.temperature && this->timestamp == other.timestamp &&
|
||||||
this->maxTemperature.temp == other.maxTemperature.temp && this->minTemperature.temp == other.maxTemperature.temp &&
|
this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature &&
|
||||||
std::strcmp(this->location.data(), other.location.data()) == 0;
|
std::strcmp(this->location.data(), other.location.data()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleWeatherService::Forecast::Day::operator==(const SimpleWeatherService::Forecast::Day& other) const {
|
bool SimpleWeatherService::Forecast::Day::operator==(const SimpleWeatherService::Forecast::Day& other) const {
|
||||||
return this->iconId == other.iconId && this->maxTemperature.temp == other.maxTemperature.temp &&
|
return this->iconId == other.iconId && this->maxTemperature == other.maxTemperature && this->minTemperature == other.maxTemperature;
|
||||||
this->minTemperature.temp == other.maxTemperature.temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimpleWeatherService::Forecast::operator==(const SimpleWeatherService::Forecast& other) const {
|
bool SimpleWeatherService::Forecast::operator==(const SimpleWeatherService::Forecast& other) const {
|
||||||
|
|
|
@ -61,8 +61,33 @@ namespace Pinetime {
|
||||||
Unknown = 255
|
Unknown = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Temperature {
|
class Temperature {
|
||||||
int16_t temp;
|
public:
|
||||||
|
explicit Temperature(int16_t raw = 0) : raw {raw} {
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int16_t PreciseCelsius() const {
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int16_t PreciseFahrenheit() const {
|
||||||
|
return raw * 9 / 5 + 3200;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int16_t Celsius() const {
|
||||||
|
return (PreciseCelsius() + 50) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] int16_t Fahrenheit() const {
|
||||||
|
return (PreciseFahrenheit() + 50) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Temperature& other) const {
|
||||||
|
return raw == other.raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int16_t raw;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Location = std::array<char, 33>; // 32 char + \0 (end of string)
|
using Location = std::array<char, 33>; // 32 char + \0 (end of string)
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
#include "displayapp/Weather.h"
|
|
||||||
|
|
||||||
using namespace Pinetime::Applications;
|
|
||||||
|
|
||||||
Temperature Pinetime::Applications::Convert(Controllers::SimpleWeatherService::Temperature temp,
|
|
||||||
Controllers::Settings::WeatherFormat format) {
|
|
||||||
Temperature t = {temp.temp};
|
|
||||||
if (format == Controllers::Settings::WeatherFormat::Imperial) {
|
|
||||||
t.temp = t.temp * 9 / 5 + 3200;
|
|
||||||
}
|
|
||||||
t.temp = t.temp / 100 + (t.temp % 100 >= 50 ? 1 : 0);
|
|
||||||
return t;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
#include "components/ble/SimpleWeatherService.h"
|
|
||||||
#include "components/settings/Settings.h"
|
|
||||||
|
|
||||||
namespace Pinetime {
|
|
||||||
namespace Applications {
|
|
||||||
struct Temperature {
|
|
||||||
int16_t temp;
|
|
||||||
};
|
|
||||||
|
|
||||||
Temperature Convert(Controllers::SimpleWeatherService::Temperature temp, Controllers::Settings::WeatherFormat format);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "displayapp/Weather.h"
|
|
||||||
#include "displayapp/screens/NotificationIcon.h"
|
#include "displayapp/screens/NotificationIcon.h"
|
||||||
#include "displayapp/screens/Symbols.h"
|
#include "displayapp/screens/Symbols.h"
|
||||||
#include "displayapp/screens/WeatherSymbols.h"
|
#include "displayapp/screens/WeatherSymbols.h"
|
||||||
|
@ -176,12 +175,13 @@ void WatchFaceDigital::Refresh() {
|
||||||
if (currentWeather.IsUpdated()) {
|
if (currentWeather.IsUpdated()) {
|
||||||
auto optCurrentWeather = currentWeather.Get();
|
auto optCurrentWeather = currentWeather.Get();
|
||||||
if (optCurrentWeather) {
|
if (optCurrentWeather) {
|
||||||
|
int16_t temp = optCurrentWeather->temperature.Celsius();
|
||||||
char tempUnit = 'C';
|
char tempUnit = 'C';
|
||||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||||
|
temp = optCurrentWeather->temperature.Fahrenheit();
|
||||||
tempUnit = 'F';
|
tempUnit = 'F';
|
||||||
}
|
}
|
||||||
Applications::Temperature temp = Applications::Convert(optCurrentWeather->temperature, settingsController.GetWeatherFormat());
|
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
|
||||||
lv_label_set_text_fmt(temperature, "%d°%c", temp.temp, tempUnit);
|
|
||||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text_static(temperature, "");
|
lv_label_set_text_static(temperature, "");
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <lvgl/lvgl.h>
|
#include <lvgl/lvgl.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "displayapp/Colors.h"
|
#include "displayapp/Colors.h"
|
||||||
#include "displayapp/Weather.h"
|
|
||||||
#include "displayapp/screens/BatteryIcon.h"
|
#include "displayapp/screens/BatteryIcon.h"
|
||||||
#include "displayapp/screens/BleIcon.h"
|
#include "displayapp/screens/BleIcon.h"
|
||||||
#include "displayapp/screens/NotificationIcon.h"
|
#include "displayapp/screens/NotificationIcon.h"
|
||||||
|
@ -544,7 +543,10 @@ void WatchFacePineTimeStyle::Refresh() {
|
||||||
if (currentWeather.IsUpdated()) {
|
if (currentWeather.IsUpdated()) {
|
||||||
auto optCurrentWeather = currentWeather.Get();
|
auto optCurrentWeather = currentWeather.Get();
|
||||||
if (optCurrentWeather) {
|
if (optCurrentWeather) {
|
||||||
Applications::Temperature temp = Applications::Convert(optCurrentWeather->temperature, settingsController.GetWeatherFormat());
|
int16_t temp = optCurrentWeather->temperature.Celsius();
|
||||||
|
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||||
|
temp = optCurrentWeather->temperature.Fahrenheit();
|
||||||
|
}
|
||||||
lv_label_set_text_fmt(temperature, "%d°", temp);
|
lv_label_set_text_fmt(temperature, "%d°", temp);
|
||||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include "components/ble/SimpleWeatherService.h"
|
#include "components/ble/SimpleWeatherService.h"
|
||||||
#include "components/datetime/DateTimeController.h"
|
#include "components/datetime/DateTimeController.h"
|
||||||
#include "components/settings/Settings.h"
|
#include "components/settings/Settings.h"
|
||||||
#include "displayapp/Weather.h"
|
|
||||||
#include "displayapp/DisplayApp.h"
|
#include "displayapp/DisplayApp.h"
|
||||||
#include "displayapp/screens/WeatherSymbols.h"
|
#include "displayapp/screens/WeatherSymbols.h"
|
||||||
#include "displayapp/InfiniTimeTheme.h"
|
#include "displayapp/InfiniTimeTheme.h"
|
||||||
|
@ -13,23 +12,23 @@
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
lv_color_t TemperatureColor(Pinetime::Applications::Temperature temp) {
|
lv_color_t TemperatureColor(Pinetime::Controllers::SimpleWeatherService::Temperature temp) {
|
||||||
if (temp.temp <= 0) { // freezing
|
if (temp.Celsius() <= 0) { // freezing
|
||||||
return Colors::blue;
|
return Colors::blue;
|
||||||
} else if (temp.temp <= 4) { // ice
|
} else if (temp.Celsius() <= 4) { // ice
|
||||||
return LV_COLOR_CYAN;
|
return LV_COLOR_CYAN;
|
||||||
} else if (temp.temp >= 27) { // hot
|
} else if (temp.Celsius() >= 27) { // hot
|
||||||
return Colors::deepOrange;
|
return Colors::deepOrange;
|
||||||
}
|
}
|
||||||
return Colors::orange; // normal
|
return Colors::orange; // normal
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t TemperatureStyle(Pinetime::Applications::Temperature temp) {
|
uint8_t TemperatureStyle(Pinetime::Controllers::SimpleWeatherService::Temperature temp) {
|
||||||
if (temp.temp <= 0) { // freezing
|
if (temp.Celsius() <= 0) { // freezing
|
||||||
return LV_TABLE_PART_CELL3;
|
return LV_TABLE_PART_CELL3;
|
||||||
} else if (temp.temp <= 4) { // ice
|
} else if (temp.Celsius() <= 4) { // ice
|
||||||
return LV_TABLE_PART_CELL4;
|
return LV_TABLE_PART_CELL4;
|
||||||
} else if (temp.temp >= 27) { // hot
|
} else if (temp.Celsius() >= 27) { // hot
|
||||||
return LV_TABLE_PART_CELL6;
|
return LV_TABLE_PART_CELL6;
|
||||||
}
|
}
|
||||||
return LV_TABLE_PART_CELL5; // normal
|
return LV_TABLE_PART_CELL5; // normal
|
||||||
|
@ -119,19 +118,25 @@ void Weather::Refresh() {
|
||||||
if (currentWeather.IsUpdated()) {
|
if (currentWeather.IsUpdated()) {
|
||||||
auto optCurrentWeather = currentWeather.Get();
|
auto optCurrentWeather = currentWeather.Get();
|
||||||
if (optCurrentWeather) {
|
if (optCurrentWeather) {
|
||||||
Applications::Temperature temp = Applications::Convert(optCurrentWeather->temperature, settingsController.GetWeatherFormat());
|
int16_t temp = optCurrentWeather->temperature.Celsius();
|
||||||
Applications::Temperature minTemp = Applications::Convert(optCurrentWeather->minTemperature, settingsController.GetWeatherFormat());
|
int16_t minTemp = optCurrentWeather->minTemperature.Celsius();
|
||||||
Applications::Temperature maxTemp = Applications::Convert(optCurrentWeather->maxTemperature, settingsController.GetWeatherFormat());
|
int16_t maxTemp = optCurrentWeather->maxTemperature.Celsius();
|
||||||
lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, TemperatureColor(temp));
|
|
||||||
char tempUnit = 'C';
|
char tempUnit = 'C';
|
||||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||||
|
temp = optCurrentWeather->temperature.Fahrenheit();
|
||||||
|
minTemp = optCurrentWeather->minTemperature.Fahrenheit();
|
||||||
|
maxTemp = optCurrentWeather->maxTemperature.Fahrenheit();
|
||||||
tempUnit = 'F';
|
tempUnit = 'F';
|
||||||
}
|
}
|
||||||
|
lv_obj_set_style_local_text_color(temperature,
|
||||||
|
LV_LABEL_PART_MAIN,
|
||||||
|
LV_STATE_DEFAULT,
|
||||||
|
TemperatureColor(optCurrentWeather->temperature));
|
||||||
lv_label_set_text(icon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
lv_label_set_text(icon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||||
lv_label_set_text(condition, Symbols::GetCondition(optCurrentWeather->iconId));
|
lv_label_set_text(condition, Symbols::GetCondition(optCurrentWeather->iconId));
|
||||||
lv_label_set_text_fmt(temperature, "%d°%c", temp.temp, tempUnit);
|
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
|
||||||
lv_label_set_text_fmt(minTemperature, "%d°", minTemp.temp);
|
lv_label_set_text_fmt(minTemperature, "%d°", minTemp);
|
||||||
lv_label_set_text_fmt(maxTemperature, "%d°", maxTemp.temp);
|
lv_label_set_text_fmt(maxTemperature, "%d°", maxTemp);
|
||||||
} else {
|
} else {
|
||||||
lv_label_set_text(icon, "");
|
lv_label_set_text(icon, "");
|
||||||
lv_label_set_text(condition, "");
|
lv_label_set_text(condition, "");
|
||||||
|
@ -149,12 +154,14 @@ void Weather::Refresh() {
|
||||||
std::tm localTime = *std::localtime(reinterpret_cast<const time_t*>(&optCurrentForecast->timestamp));
|
std::tm localTime = *std::localtime(reinterpret_cast<const time_t*>(&optCurrentForecast->timestamp));
|
||||||
|
|
||||||
for (int i = 0; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
|
for (int i = 0; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
|
||||||
Applications::Temperature maxTemp =
|
int16_t minTemp = optCurrentForecast->days[i].maxTemperature.Celsius();
|
||||||
Applications::Convert(optCurrentForecast->days[i].maxTemperature, settingsController.GetWeatherFormat());
|
int16_t maxTemp = optCurrentForecast->days[i].minTemperature.Celsius();
|
||||||
Applications::Temperature minTemp =
|
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||||
Applications::Convert(optCurrentForecast->days[i].minTemperature, settingsController.GetWeatherFormat());
|
minTemp = optCurrentForecast->days[i].maxTemperature.Fahrenheit();
|
||||||
lv_table_set_cell_type(forecast, 2, i, TemperatureStyle(maxTemp));
|
maxTemp = optCurrentForecast->days[i].minTemperature.Fahrenheit();
|
||||||
lv_table_set_cell_type(forecast, 3, i, TemperatureStyle(minTemp));
|
}
|
||||||
|
lv_table_set_cell_type(forecast, 2, i, TemperatureStyle(optCurrentForecast->days[i].maxTemperature));
|
||||||
|
lv_table_set_cell_type(forecast, 3, i, TemperatureStyle(optCurrentForecast->days[i].minTemperature));
|
||||||
uint8_t wday = localTime.tm_wday + i + 1;
|
uint8_t wday = localTime.tm_wday + i + 1;
|
||||||
if (wday > 7) {
|
if (wday > 7) {
|
||||||
wday -= 7;
|
wday -= 7;
|
||||||
|
@ -165,7 +172,7 @@ void Weather::Refresh() {
|
||||||
// Pad cells based on the largest number of digits on each column
|
// Pad cells based on the largest number of digits on each column
|
||||||
char maxPadding[3] = " ";
|
char maxPadding[3] = " ";
|
||||||
char minPadding[3] = " ";
|
char minPadding[3] = " ";
|
||||||
int diff = snprintf(nullptr, 0, "%d", maxTemp.temp) - snprintf(nullptr, 0, "%d", minTemp.temp);
|
int diff = snprintf(nullptr, 0, "%d", maxTemp) - snprintf(nullptr, 0, "%d", minTemp);
|
||||||
if (diff <= 0) {
|
if (diff <= 0) {
|
||||||
maxPadding[-diff] = '\0';
|
maxPadding[-diff] = '\0';
|
||||||
minPadding[0] = '\0';
|
minPadding[0] = '\0';
|
||||||
|
@ -173,8 +180,8 @@ void Weather::Refresh() {
|
||||||
maxPadding[0] = '\0';
|
maxPadding[0] = '\0';
|
||||||
minPadding[diff] = '\0';
|
minPadding[diff] = '\0';
|
||||||
}
|
}
|
||||||
lv_table_set_cell_value_fmt(forecast, 2, i, "%s%d", maxPadding, maxTemp.temp);
|
lv_table_set_cell_value_fmt(forecast, 2, i, "%s%d", maxPadding, maxTemp);
|
||||||
lv_table_set_cell_value_fmt(forecast, 3, i, "%s%d", minPadding, minTemp.temp);
|
lv_table_set_cell_value_fmt(forecast, 3, i, "%s%d", minPadding, minTemp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
|
for (int i = 0; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user