added code for weather in g7710 watchface
This commit is contained in:
parent
42cf686dae
commit
f408bc1c71
@ -11,6 +11,7 @@
|
||||
#include "components/ble/NotificationManager.h"
|
||||
#include "components/motion/MotionController.h"
|
||||
#include "components/settings/Settings.h"
|
||||
#include "components/ble/SimpleWeatherService.h"
|
||||
using namespace Pinetime::Applications::Screens;
|
||||
|
||||
WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController,
|
||||
@ -19,7 +20,8 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
|
||||
Controllers::NotificationManager& notificatioManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem)
|
||||
Controllers::FS& filesystem
|
||||
Controllers::SimpleWeatherService& weatherService)
|
||||
: currentDateTime {{}},
|
||||
batteryIcon(false),
|
||||
dateTimeController {dateTimeController},
|
||||
@ -27,6 +29,7 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
|
||||
bleController {bleController},
|
||||
notificatioManager {notificatioManager},
|
||||
settingsController {settingsController},
|
||||
weatherService {weatherService},
|
||||
motionController {motionController} {
|
||||
|
||||
lfs_file f = {};
|
||||
@ -292,6 +295,28 @@ void WatchFaceCasioStyleG7710::Refresh() {
|
||||
lv_obj_realign(stepValue);
|
||||
lv_obj_realign(stepValue);
|
||||
}
|
||||
|
||||
|
||||
currentWeather = weatherService.Current();
|
||||
if (currentWeather.IsUpdated()) {
|
||||
auto optCurrentWeather = currentWeather.Get();
|
||||
if (optCurrentWeather) {
|
||||
int16_t temp = optCurrentWeather->temperature;
|
||||
char tempUnit = 'C';
|
||||
if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) {
|
||||
temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp);
|
||||
tempUnit = 'F';
|
||||
}
|
||||
temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0);
|
||||
lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit);
|
||||
lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId));
|
||||
} else {
|
||||
lv_label_set_text_static(temperature, "");
|
||||
lv_label_set_text(weatherIcon, "");
|
||||
}
|
||||
lv_obj_realign(temperature);
|
||||
lv_obj_realign(weatherIcon);
|
||||
}
|
||||
}
|
||||
|
||||
bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "components/ble/BleController.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "displayapp/apps/Apps.h"
|
||||
#include "components/ble/SimpleWeatherService.h"
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
@ -32,7 +33,8 @@ namespace Pinetime {
|
||||
Controllers::NotificationManager& notificatioManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
Controllers::FS& filesystem);
|
||||
Controllers::FS& filesystem,
|
||||
Controllers::SimpleWeatherService& weather);
|
||||
~WatchFaceCasioStyleG7710() override;
|
||||
|
||||
void Refresh() override;
|
||||
@ -88,6 +90,7 @@ namespace Pinetime {
|
||||
Controllers::NotificationManager& notificatioManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::MotionController& motionController;
|
||||
Controllers::SimpleWeatherService& weatherService;
|
||||
|
||||
lv_task_t* taskRefresh;
|
||||
lv_font_t* font_dot40 = nullptr;
|
||||
@ -108,7 +111,8 @@ namespace Pinetime {
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.motionController,
|
||||
controllers.filesystem);
|
||||
controllers.filesystem,
|
||||
*controllers.weatherController);
|
||||
};
|
||||
|
||||
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {
|
||||
|
Loading…
Reference in New Issue
Block a user