This commit is contained in:
Josh 2024-05-09 09:47:59 -04:00
commit a01abc89be
2 changed files with 32 additions and 3 deletions

View File

@ -11,6 +11,7 @@
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include "components/motion/MotionController.h" #include "components/motion/MotionController.h"
#include "components/settings/Settings.h" #include "components/settings/Settings.h"
#include "components/ble/SimpleWeatherService.h"
using namespace Pinetime::Applications::Screens; using namespace Pinetime::Applications::Screens;
WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController, WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTimeController,
@ -19,7 +20,8 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
Controllers::NotificationManager& notificatioManager, Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::MotionController& motionController, Controllers::MotionController& motionController,
Controllers::FS& filesystem) Controllers::FS& filesystem
Controllers::SimpleWeatherService& weatherService)
: currentDateTime {{}}, : currentDateTime {{}},
batteryIcon(false), batteryIcon(false),
dateTimeController {dateTimeController}, dateTimeController {dateTimeController},
@ -27,6 +29,7 @@ WatchFaceCasioStyleG7710::WatchFaceCasioStyleG7710(Controllers::DateTime& dateTi
bleController {bleController}, bleController {bleController},
notificatioManager {notificatioManager}, notificatioManager {notificatioManager},
settingsController {settingsController}, settingsController {settingsController},
weatherService {weatherService},
motionController {motionController} { motionController {motionController} {
lfs_file f = {}; lfs_file f = {};
@ -292,6 +295,28 @@ void WatchFaceCasioStyleG7710::Refresh() {
lv_obj_realign(stepValue); lv_obj_realign(stepValue);
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) { bool WatchFaceCasioStyleG7710::IsAvailable(Pinetime::Controllers::FS& filesystem) {

View File

@ -11,6 +11,7 @@
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "utility/DirtyValue.h" #include "utility/DirtyValue.h"
#include "displayapp/apps/Apps.h" #include "displayapp/apps/Apps.h"
#include "components/ble/SimpleWeatherService.h"
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
@ -32,7 +33,8 @@ namespace Pinetime {
Controllers::NotificationManager& notificatioManager, Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController, Controllers::Settings& settingsController,
Controllers::MotionController& motionController, Controllers::MotionController& motionController,
Controllers::FS& filesystem); Controllers::FS& filesystem,
Controllers::SimpleWeatherService& weather);
~WatchFaceCasioStyleG7710() override; ~WatchFaceCasioStyleG7710() override;
void Refresh() override; void Refresh() override;
@ -88,6 +90,7 @@ namespace Pinetime {
Controllers::NotificationManager& notificatioManager; Controllers::NotificationManager& notificatioManager;
Controllers::Settings& settingsController; Controllers::Settings& settingsController;
Controllers::MotionController& motionController; Controllers::MotionController& motionController;
Controllers::SimpleWeatherService& weatherService;
lv_task_t* taskRefresh; lv_task_t* taskRefresh;
lv_font_t* font_dot40 = nullptr; lv_font_t* font_dot40 = nullptr;
@ -108,7 +111,8 @@ namespace Pinetime {
controllers.notificationManager, controllers.notificationManager,
controllers.settingsController, controllers.settingsController,
controllers.motionController, controllers.motionController,
controllers.filesystem); controllers.filesystem,
*controllers.weatherController);
}; };
static bool IsAvailable(Pinetime::Controllers::FS& filesystem) { static bool IsAvailable(Pinetime::Controllers::FS& filesystem) {