summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2022-04-02 14:34:53 (GMT)
committerGitea <gitea@fake.local>2022-04-02 14:34:53 (GMT)
commit187ea0f06d93c7f7df5779cb321a28ad040234ee (patch)
tree3d6d1b2f60573045734153d975e9b0aa1b327394 /src/displayapp/screens
parentadc7909c9823c5cd9fc9888a84e84f9182b9088f (diff)
parentb498e1d633522eed975d78b04508834b7a79befe (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Alarm.cpp138
-rw-r--r--src/displayapp/screens/Alarm.h17
-rw-r--r--src/displayapp/screens/BleIcon.cpp9
-rw-r--r--src/displayapp/screens/BleIcon.h4
-rw-r--r--src/displayapp/screens/Clock.cpp24
-rw-r--r--src/displayapp/screens/Clock.h1
-rw-r--r--src/displayapp/screens/DropDownDemo.cpp57
-rw-r--r--src/displayapp/screens/DropDownDemo.h27
-rw-r--r--src/displayapp/screens/HeartRate.h1
-rw-r--r--src/displayapp/screens/Motion.h1
-rw-r--r--src/displayapp/screens/Music.h4
-rw-r--r--src/displayapp/screens/Notifications.cpp93
-rw-r--r--src/displayapp/screens/Notifications.h19
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp97
-rw-r--r--src/displayapp/screens/PineTimeStyle.h9
-rw-r--r--src/displayapp/screens/StopWatch.cpp9
-rw-r--r--src/displayapp/screens/StopWatch.h2
-rw-r--r--src/displayapp/screens/Tile.cpp4
-rw-r--r--src/displayapp/screens/Timer.cpp19
-rw-r--r--src/displayapp/screens/Timer.h27
-rw-r--r--src/displayapp/screens/Twos.cpp2
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp13
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.h9
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp105
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h9
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.cpp183
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.h81
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.cpp93
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.h31
-rw-r--r--src/displayapp/screens/settings/SettingChimes.h2
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.cpp75
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.h41
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp2
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h1
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp2
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h2
-rw-r--r--src/displayapp/screens/settings/Settings.cpp37
-rw-r--r--src/displayapp/screens/settings/Settings.h3
39 files changed, 865 insertions, 392 deletions
diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp
index 537ac0e..879e50d 100644
--- a/src/displayapp/screens/Alarm.cpp
+++ b/src/displayapp/screens/Alarm.cpp
@@ -23,12 +23,20 @@ using namespace Pinetime::Applications::Screens;
using Pinetime::Controllers::AlarmController;
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
- Alarm* screen = static_cast<Alarm*>(obj->user_data);
+ auto* screen = static_cast<Alarm*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
-Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
- : Screen(app), running {true}, alarmController {alarmController} {
+static void StopAlarmTaskCallback(lv_task_t* task) {
+ auto* screen = static_cast<Alarm*>(task->user_data);
+ screen->StopAlerting();
+}
+
+Alarm::Alarm(DisplayApp* app,
+ Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::Settings& settingsController,
+ System::SystemTask& systemTask)
+ : Screen(app), alarmController {alarmController}, settingsController {settingsController}, systemTask {systemTask} {
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@@ -40,6 +48,13 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
+ lblampm = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
+ lv_obj_set_style_local_text_color(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_label_set_text_static(lblampm, " ");
+ lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, 0, 30);
+
btnHoursUp = lv_btn_create(lv_scr_act(), nullptr);
btnHoursUp->user_data = this;
lv_obj_set_event_cb(btnHoursUp, btnEventHandler);
@@ -72,13 +87,15 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
txtMinDown = lv_label_create(btnMinutesDown, nullptr);
lv_label_set_text_static(txtMinDown, "-");
- btnEnable = lv_btn_create(lv_scr_act(), nullptr);
- btnEnable->user_data = this;
- lv_obj_set_event_cb(btnEnable, btnEventHandler);
- lv_obj_set_size(btnEnable, 115, 50);
- lv_obj_align(btnEnable, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
- txtEnable = lv_label_create(btnEnable, nullptr);
- SetEnableButtonState();
+ btnStop = lv_btn_create(lv_scr_act(), nullptr);
+ btnStop->user_data = this;
+ lv_obj_set_event_cb(btnStop, btnEventHandler);
+ lv_obj_set_size(btnStop, 115, 50);
+ lv_obj_align(btnStop, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ lv_obj_set_style_local_bg_color(btnStop, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
+ txtStop = lv_label_create(btnStop, nullptr);
+ lv_label_set_text_static(txtStop, Symbols::stop);
+ lv_obj_set_hidden(btnStop, true);
btnRecur = lv_btn_create(lv_scr_act(), nullptr);
btnRecur->user_data = this;
@@ -95,24 +112,35 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
lv_obj_align(btnInfo, lv_scr_act(), LV_ALIGN_CENTER, 0, -85);
txtInfo = lv_label_create(btnInfo, nullptr);
lv_label_set_text_static(txtInfo, "i");
+
+ enableSwitch = lv_switch_create(lv_scr_act(), nullptr);
+ enableSwitch->user_data = this;
+ lv_obj_set_event_cb(enableSwitch, btnEventHandler);
+ lv_obj_set_size(enableSwitch, 100, 50);
+ // Align to the center of 115px from edge
+ lv_obj_align(enableSwitch, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 7, 0);
+
+ UpdateAlarmTime();
+
+ if (alarmController.State() == Controllers::AlarmController::AlarmState::Alerting) {
+ SetAlerting();
+ } else {
+ SetSwitchState(LV_ANIM_OFF);
+ }
}
Alarm::~Alarm() {
+ if (alarmController.State() == AlarmController::AlarmState::Alerting) {
+ StopAlerting();
+ }
lv_obj_clean(lv_scr_act());
}
void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
using Pinetime::Controllers::AlarmController;
if (event == LV_EVENT_CLICKED) {
- if (obj == btnEnable) {
- if (alarmController.State() == AlarmController::AlarmState::Alerting) {
- alarmController.StopAlerting();
- } else if (alarmController.State() == AlarmController::AlarmState::Set) {
- alarmController.DisableAlarm();
- } else {
- alarmController.ScheduleAlarm();
- }
- SetEnableButtonState();
+ if (obj == btnStop) {
+ StopAlerting();
return;
}
if (obj == btnInfo) {
@@ -123,11 +151,19 @@ void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
HideInfo();
return;
}
+ if (obj == enableSwitch) {
+ if (lv_switch_get_state(enableSwitch)) {
+ alarmController.ScheduleAlarm();
+ } else {
+ alarmController.DisableAlarm();
+ }
+ return;
+ }
// If any other button was pressed, disable the alarm
// this is to make it clear that the alarm won't be set until it is turned back on
if (alarmController.State() == AlarmController::AlarmState::Set) {
alarmController.DisableAlarm();
- SetEnableButtonState();
+ lv_switch_off(enableSwitch, LV_ANIM_ON);
}
if (obj == btnMinutesUp) {
if (alarmMinutes >= 59) {
@@ -176,31 +212,73 @@ bool Alarm::OnButtonPushed() {
HideInfo();
return true;
}
+ if (alarmController.State() == AlarmController::AlarmState::Alerting) {
+ StopAlerting();
+ return true;
+ }
return false;
}
+bool Alarm::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ // Don't allow closing the screen by swiping while the alarm is alerting
+ return alarmController.State() == AlarmController::AlarmState::Alerting && event == TouchEvents::SwipeDown;
+}
+
void Alarm::UpdateAlarmTime() {
- lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ switch (alarmHours) {
+ case 0:
+ lv_label_set_text_static(lblampm, "AM");
+ lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes);
+ break;
+ case 1 ... 11:
+ lv_label_set_text_static(lblampm, "AM");
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ break;
+ case 12:
+ lv_label_set_text_static(lblampm, "PM");
+ lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes);
+ break;
+ case 13 ... 23:
+ lv_label_set_text_static(lblampm, "PM");
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours - 12, alarmMinutes);
+ break;
+ }
+ } else {
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ }
alarmController.SetAlarmTime(alarmHours, alarmMinutes);
}
void Alarm::SetAlerting() {
- SetEnableButtonState();
+ lv_obj_set_hidden(enableSwitch, true);
+ lv_obj_set_hidden(btnStop, false);
+ taskStopAlarm = lv_task_create(StopAlarmTaskCallback, pdMS_TO_TICKS(60 * 1000), LV_TASK_PRIO_MID, this);
+ systemTask.PushMessage(System::Messages::DisableSleeping);
}
-void Alarm::SetEnableButtonState() {
+void Alarm::StopAlerting() {
+ alarmController.StopAlerting();
+ SetSwitchState(LV_ANIM_OFF);
+ if (taskStopAlarm != nullptr) {
+ lv_task_del(taskStopAlarm);
+ taskStopAlarm = nullptr;
+ }
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ lv_obj_set_hidden(enableSwitch, false);
+ lv_obj_set_hidden(btnStop, true);
+}
+
+void Alarm::SetSwitchState(lv_anim_enable_t anim) {
switch (alarmController.State()) {
case AlarmController::AlarmState::Set:
- lv_label_set_text(txtEnable, "ON");
- lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ lv_switch_on(enableSwitch, anim);
break;
case AlarmController::AlarmState::Not_Set:
- lv_label_set_text(txtEnable, "OFF");
- lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_switch_off(enableSwitch, anim);
+ break;
+ default:
break;
- case AlarmController::AlarmState::Alerting:
- lv_label_set_text(txtEnable, Symbols::stop);
- lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
}
}
diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h
index 4b301ce..f74dd68 100644
--- a/src/displayapp/screens/Alarm.h
+++ b/src/displayapp/screens/Alarm.h
@@ -27,26 +27,33 @@ namespace Pinetime {
namespace Screens {
class Alarm : public Screen {
public:
- Alarm(DisplayApp* app, Controllers::AlarmController& alarmController);
+ Alarm(DisplayApp* app,
+ Controllers::AlarmController& alarmController,
+ Pinetime::Controllers::Settings& settingsController,
+ System::SystemTask& systemTask);
~Alarm() override;
void SetAlerting();
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
bool OnButtonPushed() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ void StopAlerting();
private:
- bool running;
uint8_t alarmHours;
uint8_t alarmMinutes;
Controllers::AlarmController& alarmController;
+ Controllers::Settings& settingsController;
+ System::SystemTask& systemTask;
- lv_obj_t *time, *btnEnable, *txtEnable, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
- *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo;
+ lv_obj_t *time, *lblampm, *btnStop, *txtStop, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp,
+ *txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo, *enableSwitch;
lv_obj_t* txtMessage = nullptr;
lv_obj_t* btnMessage = nullptr;
+ lv_task_t* taskStopAlarm = nullptr;
enum class EnableButtonState { On, Off, Alerting };
- void SetEnableButtonState();
void SetRecurButtonState();
+ void SetSwitchState(lv_anim_enable_t anim);
void SetAlarm();
void ShowInfo();
void HideInfo();
diff --git a/src/displayapp/screens/BleIcon.cpp b/src/displayapp/screens/BleIcon.cpp
index 5058f3e..780a14c 100644
--- a/src/displayapp/screens/BleIcon.cpp
+++ b/src/displayapp/screens/BleIcon.cpp
@@ -3,8 +3,9 @@
using namespace Pinetime::Applications::Screens;
const char* BleIcon::GetIcon(bool isConnected) {
- if (isConnected)
+ if (isConnected) {
return Symbols::bluetooth;
- else
- return "";
-} \ No newline at end of file
+ }
+
+ return Symbols::none;
+}
diff --git a/src/displayapp/screens/BleIcon.h b/src/displayapp/screens/BleIcon.h
index c1398d2..d9a4654 100644
--- a/src/displayapp/screens/BleIcon.h
+++ b/src/displayapp/screens/BleIcon.h
@@ -1,5 +1,7 @@
#pragma once
+#include "components/ble/BleController.h"
+
namespace Pinetime {
namespace Applications {
namespace Screens {
@@ -9,4 +11,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 1415e8e..fd74683 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -9,6 +9,7 @@
#include "components/settings/Settings.h"
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/WatchFaceDigital.h"
+#include "displayapp/screens/WatchFaceTerminal.h"
#include "displayapp/screens/WatchFaceAnalog.h"
#include "displayapp/screens/PineTimeStyle.h"
@@ -41,6 +42,9 @@ Clock::Clock(DisplayApp* app,
case 2:
return PineTimeStyleScreen();
break;
+ case 3:
+ return WatchFaceTerminalScreen();
+ break;
}
return WatchFaceDigitalScreen();
}()} {
@@ -76,11 +80,17 @@ std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
}
std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
- return std::make_unique<Screens::PineTimeStyle>(app,
- dateTimeController,
- batteryController,
- bleController,
- notificatioManager,
- settingsController,
- motionController);
+ return std::make_unique<Screens::PineTimeStyle>(
+ app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, motionController);
+}
+
+std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
+ return std::make_unique<Screens::WatchFaceTerminal>(app,
+ dateTimeController,
+ batteryController,
+ bleController,
+ notificatioManager,
+ settingsController,
+ heartRateController,
+ motionController);
}
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index fcecc6b..50996a7 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -47,6 +47,7 @@ namespace Pinetime {
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
std::unique_ptr<Screen> PineTimeStyleScreen();
+ std::unique_ptr<Screen> WatchFaceTerminalScreen();
};
}
}
diff --git a/src/displayapp/screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp
deleted file mode 100644
index cf239a2..0000000
--- a/src/displayapp/screens/DropDownDemo.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "displayapp/screens/DropDownDemo.h"
-#include <lvgl/lvgl.h>
-#include <libraries/log/nrf_log.h>
-#include "displayapp/DisplayApp.h"
-
-using namespace Pinetime::Applications::Screens;
-
-DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp* app) : Screen(app) {
- // Create the dropdown object, with many item, and fix its height
- ddlist = lv_ddlist_create(lv_scr_act(), nullptr);
- lv_ddlist_set_options(ddlist,
- "Apple\n"
- "Banana\n"
- "Orange\n"
- "Melon\n"
- "Grape\n"
- "Raspberry\n"
- "A\n"
- "B\n"
- "C\n"
- "D\n"
- "E");
- lv_ddlist_set_fix_width(ddlist, 150);
- lv_ddlist_set_draw_arrow(ddlist, true);
- lv_ddlist_set_fix_height(ddlist, 150);
- lv_obj_align(ddlist, nullptr, LV_ALIGN_IN_TOP_MID, 0, 20);
-}
-
-DropDownDemo::~DropDownDemo() {
- // Reset the touchmode
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
- lv_obj_clean(lv_scr_act());
-}
-
-bool DropDownDemo::Refresh() {
- auto* list = static_cast<lv_ddlist_ext_t*>(ddlist->ext_attr);
-
- // Switch touchmode to Polling if the dropdown is opened. This will allow to scroll inside the
- // dropdown while it is opened.
- // Disable the polling mode when the dropdown is closed to be able to handle the gestures.
- if (list->opened)
- app->SetTouchMode(DisplayApp::TouchModes::Polling);
- else
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
- return running;
-}
-
-bool DropDownDemo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- // If the dropdown is opened, notify Display app that it doesn't need to handle the event
- // (this will prevent displayApp from going back to the menu or clock scree).
- auto* list = static_cast<lv_ddlist_ext_t*>(ddlist->ext_attr);
- if (list->opened) {
- return true;
- } else {
- return false;
- }
-}
diff --git a/src/displayapp/screens/DropDownDemo.h b/src/displayapp/screens/DropDownDemo.h
deleted file mode 100644
index bcf0f45..0000000
--- a/src/displayapp/screens/DropDownDemo.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include "displayapp/screens/Screen.h"
-#include <lvgl/src/lv_core/lv_obj.h>
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
-
- class DropDownDemo : public Screen {
- public:
- DropDownDemo(DisplayApp* app);
- ~DropDownDemo() override;
-
- bool Refresh() override;
-
- bool OnTouchEvent(TouchEvents event) override;
-
- private:
- lv_obj_t* ddlist;
-
- bool isDropDownOpened = false;
- };
- }
- }
-}
diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h
index baa0ccd..2ad0035 100644
--- a/src/displayapp/screens/HeartRate.h
+++ b/src/displayapp/screens/HeartRate.h
@@ -3,7 +3,6 @@
#include <cstdint>
#include <chrono>
#include "displayapp/screens/Screen.h"
-#include <bits/unique_ptr.h>
#include "systemtask/SystemTask.h"
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
index d699740..4d2bd4f 100644
--- a/src/displayapp/screens/Motion.h
+++ b/src/displayapp/screens/Motion.h
@@ -3,7 +3,6 @@
#include <cstdint>
#include <chrono>
#include "displayapp/screens/Screen.h"
-#include <bits/unique_ptr.h>
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
#include <components/motion/MotionController.h>
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index f9b4eaa..27b2d3d 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -40,7 +40,7 @@ namespace Pinetime {
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
private:
- bool OnTouchEvent(TouchEvents event);
+ bool OnTouchEvent(TouchEvents event) override;
void UpdateLength();
@@ -69,7 +69,7 @@ namespace Pinetime {
std::string track;
/** Total length in seconds */
- int totalLength;
+ int totalLength = 0;
/** Current length in seconds */
int currentLength;
/** Last length */
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 569c422..f9afd8c 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -12,8 +12,14 @@ Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
+ System::SystemTask& systemTask,
Modes mode)
- : Screen(app), notificationManager {notificationManager}, alertNotificationService {alertNotificationService}, mode {mode} {
+ : Screen(app),
+ notificationManager {notificationManager},
+ alertNotificationService {alertNotificationService},
+ motorController {motorController},
+ systemTask {systemTask},
+ mode {mode} {
notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification();
if (notification.valid) {
@@ -24,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
validDisplay = true;
} else {
currentItem = std::make_unique<NotificationItem>("Notification",
@@ -33,24 +40,27 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
if (mode == Modes::Preview) {
+ systemTask.PushMessage(System::Messages::DisableSleeping);
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
motorController.StartRinging();
} else {
motorController.RunForDuration(35);
- timeoutLine = lv_line_create(lv_scr_act(), nullptr);
+ }
- lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
+ timeoutLine = lv_line_create(lv_scr_act(), nullptr);
- lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
- timeoutTickCountStart = xTaskGetTickCount();
- timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
- }
+ lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
+ lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
+
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ timeoutTickCountStart = xTaskGetTickCount();
+ interacted = false;
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -59,24 +69,41 @@ Notifications::Notifications(DisplayApp* app,
Notifications::~Notifications() {
lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
+ systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
void Notifications::Refresh() {
if (mode == Modes::Preview && timeoutLine != nullptr) {
- auto tick = xTaskGetTickCount();
- int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
- if (pos < 0)
+ TickType_t tick = xTaskGetTickCount();
+ int32_t pos = 240 - ((tick - timeoutTickCountStart) / (timeoutLength / 240));
+ if (pos <= 0) {
running = false;
+ } else {
+ timeoutLinePoints[1].x = pos;
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ }
+ }
+ running = currentItem->IsRunning() && running;
+}
- timeoutLinePoints[1].x = pos;
- lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+void Notifications::OnPreviewInteraction() {
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ motorController.StopRinging();
+ if (timeoutLine != nullptr) {
+ lv_obj_del(timeoutLine);
+ timeoutLine = nullptr;
}
}
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if (mode != Modes::Normal) {
+ if (!interacted && event == TouchEvents::Tap) {
+ interacted = true;
+ OnPreviewInteraction();
+ return true;
+ }
return false;
}
@@ -101,7 +128,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
previousNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
case Pinetime::Applications::TouchEvents::SwipeUp: {
@@ -126,7 +154,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
nextNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
default:
@@ -147,8 +176,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService)
- : mode {mode}, alertNotificationService {alertNotificationService} {
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController)
+ : mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
@@ -168,15 +198,18 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888));
- if (title == nullptr)
- title = "Notification";
- char* pchar;
- pchar = strchr(title, '\n');
- while (pchar != nullptr) {
- *pchar = ' ';
- pchar = strchr(pchar + 1, '\n');
+ if(title == nullptr) {
+ lv_label_set_text_static(alert_type, "Notification");
+ } else {
+ // copy title to label and replace newlines with spaces
+ lv_label_set_text(alert_type, title);
+ char *pchar = strchr(lv_label_get_text(alert_type), '\n');
+ while (pchar != nullptr) {
+ *pchar = ' ';
+ pchar = strchr(pchar + 1, '\n');
+ }
+ lv_label_refr_text(alert_type);
}
- lv_label_set_text(alert_type, title);
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC);
lv_obj_set_width(alert_type, 180);
lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16);
@@ -245,7 +278,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_
return;
}
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
if (obj == bt_accept) {
alertNotificationService.AcceptIncomingCall();
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index cbb7af6..7416035 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -1,11 +1,13 @@
#pragma once
#include <lvgl/lvgl.h>
+#include <FreeRTOS.h>
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
+#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Controllers {
@@ -21,11 +23,13 @@ namespace Pinetime {
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
+ System::SystemTask& systemTask,
Modes mode);
~Notifications() override;
void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
+ void OnPreviewInteraction();
class NotificationItem {
public:
@@ -35,7 +39,8 @@ namespace Pinetime {
Controllers::NotificationManager::Categories,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService);
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController);
~NotificationItem();
bool IsRunning() const {
return running;
@@ -52,16 +57,15 @@ namespace Pinetime {
lv_obj_t* label_reject;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ Pinetime::Controllers::MotorController& motorController;
bool running = true;
};
private:
- struct NotificationData {
- const char* title;
- const char* text;
- };
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ Pinetime::Controllers::MotorController& motorController;
+ System::SystemTask& systemTask;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;
@@ -69,8 +73,9 @@ namespace Pinetime {
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
lv_obj_t* timeoutLine = nullptr;
- uint32_t timeoutTickCountStart;
- uint32_t timeoutTickCountEnd;
+ TickType_t timeoutTickCountStart;
+ static const TickType_t timeoutLength = pdMS_TO_TICKS(7000);
+ bool interacted = true;
lv_task_t* taskRefresh;
};
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index b2b972d..e807289 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -42,6 +42,13 @@ namespace {
auto* screen = static_cast<PineTimeStyle*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
+
+ bool IsBleIconVisible(bool isRadioEnabled, bool isConnected) {
+ if(!isRadioEnabled) {
+ return true;
+ }
+ return isConnected;
+ }
}
PineTimeStyle::PineTimeStyle(DisplayApp* app,
@@ -60,12 +67,6 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
settingsController {settingsController},
motionController {motionController} {
- displayedChar[0] = 0;
- displayedChar[1] = 0;
- displayedChar[2] = 0;
- displayedChar[3] = 0;
- displayedChar[4] = 0;
-
// Create a 200px wide background rectangle
timebar = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
@@ -77,19 +78,19 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD1, "00");
+ lv_label_set_text_static(timeDD1, "00");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD2, "00");
+ lv_label_set_text_static(timeDD2, "00");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
- lv_label_set_text(timeAMPM, "");
+ lv_label_set_text_static(timeAMPM, "");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
// Create a 40px wide bar down the right side of the screen
@@ -102,17 +103,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
// Display icons
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
lv_obj_set_auto_realign(batteryIcon, true);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(bleIcon, "");
+ lv_label_set_text_static(bleIcon, "");
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(notificationIcon, "");
+ lv_label_set_text_static(notificationIcon, "");
// Calendar icon
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
@@ -154,17 +155,17 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
// Display date
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_label_set_text(dateDayOfWeek, "THU");
+ lv_label_set_text_static(dateDayOfWeek, "THU");
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
dateDay = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_label_set_text(dateDay, "25");
+ lv_label_set_text_static(dateDay, "25");
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
dateMonth = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_label_set_text(dateMonth, "MAR");
+ lv_label_set_text_static(dateMonth, "MAR");
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
// Step count gauge
@@ -199,7 +200,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
btnNextTime->user_data = this;
@@ -339,9 +340,10 @@ bool PineTimeStyle::OnButtonPushed() {
void PineTimeStyle::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
+
void PineTimeStyle::AlignIcons() {
if (notificationState.Get() && bleState.Get()) {
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 8, 25);
@@ -357,7 +359,7 @@ void PineTimeStyle::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {
- lv_label_set_text(batteryIcon, Symbols::plug);
+ lv_label_set_text_static(batteryIcon, Symbols::plug);
} else {
SetBatteryIcon();
}
@@ -370,14 +372,15 @@ void PineTimeStyle::Refresh() {
}
bleState = bleController.IsConnected();
- if (bleState.IsUpdated()) {
+ bleRadioEnabled = bleController.IsRadioEnabled();
+ if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
AlignIcons();
}
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
AlignIcons();
}
@@ -394,45 +397,31 @@ void PineTimeStyle::Refresh() {
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
- int hour = time.hours().count();
- auto minute = time.minutes().count();
-
- char minutesChar[3];
- sprintf(minutesChar, "%02d", static_cast<int>(minute));
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
- char hoursChar[3];
- char ampmChar[5];
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
- } else {
- if (hour == 0 && hour != 12) {
- hour = 12;
- sprintf(ampmChar, "A\nM");
- } else if (hour == 12 && hour != 0) {
- hour = 12;
- sprintf(ampmChar, "P\nM");
- } else if (hour < 12 && hour != 0) {
- sprintf(ampmChar, "A\nM");
- } else if (hour > 12 && hour != 0) {
- hour = hour - 12;
- sprintf(ampmChar, "P\nM");
- }
- sprintf(hoursChar, "%02d", hour);
- }
-
- if (hoursChar[0] != displayedChar[0] or hoursChar[1] != displayedChar[1] or minutesChar[0] != displayedChar[2] or
- minutesChar[1] != displayedChar[3]) {
- displayedChar[0] = hoursChar[0];
- displayedChar[1] = hoursChar[1];
- displayedChar[2] = minutesChar[0];
- displayedChar[3] = minutesChar[1];
+ if (displayedHour != hour || displayedMinute != minute) {
+ displayedHour = hour;
+ displayedMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[4] = "A\nM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
+ }
lv_label_set_text(timeAMPM, ampmChar);
+ // Should be padded with blank spaces, but the space character doesn't exist in the font
+ lv_label_set_text_fmt(timeDD1, "%02d", hour);
+ lv_label_set_text_fmt(timeDD2, "%02d", minute);
+ } else {
+ lv_label_set_text_fmt(timeDD1, "%02d", hour);
+ lv_label_set_text_fmt(timeDD2, "%02d", minute);
}
-
- lv_label_set_text_fmt(timeDD1, "%s", hoursChar);
- lv_label_set_text_fmt(timeDD2, "%s", minutesChar);
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index df8b7d5..5de9a5f 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -7,6 +7,7 @@
#include "displayapp/screens/Screen.h"
#include "displayapp/Colors.h"
#include "components/datetime/DateTimeController.h"
+#include "components/ble/BleController.h"
namespace Pinetime {
namespace Controllers {
@@ -39,17 +40,19 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t *object, lv_event_t event);
private:
- char displayedChar[5];
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
- Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
- Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
uint32_t savedTick = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> isCharging {};
DirtyValue<bool> bleState {};
+ DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
DirtyValue<uint32_t> stepCount {};
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index a260d29..8749839 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -1,13 +1,10 @@
-#include "StopWatch.h"
+#include "displayapp/screens/StopWatch.h"
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
#include <lvgl/lvgl.h>
-#include "projdefs.h"
-#include "FreeRTOSConfig.h"
-#include "task.h"
-
-#include <tuple>
+#include <FreeRTOS.h>
+#include <task.h>
using namespace Pinetime::Applications::Screens;
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h
index 0720a58..06193f6 100644
--- a/src/displayapp/screens/StopWatch.h
+++ b/src/displayapp/screens/StopWatch.h
@@ -4,7 +4,7 @@
#include "components/datetime/DateTimeController.h"
#include "displayapp/LittleVgl.h"
-#include "FreeRTOS.h"
+#include <FreeRTOS.h>
#include "portmacro_cmsis.h"
#include <array>
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index ba764a2..23d9bca 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -33,7 +33,7 @@ Tile::Tile(uint8_t screenID,
// Time
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_time, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
@@ -119,7 +119,7 @@ Tile::~Tile() {
}
void Tile::UpdateScreen() {
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index a5e4019..5cd496c 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -1,5 +1,4 @@
#include "displayapp/screens/Timer.h"
-
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
#include <lvgl/lvgl.h>
@@ -7,11 +6,11 @@
using namespace Pinetime::Applications::Screens;
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
- Timer* screen = static_cast<Timer*>(obj->user_data);
+ auto* screen = static_cast<Timer*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
-void Timer::createButtons() {
+void Timer::CreateButtons() {
btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesUp->user_data = this;
lv_obj_set_event_cb(btnMinutesUp, btnEventHandler);
@@ -51,6 +50,12 @@ void Timer::createButtons() {
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
: Screen(app), running {true}, timerController {timerController} {
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_click(backgroundLabel, true);
+ lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
+ lv_obj_set_size(backgroundLabel, 240, 240);
+ lv_obj_set_pos(backgroundLabel, 0, 0);
+ lv_label_set_text(backgroundLabel, "");
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@@ -71,7 +76,7 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
lv_label_set_text(txtPlayPause, Symbols::pause);
} else {
lv_label_set_text(txtPlayPause, Symbols::play);
- createButtons();
+ CreateButtons();
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -98,7 +103,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
minutesToSet = seconds / 60;
secondsToSet = seconds % 60;
timerController.StopTimer();
- createButtons();
+ CreateButtons();
} else if (secondsToSet + minutesToSet > 0) {
lv_label_set_text(txtPlayPause, Symbols::pause);
@@ -152,10 +157,10 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
}
}
-void Timer::setDone() {
+void Timer::SetDone() {
lv_label_set_text(time, "00:00");
lv_label_set_text(txtPlayPause, Symbols::play);
secondsToSet = 0;
minutesToSet = 0;
- createButtons();
+ CreateButtons();
}
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 23c8734..93e84c8 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -8,32 +8,35 @@
#include "components/timer/TimerController.h"
namespace Pinetime::Applications::Screens {
-
class Timer : public Screen {
public:
enum class Modes { Normal, Done };
Timer(DisplayApp* app, Controllers::TimerController& timerController);
-
~Timer() override;
-
void Refresh() override;
-
- void setDone();
-
+ void SetDone();
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
private:
+ void CreateButtons();
bool running;
uint8_t secondsToSet = 0;
uint8_t minutesToSet = 0;
Controllers::TimerController& timerController;
-
- void createButtons();
-
- lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
- *txtMDown, *txtSUp, *txtSDown;
-
+ lv_obj_t* backgroundLabel;
+ lv_obj_t* time;
+ lv_obj_t* msecTime;
+ lv_obj_t* btnPlayPause;
+ lv_obj_t* txtPlayPause;
+ lv_obj_t* btnMinutesUp;
+ lv_obj_t* btnMinutesDown;
+ lv_obj_t* btnSecondsUp;
+ lv_obj_t* btnSecondsDown;
+ lv_obj_t* txtMUp;
+ lv_obj_t* txtMDown;
+ lv_obj_t* txtSUp;
+ lv_obj_t* txtSDown;
lv_task_t* taskRefresh;
};
}
diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp
index b15332f..6d67585 100644
--- a/src/displayapp/screens/Twos.cpp
+++ b/src/displayapp/screens/Twos.cpp
@@ -130,7 +130,7 @@ bool Twos::placeNewTile() {
}
bool Twos::tryMerge(TwosTile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol) {
- if ((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) {
+ if (grid[newRow][newCol].value == grid[oldRow][oldCol].value) {
if ((newCol != oldCol) || (newRow != oldRow)) {
if (!grid[newRow][newCol].merged) {
unsigned int newVal = grid[oldRow][oldCol].value *= 2;
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index f027a74..6104281 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -57,7 +57,6 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
bleController {bleController},
notificationManager {notificationManager},
settingsController {settingsController} {
- settingsController.SetClockFace(1);
sHour = 99;
sMinute = 99;
@@ -138,9 +137,9 @@ WatchFaceAnalog::~WatchFaceAnalog() {
}
void WatchFaceAnalog::UpdateClock() {
- hour = dateTimeController.Hours();
- minute = dateTimeController.Minutes();
- second = dateTimeController.Seconds();
+ uint8_t hour = dateTimeController.Hours();
+ uint8_t minute = dateTimeController.Minutes();
+ uint8_t second = dateTimeController.Seconds();
if (sMinute != minute) {
auto const angle = minute * 6;
@@ -215,9 +214,9 @@ void WatchFaceAnalog::Refresh() {
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
- month = dateTimeController.Month();
- day = dateTimeController.Day();
- dayOfWeek = dateTimeController.DayOfWeek();
+ Pinetime::Controllers::DateTime::Months month = dateTimeController.Month();
+ uint8_t day = dateTimeController.Day();
+ Pinetime::Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
UpdateClock();
diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h
index a18eb29..4d76298 100644
--- a/src/displayapp/screens/WatchFaceAnalog.h
+++ b/src/displayapp/screens/WatchFaceAnalog.h
@@ -35,13 +35,6 @@ namespace Pinetime {
private:
uint8_t sHour, sMinute, sSecond;
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
-
- Pinetime::Controllers::DateTime::Months month;
- uint8_t day;
- Pinetime::Controllers::DateTime::Days dayOfWeek;
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
@@ -74,7 +67,7 @@ namespace Pinetime {
lv_obj_t* batteryIcon;
lv_obj_t* notificationIcon;
- Controllers::DateTime& dateTimeController;
+ const Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
Controllers::NotificationManager& notificationManager;
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 4d9eaf3..6a91488 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -32,25 +32,24 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController} {
- settingsController.SetClockFace(0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
- lv_label_set_text(batteryPlug, Symbols::plug);
+ lv_label_set_text_static(batteryPlug, Symbols::plug);
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
- lv_label_set_text(bleIcon, Symbols::bluetooth);
+ lv_label_set_text_static(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
label_date = lv_label_create(lv_scr_act(), nullptr);
@@ -71,26 +70,26 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(heartbeatIcon, Symbols::heartBeat);
+ lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
- lv_label_set_text(heartbeatValue, "");
+ lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
- lv_label_set_text(stepValue, "0");
+ lv_label_set_text_static(stepValue, "0");
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
stepIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
- lv_label_set_text(stepIcon, Symbols::shoe);
+ lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -105,7 +104,7 @@ WatchFaceDigital::~WatchFaceDigital() {
void WatchFaceDigital::Refresh() {
powerPresent = batteryController.IsPowerPresent();
if (powerPresent.IsUpdated()) {
- lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
+ lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
}
batteryPercentRemaining = batteryController.PercentRemaining();
@@ -116,20 +115,21 @@ void WatchFaceDigital::Refresh() {
} else {
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
bleState = bleController.IsConnected();
- if (bleState.IsUpdated()) {
+ bleRadioEnabled = bleController.IsRadioEnabled();
+ if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
- lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
- lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_realign(batteryIcon);
+ lv_obj_realign(batteryPlug);
+ lv_obj_realign(bleIcon);
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
@@ -146,62 +146,41 @@ void WatchFaceDigital::Refresh() {
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
- int hour = time.hours().count();
- auto minute = time.minutes().count();
-
- char minutesChar[3];
- sprintf(minutesChar, "%02d", static_cast<int>(minute));
-
- char hoursChar[3];
- char ampmChar[3];
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
- } else {
- if (hour == 0 && hour != 12) {
- hour = 12;
- sprintf(ampmChar, "AM");
- } else if (hour == 12 && hour != 0) {
- hour = 12;
- sprintf(ampmChar, "PM");
- } else if (hour < 12 && hour != 0) {
- sprintf(ampmChar, "AM");
- } else if (hour > 12 && hour != 0) {
- hour = hour - 12;
- sprintf(ampmChar, "PM");
- }
- sprintf(hoursChar, "%02d", hour);
- }
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
- if ((hoursChar[0] != displayedChar[0]) or (hoursChar[1] != displayedChar[1]) or (minutesChar[0] != displayedChar[2]) or
- (minutesChar[1] != displayedChar[3])) {
- displayedChar[0] = hoursChar[0];
- displayedChar[1] = hoursChar[1];
- displayedChar[2] = minutesChar[0];
- displayedChar[3] = minutesChar[1];
+ if (displayedHour != hour || displayedMinute != minute) {
+ displayedHour = hour;
+ displayedMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
- lv_label_set_text(label_time_ampm, ampmChar);
- if (hoursChar[0] == '0') {
- hoursChar[0] = ' ';
+ char ampmChar[3] = "AM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
}
- }
-
- lv_label_set_text_fmt(label_time, "%s:%s", hoursChar, minutesChar);
-
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ lv_label_set_text(label_time_ampm, ampmChar);
+ lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
} else {
+ lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
}
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- lv_label_set_text_fmt(label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
+ lv_label_set_text_fmt(
+ label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
} else {
- lv_label_set_text_fmt(label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
+ lv_label_set_text_fmt(
+ label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
}
- lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
+ lv_obj_realign(label_date);
currentYear = year;
currentMonth = month;
@@ -221,15 +200,15 @@ void WatchFaceDigital::Refresh() {
lv_label_set_text_static(heartbeatValue, "");
}
- lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
- lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
+ lv_obj_realign(heartbeatIcon);
+ lv_obj_realign(heartbeatValue);
}
stepCount = motionController.NbSteps();
motionSensorOk = motionController.IsSensorOk();
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
- lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
- lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_realign(stepValue);
+ lv_obj_realign(stepIcon);
}
}
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index 627154c..d33434c 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -6,6 +6,7 @@
#include <memory>
#include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h"
+#include "components/ble/BleController.h"
namespace Pinetime {
namespace Controllers {
@@ -35,16 +36,18 @@ namespace Pinetime {
void Refresh() override;
private:
- char displayedChar[5] {};
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
- Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
- Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> powerPresent {};
DirtyValue<bool> bleState {};
+ DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
DirtyValue<uint32_t> stepCount {};
diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp
new file mode 100644
index 0000000..3a47fc5
--- /dev/null
+++ b/src/displayapp/screens/WatchFaceTerminal.cpp
@@ -0,0 +1,183 @@
+#include <date/date.h>
+#include <lvgl/lvgl.h>
+#include "displayapp/screens/WatchFaceTerminal.h"
+#include "displayapp/screens/BatteryIcon.h"
+#include "displayapp/screens/NotificationIcon.h"
+#include "displayapp/screens/Symbols.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
+#include "components/ble/NotificationManager.h"
+#include "components/heartrate/HeartRateController.h"
+#include "components/motion/MotionController.h"
+#include "components/settings/Settings.h"
+
+using namespace Pinetime::Applications::Screens;
+
+WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::HeartRateController& heartRateController,
+ Controllers::MotionController& motionController)
+ : Screen(app),
+ currentDateTime {{}},
+ dateTimeController {dateTimeController},
+ batteryController {batteryController},
+ bleController {bleController},
+ notificatioManager {notificatioManager},
+ settingsController {settingsController},
+ heartRateController {heartRateController},
+ motionController {motionController} {
+ settingsController.SetClockFace(3);
+
+ batteryValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(batteryValue, true);
+ lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
+
+ connectState = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(connectState, true);
+ lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
+
+ notificationIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
+
+ label_date = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(label_date, true);
+ lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
+
+ label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
+ lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
+
+ label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
+ lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
+
+ label_time = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(label_time, true);
+ lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
+
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_click(backgroundLabel, true);
+ lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
+ lv_obj_set_size(backgroundLabel, 240, 240);
+ lv_obj_set_pos(backgroundLabel, 0, 0);
+ lv_label_set_text_static(backgroundLabel, "");
+
+ heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(heartbeatValue, true);
+ lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
+
+ stepValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(stepValue, true);
+ lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+ Refresh();
+}
+
+WatchFaceTerminal::~WatchFaceTerminal() {
+ lv_task_del(taskRefresh);
+ lv_obj_clean(lv_scr_act());
+}
+
+void WatchFaceTerminal::Refresh() {
+ powerPresent = batteryController.IsPowerPresent();
+ batteryPercentRemaining = batteryController.PercentRemaining();
+ if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
+ lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
+ if (batteryController.IsPowerPresent()) {
+ lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
+ }
+ }
+
+ bleState = bleController.IsConnected();
+ bleRadioEnabled = bleController.IsRadioEnabled();
+ if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
+ if(!bleRadioEnabled.Get()) {
+ lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
+ } else {
+ if (bleState.Get()) {
+ lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
+ } else {
+ lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
+ }
+ }
+ }
+
+ notificationState = notificatioManager.AreNewNotificationsAvailable();
+ if (notificationState.IsUpdated()) {
+ if (notificationState.Get()) {
+ lv_label_set_text_static(notificationIcon, "You have mail.");
+ } else {
+ lv_label_set_text_static(notificationIcon, "");
+ }
+ }
+
+ currentDateTime = dateTimeController.CurrentDateTime();
+
+ if (currentDateTime.IsUpdated()) {
+ auto newDateTime = currentDateTime.Get();
+
+ auto dp = date::floor<date::days>(newDateTime);
+ auto time = date::make_time(newDateTime - dp);
+ auto yearMonthDay = date::year_month_day(dp);
+
+ auto year = static_cast<int>(yearMonthDay.year());
+ auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
+ auto day = static_cast<unsigned>(yearMonthDay.day());
+ auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
+
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
+ uint8_t second = time.seconds().count();
+
+ if (displayedHour != hour || displayedMinute != minute || displayedSecond != second) {
+ displayedHour = hour;
+ displayedMinute = minute;
+ displayedSecond = second;
+
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[3] = "AM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
+ }
+ lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
+ } else {
+ lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
+ }
+ }
+
+ if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
+ lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d.%02d.%02d#", short(year), char(month), char(day));
+
+ currentYear = year;
+ currentMonth = month;
+ currentDayOfWeek = dayOfWeek;
+ currentDay = day;
+ }
+ }
+
+ heartbeat = heartRateController.HeartRate();
+ heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
+ if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
+ if (heartbeatRunning.Get()) {
+ lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
+ } else {
+ lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
+ }
+ }
+
+ stepCount = motionController.NbSteps();
+ motionSensorOk = motionController.IsSensorOk();
+ if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
+ lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
+ }
+}
diff --git a/src/displayapp/screens/WatchFaceTerminal.h b/src/displayapp/screens/WatchFaceTerminal.h
new file mode 100644
index 0000000..d236da3
--- /dev/null
+++ b/src/displayapp/screens/WatchFaceTerminal.h
@@ -0,0 +1,81 @@
+#pragma once
+
+#include <lvgl/src/lv_core/lv_obj.h>
+#include <chrono>
+#include <cstdint>
+#include <memory>
+#include "displayapp/screens/Screen.h"
+#include "components/datetime/DateTimeController.h"
+
+namespace Pinetime {
+ namespace Controllers {
+ class Settings;
+ class Battery;
+ class Ble;
+ class NotificationManager;
+ class HeartRateController;
+ class MotionController;
+ }
+
+ namespace Applications {
+ namespace Screens {
+
+ class WatchFaceTerminal : public Screen {
+ public:
+ WatchFaceTerminal(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::HeartRateController& heartRateController,
+ Controllers::MotionController& motionController);
+ ~WatchFaceTerminal() override;
+
+ void Refresh() override;
+
+ private:
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
+ uint8_t displayedSecond = -1;
+
+ uint16_t currentYear = 1970;
+ Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ uint8_t currentDay = 0;
+
+ DirtyValue<int> batteryPercentRemaining {};
+ DirtyValue<bool> powerPresent {};
+ DirtyValue<bool> bleState {};
+ DirtyValue<bool> bleRadioEnabled {};
+ DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
+ DirtyValue<bool> motionSensorOk {};
+ DirtyValue<uint32_t> stepCount {};
+ DirtyValue<uint8_t> heartbeat {};
+ DirtyValue<bool> heartbeatRunning {};
+ DirtyValue<bool> notificationState {};
+
+ lv_obj_t* label_time;
+ lv_obj_t* label_date;
+ lv_obj_t* label_prompt_1;
+ lv_obj_t* label_prompt_2;
+ lv_obj_t* backgroundLabel;
+ lv_obj_t* batteryValue;
+ lv_obj_t* heartbeatValue;
+ lv_obj_t* stepValue;
+ lv_obj_t* notificationIcon;
+ lv_obj_t* connectState;
+
+ Controllers::DateTime& dateTimeController;
+ Controllers::Battery& batteryController;
+ Controllers::Ble& bleController;
+ Controllers::NotificationManager& notificatioManager;
+ Controllers::Settings& settingsController;
+ Controllers::HeartRateController& heartRateController;
+ Controllers::MotionController& motionController;
+
+ lv_task_t* taskRefresh;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index 5d3a983..cd56c14 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -35,7 +35,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
// Time
label_time = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
@@ -123,7 +123,7 @@ QuickSettings::~QuickSettings() {
}
void QuickSettings::UpdateScreen() {
- lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes());
+ lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
diff --git a/src/displayapp/screens/settings/SettingBluetooth.cpp b/src/displayapp/screens/settings/SettingBluetooth.cpp
new file mode 100644
index 0000000..ab1af22
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingBluetooth.cpp
@@ -0,0 +1,93 @@
+#include "displayapp/screens/settings/SettingBluetooth.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/Messages.h"
+#include "displayapp/screens/Styles.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
+ screen->OnBluetoothDisabled(obj, event);
+ }
+
+ static void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
+ screen->OnBluetoothEnabled(obj, event);
+ }
+}
+
+SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), settingsController {settingsController} {
+
+ lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
+
+ lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
+ lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
+ lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
+ lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
+
+ lv_obj_set_pos(container1, 10, 60);
+ lv_obj_set_width(container1, LV_HOR_RES - 20);
+ lv_obj_set_height(container1, LV_VER_RES - 50);
+ lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
+
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(title, "Bluetooth");
+ lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
+
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_label_set_text_static(icon, Symbols::bluetooth);
+ lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
+
+ cbEnabled = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text(cbEnabled, " Enabled");
+ cbEnabled->user_data = this;
+ lv_obj_set_event_cb(cbEnabled, OnBluetoothEnabledEvent);
+ SetRadioButtonStyle(cbEnabled);
+
+ cbDisabled = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text(cbDisabled, " Disabled");
+ cbDisabled->user_data = this;
+ lv_obj_set_event_cb(cbDisabled, OnBluetoothDisabledEvent);
+ SetRadioButtonStyle(cbDisabled);
+
+ if (settingsController.GetBleRadioEnabled()) {
+ lv_checkbox_set_checked(cbEnabled, true);
+ priorMode = true;
+ } else {
+ lv_checkbox_set_checked(cbDisabled, true);
+ priorMode = false;
+ }
+}
+
+SettingBluetooth::~SettingBluetooth() {
+ lv_obj_clean(lv_scr_act());
+ // Do not call SaveSettings - see src/components/settings/Settings.h
+ if (priorMode != settingsController.GetBleRadioEnabled()) {
+ app->PushMessage(Pinetime::Applications::Display::Messages::BleRadioEnableToggle);
+ }
+}
+
+void SettingBluetooth::OnBluetoothDisabled(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ lv_checkbox_set_checked(cbEnabled, false);
+ lv_checkbox_set_checked(cbDisabled, true);
+ settingsController.SetBleRadioEnabled(false);
+ }
+}
+
+void SettingBluetooth::OnBluetoothEnabled(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ lv_checkbox_set_checked(cbEnabled, true);
+ lv_checkbox_set_checked(cbDisabled, false);
+ settingsController.SetBleRadioEnabled(true);
+ }
+}
+
diff --git a/src/displayapp/screens/settings/SettingBluetooth.h b/src/displayapp/screens/settings/SettingBluetooth.h
new file mode 100644
index 0000000..12bb459
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingBluetooth.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <array>
+#include <cstdint>
+#include <lvgl/lvgl.h>
+
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingBluetooth : public Screen {
+ public:
+ SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingBluetooth() override;
+
+ void OnBluetoothEnabled(lv_obj_t* object, lv_event_t event);
+ void OnBluetoothDisabled(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ lv_obj_t* cbEnabled;
+ lv_obj_t* cbDisabled;
+ bool priorMode;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingChimes.h b/src/displayapp/screens/settings/SettingChimes.h
index 653f87f..a251e95 100644
--- a/src/displayapp/screens/settings/SettingChimes.h
+++ b/src/displayapp/screens/settings/SettingChimes.h
@@ -20,7 +20,7 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
uint8_t optionsTotal;
- lv_obj_t* cbOption[2];
+ lv_obj_t* cbOption[3];
};
}
}
diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp
index 5351ade..037611f 100644
--- a/src/displayapp/screens/settings/SettingSetTime.cpp
+++ b/src/displayapp/screens/settings/SettingSetTime.cpp
@@ -4,6 +4,7 @@
#include <nrf_log.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Symbols.h"
+#include "components/settings/Settings.h"
using namespace Pinetime::Applications::Screens;
@@ -16,23 +17,24 @@ namespace {
constexpr int16_t POS_Y_MINUS = 40;
constexpr int16_t OFS_Y_COLON = -2;
- void event_handler(lv_obj_t * obj, lv_event_t event) {
- auto* screen = static_cast<SettingSetTime *>(obj->user_data);
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingSetTime*>(obj->user_data);
screen->HandleButtonPress(obj, event);
}
}
-SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
- Screen(app),
- dateTimeController {dateTimeController} {
- lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr);
+SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp* app,
+ Pinetime::Controllers::DateTime& dateTimeController,
+ Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), dateTimeController {dateTimeController}, settingsController {settingsController} {
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(title, "Set current time");
lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
- lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
-
+
lv_label_set_text_static(icon, Symbols::clock);
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
@@ -45,7 +47,7 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT);
lv_obj_set_auto_realign(lblHours, true);
- lv_obj_t * lblColon1 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* lblColon1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblColon1, ":");
lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER);
@@ -59,18 +61,24 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT);
lv_obj_set_auto_realign(lblMinutes, true);
- lv_obj_t * lblColon2 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* lblColon2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblColon2, ":");
lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON);
- lv_obj_t * lblSeconds = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_t* lblSeconds = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_static(lblSeconds, "00");
lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER);
lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT);
+ lblampm = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
+ lv_label_set_text_static(lblampm, " ");
+ lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_PLUS);
+
btnHoursPlus = lv_btn_create(lv_scr_act(), nullptr);
btnHoursPlus->user_data = this;
lv_obj_set_size(btnHoursPlus, 50, 40);
@@ -105,38 +113,69 @@ SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime
lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set");
lv_obj_set_event_cb(btnSetTime, event_handler);
+
+ SetHourLabels();
}
SettingSetTime::~SettingSetTime() {
lv_obj_clean(lv_scr_act());
}
-void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
+void SettingSetTime::SetHourLabels() {
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ switch (hoursValue) {
+ case 0:
+ lv_label_set_text_static(lblHours, "12");
+ lv_label_set_text_static(lblampm, "AM");
+ break;
+ case 1 ... 11:
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ lv_label_set_text_static(lblampm, "AM");
+ break;
+ case 12:
+ lv_label_set_text_static(lblHours, "12");
+ lv_label_set_text_static(lblampm, "PM");
+ break;
+ case 13 ... 23:
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue - 12);
+ lv_label_set_text_static(lblampm, "PM");
+ break;
+ }
+ } else {
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ }
+}
+
+void SettingSetTime::HandleButtonPress(lv_obj_t* object, lv_event_t event) {
if (event != LV_EVENT_CLICKED)
return;
if (object == btnHoursPlus) {
hoursValue++;
- if (hoursValue > 23)
+ if (hoursValue > 23) {
hoursValue = 0;
- lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ }
+ SetHourLabels();
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnHoursMinus) {
hoursValue--;
- if (hoursValue < 0)
+ if (hoursValue < 0) {
hoursValue = 23;
- lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ }
+ SetHourLabels();
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnMinutesPlus) {
minutesValue++;
- if (minutesValue > 59)
+ if (minutesValue > 59) {
minutesValue = 0;
+ }
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnMinutesMinus) {
minutesValue--;
- if (minutesValue < 0)
+ if (minutesValue < 0) {
minutesValue = 59;
+ }
lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
} else if (object == btnSetTime) {
diff --git a/src/displayapp/screens/settings/SettingSetTime.h b/src/displayapp/screens/settings/SettingSetTime.h
index 8ba41ea..d02c332 100644
--- a/src/displayapp/screens/settings/SettingSetTime.h
+++ b/src/displayapp/screens/settings/SettingSetTime.h
@@ -3,30 +3,37 @@
#include <cstdint>
#include <lvgl/lvgl.h>
#include "components/datetime/DateTimeController.h"
+#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
namespace Pinetime {
namespace Applications {
namespace Screens {
- class SettingSetTime : public Screen{
- public:
- SettingSetTime(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController);
- ~SettingSetTime() override;
+ class SettingSetTime : public Screen {
+ public:
+ SettingSetTime(DisplayApp* app,
+ Pinetime::Controllers::DateTime& dateTimeController,
+ Pinetime::Controllers::Settings& settingsController);
+ ~SettingSetTime() override;
- void HandleButtonPress(lv_obj_t *object, lv_event_t event);
-
- private:
- Controllers::DateTime& dateTimeController;
+ void HandleButtonPress(lv_obj_t* object, lv_event_t event);
- int hoursValue;
- int minutesValue;
- lv_obj_t * lblHours;
- lv_obj_t * lblMinutes;
- lv_obj_t * btnHoursPlus;
- lv_obj_t * btnHoursMinus;
- lv_obj_t * btnMinutesPlus;
- lv_obj_t * btnMinutesMinus;
- lv_obj_t * btnSetTime;
+ private:
+ Controllers::DateTime& dateTimeController;
+ Controllers::Settings& settingsController;
+
+ void SetHourLabels();
+
+ int hoursValue;
+ int minutesValue;
+ lv_obj_t* lblHours;
+ lv_obj_t* lblMinutes;
+ lv_obj_t* lblampm;
+ lv_obj_t* btnHoursPlus;
+ lv_obj_t* btnHoursMinus;
+ lv_obj_t* btnMinutesPlus;
+ lv_obj_t* btnMinutesMinus;
+ lv_obj_t* btnSetTime;
};
}
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index 1791b55..9d40fcf 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -1,4 +1,4 @@
-#include "SettingShakeThreshold.h"
+#include "displayapp/screens/settings/SettingShakeThreshold.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h"
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
index b9ddd8b..37f4a65 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.h
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -5,6 +5,7 @@
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
#include <components/motion/MotionController.h>
+#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index a24eaa1..5008592 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -14,7 +14,7 @@ namespace {
}
}
-constexpr std::array<const char*, 3> SettingWatchFace::options;
+constexpr std::array<const char*, 4> SettingWatchFace::options;
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index ccba7d1..62427b4 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -20,7 +20,7 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
- static constexpr std::array<const char*, 3> options = {" Digital face", " Analog face", " PineTimeStyle"};
+ static constexpr std::array<const char*, 4> options = {" Digital face", " Analog face", " PineTimeStyle", " Terminal"};
Controllers::Settings& settingsController;
lv_obj_t* cbOption[options.size()];
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 7bc90b4..bc7efcc 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -21,7 +21,11 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
},
[this]() -> std::unique_ptr<Screen> {
return CreateScreen3();
- }},
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen4();
+ },
+ },
Screens::ScreenListModes::UpDown} {
}
@@ -34,7 +38,6 @@ bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
}
std::unique_ptr<Screen> Settings::CreateScreen1() {
-
std::array<Screens::List::Applications, 4> applications {{
{Symbols::sun, "Display", Apps::SettingDisplay},
{Symbols::eye, "Wake Up", Apps::SettingWakeUp},
@@ -42,17 +45,17 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::home, "Watch face", Apps::SettingWatchFace},
}};
- return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(0, 4, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::shoe, "Steps", Apps::SettingSteps},
+ {Symbols::clock, "Set date", Apps::SettingSetDate},
+ {Symbols::clock, "Set time", Apps::SettingSetTime},
+ {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
- std::array<Screens::List::Applications, 4> applications {{{Symbols::shoe, "Steps", Apps::SettingSteps},
- {Symbols::clock, "Set date", Apps::SettingSetDate},
- {Symbols::clock, "Set time", Apps::SettingSetTime},
- {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
-
- return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(1, 4, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen3() {
@@ -61,8 +64,20 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
{Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::list, "About", Apps::SysInfo}
+ {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}
+ }};
+
+ return std::make_unique<Screens::List>(2, 4, app, settingsController, applications);
+}
+
+std::unique_ptr<Screen> Settings::CreateScreen4() {
+
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::list, "About", Apps::SysInfo},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None}
}};
- return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(3, 4, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 6c54cde..be09007 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -19,11 +19,12 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
- ScreenList<3> screens;
+ ScreenList<4> screens;
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
std::unique_ptr<Screen> CreateScreen3();
+ std::unique_ptr<Screen> CreateScreen4();
};
}
}