summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Alarm.cpp265
-rw-r--r--src/displayapp/screens/Alarm.h56
-rw-r--r--src/displayapp/screens/ApplicationList.cpp8
-rw-r--r--src/displayapp/screens/ApplicationList.h3
-rw-r--r--src/displayapp/screens/BatteryInfo.cpp21
-rw-r--r--src/displayapp/screens/BatteryInfo.h6
-rw-r--r--src/displayapp/screens/Brightness.cpp4
-rw-r--r--src/displayapp/screens/Brightness.h3
-rw-r--r--src/displayapp/screens/Clock.cpp7
-rw-r--r--src/displayapp/screens/Clock.h2
-rw-r--r--src/displayapp/screens/Error.cpp50
-rw-r--r--src/displayapp/screens/Error.h21
-rw-r--r--src/displayapp/screens/FirmwareUpdate.cpp5
-rw-r--r--src/displayapp/screens/FirmwareUpdate.h3
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp4
-rw-r--r--src/displayapp/screens/FirmwareValidation.h2
-rw-r--r--src/displayapp/screens/FlashLight.cpp4
-rw-r--r--src/displayapp/screens/FlashLight.h2
-rw-r--r--src/displayapp/screens/HeartRate.cpp7
-rw-r--r--src/displayapp/screens/HeartRate.h4
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp4
-rw-r--r--src/displayapp/screens/InfiniPaint.h2
-rw-r--r--src/displayapp/screens/Label.cpp4
-rw-r--r--src/displayapp/screens/Label.h2
-rw-r--r--src/displayapp/screens/List.cpp5
-rw-r--r--src/displayapp/screens/List.h2
-rw-r--r--src/displayapp/screens/Meter.cpp8
-rw-r--r--src/displayapp/screens/Meter.h4
-rw-r--r--src/displayapp/screens/Metronome.cpp8
-rw-r--r--src/displayapp/screens/Metronome.h4
-rw-r--r--src/displayapp/screens/Motion.cpp7
-rw-r--r--src/displayapp/screens/Motion.h3
-rw-r--r--src/displayapp/screens/Music.cpp7
-rw-r--r--src/displayapp/screens/Music.h4
-rw-r--r--src/displayapp/screens/Navigation.cpp9
-rw-r--r--src/displayapp/screens/Navigation.h4
-rw-r--r--src/displayapp/screens/Notifications.cpp12
-rw-r--r--src/displayapp/screens/Notifications.h12
-rw-r--r--src/displayapp/screens/Paddle.cpp10
-rw-r--r--src/displayapp/screens/Paddle.h4
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp71
-rw-r--r--src/displayapp/screens/PineTimeStyle.h8
-rw-r--r--src/displayapp/screens/Screen.cpp6
-rw-r--r--src/displayapp/screens/Screen.h24
-rw-r--r--src/displayapp/screens/ScreenList.h5
-rw-r--r--src/displayapp/screens/Steps.cpp8
-rw-r--r--src/displayapp/screens/Steps.h25
-rw-r--r--src/displayapp/screens/StopWatch.cpp12
-rw-r--r--src/displayapp/screens/StopWatch.h5
-rw-r--r--src/displayapp/screens/SystemInfo.cpp22
-rw-r--r--src/displayapp/screens/SystemInfo.h5
-rw-r--r--src/displayapp/screens/Tile.cpp4
-rw-r--r--src/displayapp/screens/Tile.h1
-rw-r--r--src/displayapp/screens/Timer.cpp46
-rw-r--r--src/displayapp/screens/Timer.h35
-rw-r--r--src/displayapp/screens/Twos.cpp6
-rw-r--r--src/displayapp/screens/Twos.h3
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp36
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.h6
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp20
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h5
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp10
-rw-r--r--src/displayapp/screens/settings/QuickSettings.h2
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingDisplay.h1
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp318
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.h56
-rw-r--r--src/displayapp/screens/settings/SettingSetDate.cpp198
-rw-r--r--src/displayapp/screens/settings/SettingSetDate.h41
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.cpp154
-rw-r--r--src/displayapp/screens/settings/SettingSetTime.h33
-rw-r--r--src/displayapp/screens/settings/SettingSteps.cpp7
-rw-r--r--src/displayapp/screens/settings/SettingSteps.h23
-rw-r--r--src/displayapp/screens/settings/SettingTimeFormat.cpp6
-rw-r--r--src/displayapp/screens/settings/SettingTimeFormat.h1
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.h1
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h1
-rw-r--r--src/displayapp/screens/settings/Settings.cpp28
-rw-r--r--src/displayapp/screens/settings/Settings.h5
81 files changed, 1489 insertions, 353 deletions
diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp
new file mode 100644
index 00000000..6b45a36e
--- /dev/null
+++ b/src/displayapp/screens/Alarm.cpp
@@ -0,0 +1,265 @@
+/* Copyright (C) 2021 mruss77, Florian
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#include "Alarm.h"
+#include "Screen.h"
+#include "Symbols.h"
+
+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);
+ screen->OnButtonEvent(obj, event);
+}
+
+Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
+ : Screen(app), running {true}, alarmController {alarmController} {
+
+ 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);
+ lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+
+ alarmHours = alarmController.Hours();
+ alarmMinutes = alarmController.Minutes();
+ lv_label_set_text_fmt(time, "%02lu:%02lu", alarmHours, alarmMinutes);
+
+ lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
+
+ btnHoursUp = lv_btn_create(lv_scr_act(), nullptr);
+ btnHoursUp->user_data = this;
+ lv_obj_set_event_cb(btnHoursUp, btnEventHandler);
+ lv_obj_set_size(btnHoursUp, 60, 40);
+ lv_obj_align(btnHoursUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -85);
+ txtHrUp = lv_label_create(btnHoursUp, nullptr);
+ lv_label_set_text_static(txtHrUp, "+");
+
+ btnHoursDown = lv_btn_create(lv_scr_act(), nullptr);
+ btnHoursDown->user_data = this;
+ lv_obj_set_event_cb(btnHoursDown, btnEventHandler);
+ lv_obj_set_size(btnHoursDown, 60, 40);
+ lv_obj_align(btnHoursDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, 35);
+ txtHrDown = lv_label_create(btnHoursDown, nullptr);
+ lv_label_set_text_static(txtHrDown, "-");
+
+ btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr);
+ btnMinutesUp->user_data = this;
+ lv_obj_set_event_cb(btnMinutesUp, btnEventHandler);
+ lv_obj_set_size(btnMinutesUp, 60, 40);
+ lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, -85);
+ txtMinUp = lv_label_create(btnMinutesUp, nullptr);
+ lv_label_set_text_static(txtMinUp, "+");
+
+ btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
+ btnMinutesDown->user_data = this;
+ lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
+ lv_obj_set_size(btnMinutesDown, 60, 40);
+ lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, 35);
+ 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();
+
+ btnRecur = lv_btn_create(lv_scr_act(), nullptr);
+ btnRecur->user_data = this;
+ lv_obj_set_event_cb(btnRecur, btnEventHandler);
+ lv_obj_set_size(btnRecur, 115, 50);
+ lv_obj_align(btnRecur, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ txtRecur = lv_label_create(btnRecur, nullptr);
+ SetRecurButtonState();
+
+ btnInfo = lv_btn_create(lv_scr_act(), nullptr);
+ btnInfo->user_data = this;
+ lv_obj_set_event_cb(btnInfo, btnEventHandler);
+ lv_obj_set_size(btnInfo, 50, 40);
+ 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");
+}
+
+Alarm::~Alarm() {
+ 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();
+ return;
+ }
+ if (obj == btnInfo) {
+ ShowInfo();
+ return;
+ }
+ if (obj == btnMessage) {
+ HideInfo();
+ 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();
+ }
+ if (obj == btnMinutesUp) {
+ if (alarmMinutes >= 59) {
+ alarmMinutes = 0;
+ } else {
+ alarmMinutes++;
+ }
+ UpdateAlarmTime();
+ return;
+ }
+ if (obj == btnMinutesDown) {
+ if (alarmMinutes == 0) {
+ alarmMinutes = 59;
+ } else {
+ alarmMinutes--;
+ }
+ UpdateAlarmTime();
+ return;
+ }
+ if (obj == btnHoursUp) {
+ if (alarmHours >= 23) {
+ alarmHours = 0;
+ } else {
+ alarmHours++;
+ }
+ UpdateAlarmTime();
+ return;
+ }
+ if (obj == btnHoursDown) {
+ if (alarmHours == 0) {
+ alarmHours = 23;
+ } else {
+ alarmHours--;
+ }
+ UpdateAlarmTime();
+ return;
+ }
+ if (obj == btnRecur) {
+ ToggleRecurrence();
+ }
+ }
+}
+
+bool Alarm::OnButtonPushed() {
+ if (txtMessage != nullptr && btnMessage != nullptr) {
+ HideInfo();
+ return true;
+ }
+ return false;
+}
+
+void Alarm::UpdateAlarmTime() {
+ lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
+ alarmController.SetAlarmTime(alarmHours, alarmMinutes);
+}
+
+void Alarm::SetAlerting() {
+ SetEnableButtonState();
+}
+
+void Alarm::SetEnableButtonState() {
+ 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);
+ 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);
+ 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);
+ }
+}
+
+void Alarm::ShowInfo() {
+ btnMessage = lv_btn_create(lv_scr_act(), nullptr);
+ btnMessage->user_data = this;
+ lv_obj_set_event_cb(btnMessage, btnEventHandler);
+ lv_obj_set_height(btnMessage, 200);
+ lv_obj_set_width(btnMessage, 150);
+ lv_obj_align(btnMessage, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ txtMessage = lv_label_create(btnMessage, nullptr);
+ lv_obj_set_style_local_bg_color(btnMessage, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_NAVY);
+
+ if (alarmController.State() == AlarmController::AlarmState::Set) {
+ auto timeToAlarm = alarmController.SecondsToAlarm();
+
+ auto daysToAlarm = timeToAlarm / 86400;
+ auto hrsToAlarm = (timeToAlarm % 86400) / 3600;
+ auto minToAlarm = (timeToAlarm % 3600) / 60;
+ auto secToAlarm = timeToAlarm % 60;
+
+ lv_label_set_text_fmt(
+ txtMessage, "Time to\nalarm:\n%2d Days\n%2d Hours\n%2d Minutes\n%2d Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
+ } else {
+ lv_label_set_text(txtMessage, "Alarm\nis not\nset.");
+ }
+}
+
+void Alarm::HideInfo() {
+ lv_obj_del(btnMessage);
+ txtMessage = nullptr;
+ btnMessage = nullptr;
+}
+
+void Alarm::SetRecurButtonState() {
+ using Pinetime::Controllers::AlarmController;
+ switch (alarmController.Recurrence()) {
+ case AlarmController::RecurType::None:
+ lv_label_set_text(txtRecur, "ONCE");
+ break;
+ case AlarmController::RecurType::Daily:
+ lv_label_set_text(txtRecur, "DAILY");
+ break;
+ case AlarmController::RecurType::Weekdays:
+ lv_label_set_text(txtRecur, "MON-FRI");
+ }
+}
+
+void Alarm::ToggleRecurrence() {
+ using Pinetime::Controllers::AlarmController;
+ switch (alarmController.Recurrence()) {
+ case AlarmController::RecurType::None:
+ alarmController.SetRecurrence(AlarmController::RecurType::Daily);
+ break;
+ case AlarmController::RecurType::Daily:
+ alarmController.SetRecurrence(AlarmController::RecurType::Weekdays);
+ break;
+ case AlarmController::RecurType::Weekdays:
+ alarmController.SetRecurrence(AlarmController::RecurType::None);
+ }
+ SetRecurButtonState();
+}
diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h
new file mode 100644
index 00000000..32a14d2f
--- /dev/null
+++ b/src/displayapp/screens/Alarm.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 2021 mruss77, Florian
+
+ This file is part of InfiniTime.
+
+ InfiniTime is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ InfiniTime is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include "Screen.h"
+#include "systemtask/SystemTask.h"
+#include "../LittleVgl.h"
+#include "components/alarm/AlarmController.h"
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ class Alarm : public Screen {
+ public:
+ Alarm(DisplayApp* app, Controllers::AlarmController& alarmController);
+ ~Alarm() override;
+ void SetAlerting();
+ void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
+ bool OnButtonPushed() override;
+
+ private:
+ bool running;
+ uint8_t alarmHours;
+ uint8_t alarmMinutes;
+ Controllers::AlarmController& alarmController;
+
+ lv_obj_t *time, *btnEnable, *txtEnable, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
+ *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnMessage, *txtMessage, *btnInfo, *txtInfo;
+
+ enum class EnableButtonState { On, Off, Alerting };
+ void SetEnableButtonState();
+ void SetRecurButtonState();
+ void SetAlarm();
+ void ShowInfo();
+ void HideInfo();
+ void ToggleRecurrence();
+ void UpdateAlarmTime();
+ };
+ };
+ };
+}
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index d6c3970b..5c582f60 100644
--- a/src/displayapp/screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -34,12 +34,6 @@ ApplicationList::~ApplicationList() {
lv_obj_clean(lv_scr_act());
}
-bool ApplicationList::Refresh() {
- if (running)
- running = screens.Refresh();
- return running;
-}
-
bool ApplicationList::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
@@ -64,7 +58,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
{"2", Apps::Twos},
{Symbols::chartLine, Apps::Motion},
{Symbols::drum, Apps::Metronome},
- {"", Apps::None},
+ {Symbols::clock, Apps::Alarm},
}};
return std::make_unique<Screens::Tile>(1, 2, app, settingsController, batteryController, dateTimeController, applications);
diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h
index 88534ec4..103c38ae 100644
--- a/src/displayapp/screens/ApplicationList.h
+++ b/src/displayapp/screens/ApplicationList.h
@@ -18,7 +18,6 @@ namespace Pinetime {
Pinetime::Controllers::Battery& batteryController,
Controllers::DateTime& dateTimeController);
~ApplicationList() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
private:
@@ -33,4 +32,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp
index 0ab47ebf..44ea7f51 100644
--- a/src/displayapp/screens/BatteryInfo.cpp
+++ b/src/displayapp/screens/BatteryInfo.cpp
@@ -4,11 +4,6 @@
using namespace Pinetime::Applications::Screens;
-static void lv_update_task(struct _lv_task_t* task) {
- auto user_data = static_cast<BatteryInfo*>(task->user_data);
- user_data->UpdateScreen();
-}
-
BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Battery& batteryController)
: Screen(app), batteryController {batteryController} {
@@ -49,23 +44,21 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
- taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_LOW, this);
- UpdateScreen();
+ taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this);
+ Refresh();
}
BatteryInfo::~BatteryInfo() {
- lv_task_del(taskUpdate);
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-void BatteryInfo::UpdateScreen() {
-
- batteryController.Update();
+void BatteryInfo::Refresh() {
batteryPercent = batteryController.PercentRemaining();
batteryVoltage = batteryController.Voltage();
- if (batteryController.IsCharging() and batteryPercent < 100) {
+ if (batteryController.IsCharging()) {
lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
lv_label_set_text_static(status, "Charging");
} else if (batteryPercent == 100) {
@@ -85,7 +78,3 @@ void BatteryInfo::UpdateScreen() {
lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10);
lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON);
}
-
-bool BatteryInfo::Refresh() {
- return running;
-}
diff --git a/src/displayapp/screens/BatteryInfo.h b/src/displayapp/screens/BatteryInfo.h
index 69793244..63454a26 100644
--- a/src/displayapp/screens/BatteryInfo.h
+++ b/src/displayapp/screens/BatteryInfo.h
@@ -19,9 +19,7 @@ namespace Pinetime {
BatteryInfo(DisplayApp* app, Pinetime::Controllers::Battery& batteryController);
~BatteryInfo() override;
- bool Refresh() override;
-
- void UpdateScreen();
+ void Refresh() override;
private:
Pinetime::Controllers::Battery& batteryController;
@@ -31,7 +29,7 @@ namespace Pinetime {
lv_obj_t* charging_bar;
lv_obj_t* status;
- lv_task_t* taskUpdate;
+ lv_task_t* taskRefresh;
uint8_t batteryPercent = 0;
uint16_t batteryVoltage = 0;
diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp
index 47c10561..1278cd62 100644
--- a/src/displayapp/screens/Brightness.cpp
+++ b/src/displayapp/screens/Brightness.cpp
@@ -30,10 +30,6 @@ Brightness::~Brightness() {
lv_obj_clean(lv_scr_act());
}
-bool Brightness::Refresh() {
- return running;
-}
-
const char* Brightness::LevelToString(Pinetime::Controllers::BrightnessController::Levels level) {
switch (level) {
case Pinetime::Controllers::BrightnessController::Levels::Off:
diff --git a/src/displayapp/screens/Brightness.h b/src/displayapp/screens/Brightness.h
index 9ee33753..14e48592 100644
--- a/src/displayapp/screens/Brightness.h
+++ b/src/displayapp/screens/Brightness.h
@@ -12,7 +12,6 @@ namespace Pinetime {
public:
Brightness(DisplayApp* app, Controllers::BrightnessController& brightness);
~Brightness() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
@@ -31,4 +30,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 86afee0c..5a5cd18b 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -50,11 +50,6 @@ Clock::~Clock() {
lv_obj_clean(lv_scr_act());
}
-bool Clock::Refresh() {
- screen->Refresh();
- return running;
-}
-
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screen->OnTouchEvent(event);
}
@@ -83,4 +78,4 @@ std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
notificatioManager,
settingsController,
motionController);
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 7968cced..648f72da 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -31,8 +31,6 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~Clock() override;
- bool Refresh() override;
-
bool OnTouchEvent(TouchEvents event) override;
private:
diff --git a/src/displayapp/screens/Error.cpp b/src/displayapp/screens/Error.cpp
new file mode 100644
index 00000000..75946aba
--- /dev/null
+++ b/src/displayapp/screens/Error.cpp
@@ -0,0 +1,50 @@
+#include "Error.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ void ButtonEventCallback(lv_obj_t* obj, lv_event_t /*event*/) {
+ auto* errorScreen = static_cast<Error*>(obj->user_data);
+ errorScreen->ButtonEventHandler();
+ }
+}
+
+Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error)
+ : Screen(app) {
+
+ lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_label_set_text_static(warningLabel, "Warning");
+ lv_obj_align(warningLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
+
+ lv_obj_t* causeLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(causeLabel, LV_LABEL_LONG_BREAK);
+ lv_obj_set_width(causeLabel, LV_HOR_RES);
+ lv_obj_align(causeLabel, warningLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+
+ if (error == System::BootErrors::TouchController) {
+ lv_label_set_text_static(causeLabel, "Touch controller error detected.");
+ }
+
+ lv_obj_t* tipLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(tipLabel, LV_LABEL_LONG_BREAK);
+ lv_obj_set_width(tipLabel, LV_HOR_RES);
+ lv_label_set_text_static(tipLabel, "If you encounter problems and your device is under warranty, contact the devices seller.");
+ lv_obj_align(tipLabel, causeLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+
+ btnOk = lv_btn_create(lv_scr_act(), nullptr);
+ btnOk->user_data = this;
+ lv_obj_set_event_cb(btnOk, ButtonEventCallback);
+ lv_obj_set_size(btnOk, LV_HOR_RES, 50);
+ lv_obj_align(btnOk, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_obj_set_style_local_value_str(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Proceed");
+ lv_obj_set_style_local_bg_color(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+}
+
+void Error::ButtonEventHandler() {
+ running = false;
+}
+
+Error::~Error() {
+ lv_obj_clean(lv_scr_act());
+}
diff --git a/src/displayapp/screens/Error.h b/src/displayapp/screens/Error.h
new file mode 100644
index 00000000..20dde7ee
--- /dev/null
+++ b/src/displayapp/screens/Error.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "Screen.h"
+#include "BootErrors.h"
+#include <lvgl/lvgl.h>
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ class Error : public Screen {
+ public:
+ Error(DisplayApp* app, System::BootErrors error);
+ ~Error() override;
+
+ void ButtonEventHandler();
+ private:
+ lv_obj_t* btnOk;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp
index edb2e49d..79bda0ba 100644
--- a/src/displayapp/screens/FirmwareUpdate.cpp
+++ b/src/displayapp/screens/FirmwareUpdate.cpp
@@ -30,14 +30,16 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
lv_label_set_text(percentLabel, "Waiting...");
lv_obj_set_auto_realign(percentLabel, true);
lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60);
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
startTime = xTaskGetTickCount();
}
FirmwareUpdate::~FirmwareUpdate() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool FirmwareUpdate::Refresh() {
+void FirmwareUpdate::Refresh() {
switch (bleController.State()) {
default:
case Pinetime::Controllers::Ble::FirmwareUpdateStates::Idle:
@@ -73,7 +75,6 @@ bool FirmwareUpdate::Refresh() {
}
break;
}
- return running;
}
void FirmwareUpdate::DisplayProgression() const {
diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h
index 90c99f4c..8fc86d8c 100644
--- a/src/displayapp/screens/FirmwareUpdate.h
+++ b/src/displayapp/screens/FirmwareUpdate.h
@@ -16,7 +16,7 @@ namespace Pinetime {
FirmwareUpdate(DisplayApp* app, Pinetime::Controllers::Ble& bleController);
~FirmwareUpdate() override;
- bool Refresh() override;
+ void Refresh() override;
private:
enum class States { Idle, Running, Validated, Error };
@@ -36,6 +36,7 @@ namespace Pinetime {
void UpdateError();
+ lv_task_t* taskRefresh;
TickType_t startTime;
};
}
diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index 34a43a9f..eef8f919 100644
--- a/src/displayapp/screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -63,10 +63,6 @@ FirmwareValidation::~FirmwareValidation() {
lv_obj_clean(lv_scr_act());
}
-bool FirmwareValidation::Refresh() {
- return running;
-}
-
void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
if (object == buttonValidate && event == LV_EVENT_CLICKED) {
validator.Validate();
diff --git a/src/displayapp/screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h
index 1ef5ba0a..bfdb096d 100644
--- a/src/displayapp/screens/FirmwareValidation.h
+++ b/src/displayapp/screens/FirmwareValidation.h
@@ -16,8 +16,6 @@ namespace Pinetime {
FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator);
~FirmwareValidation() override;
- bool Refresh() override;
-
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
index 63b2345e..4bc5b558 100644
--- a/src/displayapp/screens/FlashLight.cpp
+++ b/src/displayapp/screens/FlashLight.cpp
@@ -65,10 +65,6 @@ void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
}
}
-bool FlashLight::Refresh() {
- return running;
-}
-
bool FlashLight::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return false;
}
diff --git a/src/displayapp/screens/FlashLight.h b/src/displayapp/screens/FlashLight.h
index a862ffdb..7f5ca6c5 100644
--- a/src/displayapp/screens/FlashLight.h
+++ b/src/displayapp/screens/FlashLight.h
@@ -16,8 +16,6 @@ namespace Pinetime {
FlashLight(DisplayApp* app, System::SystemTask& systemTask, Controllers::BrightnessController& brightness);
~FlashLight() override;
- bool Refresh() override;
-
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
void OnClickEvent(lv_obj_t* obj, lv_event_t event);
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 5689b63e..b6ece27f 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -64,14 +64,17 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
UpdateStartStopButton(isHrRunning);
if (isHrRunning)
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
HeartRate::~HeartRate() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
-bool HeartRate::Refresh() {
+void HeartRate::Refresh() {
auto state = heartRateController.State();
switch (state) {
@@ -86,8 +89,6 @@ bool HeartRate::Refresh() {
lv_label_set_text(label_status, ToString(state));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
-
- return running;
}
void HeartRate::OnStartStopEvent(lv_event_t event) {
diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h
index a23c5af8..7f7d3ad3 100644
--- a/src/displayapp/screens/HeartRate.h
+++ b/src/displayapp/screens/HeartRate.h
@@ -20,7 +20,7 @@ namespace Pinetime {
HeartRate(DisplayApp* app, Controllers::HeartRateController& HeartRateController, System::SystemTask& systemTask);
~HeartRate() override;
- bool Refresh() override;
+ void Refresh() override;
void OnStartStopEvent(lv_event_t event);
@@ -33,6 +33,8 @@ namespace Pinetime {
lv_obj_t* label_status;
lv_obj_t* btn_startStop;
lv_obj_t* label_startStop;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index 58bfa558..85a5e826 100644
--- a/src/displayapp/screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -12,10 +12,6 @@ InfiniPaint::~InfiniPaint() {
lv_obj_clean(lv_scr_act());
}
-bool InfiniPaint::Refresh() {
- return running;
-}
-
bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case Pinetime::Applications::TouchEvents::LongTap:
diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h
index 6251752a..0a70e033 100644
--- a/src/displayapp/screens/InfiniPaint.h
+++ b/src/displayapp/screens/InfiniPaint.h
@@ -17,8 +17,6 @@ namespace Pinetime {
~InfiniPaint() override;
- bool Refresh() override;
-
bool OnTouchEvent(TouchEvents event) override;
bool OnTouchEvent(uint16_t x, uint16_t y) override;
diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp
index f724fd48..1761a7b5 100644
--- a/src/displayapp/screens/Label.cpp
+++ b/src/displayapp/screens/Label.cpp
@@ -36,7 +36,3 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ
Label::~Label() {
lv_obj_clean(lv_scr_act());
}
-
-bool Label::Refresh() {
- return running;
-}
diff --git a/src/displayapp/screens/Label.h b/src/displayapp/screens/Label.h
index 834f8c88..f1e49079 100644
--- a/src/displayapp/screens/Label.h
+++ b/src/displayapp/screens/Label.h
@@ -12,8 +12,6 @@ namespace Pinetime {
Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText);
~Label() override;
- bool Refresh() override;
-
private:
lv_obj_t* labelText = nullptr;
lv_point_t pageIndicatorBasePoints[2];
diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp
index 91cab9f0..064b47a6 100644
--- a/src/displayapp/screens/List.cpp
+++ b/src/displayapp/screens/List.cpp
@@ -98,11 +98,6 @@ List::~List() {
lv_obj_clean(lv_scr_act());
}
-bool List::Refresh() {
-
- return running;
-}
-
void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
for (int i = 0; i < MAXLISTITEMS; i++) {
diff --git a/src/displayapp/screens/List.h b/src/displayapp/screens/List.h
index a45fd1d3..d9f61f29 100644
--- a/src/displayapp/screens/List.h
+++ b/src/displayapp/screens/List.h
@@ -27,8 +27,6 @@ namespace Pinetime {
std::array<Applications, MAXLISTITEMS>& applications);
~List() override;
- bool Refresh() override;
-
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/Meter.cpp b/src/displayapp/screens/Meter.cpp
index e0dbdfad..57cde9cf 100644
--- a/src/displayapp/screens/Meter.cpp
+++ b/src/displayapp/screens/Meter.cpp
@@ -20,17 +20,17 @@ Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) {
lv_obj_set_size(lmeter, 200, 200);
lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Meter::~Meter() {
-
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Meter::Refresh() {
+void Meter::Refresh() {
lv_linemeter_set_value(lmeter, value++); /*Set the current value*/
if (value >= 60)
value = 0;
-
- return running;
}
diff --git a/src/displayapp/screens/Meter.h b/src/displayapp/screens/Meter.h
index 24af15ad..9b3d1d48 100644
--- a/src/displayapp/screens/Meter.h
+++ b/src/displayapp/screens/Meter.h
@@ -14,13 +14,15 @@ namespace Pinetime {
Meter(DisplayApp* app);
~Meter() override;
- bool Refresh() override;
+ void Refresh() override;
private:
lv_style_t style_lmeter;
lv_obj_t* lmeter;
uint32_t value = 0;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 5fbe5f36..52cb8519 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -66,16 +66,19 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl
lv_obj_set_size(playPause, 115, 50);
lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Metronome::~Metronome() {
+ lv_task_del(taskRefresh);
systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
-bool Metronome::Refresh() {
+void Metronome::Refresh() {
if (metronomeStarted) {
- if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) {
+ if (xTaskGetTickCount() - startTime > 60u * configTICK_RATE_HZ / static_cast<uint16_t>(bpm)) {
startTime += 60 * configTICK_RATE_HZ / bpm;
counter--;
if (counter == 0) {
@@ -86,7 +89,6 @@ bool Metronome::Refresh() {
}
}
}
- return running;
}
void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
index a4baa096..f3a84dc8 100644
--- a/src/displayapp/screens/Metronome.h
+++ b/src/displayapp/screens/Metronome.h
@@ -11,7 +11,7 @@ namespace Pinetime {
public:
Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
~Metronome() override;
- bool Refresh() override;
+ void Refresh() override;
void OnEvent(lv_obj_t* obj, lv_event_t event);
private:
@@ -28,6 +28,8 @@ namespace Pinetime {
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText;
lv_obj_t *playPause;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 43a5575e..2f1f7c21 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -36,13 +36,16 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
labelStep = lv_label_create(lv_scr_act(), NULL);
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text(labelStep, "Steps ---");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Motion::~Motion() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Motion::Refresh() {
+void Motion::Refresh() {
lv_chart_set_next(chart, ser1, motionController.X());
lv_chart_set_next(chart, ser2, motionController.Y());
lv_chart_set_next(chart, ser3, motionController.Z());
@@ -55,6 +58,4 @@ bool Motion::Refresh() {
motionController.Y() / 0x10,
motionController.Z() / 0x10);
lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
-
- return running;
}
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
index 7e65197b..20a18d02 100644
--- a/src/displayapp/screens/Motion.h
+++ b/src/displayapp/screens/Motion.h
@@ -17,7 +17,7 @@ namespace Pinetime {
Motion(DisplayApp* app, Controllers::MotionController& motionController);
~Motion() override;
- bool Refresh() override;
+ void Refresh() override;
private:
Controllers::MotionController& motionController;
@@ -28,6 +28,7 @@ namespace Pinetime {
lv_obj_t* label;
lv_obj_t* labelStep;
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index 257e9aea..47ddb655 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -139,14 +139,17 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
frameB = false;
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Music::~Music() {
+ lv_task_del(taskRefresh);
lv_style_reset(&btn_style);
lv_obj_clean(lv_scr_act());
}
-bool Music::Refresh() {
+void Music::Refresh() {
if (artist != musicService.getArtist()) {
artist = musicService.getArtist();
currentLength = 0;
@@ -210,8 +213,6 @@ bool Music::Refresh() {
} else {
lv_label_set_text(txtPlayPause, Symbols::play);
}
-
- return running;
}
void Music::UpdateLength() {
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index 00d3ad92..6f2d80a0 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -35,7 +35,7 @@ namespace Pinetime {
~Music() override;
- bool Refresh() override;
+ void Refresh() override;
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
@@ -79,6 +79,8 @@ namespace Pinetime {
bool playing;
+ lv_task_t* taskRefresh;
+
/** Watchapp */
};
}
diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp
index 79b04e21..d437cc6d 100644
--- a/src/displayapp/screens/Navigation.cpp
+++ b/src/displayapp/screens/Navigation.cpp
@@ -161,13 +161,16 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
lv_bar_set_anim_time(barProgress, 500);
lv_bar_set_range(barProgress, 0, 100);
lv_bar_set_value(barProgress, 0, LV_ANIM_OFF);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Navigation::~Navigation() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Navigation::Refresh() {
+void Navigation::Refresh() {
if (flag != navService.getFlag()) {
flag = navService.getFlag();
lv_label_set_text(imgFlag, iconForName(flag));
@@ -192,8 +195,4 @@ bool Navigation::Refresh() {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
}
}
-
- return running;
}
-
-
diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h
index eb7e00c4..48f00a76 100644
--- a/src/displayapp/screens/Navigation.h
+++ b/src/displayapp/screens/Navigation.h
@@ -35,7 +35,7 @@ namespace Pinetime {
Navigation(DisplayApp* app, Pinetime::Controllers::NavigationService& nav);
~Navigation() override;
- bool Refresh() override;
+ void Refresh() override;
private:
lv_obj_t* imgFlag;
@@ -49,6 +49,8 @@ namespace Pinetime {
std::string narrative;
std::string manDist;
int progress;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index c061c146..4f475813 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -52,15 +52,18 @@ Notifications::Notifications(DisplayApp* app,
timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
}
}
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Notifications::~Notifications() {
+ lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
Controllers::MotorController::StopRinging();
lv_obj_clean(lv_scr_act());
}
-bool Notifications::Refresh() {
+void Notifications::Refresh() {
if (mode == Modes::Preview && timeoutLine != nullptr) {
auto tick = xTaskGetTickCount();
int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
@@ -70,7 +73,6 @@ bool Notifications::Refresh() {
timeoutLinePoints[1].x = pos;
lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
}
- return running && currentItem->IsRunning();
}
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
@@ -127,10 +129,6 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
alertNotificationService);
}
return true;
- case Pinetime::Applications::TouchEvents::LongTap: {
- // notificationManager.ToggleVibrations();
- return true;
- }
default:
return false;
}
@@ -150,7 +148,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
uint8_t notifNb,
Modes mode,
Pinetime::Controllers::AlertNotificationService& alertNotificationService)
- : notifNr {notifNr}, notifNb {notifNb}, mode {mode}, alertNotificationService {alertNotificationService} {
+ : mode {mode}, alertNotificationService {alertNotificationService} {
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));
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index a02d9b46..0b5271e7 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -24,7 +24,7 @@ namespace Pinetime {
Modes mode);
~Notifications() override;
- bool Refresh() override;
+ void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
class NotificationItem {
@@ -43,21 +43,13 @@ namespace Pinetime {
void OnCallButtonEvent(lv_obj_t*, lv_event_t event);
private:
- uint8_t notifNr = 0;
- uint8_t notifNb = 0;
- char pageText[4];
-
lv_obj_t* container1;
- lv_obj_t* t1;
- lv_obj_t* l1;
- lv_obj_t* l2;
lv_obj_t* bt_accept;
lv_obj_t* bt_mute;
lv_obj_t* bt_reject;
lv_obj_t* label_accept;
lv_obj_t* label_mute;
lv_obj_t* label_reject;
- lv_obj_t* bottomPlaceholder;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
bool running = true;
@@ -79,6 +71,8 @@ namespace Pinetime {
lv_obj_t* timeoutLine = nullptr;
uint32_t timeoutTickCountStart;
uint32_t timeoutTickCountEnd;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
index 79e0c3d3..26c2368b 100644
--- a/src/displayapp/screens/Paddle.cpp
+++ b/src/displayapp/screens/Paddle.cpp
@@ -27,13 +27,16 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_size(ball, ballSize, ballSize);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Paddle::~Paddle() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Paddle::Refresh() {
+void Paddle::Refresh() {
ballX += dx;
ballY += dy;
@@ -44,8 +47,8 @@ bool Paddle::Refresh() {
dy *= -1;
}
- // checks if it has touched the side (left side)
- if (ballX >= LV_VER_RES - ballSize - 1) {
+ // checks if it has touched the side (right side)
+ if (ballX >= LV_HOR_RES - ballSize - 1) {
dx *= -1;
}
@@ -65,7 +68,6 @@ bool Paddle::Refresh() {
}
}
lv_label_set_text_fmt(points, "%04d", score);
- return running;
}
bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h
index 30ab8f94..fc2131a1 100644
--- a/src/displayapp/screens/Paddle.h
+++ b/src/displayapp/screens/Paddle.h
@@ -16,7 +16,7 @@ namespace Pinetime {
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
~Paddle() override;
- bool Refresh() override;
+ void Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
bool OnTouchEvent(uint16_t x, uint16_t y) override;
@@ -40,6 +40,8 @@ namespace Pinetime {
lv_obj_t* paddle;
lv_obj_t* ball;
lv_obj_t* background;
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index 98fd976c..fa88d459 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -1,5 +1,5 @@
/*
- * This file is part of the Infinitime distribution (https://github.com/JF002/Infinitime).
+ * This file is part of the Infinitime distribution (https://github.com/InfiniTimeOrg/Infinitime).
* Copyright (c) 2021 Kieran Cawthray.
*
* This program is free software: you can redistribute it and/or modify
@@ -23,6 +23,7 @@
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
+#include <displayapp/Colors.h>
#include "BatteryIcon.h"
#include "BleIcon.h"
#include "NotificationIcon.h"
@@ -51,7 +52,8 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
notificatioManager {notificatioManager},
settingsController {settingsController},
motionController {motionController} {
- /* This sets the watchface number to return to after leaving the menu */
+
+ // This sets the watchface number to return to after leaving the menu
settingsController.SetClockFace(2);
displayedChar[0] = 0;
@@ -60,48 +62,45 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
displayedChar[3] = 0;
displayedChar[4] = 0;
- /* Create a 200px wide background rectangle */
+ //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, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(timebar, 200, 240);
lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
- /* Display the time */
+ // Display the time
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, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD1, "12");
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, lv_color_hex(0x008080));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_label_set_text(timeDD2, "34");
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, lv_color_hex(0x008080));
+ 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_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
- /* Create a 40px wide bar down the right side of the screen */
+ // Create a 40px wide bar down the right side of the screen
sidebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x008080));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(sidebar, 40, 240);
lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- /* Display icons */
+ // 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_hex(0x000000));
lv_label_set_text(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
-
- 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(0x000000));
- lv_obj_align(batteryPlug, 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));
@@ -111,7 +110,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40);
- /* Calendar icon */
+ // Calendar icon
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -148,7 +147,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(calendarCrossBar2, 8, 3);
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- /* Display date */
+ // 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_hex(0x000000));
lv_label_set_text(dateDayOfWeek, "THU");
@@ -184,7 +183,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
@@ -193,24 +192,34 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text(backgroundLabel, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+ Refresh();
}
PineTimeStyle::~PineTimeStyle() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool PineTimeStyle::Refresh() {
- batteryPercentRemaining = batteryController.PercentRemaining();
- if (batteryPercentRemaining.IsUpdated()) {
- auto batteryPercent = batteryPercentRemaining.Get();
- if (batteryController.IsCharging()) {
- auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent();
- lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging));
- lv_obj_realign(batteryPlug);
- lv_label_set_text(batteryIcon, "");
+void PineTimeStyle::SetBatteryIcon() {
+ auto batteryPercent = batteryPercentRemaining.Get();
+ lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+}
+
+void PineTimeStyle::Refresh() {
+ isCharging = batteryController.IsCharging();
+ if (isCharging.IsUpdated()) {
+ if (isCharging.Get()) {
+ lv_label_set_text(batteryIcon, Symbols::plug);
} else {
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
- lv_label_set_text(batteryPlug, "");
+ SetBatteryIcon();
+ }
+ }
+ if (!isCharging.Get()) {
+ batteryPercentRemaining = batteryController.PercentRemaining();
+ if (batteryPercentRemaining.IsUpdated()) {
+ SetBatteryIcon();
}
}
@@ -303,6 +312,4 @@ bool PineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
}
-
- return running;
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index f4cd28e4..ba473806 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -30,7 +30,7 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~PineTimeStyle() override;
- bool Refresh() override;
+ void Refresh() override;
private:
char displayedChar[5];
@@ -41,6 +41,7 @@ namespace Pinetime {
uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
+ DirtyValue<bool> isCharging {};
DirtyValue<bool> bleState {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
@@ -58,7 +59,6 @@ namespace Pinetime {
lv_obj_t* backgroundLabel;
lv_obj_t* batteryIcon;
lv_obj_t* bleIcon;
- lv_obj_t* batteryPlug;
lv_obj_t* calendarOuter;
lv_obj_t* calendarInner;
lv_obj_t* calendarBar1;
@@ -75,6 +75,10 @@ namespace Pinetime {
Controllers::NotificationManager& notificatioManager;
Controllers::Settings& settingsController;
Controllers::MotionController& motionController;
+
+ void SetBatteryIcon();
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/Screen.cpp b/src/displayapp/screens/Screen.cpp
index 1467df33..6ae5b7bb 100644
--- a/src/displayapp/screens/Screen.cpp
+++ b/src/displayapp/screens/Screen.cpp
@@ -1,2 +1,6 @@
#include "Screen.h"
-using namespace Pinetime::Applications::Screens; \ No newline at end of file
+using namespace Pinetime::Applications::Screens;
+
+void Screen::RefreshTaskCallback(lv_task_t* task) {
+ static_cast<Screen*>(task->user_data)->Refresh();
+}
diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h
index 420f2015..ce5741b2 100644
--- a/src/displayapp/screens/Screen.h
+++ b/src/displayapp/screens/Screen.h
@@ -2,6 +2,7 @@
#include <cstdint>
#include "../TouchEvents.h"
+#include <lvgl/lvgl.h>
namespace Pinetime {
namespace Applications {
@@ -38,25 +39,20 @@ namespace Pinetime {
};
class Screen {
+ private:
+ virtual void Refresh() {
+ }
+
public:
explicit Screen(DisplayApp* app) : app {app} {
}
virtual ~Screen() = default;
- /**
- * Most of the time, apps only react to events (touch events, for example).
- * In this case you don't need to do anything in this method.
- *
- * For example, InfiniPaint does nothing in Refresh().
- * But, if you want to update your display periodically, draw an animation...
- * you cannot do it in a touch event handler because these handlers are not
- * called if the user does not touch the screen.
- *
- * That's why Refresh() is there: update the display periodically.
- *
- * @return false if the app can be closed, true if it must continue to run
- **/
- virtual bool Refresh() = 0;
+ static void RefreshTaskCallback(lv_task_t* task);
+
+ bool IsRunning() const {
+ return running;
+ }
/** @return false if the button hasn't been handled by the app, true if it has been handled */
virtual bool OnButtonPushed() {
diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h
index 50d66328..a9d747aa 100644
--- a/src/displayapp/screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -30,11 +30,6 @@ namespace Pinetime {
lv_obj_clean(lv_scr_act());
}
- bool Refresh() override {
- running = current->Refresh();
- return running;
- }
-
bool OnTouchEvent(TouchEvents event) override {
if (mode == ScreenListModes::UpDown) {
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index d72e8333..c41163ab 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -47,20 +47,20 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
Steps::~Steps() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool Steps::Refresh() {
-
+void Steps::Refresh() {
stepsCount = motionController.NbSteps();
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
-
- return running;
}
diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h
index 9c135e26..d7cf31e1 100644
--- a/src/displayapp/screens/Steps.h
+++ b/src/displayapp/screens/Steps.h
@@ -15,24 +15,23 @@ namespace Pinetime {
namespace Screens {
class Steps : public Screen {
- public:
- Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings &settingsController);
- ~Steps() override;
+ public:
+ Steps(DisplayApp* app, Controllers::MotionController& motionController, Controllers::Settings& settingsController);
+ ~Steps() override;
- bool Refresh() override;
-
+ void Refresh() override;
- private:
+ private:
+ Controllers::MotionController& motionController;
+ Controllers::Settings& settingsController;
- Controllers::MotionController& motionController;
- Controllers::Settings& settingsController;
+ lv_obj_t* lSteps;
+ lv_obj_t* lStepsIcon;
+ lv_obj_t* stepsArc;
- lv_obj_t * lSteps;
- lv_obj_t * lStepsIcon;
- lv_obj_t * stepsArc;
-
- uint32_t stepsCount;
+ uint32_t stepsCount;
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index e3db6299..9b27a89d 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -48,7 +48,6 @@ static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) {
StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
: Screen(app),
systemTask {systemTask},
- running {true},
currentState {States::Init},
startTime {},
oldTimeElapsed {},
@@ -101,9 +100,12 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55);
lv_label_set_text(lapTwoText, "");
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
StopWatch::~StopWatch() {
+ lv_task_del(taskRefresh);
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
@@ -149,7 +151,7 @@ void StopWatch::pause() {
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
-bool StopWatch::Refresh() {
+void StopWatch::Refresh() {
if (currentState == States::Running) {
timeElapsed = calculateDelta(startTime, xTaskGetTickCount());
currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed));
@@ -157,7 +159,6 @@ bool StopWatch::Refresh() {
lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs);
lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths);
}
- return running;
}
void StopWatch::playPauseBtnEventHandler(lv_event_t event) {
@@ -196,8 +197,7 @@ void StopWatch::stopLapBtnEventHandler(lv_event_t event) {
bool StopWatch::OnButtonPushed() {
if (currentState == States::Running) {
pause();
- } else {
- running = false;
+ return true;
}
- return true;
+ return false;
}
diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h
index e132f158..25634e92 100644
--- a/src/displayapp/screens/StopWatch.h
+++ b/src/displayapp/screens/StopWatch.h
@@ -64,7 +64,7 @@ namespace Pinetime::Applications::Screens {
public:
StopWatch(DisplayApp* app, System::SystemTask& systemTask);
~StopWatch() override;
- bool Refresh() override;
+ void Refresh() override;
void playPauseBtnEventHandler(lv_event_t event);
void stopLapBtnEventHandler(lv_event_t event);
@@ -77,7 +77,6 @@ namespace Pinetime::Applications::Screens {
private:
Pinetime::System::SystemTask& systemTask;
TickType_t timeElapsed;
- bool running;
States currentState;
TickType_t startTime;
TickType_t oldTimeElapsed;
@@ -86,5 +85,7 @@ namespace Pinetime::Applications::Screens {
int lapNr = 0;
lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap;
lv_obj_t *lapOneText, *lapTwoText;
+
+ lv_task_t* taskRefresh;
};
}
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index ad758a8b..343b72bf 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -33,7 +33,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::Ble& bleController,
Pinetime::Drivers::WatchdogView& watchdog,
- Pinetime::Controllers::MotionController& motionController)
+ Pinetime::Controllers::MotionController& motionController,
+ Pinetime::Drivers::Cst816S& touchPanel)
: Screen(app),
dateTimeController {dateTimeController},
batteryController {batteryController},
@@ -41,6 +42,7 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
bleController {bleController},
watchdog {watchdog},
motionController{motionController},
+ touchPanel{touchPanel},
screens {app,
0,
{[this]() -> std::unique_ptr<Screen> {
@@ -65,13 +67,6 @@ SystemInfo::~SystemInfo() {
lv_obj_clean(lv_scr_act());
}
-bool SystemInfo::Refresh() {
- if (running) {
- screens.Refresh();
- }
- return running;
-}
-
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
@@ -148,7 +143,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
"#444444 Battery# %d%%/%03imV\n"
"#444444 Backlight# %s\n"
"#444444 Last reset# %s\n"
- "#444444 Accel.# %s\n",
+ "#444444 Accel.# %s\n"
+ "#444444 Touch.# %x.%x.%x\n",
dateTimeController.Day(),
static_cast<uint8_t>(dateTimeController.Month()),
dateTimeController.Year(),
@@ -163,7 +159,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
batteryController.Voltage(),
brightnessController.ToString(),
resetReason,
- ToString(motionController.DeviceType()));
+ ToString(motionController.DeviceType()),
+ touchPanel.GetChipId(),
+ touchPanel.GetVendorId(),
+ touchPanel.GetFwVersion());
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(1, 5, app, label);
}
@@ -271,7 +270,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"Public License v3\n"
"#444444 Source code#\n"
"#FFFF00 https://github.com/#\n"
- "#FFFF00 JF002/InfiniTime#");
+ "#FFFF00 InfiniTimeOrg/#\n"
+ "#FFFF00 InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(4, 5, app, label);
diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h
index a9ad652d..bfcc3aa4 100644
--- a/src/displayapp/screens/SystemInfo.h
+++ b/src/displayapp/screens/SystemInfo.h
@@ -28,9 +28,9 @@ namespace Pinetime {
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::Ble& bleController,
Pinetime::Drivers::WatchdogView& watchdog,
- Pinetime::Controllers::MotionController& motionController);
+ Pinetime::Controllers::MotionController& motionController,
+ Pinetime::Drivers::Cst816S& touchPanel);
~SystemInfo() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
private:
@@ -40,6 +40,7 @@ namespace Pinetime {
Pinetime::Controllers::Ble& bleController;
Pinetime::Drivers::WatchdogView& watchdog;
Pinetime::Controllers::MotionController& motionController;
+ Pinetime::Drivers::Cst816S& touchPanel;
ScreenList<5> screens;
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index 2ffbfbc2..1d4f0d0e 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -123,10 +123,6 @@ void Tile::UpdateScreen() {
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
-bool Tile::Refresh() {
- return running;
-}
-
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
if(obj != btnm1) return;
diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h
index 765a8def..83d3fdf5 100644
--- a/src/displayapp/screens/Tile.h
+++ b/src/displayapp/screens/Tile.h
@@ -30,7 +30,6 @@ namespace Pinetime {
~Tile() override;
- bool Refresh() override;
void UpdateScreen();
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index 99e979ba..ff3099d5 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -4,10 +4,8 @@
#include "Symbols.h"
#include "lvgl/lvgl.h"
-
using namespace Pinetime::Applications::Screens;
-
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
Timer* screen = static_cast<Timer*>(obj->user_data);
screen->OnButtonEvent(obj, event);
@@ -22,7 +20,7 @@ void Timer::createButtons() {
lv_obj_set_width(btnMinutesUp, 60);
txtMUp = lv_label_create(btnMinutesUp, nullptr);
lv_label_set_text(txtMUp, "+");
-
+
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesDown->user_data = this;
lv_obj_set_event_cb(btnMinutesDown, btnEventHandler);
@@ -31,7 +29,7 @@ void Timer::createButtons() {
lv_obj_set_width(btnMinutesDown, 60);
txtMDown = lv_label_create(btnMinutesDown, nullptr);
lv_label_set_text(txtMDown, "-");
-
+
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsUp->user_data = this;
lv_obj_set_event_cb(btnSecondsUp, btnEventHandler);
@@ -40,7 +38,7 @@ void Timer::createButtons() {
lv_obj_set_width(btnSecondsUp, 60);
txtSUp = lv_label_create(btnSecondsUp, nullptr);
lv_label_set_text(txtSUp, "+");
-
+
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsDown->user_data = this;
lv_obj_set_event_cb(btnSecondsDown, btnEventHandler);
@@ -49,24 +47,20 @@ void Timer::createButtons() {
lv_obj_set_width(btnSecondsDown, 60);
txtSDown = lv_label_create(btnSecondsDown, nullptr);
lv_label_set_text(txtSDown, "-");
-
}
-
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
- : Screen(app),
- running{true},
- timerController{timerController} {
-
+ : Screen(app), running {true}, timerController {timerController} {
+
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);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
-
+
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
-
+
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
lv_obj_set_event_cb(btnPlayPause, btnEventHandler);
@@ -79,20 +73,20 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
lv_label_set_text(txtPlayPause, Symbols::play);
createButtons();
}
-
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
Timer::~Timer() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
-
}
-bool Timer::Refresh() {
+void Timer::Refresh() {
if (timerController.IsRunning()) {
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60);
}
- return running;
}
void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
@@ -105,11 +99,11 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet = seconds % 60;
timerController.StopTimer();
createButtons();
-
+
} else if (secondsToSet + minutesToSet > 0) {
lv_label_set_text(txtPlayPause, Symbols::pause);
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
-
+
lv_obj_del(btnSecondsDown);
btnSecondsDown = nullptr;
lv_obj_del(btnSecondsUp);
@@ -118,7 +112,6 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
btnMinutesDown = nullptr;
lv_obj_del(btnMinutesUp);
btnMinutesUp = nullptr;
-
}
} else {
if (!timerController.IsRunning()) {
@@ -129,7 +122,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
minutesToSet++;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+
} else if (obj == btnMinutesDown) {
if (minutesToSet == 0) {
minutesToSet = 59;
@@ -137,7 +130,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
minutesToSet--;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+
} else if (obj == btnSecondsUp) {
if (secondsToSet >= 59) {
secondsToSet = 0;
@@ -145,7 +138,7 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet++;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
+
} else if (obj == btnSecondsDown) {
if (secondsToSet == 0) {
secondsToSet = 59;
@@ -153,21 +146,16 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
secondsToSet--;
}
lv_label_set_text_fmt(time, "%02d:%02d", minutesToSet, secondsToSet);
-
}
}
-
}
-
}
-
}
-
void Timer::setDone() {
lv_label_set_text(time, "00:00");
lv_label_set_text(txtPlayPause, Symbols::play);
secondsToSet = 0;
minutesToSet = 0;
createButtons();
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 0d66f2d4..d0fc8ed1 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -8,35 +8,32 @@
#include "components/timer/TimerController.h"
namespace Pinetime::Applications::Screens {
-
-
+
class Timer : public Screen {
public:
-
- enum class Modes {
- Normal, Done
- };
-
+ enum class Modes { Normal, Done };
+
Timer(DisplayApp* app, Controllers::TimerController& timerController);
-
+
~Timer() override;
-
- bool Refresh() override;
-
+
+ void Refresh() override;
+
void setDone();
-
+
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
-
+
private:
-
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 *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
+ *txtMDown, *txtSUp, *txtSDown;
+
+ lv_task_t* taskRefresh;
};
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp
index eb268077..4201d501 100644
--- a/src/displayapp/screens/Twos.cpp
+++ b/src/displayapp/screens/Twos.cpp
@@ -102,10 +102,6 @@ Twos::~Twos() {
lv_obj_clean(lv_scr_act());
}
-bool Twos::Refresh() {
- return running;
-}
-
bool Twos::placeNewTile() {
std::vector<std::pair<int, int>> availableCells;
for (int row = 0; row < 4; row++) {
@@ -295,4 +291,4 @@ void Twos::updateGridDisplay(Tile grid[][4]) {
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h
index 3367618f..6d85cff6 100644
--- a/src/displayapp/screens/Twos.h
+++ b/src/displayapp/screens/Twos.h
@@ -14,7 +14,6 @@ namespace Pinetime {
public:
Twos(DisplayApp* app);
~Twos() override;
- bool Refresh() override;
bool OnTouchEvent(TouchEvents event) override;
@@ -36,4 +35,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 1410fc28..53e7faf7 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -68,6 +68,7 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text(batteryIcon, Symbols::batteryHalf);
lv_obj_align(batteryIcon, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+ lv_obj_set_auto_realign(batteryIcon, true);
notificationIcon = lv_label_create(lv_scr_act(), NULL);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
@@ -118,10 +119,13 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false);
lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace);
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
UpdateClock();
}
WatchFaceAnalog::~WatchFaceAnalog() {
+ lv_task_del(taskRefresh);
+
lv_style_reset(&hour_line_style);
lv_style_reset(&hour_line_style_trace);
lv_style_reset(&minute_line_style);
@@ -173,11 +177,31 @@ void WatchFaceAnalog::UpdateClock() {
}
}
-bool WatchFaceAnalog::Refresh() {
- batteryPercentRemaining = batteryController.PercentRemaining();
- if (batteryPercentRemaining.IsUpdated()) {
- auto batteryPercent = batteryPercentRemaining.Get();
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+void WatchFaceAnalog::SetBatteryIcon() {
+ auto batteryPercent = batteryPercentRemaining.Get();
+ if (batteryPercent == 100) {
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ } 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));
+}
+
+void WatchFaceAnalog::Refresh() {
+ isCharging = batteryController.IsCharging();
+ if (isCharging.IsUpdated()) {
+ if (isCharging.Get()) {
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
+ lv_label_set_text(batteryIcon, Symbols::plug);
+ } else {
+ SetBatteryIcon();
+ }
+ }
+ if (!isCharging.Get()) {
+ batteryPercentRemaining = batteryController.PercentRemaining();
+ if (batteryPercentRemaining.IsUpdated()) {
+ SetBatteryIcon();
+ }
}
notificationState = notificationManager.AreNewNotificationsAvailable();
@@ -203,6 +227,4 @@ bool WatchFaceAnalog::Refresh() {
currentDay = day;
}
}
-
- return true;
}
diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h
index 5d8c6a24..001414a6 100644
--- a/src/displayapp/screens/WatchFaceAnalog.h
+++ b/src/displayapp/screens/WatchFaceAnalog.h
@@ -32,7 +32,7 @@ namespace Pinetime {
~WatchFaceAnalog() override;
- bool Refresh() override;
+ void Refresh() override;
private:
uint8_t sHour, sMinute, sSecond;
@@ -49,6 +49,7 @@ namespace Pinetime {
uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {0};
+ DirtyValue<bool> isCharging {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime;
DirtyValue<bool> notificationState {false};
@@ -81,6 +82,9 @@ namespace Pinetime {
Controllers::Settings& settingsController;
void UpdateClock();
+ void SetBatteryIcon();
+
+ lv_task_t* taskRefresh;
};
}
}
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 2b902b3b..2ecab609 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -91,19 +91,31 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
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_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);
+ Refresh();
}
WatchFaceDigital::~WatchFaceDigital() {
+ lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool WatchFaceDigital::Refresh() {
+void WatchFaceDigital::Refresh() {
+ powerPresent = batteryController.IsPowerPresent();
+ if (powerPresent.IsUpdated()) {
+ lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
+ }
+
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated()) {
auto batteryPercent = batteryPercentRemaining.Get();
+ if (batteryPercent == 100) {
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
+ } 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));
- auto isCharging = batteryController.IsCharging() or batteryController.IsPowerPresent();
- lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging));
}
bleState = bleController.IsConnected();
@@ -219,6 +231,4 @@ bool WatchFaceDigital::Refresh() {
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);
}
-
- return running;
}
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index 6a6e1ac6..e27545f3 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -33,7 +33,7 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~WatchFaceDigital() override;
- bool Refresh() override;
+ void Refresh() override;
private:
char displayedChar[5] {};
@@ -44,6 +44,7 @@ namespace Pinetime {
uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
+ DirtyValue<bool> powerPresent {};
DirtyValue<bool> bleState {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
@@ -72,6 +73,8 @@ namespace Pinetime {
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 8190f9d7..691c40c8 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -88,7 +88,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
btn3_lvl = lv_label_create(btn3, nullptr);
lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
- if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::ON) {
+ if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) {
lv_obj_add_state(btn3, LV_STATE_CHECKED);
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
} else {
@@ -142,11 +142,11 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
} else if (object == btn3 && event == LV_EVENT_VALUE_CHANGED) {
if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) {
- settingsController.SetVibrationStatus(Controllers::Settings::Vibration::ON);
+ settingsController.SetNotificationStatus(Controllers::Settings::Notification::ON);
motorController.RunForDuration(35);
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
} else {
- settingsController.SetVibrationStatus(Controllers::Settings::Vibration::OFF);
+ settingsController.SetNotificationStatus(Controllers::Settings::Notification::OFF);
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
}
@@ -156,7 +156,3 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up);
}
}
-
-bool QuickSettings::Refresh() {
- return running;
-}
diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h
index 2eefe1a7..c036fa5c 100644
--- a/src/displayapp/screens/settings/QuickSettings.h
+++ b/src/displayapp/screens/settings/QuickSettings.h
@@ -27,8 +27,6 @@ namespace Pinetime {
~QuickSettings() override;
- bool Refresh() override;
-
void OnButtonEvent(lv_obj_t* object, lv_event_t event);
void UpdateScreen();
diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp
index aaf6a9f0..d8d6c767 100644
--- a/src/displayapp/screens/settings/SettingDisplay.cpp
+++ b/src/displayapp/screens/settings/SettingDisplay.cpp
@@ -80,10 +80,6 @@ SettingDisplay::~SettingDisplay() {
settingsController.SaveSettings();
}
-bool SettingDisplay::Refresh() {
- return running;
-}
-
void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
for (int i = 0; i < optionsTotal; i++) {
diff --git a/src/displayapp/screens/settings/SettingDisplay.h b/src/displayapp/screens/settings/SettingDisplay.h
index b8ed87ec..51b23aca 100644
--- a/src/displayapp/screens/settings/SettingDisplay.h
+++ b/src/displayapp/screens/settings/SettingDisplay.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingDisplay() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
new file mode 100644
index 00000000..c9af19b6
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
@@ -0,0 +1,318 @@
+#include "SettingPineTimeStyle.h"
+#include <lvgl/lvgl.h>
+#include <displayapp/Colors.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void event_handler(lv_obj_t* obj, lv_event_t event) {
+ SettingPineTimeStyle* screen = static_cast<SettingPineTimeStyle*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
+SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), settingsController {settingsController} {
+ 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()));
+ lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(timebar, 200, 240);
+ lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
+
+ // Display the time
+
+ 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, "12");
+ 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, "34");
+ 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, "A\nM");
+ lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
+
+ // Create a 40px wide bar down the right side of the screen
+
+ sidebar = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
+ lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(sidebar, 40, 240);
+ lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
+
+ // 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_hex(0x000000));
+ lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
+
+ 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, Symbols::bluetooth);
+ lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
+
+ // Calendar icon
+
+ calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarOuter, 34, 34);
+ lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
+
+ calendarInner = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
+ lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarInner, 27, 27);
+ lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
+
+ calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarBar1, 3, 12);
+ lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
+
+ calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarBar2, 3, 12);
+ lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
+
+ calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarCrossBar1, 8, 3);
+ lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+
+ calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
+ lv_obj_set_size(calendarCrossBar2, 8, 3);
+ lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+
+ // 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_hex(0x000000));
+ lv_label_set_text(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_hex(0x000000));
+ lv_label_set_text(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_hex(0x000000));
+ lv_label_set_text(dateMonth, "MAR");
+ lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
+
+ // Step count gauge
+ needle_colors[0] = LV_COLOR_WHITE;
+ stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
+ lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
+ lv_obj_set_size(stepGauge, 40, 40);
+ lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_gauge_set_scale(stepGauge, 360, 11, 0);
+ lv_gauge_set_angle_offset(stepGauge, 180);
+ lv_gauge_set_critical_value(stepGauge, (100));
+ lv_gauge_set_range(stepGauge, 0, (100));
+ lv_gauge_set_value(stepGauge, 0, 0);
+
+ lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
+ lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
+ lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
+ lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
+
+ 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, "");
+
+ btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextTime->user_data = this;
+ lv_obj_set_size(btnNextTime, 60, 60);
+ lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
+ lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextTime, event_handler);
+
+ btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevTime->user_data = this;
+ lv_obj_set_size(btnPrevTime, 60, 60);
+ lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
+ lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevTime, event_handler);
+
+ btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBar->user_data = this;
+ lv_obj_set_size(btnNextBar, 60, 60);
+ lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
+ lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBar, event_handler);
+
+ btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBar->user_data = this;
+ lv_obj_set_size(btnPrevBar, 60, 60);
+ lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
+ lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBar, event_handler);
+
+ btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBG->user_data = this;
+ lv_obj_set_size(btnNextBG, 60, 60);
+ lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
+ lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBG, event_handler);
+
+ btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBG->user_data = this;
+ lv_obj_set_size(btnPrevBG, 60, 60);
+ lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
+ lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBG, event_handler);
+
+ btnReset = lv_btn_create(lv_scr_act(), nullptr);
+ btnReset->user_data = this;
+ lv_obj_set_size(btnReset, 60, 60);
+ lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
+ lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
+ lv_obj_set_event_cb(btnReset, event_handler);
+
+ btnRandom = lv_btn_create(lv_scr_act(), nullptr);
+ btnRandom->user_data = this;
+ lv_obj_set_size(btnRandom, 60, 60);
+ lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
+ lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
+ lv_obj_set_event_cb(btnRandom, event_handler);
+}
+
+SettingPineTimeStyle::~SettingPineTimeStyle() {
+ lv_obj_clean(lv_scr_act());
+ settingsController.SaveSettings();
+}
+
+void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ auto valueTime = settingsController.GetPTSColorTime();
+ auto valueBar = settingsController.GetPTSColorBar();
+ auto valueBG = settingsController.GetPTSColorBG();
+
+ if (event == LV_EVENT_CLICKED) {
+ if (object == btnNextTime) {
+ valueTime = GetNext(valueTime);
+
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnPrevTime) {
+ valueTime = GetPrevious(valueTime);
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnNextBar) {
+ valueBar = GetNext(valueBar);
+ if(valueBar == Controllers::Settings::Colors::Black)
+ valueBar = GetNext(valueBar);
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnPrevBar) {
+ valueBar = GetPrevious(valueBar);
+ if(valueBar == Controllers::Settings::Colors::Black)
+ valueBar = GetPrevious(valueBar);
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnNextBG) {
+ valueBG = GetNext(valueBG);
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnPrevBG) {
+ valueBG = GetPrevious(valueBG);
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnReset) {
+ settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
+ }
+ if (object == btnRandom) {
+ uint8_t randTime = rand() % 17;
+ uint8_t randBar = rand() % 17;
+ uint8_t randBG = rand() % 17;
+ // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values.
+ if (randTime == randBG) {
+ randBG += 1;
+ }
+ if (randBar == 3) {
+ randBar -= 1;
+ }
+ settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
+ settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
+ settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
+ }
+ }
+}
+
+Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors nextColor;
+ if (colorAsInt < 16) {
+ nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
+ } else {
+ nextColor = static_cast<Controllers::Settings::Colors>(0);
+ }
+ return nextColor;
+}
+
+Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors prevColor;
+
+ if (colorAsInt > 0) {
+ prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
+ } else {
+ prevColor = static_cast<Controllers::Settings::Colors>(16);
+ }
+ return prevColor;
+}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h
new file mode 100644
index 00000000..397bd86d
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingPineTimeStyle : public Screen{
+ public:
+ SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
+ ~SettingPineTimeStyle() override;
+
+ void UpdateSelected(lv_obj_t *object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+
+ Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
+ Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
+
+ lv_obj_t * btnNextTime;
+ lv_obj_t * btnPrevTime;
+ lv_obj_t * btnNextBar;
+ lv_obj_t * btnPrevBar;
+ lv_obj_t * btnNextBG;
+ lv_obj_t * btnPrevBG;
+ lv_obj_t * btnReset;
+ lv_obj_t * btnRandom;
+ lv_obj_t * timebar;
+ lv_obj_t * sidebar;
+ lv_obj_t * timeDD1;
+ lv_obj_t * timeDD2;
+ lv_obj_t * timeAMPM;
+ lv_obj_t * dateDayOfWeek;
+ lv_obj_t * dateDay;
+ lv_obj_t * dateMonth;
+ lv_obj_t * backgroundLabel;
+ lv_obj_t * batteryIcon;
+ lv_obj_t * bleIcon;
+ lv_obj_t * calendarOuter;
+ lv_obj_t * calendarInner;
+ lv_obj_t * calendarBar1;
+ lv_obj_t * calendarBar2;
+ lv_obj_t * calendarCrossBar1;
+ lv_obj_t * calendarCrossBar2;
+ lv_obj_t * stepGauge;
+ lv_color_t needle_colors[1];
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingSetDate.cpp b/src/displayapp/screens/settings/SettingSetDate.cpp
new file mode 100644
index 00000000..ba3413ef
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingSetDate.cpp
@@ -0,0 +1,198 @@
+#include "SettingSetDate.h"
+#include <lvgl/lvgl.h>
+#include <hal/nrf_rtc.h>
+#include <nrf_log.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ constexpr int16_t POS_X_DAY = -72;
+ constexpr int16_t POS_X_MONTH = 0;
+ constexpr int16_t POS_X_YEAR = 72;
+ constexpr int16_t POS_Y_PLUS = -50;
+ constexpr int16_t POS_Y_TEXT = -6;
+ constexpr int16_t POS_Y_MINUS = 40;
+
+ void event_handler(lv_obj_t * obj, lv_event_t event) {
+ auto* screen = static_cast<SettingSetDate *>(obj->user_data);
+ screen->HandleButtonPress(obj, event);
+ }
+}
+
+SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) :
+ Screen(app),
+ dateTimeController {dateTimeController} {
+ lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(title, "Set current date");
+ 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::clock);
+ lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
+
+ dayValue = static_cast<int>(dateTimeController.Day());
+ lblDay = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_fmt(lblDay, "%d", dayValue);
+ lv_label_set_align(lblDay, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblDay, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT);
+ lv_obj_set_auto_realign(lblDay, true);
+
+ monthValue = static_cast<int>(dateTimeController.Month());
+ lblMonth = lv_label_create(lv_scr_act(), nullptr);
+ UpdateMonthLabel();
+ lv_label_set_align(lblMonth, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblMonth, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_TEXT);
+ lv_obj_set_auto_realign(lblMonth, true);
+
+ yearValue = static_cast<int>(dateTimeController.Year());
+ if (yearValue < 2021)
+ yearValue = 2021;
+ lblYear = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_fmt(lblYear, "%d", yearValue);
+ lv_label_set_align(lblYear, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(lblYear, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_TEXT);
+ lv_obj_set_auto_realign(lblYear, true);
+
+ btnDayPlus = lv_btn_create(lv_scr_act(), nullptr);
+ btnDayPlus->user_data = this;
+ lv_obj_set_size(btnDayPlus, 50, 40);
+ lv_obj_align(btnDayPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_PLUS);
+ lv_obj_set_style_local_value_str(btnDayPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
+ lv_obj_set_event_cb(btnDayPlus, event_handler);
+
+ btnDayMinus = lv_btn_create(lv_scr_act(), nullptr);
+ btnDayMinus->user_data = this;
+ lv_obj_set_size(btnDayMinus, 50, 40);
+ lv_obj_align(btnDayMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_MINUS);
+ lv_obj_set_style_local_value_str(btnDayMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
+ lv_obj_set_event_cb(btnDayMinus, event_handler);
+
+ btnMonthPlus = lv_btn_create(lv_scr_act(), nullptr);
+ btnMonthPlus->user_data = this;
+ lv_obj_set_size(btnMonthPlus, 50, 40);
+ lv_obj_align(btnMonthPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_PLUS);
+ lv_obj_set_style_local_value_str(btnMonthPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
+ lv_obj_set_event_cb(btnMonthPlus, event_handler);
+
+ btnMonthMinus = lv_btn_create(lv_scr_act(), nullptr);
+ btnMonthMinus->user_data = this;
+ lv_obj_set_size(btnMonthMinus, 50, 40);
+ lv_obj_align(btnMonthMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_MINUS);
+ lv_obj_set_style_local_value_str(btnMonthMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
+ lv_obj_set_event_cb(btnMonthMinus, event_handler);
+
+ btnYearPlus = lv_btn_create(lv_scr_act(), nullptr);
+ btnYearPlus->user_data = this;
+ lv_obj_set_size(btnYearPlus, 50, 40);
+ lv_obj_align(btnYearPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_PLUS);
+ lv_obj_set_style_local_value_str(btnYearPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
+ lv_obj_set_event_cb(btnYearPlus, event_handler);
+
+ btnYearMinus = lv_btn_create(lv_scr_act(), nullptr);
+ btnYearMinus->user_data = this;
+ lv_obj_set_size(btnYearMinus, 50, 40);
+ lv_obj_align(btnYearMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_MINUS);
+ lv_obj_set_style_local_value_str(btnYearMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
+ lv_obj_set_event_cb(btnYearMinus, event_handler);
+
+ btnSetTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnSetTime->user_data = this;
+ lv_obj_set_size(btnSetTime, 120, 48);
+ 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);
+}
+
+SettingSetDate::~SettingSetDate() {
+ lv_obj_clean(lv_scr_act());
+}
+
+void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
+ if (event != LV_EVENT_CLICKED)
+ return;
+
+ if (object == btnDayPlus) {
+ dayValue++;
+ if (dayValue > MaximumDayOfMonth())
+ dayValue = 1;
+ lv_label_set_text_fmt(lblDay, "%d", dayValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ } else if (object == btnDayMinus) {
+ dayValue--;
+ if (dayValue < 1)
+ dayValue = MaximumDayOfMonth();
+ lv_label_set_text_fmt(lblDay, "%d", dayValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ } else if (object == btnMonthPlus) {
+ monthValue++;
+ if (monthValue > 12)
+ monthValue = 1;
+ UpdateMonthLabel();
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ CheckDay();
+ } else if (object == btnMonthMinus) {
+ monthValue--;
+ if (monthValue < 1)
+ monthValue = 12;
+ UpdateMonthLabel();
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ CheckDay();
+ } else if (object == btnYearPlus) {
+ yearValue++;
+ lv_label_set_text_fmt(lblYear, "%d", yearValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ CheckDay();
+ } else if (object == btnYearMinus) {
+ yearValue--;
+ lv_label_set_text_fmt(lblYear, "%d", yearValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ CheckDay();
+ } else if (object == btnSetTime) {
+ NRF_LOG_INFO("Setting date (manually) to %04d-%02d-%02d", yearValue, monthValue, dayValue);
+ dateTimeController.SetTime(static_cast<uint16_t>(yearValue),
+ static_cast<uint8_t>(monthValue),
+ static_cast<uint8_t>(dayValue),
+ 0,
+ dateTimeController.Hours(),
+ dateTimeController.Minutes(),
+ dateTimeController.Seconds(),
+ nrf_rtc_counter_get(portNRF_RTC_REG));
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
+ }
+}
+
+int SettingSetDate::MaximumDayOfMonth() const {
+ switch (monthValue) {
+ case 2:
+ if ((((yearValue % 4) == 0) && ((yearValue % 100) != 0)) || ((yearValue % 400) == 0))
+ return 29;
+ return 28;
+ case 4:
+ case 6:
+ case 9:
+ case 11:
+ return 30;
+ default:
+ return 31;
+ }
+}
+
+void SettingSetDate::CheckDay() {
+ int maxDay = MaximumDayOfMonth();
+ if (dayValue > maxDay) {
+ dayValue = maxDay;
+ lv_label_set_text_fmt(lblDay, "%d", dayValue);
+ lv_obj_align(lblDay, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT);
+ }
+}
+
+void SettingSetDate::UpdateMonthLabel() {
+ lv_label_set_text_static(
+ lblMonth, Pinetime::Controllers::DateTime::MonthShortToStringLow(static_cast<Pinetime::Controllers::DateTime::Months>(monthValue)));
+}
diff --git a/src/displayapp/screens/settings/SettingSetDate.h b/src/displayapp/screens/settings/SettingSetDate.h
new file mode 100644
index 00000000..477337ff
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingSetDate.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/datetime/DateTimeController.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+ namespace Applications {
+ namespace Screens {
+ class SettingSetDate : public Screen{
+ public:
+ SettingSetDate(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController);
+ ~SettingSetDate() override;
+
+ void HandleButtonPress(lv_obj_t *object, lv_event_t event);
+
+ private:
+ Controllers::DateTime& dateTimeController;
+
+ int dayValue;
+ int monthValue;
+ int yearValue;
+ lv_obj_t * lblDay;
+ lv_obj_t * lblMonth;
+ lv_obj_t * lblYear;
+ lv_obj_t * btnDayPlus;
+ lv_obj_t * btnDayMinus;
+ lv_obj_t * btnMonthPlus;
+ lv_obj_t * btnMonthMinus;
+ lv_obj_t * btnYearPlus;
+ lv_obj_t * btnYearMinus;
+ lv_obj_t * btnSetTime;
+
+ int MaximumDayOfMonth() const;
+ void CheckDay();
+ void UpdateMonthLabel();
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp
new file mode 100644
index 00000000..194bf5eb
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingSetTime.cpp
@@ -0,0 +1,154 @@
+#include "SettingSetTime.h"
+#include <lvgl/lvgl.h>
+#include <hal/nrf_rtc.h>
+#include <nrf_log.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ constexpr int16_t POS_X_HOURS = -72;
+ constexpr int16_t POS_X_MINUTES = 0;
+ constexpr int16_t POS_X_SECONDS = 72;
+ constexpr int16_t POS_Y_PLUS = -50;
+ constexpr int16_t POS_Y_TEXT = -6;
+ 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);
+ 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);
+ 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_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);
+
+ hoursValue = static_cast<int>(dateTimeController.Hours());
+ lblHours = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ lv_label_set_align(lblHours, LV_LABEL_ALIGN_CENTER);
+ 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_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);
+ lv_obj_align(lblColon1, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON);
+
+ minutesValue = static_cast<int>(dateTimeController.Minutes());
+ lblMinutes = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
+ lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
+ lv_label_set_align(lblMinutes, LV_LABEL_ALIGN_CENTER);
+ 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_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_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);
+
+ btnHoursPlus = lv_btn_create(lv_scr_act(), nullptr);
+ btnHoursPlus->user_data = this;
+ lv_obj_set_size(btnHoursPlus, 50, 40);
+ lv_obj_align(btnHoursPlus, lv_scr_act(), LV_ALIGN_CENTER, -72, -50);
+ lv_obj_set_style_local_value_str(btnHoursPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
+ lv_obj_set_event_cb(btnHoursPlus, event_handler);
+
+ btnHoursMinus = lv_btn_create(lv_scr_act(), nullptr);
+ btnHoursMinus->user_data = this;
+ lv_obj_set_size(btnHoursMinus, 50, 40);
+ lv_obj_align(btnHoursMinus, lv_scr_act(), LV_ALIGN_CENTER, -72, 40);
+ lv_obj_set_style_local_value_str(btnHoursMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
+ lv_obj_set_event_cb(btnHoursMinus, event_handler);
+
+ btnMinutesPlus = lv_btn_create(lv_scr_act(), nullptr);
+ btnMinutesPlus->user_data = this;
+ lv_obj_set_size(btnMinutesPlus, 50, 40);
+ lv_obj_align(btnMinutesPlus, lv_scr_act(), LV_ALIGN_CENTER, 0, -50);
+ lv_obj_set_style_local_value_str(btnMinutesPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+");
+ lv_obj_set_event_cb(btnMinutesPlus, event_handler);
+
+ btnMinutesMinus = lv_btn_create(lv_scr_act(), nullptr);
+ btnMinutesMinus->user_data = this;
+ lv_obj_set_size(btnMinutesMinus, 50, 40);
+ lv_obj_align(btnMinutesMinus, lv_scr_act(), LV_ALIGN_CENTER, 0, 40);
+ lv_obj_set_style_local_value_str(btnMinutesMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-");
+ lv_obj_set_event_cb(btnMinutesMinus, event_handler);
+
+ btnSetTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnSetTime->user_data = this;
+ lv_obj_set_size(btnSetTime, 120, 48);
+ 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);
+}
+
+SettingSetTime::~SettingSetTime() {
+ lv_obj_clean(lv_scr_act());
+}
+
+void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) {
+ if (event != LV_EVENT_CLICKED)
+ return;
+
+ if (object == btnHoursPlus) {
+ hoursValue++;
+ if (hoursValue > 23)
+ hoursValue = 0;
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ } else if (object == btnHoursMinus) {
+ hoursValue--;
+ if (hoursValue < 0)
+ hoursValue = 23;
+ lv_label_set_text_fmt(lblHours, "%02d", hoursValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ } else if (object == btnMinutesPlus) {
+ minutesValue++;
+ 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)
+ minutesValue = 59;
+ lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue);
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED);
+ } else if (object == btnSetTime) {
+ NRF_LOG_INFO("Setting time (manually) to %02d:%02d:00", hoursValue, minutesValue);
+ dateTimeController.SetTime(dateTimeController.Year(),
+ static_cast<uint8_t>(dateTimeController.Month()),
+ dateTimeController.Day(),
+ static_cast<uint8_t>(dateTimeController.DayOfWeek()),
+ static_cast<uint8_t>(hoursValue),
+ static_cast<uint8_t>(minutesValue),
+ 0,
+ nrf_rtc_counter_get(portNRF_RTC_REG));
+ lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED);
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingSetTime.h b/src/displayapp/screens/settings/SettingSetTime.h
new file mode 100644
index 00000000..8ba41eae
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingSetTime.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/datetime/DateTimeController.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;
+
+ void HandleButtonPress(lv_obj_t *object, lv_event_t event);
+
+ private:
+ Controllers::DateTime& dateTimeController;
+
+ 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;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp
index faa843e6..bec7972b 100644
--- a/src/displayapp/screens/settings/SettingSteps.cpp
+++ b/src/displayapp/screens/settings/SettingSteps.cpp
@@ -70,11 +70,6 @@ SettingSteps::~SettingSteps() {
settingsController.SaveSettings();
}
-bool SettingSteps::Refresh() {
- return running;
-}
-
-
void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
uint32_t value = settingsController.GetStepsGoal();
if(object == btnPlus && (event == LV_EVENT_PRESSED)) {
@@ -95,4 +90,4 @@ void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) {
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/settings/SettingSteps.h b/src/displayapp/screens/settings/SettingSteps.h
index 0a4c2056..5fc05dee 100644
--- a/src/displayapp/screens/settings/SettingSteps.h
+++ b/src/displayapp/screens/settings/SettingSteps.h
@@ -10,22 +10,19 @@ namespace Pinetime {
namespace Applications {
namespace Screens {
- class SettingSteps : public Screen{
- public:
- SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
- ~SettingSteps() override;
+ class SettingSteps : public Screen {
+ public:
+ SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingSteps() override;
- bool Refresh() override;
- void UpdateSelected(lv_obj_t *object, lv_event_t event);
-
- private:
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
- Controllers::Settings& settingsController;
+ private:
+ Controllers::Settings& settingsController;
- lv_obj_t * stepValue;
- lv_obj_t * btnPlus;
- lv_obj_t * btnMinus;
-
+ lv_obj_t* stepValue;
+ lv_obj_t* btnPlus;
+ lv_obj_t* btnMinus;
};
}
}
diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp
index 031a2a72..c99e3a0e 100644
--- a/src/displayapp/screens/settings/SettingTimeFormat.cpp
+++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp
@@ -64,10 +64,6 @@ SettingTimeFormat::~SettingTimeFormat() {
settingsController.SaveSettings();
}
-bool SettingTimeFormat::Refresh() {
- return running;
-}
-
void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
for (int i = 0; i < optionsTotal; i++) {
@@ -86,4 +82,4 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) {
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/settings/SettingTimeFormat.h b/src/displayapp/screens/settings/SettingTimeFormat.h
index 9203b45b..eac4bdc9 100644
--- a/src/displayapp/screens/settings/SettingTimeFormat.h
+++ b/src/displayapp/screens/settings/SettingTimeFormat.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingTimeFormat() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp
index cce9a60d..d999004b 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.cpp
+++ b/src/displayapp/screens/settings/SettingWakeUp.cpp
@@ -72,10 +72,6 @@ SettingWakeUp::~SettingWakeUp() {
settingsController.SaveSettings();
}
-bool SettingWakeUp::Refresh() {
- return running;
-}
-
void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) {
using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode;
if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) {
diff --git a/src/displayapp/screens/settings/SettingWakeUp.h b/src/displayapp/screens/settings/SettingWakeUp.h
index 248dd9ac..b9a31dc9 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.h
+++ b/src/displayapp/screens/settings/SettingWakeUp.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWakeUp() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index 02b90816..cdec704c 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -75,10 +75,6 @@ SettingWatchFace::~SettingWatchFace() {
settingsController.SaveSettings();
}
-bool SettingWatchFace::Refresh() {
- return running;
-}
-
void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_VALUE_CHANGED) {
for (uint8_t i = 0; i < optionsTotal; i++) {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index 1930a228..d4a96c6d 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -15,7 +15,6 @@ namespace Pinetime {
SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~SettingWatchFace() override;
- bool Refresh() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 0ab21377..1daf311e 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -18,6 +18,9 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
},
[this]() -> std::unique_ptr<Screen> {
return CreateScreen2();
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen3();
}},
Screens::ScreenListModes::UpDown} {
}
@@ -26,13 +29,6 @@ Settings::~Settings() {
lv_obj_clean(lv_scr_act());
}
-bool Settings::Refresh() {
-
- if (running)
- running = screens.Refresh();
- return running;
-}
-
bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
@@ -46,17 +42,29 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::home, "Watch face", Apps::SettingWatchFace},
}};
- return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
+ return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
std::array<Screens::List::Applications, 4> applications {{
{Symbols::shoe, "Steps", Apps::SettingSteps},
- {Symbols::batteryHalf, "Battery", Apps::BatteryInfo},
+ {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);
+}
+
+std::unique_ptr<Screen> Settings::CreateScreen3() {
+
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
{Symbols::list, "About", Apps::SysInfo},
+ {Symbols::none, "None", Apps::None},
}};
- return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
+ return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 711a6be6..6c54cdeb 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -14,17 +14,16 @@ namespace Pinetime {
Settings(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
~Settings() override;
- bool Refresh() override;
-
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private:
Controllers::Settings& settingsController;
- ScreenList<2> screens;
+ ScreenList<3> screens;
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
+ std::unique_ptr<Screen> CreateScreen3();
};
}
}