summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorMax Friedrich <minacode@users.noreply.github.com>2022-04-19 00:40:29 +0200
committerGitHub <noreply@github.com>2022-04-19 00:40:29 +0200
commitf84a0a38972e6b6d9a537dc9de2e2c416312f882 (patch)
tree3ce9dab83f8b6af8e9df1c8d3aa0219f5a67acbe /src/displayapp/screens
parenta1db9fca136493eef38e536abaa660dd6ce23e57 (diff)
parented91b5a9981898078ad8e4cf105b5d52c7b63dfe (diff)
Merge branch 'develop' into remove-nm-reference
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Alarm.cpp8
-rw-r--r--src/displayapp/screens/BleIcon.cpp9
-rw-r--r--src/displayapp/screens/BleIcon.h4
-rw-r--r--src/displayapp/screens/Clock.cpp30
-rw-r--r--src/displayapp/screens/Clock.h3
-rw-r--r--src/displayapp/screens/DropDownDemo.cpp57
-rw-r--r--src/displayapp/screens/DropDownDemo.h27
-rw-r--r--src/displayapp/screens/FirmwareUpdate.cpp11
-rw-r--r--src/displayapp/screens/FirmwareUpdate.h1
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp4
-rw-r--r--src/displayapp/screens/FlashLight.cpp2
-rw-r--r--src/displayapp/screens/HeartRate.cpp14
-rw-r--r--src/displayapp/screens/HeartRate.h1
-rw-r--r--src/displayapp/screens/Motion.cpp2
-rw-r--r--src/displayapp/screens/Motion.h1
-rw-r--r--src/displayapp/screens/Music.cpp50
-rw-r--r--src/displayapp/screens/Music.h2
-rw-r--r--src/displayapp/screens/Navigation.cpp8
-rw-r--r--src/displayapp/screens/Notifications.cpp53
-rw-r--r--src/displayapp/screens/Notifications.h9
-rw-r--r--src/displayapp/screens/Paddle.cpp2
-rw-r--r--src/displayapp/screens/PassKey.cpp2
-rw-r--r--src/displayapp/screens/Steps.cpp2
-rw-r--r--src/displayapp/screens/StopWatch.cpp28
-rw-r--r--src/displayapp/screens/Tile.cpp4
-rw-r--r--src/displayapp/screens/Timer.cpp39
-rw-r--r--src/displayapp/screens/Timer.h27
-rw-r--r--src/displayapp/screens/Twos.cpp4
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp23
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.h9
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp4
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h6
-rw-r--r--src/displayapp/screens/WatchFacePineTimeStyle.cpp (renamed from src/displayapp/screens/PineTimeStyle.cpp)40
-rw-r--r--src/displayapp/screens/WatchFacePineTimeStyle.h (renamed from src/displayapp/screens/PineTimeStyle.h)12
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.cpp183
-rw-r--r--src/displayapp/screens/WatchFaceTerminal.h81
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.cpp93
-rw-r--r--src/displayapp/screens/settings/SettingBluetooth.h31
-rw-r--r--src/displayapp/screens/settings/SettingChimes.h2
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp10
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h1
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.cpp2
-rw-r--r--src/displayapp/screens/settings/SettingWatchFace.h2
-rw-r--r--src/displayapp/screens/settings/Settings.cpp37
-rw-r--r--src/displayapp/screens/settings/Settings.h3
46 files changed, 647 insertions, 300 deletions
diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp
index 879e50d8..d5fc2c04 100644
--- a/src/displayapp/screens/Alarm.cpp
+++ b/src/displayapp/screens/Alarm.cpp
@@ -303,7 +303,7 @@ void Alarm::ShowInfo() {
lv_label_set_text_fmt(
txtMessage, "Time to\nalarm:\n%2lu Days\n%2lu Hours\n%2lu Minutes\n%2lu Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm);
} else {
- lv_label_set_text(txtMessage, "Alarm\nis not\nset.");
+ lv_label_set_text_static(txtMessage, "Alarm\nis not\nset.");
}
}
@@ -317,13 +317,13 @@ void Alarm::SetRecurButtonState() {
using Pinetime::Controllers::AlarmController;
switch (alarmController.Recurrence()) {
case AlarmController::RecurType::None:
- lv_label_set_text(txtRecur, "ONCE");
+ lv_label_set_text_static(txtRecur, "ONCE");
break;
case AlarmController::RecurType::Daily:
- lv_label_set_text(txtRecur, "DAILY");
+ lv_label_set_text_static(txtRecur, "DAILY");
break;
case AlarmController::RecurType::Weekdays:
- lv_label_set_text(txtRecur, "MON-FRI");
+ lv_label_set_text_static(txtRecur, "MON-FRI");
}
}
diff --git a/src/displayapp/screens/BleIcon.cpp b/src/displayapp/screens/BleIcon.cpp
index 5058f3eb..780a14cf 100644
--- a/src/displayapp/screens/BleIcon.cpp
+++ b/src/displayapp/screens/BleIcon.cpp
@@ -3,8 +3,9 @@
using namespace Pinetime::Applications::Screens;
const char* BleIcon::GetIcon(bool isConnected) {
- if (isConnected)
+ if (isConnected) {
return Symbols::bluetooth;
- else
- return "";
-} \ No newline at end of file
+ }
+
+ return Symbols::none;
+}
diff --git a/src/displayapp/screens/BleIcon.h b/src/displayapp/screens/BleIcon.h
index c1398d2a..d9a46541 100644
--- a/src/displayapp/screens/BleIcon.h
+++ b/src/displayapp/screens/BleIcon.h
@@ -1,5 +1,7 @@
#pragma once
+#include "components/ble/BleController.h"
+
namespace Pinetime {
namespace Applications {
namespace Screens {
@@ -9,4 +11,4 @@ namespace Pinetime {
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 1415e8ec..693e42a9 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -9,8 +9,9 @@
#include "components/settings/Settings.h"
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/WatchFaceDigital.h"
+#include "displayapp/screens/WatchFaceTerminal.h"
#include "displayapp/screens/WatchFaceAnalog.h"
-#include "displayapp/screens/PineTimeStyle.h"
+#include "displayapp/screens/WatchFacePineTimeStyle.h"
using namespace Pinetime::Applications::Screens;
@@ -39,7 +40,10 @@ Clock::Clock(DisplayApp* app,
return WatchFaceAnalogScreen();
break;
case 2:
- return PineTimeStyleScreen();
+ return WatchFacePineTimeStyleScreen();
+ break;
+ case 3:
+ return WatchFaceTerminalScreen();
break;
}
return WatchFaceDigitalScreen();
@@ -75,12 +79,18 @@ std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() {
app, dateTimeController, batteryController, bleController, notificatioManager, settingsController);
}
-std::unique_ptr<Screen> Clock::PineTimeStyleScreen() {
- return std::make_unique<Screens::PineTimeStyle>(app,
- dateTimeController,
- batteryController,
- bleController,
- notificatioManager,
- settingsController,
- motionController);
+std::unique_ptr<Screen> Clock::WatchFacePineTimeStyleScreen() {
+ return std::make_unique<Screens::WatchFacePineTimeStyle>(
+ app, dateTimeController, batteryController, bleController, notificatioManager, settingsController, motionController);
+}
+
+std::unique_ptr<Screen> Clock::WatchFaceTerminalScreen() {
+ return std::make_unique<Screens::WatchFaceTerminal>(app,
+ dateTimeController,
+ batteryController,
+ bleController,
+ notificatioManager,
+ settingsController,
+ heartRateController,
+ motionController);
}
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index fcecc6b3..1ba752c7 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -46,7 +46,8 @@ namespace Pinetime {
std::unique_ptr<Screen> screen;
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
- std::unique_ptr<Screen> PineTimeStyleScreen();
+ std::unique_ptr<Screen> WatchFacePineTimeStyleScreen();
+ std::unique_ptr<Screen> WatchFaceTerminalScreen();
};
}
}
diff --git a/src/displayapp/screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp
deleted file mode 100644
index cf239a2f..00000000
--- a/src/displayapp/screens/DropDownDemo.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "displayapp/screens/DropDownDemo.h"
-#include <lvgl/lvgl.h>
-#include <libraries/log/nrf_log.h>
-#include "displayapp/DisplayApp.h"
-
-using namespace Pinetime::Applications::Screens;
-
-DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp* app) : Screen(app) {
- // Create the dropdown object, with many item, and fix its height
- ddlist = lv_ddlist_create(lv_scr_act(), nullptr);
- lv_ddlist_set_options(ddlist,
- "Apple\n"
- "Banana\n"
- "Orange\n"
- "Melon\n"
- "Grape\n"
- "Raspberry\n"
- "A\n"
- "B\n"
- "C\n"
- "D\n"
- "E");
- lv_ddlist_set_fix_width(ddlist, 150);
- lv_ddlist_set_draw_arrow(ddlist, true);
- lv_ddlist_set_fix_height(ddlist, 150);
- lv_obj_align(ddlist, nullptr, LV_ALIGN_IN_TOP_MID, 0, 20);
-}
-
-DropDownDemo::~DropDownDemo() {
- // Reset the touchmode
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
- lv_obj_clean(lv_scr_act());
-}
-
-bool DropDownDemo::Refresh() {
- auto* list = static_cast<lv_ddlist_ext_t*>(ddlist->ext_attr);
-
- // Switch touchmode to Polling if the dropdown is opened. This will allow to scroll inside the
- // dropdown while it is opened.
- // Disable the polling mode when the dropdown is closed to be able to handle the gestures.
- if (list->opened)
- app->SetTouchMode(DisplayApp::TouchModes::Polling);
- else
- app->SetTouchMode(DisplayApp::TouchModes::Gestures);
- return running;
-}
-
-bool DropDownDemo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- // If the dropdown is opened, notify Display app that it doesn't need to handle the event
- // (this will prevent displayApp from going back to the menu or clock scree).
- auto* list = static_cast<lv_ddlist_ext_t*>(ddlist->ext_attr);
- if (list->opened) {
- return true;
- } else {
- return false;
- }
-}
diff --git a/src/displayapp/screens/DropDownDemo.h b/src/displayapp/screens/DropDownDemo.h
deleted file mode 100644
index bcf0f45c..00000000
--- a/src/displayapp/screens/DropDownDemo.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include "displayapp/screens/Screen.h"
-#include <lvgl/src/lv_core/lv_obj.h>
-
-namespace Pinetime {
- namespace Applications {
- namespace Screens {
-
- class DropDownDemo : public Screen {
- public:
- DropDownDemo(DisplayApp* app);
- ~DropDownDemo() override;
-
- bool Refresh() override;
-
- bool OnTouchEvent(TouchEvents event) override;
-
- private:
- lv_obj_t* ddlist;
-
- bool isDropDownOpened = false;
- };
- }
- }
-}
diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp
index 373fcae4..0a8544b3 100644
--- a/src/displayapp/screens/FirmwareUpdate.cpp
+++ b/src/displayapp/screens/FirmwareUpdate.cpp
@@ -15,7 +15,7 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
lv_label_set_text_static(backgroundLabel, "");
titleLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(titleLabel, "Firmware update");
+ lv_label_set_text_static(titleLabel, "Firmware update");
lv_obj_set_auto_realign(titleLabel, true);
lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50);
@@ -27,7 +27,7 @@ FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime
lv_bar_set_value(bar1, 0, LV_ANIM_OFF);
percentLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(percentLabel, "Waiting...");
+ lv_label_set_text_static(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);
@@ -81,20 +81,19 @@ void FirmwareUpdate::DisplayProgression() const {
float current = bleController.FirmwareUpdateCurrentBytes() / 1024.0f;
float total = bleController.FirmwareUpdateTotalBytes() / 1024.0f;
int16_t pc = (current / total) * 100.0f;
- sprintf(percentStr, "%d %%", pc);
- lv_label_set_text(percentLabel, percentStr);
+ lv_label_set_text_fmt(percentLabel, "%d %%", pc);
lv_bar_set_value(bar1, pc, LV_ANIM_OFF);
}
void FirmwareUpdate::UpdateValidated() {
lv_label_set_recolor(percentLabel, true);
- lv_label_set_text(percentLabel, "#00ff00 Image Ok!#");
+ lv_label_set_text_static(percentLabel, "#00ff00 Image Ok!#");
}
void FirmwareUpdate::UpdateError() {
lv_label_set_recolor(percentLabel, true);
- lv_label_set_text(percentLabel, "#ff0000 Error!#");
+ lv_label_set_text_static(percentLabel, "#ff0000 Error!#");
startTime = xTaskGetTickCount();
}
diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h
index a61178ce..5156b7ea 100644
--- a/src/displayapp/screens/FirmwareUpdate.h
+++ b/src/displayapp/screens/FirmwareUpdate.h
@@ -24,7 +24,6 @@ namespace Pinetime {
lv_obj_t* bar1;
lv_obj_t* percentLabel;
lv_obj_t* titleLabel;
- mutable char percentStr[10];
States state = States::Idle;
diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index c7a5b27e..16244ad5 100644
--- a/src/displayapp/screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -33,9 +33,9 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
lv_obj_set_width(labelIsValidated, 240);
if (validator.IsValidated())
- lv_label_set_text(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
+ lv_label_set_text_static(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
else {
- lv_label_set_text(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
+ lv_label_set_text_static(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
buttonValidate->user_data = this;
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
index c4d02643..0634187d 100644
--- a/src/displayapp/screens/FlashLight.cpp
+++ b/src/displayapp/screens/FlashLight.cpp
@@ -45,7 +45,7 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundAction, 240, 240);
lv_obj_set_pos(backgroundAction, 0, 0);
- lv_label_set_text(backgroundAction, "");
+ lv_label_set_text_static(backgroundAction, "");
lv_obj_set_click(backgroundAction, true);
backgroundAction->user_data = this;
lv_obj_set_event_cb(backgroundAction, event_handler);
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 513c40bf..89b43bb5 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -41,16 +41,16 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
else
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- lv_label_set_text(label_hr, "000");
+ lv_label_set_text_static(label_hr, "000");
lv_obj_align(label_hr, nullptr, LV_ALIGN_CENTER, 0, -40);
label_bpm = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(label_bpm, "Heart rate BPM");
+ lv_label_set_text_static(label_bpm, "Heart rate BPM");
lv_obj_align(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20);
label_status = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
- lv_label_set_text(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData));
+ lv_label_set_text_static(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
@@ -81,13 +81,13 @@ void HeartRate::Refresh() {
case Controllers::HeartRateController::States::NoTouch:
case Controllers::HeartRateController::States::NotEnoughData:
// case Controllers::HeartRateController::States::Stopped:
- lv_label_set_text(label_hr, "000");
+ lv_label_set_text_static(label_hr, "000");
break;
default:
lv_label_set_text_fmt(label_hr, "%03d", heartRateController.HeartRate());
}
- lv_label_set_text(label_status, ToString(state));
+ lv_label_set_text_static(label_status, ToString(state));
lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
}
@@ -109,7 +109,7 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
void HeartRate::UpdateStartStopButton(bool isRunning) {
if (isRunning)
- lv_label_set_text(label_startStop, "Stop");
+ lv_label_set_text_static(label_startStop, "Stop");
else
- lv_label_set_text(label_startStop, "Start");
+ lv_label_set_text_static(label_startStop, "Start");
}
diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h
index baa0ccdd..2ad00351 100644
--- a/src/displayapp/screens/HeartRate.h
+++ b/src/displayapp/screens/HeartRate.h
@@ -3,7 +3,6 @@
#include <cstdint>
#include <chrono>
#include "displayapp/screens/Screen.h"
-#include <bits/unique_ptr.h>
#include "systemtask/SystemTask.h"
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index 23eb2765..799dcb3b 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -35,7 +35,7 @@ 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 ---");
+ lv_label_set_text_static(labelStep, "Steps ---");
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h
index d6997409..4d2bd4f2 100644
--- a/src/displayapp/screens/Motion.h
+++ b/src/displayapp/screens/Motion.h
@@ -3,7 +3,6 @@
#include <cstdint>
#include <chrono>
#include "displayapp/screens/Screen.h"
-#include <bits/unique_ptr.h>
#include <lvgl/src/lv_core/lv_style.h>
#include <lvgl/src/lv_core/lv_obj.h>
#include <components/motion/MotionController.h>
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index 9f17b956..dd4609cf 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -62,7 +62,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_obj_add_style(btnVolDown, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnVolDown, nullptr);
- lv_label_set_text(label, Symbols::volumDown);
+ lv_label_set_text_static(label, Symbols::volumDown);
lv_obj_set_hidden(btnVolDown, true);
btnVolUp = lv_btn_create(lv_scr_act(), nullptr);
@@ -72,7 +72,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_add_style(btnVolUp, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnVolUp, nullptr);
- lv_label_set_text(label, Symbols::volumUp);
+ lv_label_set_text_static(label, Symbols::volumUp);
lv_obj_set_hidden(btnVolUp, true);
btnPrev = lv_btn_create(lv_scr_act(), nullptr);
@@ -82,7 +82,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_obj_add_style(btnPrev, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnPrev, nullptr);
- lv_label_set_text(label, Symbols::stepBackward);
+ lv_label_set_text_static(label, Symbols::stepBackward);
btnNext = lv_btn_create(lv_scr_act(), nullptr);
btnNext->user_data = this;
@@ -91,7 +91,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
lv_obj_add_style(btnNext, LV_STATE_DEFAULT, &btn_style);
label = lv_label_create(btnNext, nullptr);
- lv_label_set_text(label, Symbols::stepForward);
+ lv_label_set_text_static(label, Symbols::stepForward);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
@@ -100,12 +100,12 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_obj_add_style(btnPlayPause, LV_STATE_DEFAULT, &btn_style);
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
- lv_label_set_text(txtTrackDuration, "--:--/--:--");
+ lv_label_set_text_static(txtTrackDuration, "--:--/--:--");
lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
@@ -117,7 +117,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
lv_obj_set_width(txtArtist, LV_HOR_RES - 12);
- lv_label_set_text(txtArtist, "Artist Name");
+ lv_label_set_text_static(txtArtist, "Artist Name");
txtTrack = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL_CIRC);
@@ -125,7 +125,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus
lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
lv_obj_set_width(txtTrack, LV_HOR_RES - 12);
- lv_label_set_text(txtTrack, "This is a very long getTrack name");
+ lv_label_set_text_static(txtTrack, "This is a very long getTrack name");
/** Init animation */
imgDisc = lv_img_create(lv_scr_act(), nullptr);
@@ -187,7 +187,7 @@ void Music::Refresh() {
}
if (playing == Pinetime::Controllers::MusicService::MusicStatus::Playing) {
- lv_label_set_text(txtPlayPause, Symbols::pause);
+ lv_label_set_text_static(txtPlayPause, Symbols::pause);
if (xTaskGetTickCount() - 1024 >= lastIncrement) {
if (frameB) {
@@ -211,31 +211,27 @@ void Music::Refresh() {
UpdateLength();
}
} else {
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
}
}
void Music::UpdateLength() {
if (totalLength > (99 * 60 * 60)) {
- lv_label_set_text(txtTrackDuration, "Inf/Inf");
+ lv_label_set_text_static(txtTrackDuration, "Inf/Inf");
} else if (totalLength > (99 * 60)) {
- char timer[12];
- sprintf(timer,
- "%02d:%02d/%02d:%02d",
- (currentLength / (60 * 60)) % 100,
- ((currentLength % (60 * 60)) / 60) % 100,
- (totalLength / (60 * 60)) % 100,
- ((totalLength % (60 * 60)) / 60) % 100);
- lv_label_set_text(txtTrackDuration, timer);
+ lv_label_set_text_fmt(txtTrackDuration,
+ "%02d:%02d/%02d:%02d",
+ (currentLength / (60 * 60)) % 100,
+ ((currentLength % (60 * 60)) / 60) % 100,
+ (totalLength / (60 * 60)) % 100,
+ ((totalLength % (60 * 60)) / 60) % 100);
} else {
- char timer[12];
- sprintf(timer,
- "%02d:%02d/%02d:%02d",
- (currentLength / 60) % 100,
- (currentLength % 60) % 100,
- (totalLength / 60) % 100,
- (totalLength % 60) % 100);
- lv_label_set_text(txtTrackDuration, timer);
+ lv_label_set_text_fmt(txtTrackDuration,
+ "%02d:%02d/%02d:%02d",
+ (currentLength / 60) % 100,
+ (currentLength % 60) % 100,
+ (totalLength / 60) % 100,
+ (totalLength % 60) % 100);
}
}
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index 35f7bab5..27b2d3d2 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -40,7 +40,7 @@ namespace Pinetime {
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
private:
- bool OnTouchEvent(TouchEvents event);
+ bool OnTouchEvent(TouchEvents event) override;
void UpdateLength();
diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp
index 674362a6..0dd0d303 100644
--- a/src/displayapp/screens/Navigation.cpp
+++ b/src/displayapp/screens/Navigation.cpp
@@ -134,13 +134,13 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
imgFlag = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_navi_80);
lv_obj_set_style_local_text_color(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
- lv_label_set_text(imgFlag, iconForName("flag"));
+ lv_label_set_text_static(imgFlag, iconForName("flag"));
lv_obj_align(imgFlag, nullptr, LV_ALIGN_CENTER, 0, -60);
txtNarrative = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(txtNarrative, LV_LABEL_LONG_BREAK);
lv_obj_set_width(txtNarrative, LV_HOR_RES);
- lv_label_set_text(txtNarrative, "Navigation");
+ lv_label_set_text_static(txtNarrative, "Navigation");
lv_label_set_align(txtNarrative, LV_LABEL_ALIGN_CENTER);
lv_obj_align(txtNarrative, nullptr, LV_ALIGN_CENTER, 0, 10);
@@ -148,7 +148,7 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro
lv_label_set_long_mode(txtManDist, LV_LABEL_LONG_BREAK);
lv_obj_set_style_local_text_color(txtManDist, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
lv_obj_set_width(txtManDist, LV_HOR_RES);
- lv_label_set_text(txtManDist, "--M");
+ lv_label_set_text_static(txtManDist, "--M");
lv_label_set_align(txtManDist, LV_LABEL_ALIGN_CENTER);
lv_obj_align(txtManDist, nullptr, LV_ALIGN_CENTER, 0, 60);
@@ -173,7 +173,7 @@ Navigation::~Navigation() {
void Navigation::Refresh() {
if (flag != navService.getFlag()) {
flag = navService.getFlag();
- lv_label_set_text(imgFlag, iconForName(flag));
+ lv_label_set_text_static(imgFlag, iconForName(flag));
}
if (narrative != navService.getNarrative()) {
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 8fe08a82..600f7488 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -17,6 +17,7 @@ Notifications::Notifications(DisplayApp* app,
: Screen(app),
notificationManager {notificationManager},
alertNotificationService {alertNotificationService},
+ motorController {motorController},
systemTask {systemTask},
mode {mode} {
notificationManager.ClearNewNotificationFlag();
@@ -29,7 +30,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
validDisplay = true;
} else {
currentItem = std::make_unique<NotificationItem>("Notification",
@@ -38,7 +40,8 @@ Notifications::Notifications(DisplayApp* app,
notification.category,
notificationManager.NbNotifications(),
Modes::Preview,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
if (mode == Modes::Preview) {
@@ -66,7 +69,7 @@ Notifications::Notifications(DisplayApp* app,
Notifications::~Notifications() {
lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
@@ -87,7 +90,7 @@ void Notifications::Refresh() {
void Notifications::OnPreviewInteraction() {
systemTask.PushMessage(System::Messages::EnableSleeping);
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
if (timeoutLine != nullptr) {
lv_obj_del(timeoutLine);
timeoutLine = nullptr;
@@ -125,7 +128,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
previousNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
case Pinetime::Applications::TouchEvents::SwipeUp: {
@@ -150,7 +154,8 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
nextNotification.category,
notificationManager.NbNotifications(),
mode,
- alertNotificationService);
+ alertNotificationService,
+ motorController);
}
return true;
default:
@@ -171,8 +176,9 @@ Notifications::NotificationItem::NotificationItem(const char* title,
Controllers::NotificationManager::Categories category,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService)
- : mode {mode}, alertNotificationService {alertNotificationService} {
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController)
+ : mode {mode}, alertNotificationService {alertNotificationService}, motorController {motorController} {
lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL);
lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222));
@@ -192,15 +198,18 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888));
- if (title == nullptr)
- title = "Notification";
- char* pchar;
- pchar = strchr(title, '\n');
- while (pchar != nullptr) {
- *pchar = ' ';
- pchar = strchr(pchar + 1, '\n');
+ if(title == nullptr) {
+ lv_label_set_text_static(alert_type, "Notification");
+ } else {
+ // copy title to label and replace newlines with spaces
+ lv_label_set_text(alert_type, title);
+ char *pchar = strchr(lv_label_get_text(alert_type), '\n');
+ while (pchar != nullptr) {
+ *pchar = ' ';
+ pchar = strchr(pchar + 1, '\n');
+ }
+ lv_label_refr_text(alert_type);
}
- lv_label_set_text(alert_type, title);
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC);
lv_obj_set_width(alert_type, 180);
lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16);
@@ -220,7 +229,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
lv_obj_set_width(alert_subject, LV_HOR_RES - 20);
- lv_label_set_text(alert_subject, "Incoming call from");
+ lv_label_set_text_static(alert_subject, "Incoming call from");
lv_obj_t* alert_caller = lv_label_create(container1, nullptr);
lv_obj_align(alert_caller, alert_subject, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
@@ -234,7 +243,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_size(bt_accept, 76, 76);
lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label_accept = lv_label_create(bt_accept, nullptr);
- lv_label_set_text(label_accept, Symbols::phone);
+ lv_label_set_text_static(label_accept, Symbols::phone);
lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
bt_reject = lv_btn_create(lv_scr_act(), nullptr);
@@ -243,7 +252,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_size(bt_reject, 76, 76);
lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
label_reject = lv_label_create(bt_reject, nullptr);
- lv_label_set_text(label_reject, Symbols::phoneSlash);
+ lv_label_set_text_static(label_reject, Symbols::phoneSlash);
lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
bt_mute = lv_btn_create(lv_scr_act(), nullptr);
@@ -252,7 +261,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_set_size(bt_mute, 76, 76);
lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label_mute = lv_label_create(bt_mute, nullptr);
- lv_label_set_text(label_mute, Symbols::volumMute);
+ lv_label_set_text_static(label_mute, Symbols::volumMute);
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
} break;
}
@@ -261,7 +270,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
}
void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) {
@@ -269,7 +278,7 @@ void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_
return;
}
- Controllers::MotorController::StopRinging();
+ motorController.StopRinging();
if (obj == bt_accept) {
alertNotificationService.AcceptIncomingCall();
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index 2f444c7c..74160356 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -39,7 +39,8 @@ namespace Pinetime {
Controllers::NotificationManager::Categories,
uint8_t notifNb,
Modes mode,
- Pinetime::Controllers::AlertNotificationService& alertNotificationService);
+ Pinetime::Controllers::AlertNotificationService& alertNotificationService,
+ Pinetime::Controllers::MotorController& motorController);
~NotificationItem();
bool IsRunning() const {
return running;
@@ -56,16 +57,14 @@ namespace Pinetime {
lv_obj_t* label_reject;
Modes mode;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ Pinetime::Controllers::MotorController& motorController;
bool running = true;
};
private:
- struct NotificationData {
- const char* title;
- const char* text;
- };
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ Pinetime::Controllers::MotorController& motorController;
System::SystemTask& systemTask;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
index 608eb644..79401ff9 100644
--- a/src/displayapp/screens/Paddle.cpp
+++ b/src/displayapp/screens/Paddle.cpp
@@ -17,7 +17,7 @@ Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::Li
points = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
- lv_label_set_text(points, "0000");
+ lv_label_set_text_static(points, "0000");
lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 10);
paddle = lv_obj_create(lv_scr_act(), nullptr);
diff --git a/src/displayapp/screens/PassKey.cpp b/src/displayapp/screens/PassKey.cpp
index 9e43a541..e9715cd6 100644
--- a/src/displayapp/screens/PassKey.cpp
+++ b/src/displayapp/screens/PassKey.cpp
@@ -15,7 +15,7 @@ PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
}
PassKey::~PassKey() {
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index 3e7f8201..df137585 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -61,7 +61,7 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_width(resetBtn, 115);
lv_obj_align(resetBtn, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
resetButtonLabel = lv_label_create(resetBtn, nullptr);
- lv_label_set_text(resetButtonLabel, "Reset");
+ lv_label_set_text_static(resetButtonLabel, "Reset");
currentTripSteps = motionController.GetTripSteps();
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index 8749839f..fcff5f12 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -55,13 +55,13 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- lv_label_set_text(time, "00:00");
+ lv_label_set_text_static(time, "00:00");
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45);
msecTime = lv_label_create(lv_scr_act(), nullptr);
// lv_obj_set_style_local_text_font(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- lv_label_set_text(msecTime, "00");
+ lv_label_set_text_static(msecTime, "00");
lv_obj_align(msecTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 3);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
@@ -71,7 +71,7 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lv_obj_set_width(btnPlayPause, 115);
lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
btnStopLap = lv_btn_create(lv_scr_act(), nullptr);
btnStopLap->user_data = this;
@@ -82,7 +82,7 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x080808));
txtStopLap = lv_label_create(btnStopLap, nullptr);
lv_obj_set_style_local_text_color(txtStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x888888));
- lv_label_set_text(txtStopLap, Symbols::stop);
+ lv_label_set_text_static(txtStopLap, Symbols::stop);
lv_obj_set_state(btnStopLap, LV_STATE_DISABLED);
lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
@@ -90,13 +90,13 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask)
// lv_obj_set_style_local_text_font(lapOneText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
lv_obj_set_style_local_text_color(lapOneText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_obj_align(lapOneText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 30);
- lv_label_set_text(lapOneText, "");
+ lv_label_set_text_static(lapOneText, "");
lapTwoText = lv_label_create(lv_scr_act(), nullptr);
// lv_obj_set_style_local_text_font(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
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, "");
+ lv_label_set_text_static(lapTwoText, "");
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
@@ -113,11 +113,11 @@ void StopWatch::reset() {
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
- lv_label_set_text(time, "00:00");
- lv_label_set_text(msecTime, "00");
+ lv_label_set_text_static(time, "00:00");
+ lv_label_set_text_static(msecTime, "00");
- lv_label_set_text(lapOneText, "");
- lv_label_set_text(lapTwoText, "");
+ lv_label_set_text_static(lapOneText, "");
+ lv_label_set_text_static(lapTwoText, "");
lapBuffer.clearBuffer();
lapNr = 0;
lv_obj_set_state(btnStopLap, LV_STATE_DISABLED);
@@ -129,8 +129,8 @@ void StopWatch::start() {
lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
- lv_label_set_text(txtPlayPause, Symbols::pause);
- lv_label_set_text(txtStopLap, Symbols::lapsFlag);
+ lv_label_set_text_static(txtPlayPause, Symbols::pause);
+ lv_label_set_text_static(txtStopLap, Symbols::lapsFlag);
startTime = xTaskGetTickCount();
currentState = States::Running;
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
@@ -141,8 +141,8 @@ void StopWatch::pause() {
// Store the current time elapsed in cache
oldTimeElapsed += timeElapsed;
currentState = States::Halted;
- lv_label_set_text(txtPlayPause, Symbols::play);
- lv_label_set_text(txtStopLap, Symbols::stop);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtStopLap, Symbols::stop);
lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index 23d9bca7..4df69fed 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -39,7 +39,7 @@ Tile::Tile(uint8_t screenID,
// Battery
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -8, 0);
if (numScreens > 1) {
@@ -120,7 +120,7 @@ Tile::~Tile() {
void Tile::UpdateScreen() {
lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp
index a5e40195..167b7b1e 100644
--- a/src/displayapp/screens/Timer.cpp
+++ b/src/displayapp/screens/Timer.cpp
@@ -1,5 +1,4 @@
#include "displayapp/screens/Timer.h"
-
#include "displayapp/screens/Screen.h"
#include "displayapp/screens/Symbols.h"
#include <lvgl/lvgl.h>
@@ -7,11 +6,11 @@
using namespace Pinetime::Applications::Screens;
static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
- Timer* screen = static_cast<Timer*>(obj->user_data);
+ auto* screen = static_cast<Timer*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
-void Timer::createButtons() {
+void Timer::CreateButtons() {
btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesUp->user_data = this;
lv_obj_set_event_cb(btnMinutesUp, btnEventHandler);
@@ -19,7 +18,7 @@ void Timer::createButtons() {
lv_obj_set_height(btnMinutesUp, 40);
lv_obj_set_width(btnMinutesUp, 60);
txtMUp = lv_label_create(btnMinutesUp, nullptr);
- lv_label_set_text(txtMUp, "+");
+ lv_label_set_text_static(txtMUp, "+");
btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr);
btnMinutesDown->user_data = this;
@@ -28,7 +27,7 @@ void Timer::createButtons() {
lv_obj_set_height(btnMinutesDown, 40);
lv_obj_set_width(btnMinutesDown, 60);
txtMDown = lv_label_create(btnMinutesDown, nullptr);
- lv_label_set_text(txtMDown, "-");
+ lv_label_set_text_static(txtMDown, "-");
btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsUp->user_data = this;
@@ -37,7 +36,7 @@ void Timer::createButtons() {
lv_obj_set_height(btnSecondsUp, 40);
lv_obj_set_width(btnSecondsUp, 60);
txtSUp = lv_label_create(btnSecondsUp, nullptr);
- lv_label_set_text(txtSUp, "+");
+ lv_label_set_text_static(txtSUp, "+");
btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr);
btnSecondsDown->user_data = this;
@@ -46,11 +45,17 @@ void Timer::createButtons() {
lv_obj_set_height(btnSecondsDown, 40);
lv_obj_set_width(btnSecondsDown, 60);
txtSDown = lv_label_create(btnSecondsDown, nullptr);
- lv_label_set_text(txtSDown, "-");
+ lv_label_set_text_static(txtSDown, "-");
}
Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
: Screen(app), running {true}, timerController {timerController} {
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_click(backgroundLabel, true);
+ lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
+ lv_obj_set_size(backgroundLabel, 240, 240);
+ lv_obj_set_pos(backgroundLabel, 0, 0);
+ lv_label_set_text_static(backgroundLabel, "");
time = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
@@ -68,10 +73,10 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController)
lv_obj_set_height(btnPlayPause, 40);
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
if (timerController.IsRunning()) {
- lv_label_set_text(txtPlayPause, Symbols::pause);
+ lv_label_set_text_static(txtPlayPause, Symbols::pause);
} else {
- lv_label_set_text(txtPlayPause, Symbols::play);
- createButtons();
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
+ CreateButtons();
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -93,15 +98,15 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
if (obj == btnPlayPause) {
if (timerController.IsRunning()) {
- lv_label_set_text(txtPlayPause, Symbols::play);
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
uint32_t seconds = timerController.GetTimeRemaining() / 1000;
minutesToSet = seconds / 60;
secondsToSet = seconds % 60;
timerController.StopTimer();
- createButtons();
+ CreateButtons();
} else if (secondsToSet + minutesToSet > 0) {
- lv_label_set_text(txtPlayPause, Symbols::pause);
+ lv_label_set_text_static(txtPlayPause, Symbols::pause);
timerController.StartTimer((secondsToSet + minutesToSet * 60) * 1000);
lv_obj_del(btnSecondsDown);
@@ -152,10 +157,10 @@ void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
}
}
-void Timer::setDone() {
- lv_label_set_text(time, "00:00");
- lv_label_set_text(txtPlayPause, Symbols::play);
+void Timer::SetDone() {
+ lv_label_set_text_static(time, "00:00");
+ lv_label_set_text_static(txtPlayPause, Symbols::play);
secondsToSet = 0;
minutesToSet = 0;
- createButtons();
+ CreateButtons();
}
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index 23c87345..93e84c82 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -8,32 +8,35 @@
#include "components/timer/TimerController.h"
namespace Pinetime::Applications::Screens {
-
class Timer : public Screen {
public:
enum class Modes { Normal, Done };
Timer(DisplayApp* app, Controllers::TimerController& timerController);
-
~Timer() override;
-
void Refresh() override;
-
- void setDone();
-
+ void SetDone();
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
private:
+ void CreateButtons();
bool running;
uint8_t secondsToSet = 0;
uint8_t minutesToSet = 0;
Controllers::TimerController& timerController;
-
- void createButtons();
-
- lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp,
- *txtMDown, *txtSUp, *txtSDown;
-
+ lv_obj_t* backgroundLabel;
+ lv_obj_t* time;
+ lv_obj_t* msecTime;
+ lv_obj_t* btnPlayPause;
+ lv_obj_t* txtPlayPause;
+ lv_obj_t* btnMinutesUp;
+ lv_obj_t* btnMinutesDown;
+ lv_obj_t* btnSecondsUp;
+ lv_obj_t* btnSecondsDown;
+ lv_obj_t* txtMUp;
+ lv_obj_t* txtMDown;
+ lv_obj_t* txtSUp;
+ lv_obj_t* txtSDown;
lv_task_t* taskRefresh;
};
}
diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp
index b15332f1..ca9295d5 100644
--- a/src/displayapp/screens/Twos.cpp
+++ b/src/displayapp/screens/Twos.cpp
@@ -90,7 +90,7 @@ Twos::Twos(Pinetime::Applications::DisplayApp* app) : Screen(app) {
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
}
Twos::~Twos() {
@@ -130,7 +130,7 @@ bool Twos::placeNewTile() {
}
bool Twos::tryMerge(TwosTile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol) {
- if ((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) {
+ if (grid[newRow][newCol].value == grid[oldRow][oldCol].value) {
if ((newCol != oldCol) || (newRow != oldRow)) {
if (!grid[newRow][newCol].merged) {
unsigned int newVal = grid[oldRow][oldCol].value *= 2;
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index f027a744..4cfc9692 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -57,7 +57,6 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
bleController {bleController},
notificationManager {notificationManager},
settingsController {settingsController} {
- settingsController.SetClockFace(1);
sHour = 99;
sMinute = 99;
@@ -68,13 +67,13 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, Symbols::batteryHalf);
+ lv_label_set_text_static(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));
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
// Date - Day / Week day
@@ -138,9 +137,9 @@ WatchFaceAnalog::~WatchFaceAnalog() {
}
void WatchFaceAnalog::UpdateClock() {
- hour = dateTimeController.Hours();
- minute = dateTimeController.Minutes();
- second = dateTimeController.Seconds();
+ uint8_t hour = dateTimeController.Hours();
+ uint8_t minute = dateTimeController.Minutes();
+ uint8_t second = dateTimeController.Seconds();
if (sMinute != minute) {
auto const angle = minute * 6;
@@ -186,7 +185,7 @@ void WatchFaceAnalog::SetBatteryIcon() {
} else {
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
void WatchFaceAnalog::Refresh() {
@@ -194,7 +193,7 @@ void WatchFaceAnalog::Refresh() {
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);
+ lv_label_set_text_static(batteryIcon, Symbols::plug);
} else {
SetBatteryIcon();
}
@@ -209,15 +208,15 @@ void WatchFaceAnalog::Refresh() {
notificationState = notificationManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
if (currentDateTime.IsUpdated()) {
- month = dateTimeController.Month();
- day = dateTimeController.Day();
- dayOfWeek = dateTimeController.DayOfWeek();
+ Pinetime::Controllers::DateTime::Months month = dateTimeController.Month();
+ uint8_t day = dateTimeController.Day();
+ Pinetime::Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek();
UpdateClock();
diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h
index a18eb299..4d76298a 100644
--- a/src/displayapp/screens/WatchFaceAnalog.h
+++ b/src/displayapp/screens/WatchFaceAnalog.h
@@ -35,13 +35,6 @@ namespace Pinetime {
private:
uint8_t sHour, sMinute, sSecond;
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
-
- Pinetime::Controllers::DateTime::Months month;
- uint8_t day;
- Pinetime::Controllers::DateTime::Days dayOfWeek;
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
@@ -74,7 +67,7 @@ namespace Pinetime {
lv_obj_t* batteryIcon;
lv_obj_t* notificationIcon;
- Controllers::DateTime& dateTimeController;
+ const Controllers::DateTime& dateTimeController;
Controllers::Battery& batteryController;
Controllers::Ble& bleController;
Controllers::NotificationManager& notificationManager;
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index b3cb0f91..ad328e1a 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -32,7 +32,6 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController} {
- settingsController.SetClockFace(0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
@@ -120,7 +119,8 @@ void WatchFaceDigital::Refresh() {
}
bleState = bleController.IsConnected();
- if (bleState.IsUpdated()) {
+ bleRadioEnabled = bleController.IsRadioEnabled();
+ if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
lv_obj_realign(batteryIcon);
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index ab3a0285..d33434c0 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -6,6 +6,7 @@
#include <memory>
#include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h"
+#include "components/ble/BleController.h"
namespace Pinetime {
namespace Controllers {
@@ -39,13 +40,14 @@ namespace Pinetime {
uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
- Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
- Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> powerPresent {};
DirtyValue<bool> bleState {};
+ DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
DirtyValue<uint32_t> stepCount {};
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
index 7ce0bc0d..28e7a6a3 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp
@@ -19,7 +19,7 @@
* Style/layout copied from TimeStyle for Pebble by Dan Tilden (github.com/tilden)
*/
-#include "displayapp/screens/PineTimeStyle.h"
+#include "displayapp/screens/WatchFacePineTimeStyle.h"
#include <date/date.h>
#include <lvgl/lvgl.h>
#include <cstdio>
@@ -39,12 +39,19 @@ using namespace Pinetime::Applications::Screens;
namespace {
void event_handler(lv_obj_t* obj, lv_event_t event) {
- auto* screen = static_cast<PineTimeStyle*>(obj->user_data);
+ auto* screen = static_cast<WatchFacePineTimeStyle*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
+
+ bool IsBleIconVisible(bool isRadioEnabled, bool isConnected) {
+ if(!isRadioEnabled) {
+ return true;
+ }
+ return isConnected;
+ }
}
-PineTimeStyle::PineTimeStyle(DisplayApp* app,
+WatchFacePineTimeStyle::WatchFacePineTimeStyle(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
@@ -293,12 +300,12 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
Refresh();
}
-PineTimeStyle::~PineTimeStyle() {
+WatchFacePineTimeStyle::~WatchFacePineTimeStyle() {
lv_task_del(taskRefresh);
lv_obj_clean(lv_scr_act());
}
-bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+bool WatchFacePineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnRandom)) {
lv_obj_set_hidden(btnSet, false);
savedTick = lv_tick_get();
@@ -310,7 +317,7 @@ bool PineTimeStyle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return false;
}
-void PineTimeStyle::CloseMenu() {
+void WatchFacePineTimeStyle::CloseMenu() {
settingsController.SaveSettings();
lv_obj_set_hidden(btnNextTime, true);
lv_obj_set_hidden(btnPrevTime, true);
@@ -323,7 +330,7 @@ void PineTimeStyle::CloseMenu() {
lv_obj_set_hidden(btnClose, true);
}
-bool PineTimeStyle::OnButtonPushed() {
+bool WatchFacePineTimeStyle::OnButtonPushed() {
if (!lv_obj_get_hidden(btnClose)) {
CloseMenu();
return true;
@@ -331,12 +338,12 @@ bool PineTimeStyle::OnButtonPushed() {
return false;
}
-void PineTimeStyle::SetBatteryIcon() {
+void WatchFacePineTimeStyle::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
-void PineTimeStyle::AlignIcons() {
+void WatchFacePineTimeStyle::AlignIcons() {
if (notificationState.Get() && bleState.Get()) {
lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 8, 25);
lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, -8, 25);
@@ -347,7 +354,7 @@ void PineTimeStyle::AlignIcons() {
}
}
-void PineTimeStyle::Refresh() {
+void WatchFacePineTimeStyle::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {
@@ -364,7 +371,8 @@ void PineTimeStyle::Refresh() {
}
bleState = bleController.IsConnected();
- if (bleState.IsUpdated()) {
+ bleRadioEnabled = bleController.IsRadioEnabled();
+ if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
AlignIcons();
}
@@ -416,10 +424,10 @@ void PineTimeStyle::Refresh() {
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
- lv_label_set_text_fmt(dateDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString());
+ lv_label_set_text_static(dateDayOfWeek, dateTimeController.DayOfWeekShortToString());
lv_label_set_text_fmt(dateDay, "%d", day);
lv_obj_realign(dateDay);
- lv_label_set_text_fmt(dateMonth, "%s", dateTimeController.MonthShortToString());
+ lv_label_set_text_static(dateMonth, dateTimeController.MonthShortToString());
currentYear = year;
currentMonth = month;
@@ -446,7 +454,7 @@ void PineTimeStyle::Refresh() {
}
}
-void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+void WatchFacePineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
auto valueTime = settingsController.GetPTSColorTime();
auto valueBar = settingsController.GetPTSColorBar();
auto valueBG = settingsController.GetPTSColorBG();
@@ -567,7 +575,7 @@ void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
}
}
-Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+Pinetime::Controllers::Settings::Colors WatchFacePineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
auto colorAsInt = static_cast<uint8_t>(color);
Pinetime::Controllers::Settings::Colors nextColor;
if (colorAsInt < 16) {
@@ -578,7 +586,7 @@ Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Control
return nextColor;
}
-Pinetime::Controllers::Settings::Colors PineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+Pinetime::Controllers::Settings::Colors WatchFacePineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
auto colorAsInt = static_cast<uint8_t>(color);
Pinetime::Controllers::Settings::Colors prevColor;
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/WatchFacePineTimeStyle.h
index 1b972ce1..465aa705 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/WatchFacePineTimeStyle.h
@@ -7,6 +7,7 @@
#include "displayapp/screens/Screen.h"
#include "displayapp/Colors.h"
#include "components/datetime/DateTimeController.h"
+#include "components/ble/BleController.h"
namespace Pinetime {
namespace Controllers {
@@ -20,16 +21,16 @@ namespace Pinetime {
namespace Applications {
namespace Screens {
- class PineTimeStyle : public Screen {
+ class WatchFacePineTimeStyle : public Screen {
public:
- PineTimeStyle(DisplayApp* app,
+ WatchFacePineTimeStyle(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
Controllers::Ble& bleController,
Controllers::NotificationManager& notificatioManager,
Controllers::Settings& settingsController,
Controllers::MotionController& motionController);
- ~PineTimeStyle() override;
+ ~WatchFacePineTimeStyle() override;
bool OnTouchEvent(TouchEvents event) override;
bool OnButtonPushed() override;
@@ -43,14 +44,15 @@ namespace Pinetime {
uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
- Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
- Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
uint32_t savedTick = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> isCharging {};
DirtyValue<bool> bleState {};
+ DirtyValue<bool> bleRadioEnabled {};
DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
DirtyValue<bool> motionSensorOk {};
DirtyValue<uint32_t> stepCount {};
diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp
new file mode 100644
index 00000000..3a47fc53
--- /dev/null
+++ b/src/displayapp/screens/WatchFaceTerminal.cpp
@@ -0,0 +1,183 @@
+#include <date/date.h>
+#include <lvgl/lvgl.h>
+#include "displayapp/screens/WatchFaceTerminal.h"
+#include "displayapp/screens/BatteryIcon.h"
+#include "displayapp/screens/NotificationIcon.h"
+#include "displayapp/screens/Symbols.h"
+#include "components/battery/BatteryController.h"
+#include "components/ble/BleController.h"
+#include "components/ble/NotificationManager.h"
+#include "components/heartrate/HeartRateController.h"
+#include "components/motion/MotionController.h"
+#include "components/settings/Settings.h"
+
+using namespace Pinetime::Applications::Screens;
+
+WatchFaceTerminal::WatchFaceTerminal(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::HeartRateController& heartRateController,
+ Controllers::MotionController& motionController)
+ : Screen(app),
+ currentDateTime {{}},
+ dateTimeController {dateTimeController},
+ batteryController {batteryController},
+ bleController {bleController},
+ notificatioManager {notificatioManager},
+ settingsController {settingsController},
+ heartRateController {heartRateController},
+ motionController {motionController} {
+ settingsController.SetClockFace(3);
+
+ batteryValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(batteryValue, true);
+ lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
+
+ connectState = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(connectState, true);
+ lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
+
+ notificationIcon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
+
+ label_date = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(label_date, true);
+ lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
+
+ label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
+ lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
+
+ label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
+ lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
+
+ label_time = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(label_time, true);
+ lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
+
+ backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_click(backgroundLabel, true);
+ lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
+ lv_obj_set_size(backgroundLabel, 240, 240);
+ lv_obj_set_pos(backgroundLabel, 0, 0);
+ lv_label_set_text_static(backgroundLabel, "");
+
+ heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(heartbeatValue, true);
+ lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
+
+ stepValue = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_recolor(stepValue, true);
+ lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
+
+ taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+ Refresh();
+}
+
+WatchFaceTerminal::~WatchFaceTerminal() {
+ lv_task_del(taskRefresh);
+ lv_obj_clean(lv_scr_act());
+}
+
+void WatchFaceTerminal::Refresh() {
+ powerPresent = batteryController.IsPowerPresent();
+ batteryPercentRemaining = batteryController.PercentRemaining();
+ if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
+ lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
+ if (batteryController.IsPowerPresent()) {
+ lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
+ }
+ }
+
+ bleState = bleController.IsConnected();
+ bleRadioEnabled = bleController.IsRadioEnabled();
+ if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
+ if(!bleRadioEnabled.Get()) {
+ lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
+ } else {
+ if (bleState.Get()) {
+ lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
+ } else {
+ lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
+ }
+ }
+ }
+
+ notificationState = notificatioManager.AreNewNotificationsAvailable();
+ if (notificationState.IsUpdated()) {
+ if (notificationState.Get()) {
+ lv_label_set_text_static(notificationIcon, "You have mail.");
+ } else {
+ lv_label_set_text_static(notificationIcon, "");
+ }
+ }
+
+ currentDateTime = dateTimeController.CurrentDateTime();
+
+ if (currentDateTime.IsUpdated()) {
+ auto newDateTime = currentDateTime.Get();
+
+ auto dp = date::floor<date::days>(newDateTime);
+ auto time = date::make_time(newDateTime - dp);
+ auto yearMonthDay = date::year_month_day(dp);
+
+ auto year = static_cast<int>(yearMonthDay.year());
+ auto month = static_cast<Pinetime::Controllers::DateTime::Months>(static_cast<unsigned>(yearMonthDay.month()));
+ auto day = static_cast<unsigned>(yearMonthDay.day());
+ auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
+
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
+ uint8_t second = time.seconds().count();
+
+ if (displayedHour != hour || displayedMinute != minute || displayedSecond != second) {
+ displayedHour = hour;
+ displayedMinute = minute;
+ displayedSecond = second;
+
+ if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[3] = "AM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
+ }
+ lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
+ } else {
+ lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
+ }
+ }
+
+ if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
+ lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d.%02d.%02d#", short(year), char(month), char(day));
+
+ currentYear = year;
+ currentMonth = month;
+ currentDayOfWeek = dayOfWeek;
+ currentDay = day;
+ }
+ }
+
+ heartbeat = heartRateController.HeartRate();
+ heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
+ if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
+ if (heartbeatRunning.Get()) {
+ lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
+ } else {
+ lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
+ }
+ }
+
+ stepCount = motionController.NbSteps();
+ motionSensorOk = motionController.IsSensorOk();
+ if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
+ lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
+ }
+}
diff --git a/src/displayapp/screens/WatchFaceTerminal.h b/src/displayapp/screens/WatchFaceTerminal.h
new file mode 100644
index 00000000..d236da34
--- /dev/null
+++ b/src/displayapp/screens/WatchFaceTerminal.h
@@ -0,0 +1,81 @@
+#pragma once
+
+#include <lvgl/src/lv_core/lv_obj.h>
+#include <chrono>
+#include <cstdint>
+#include <memory>
+#include "displayapp/screens/Screen.h"
+#include "components/datetime/DateTimeController.h"
+
+namespace Pinetime {
+ namespace Controllers {
+ class Settings;
+ class Battery;
+ class Ble;
+ class NotificationManager;
+ class HeartRateController;
+ class MotionController;
+ }
+
+ namespace Applications {
+ namespace Screens {
+
+ class WatchFaceTerminal : public Screen {
+ public:
+ WatchFaceTerminal(DisplayApp* app,
+ Controllers::DateTime& dateTimeController,
+ Controllers::Battery& batteryController,
+ Controllers::Ble& bleController,
+ Controllers::NotificationManager& notificatioManager,
+ Controllers::Settings& settingsController,
+ Controllers::HeartRateController& heartRateController,
+ Controllers::MotionController& motionController);
+ ~WatchFaceTerminal() override;
+
+ void Refresh() override;
+
+ private:
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
+ uint8_t displayedSecond = -1;
+
+ uint16_t currentYear = 1970;
+ Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
+ Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
+ uint8_t currentDay = 0;
+
+ DirtyValue<int> batteryPercentRemaining {};
+ DirtyValue<bool> powerPresent {};
+ DirtyValue<bool> bleState {};
+ DirtyValue<bool> bleRadioEnabled {};
+ DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime {};
+ DirtyValue<bool> motionSensorOk {};
+ DirtyValue<uint32_t> stepCount {};
+ DirtyValue<uint8_t> heartbeat {};
+ DirtyValue<bool> heartbeatRunning {};
+ DirtyValue<bool> notificationState {};
+
+ lv_obj_t* label_time;
+ lv_obj_t* label_date;
+ lv_obj_t* label_prompt_1;
+ lv_obj_t* label_prompt_2;
+ lv_obj_t* backgroundLabel;
+ lv_obj_t* batteryValue;
+ lv_obj_t* heartbeatValue;
+ lv_obj_t* stepValue;
+ lv_obj_t* notificationIcon;
+ lv_obj_t* connectState;
+
+ Controllers::DateTime& dateTimeController;
+ Controllers::Battery& batteryController;
+ Controllers::Ble& bleController;
+ Controllers::NotificationManager& notificatioManager;
+ Controllers::Settings& settingsController;
+ Controllers::HeartRateController& heartRateController;
+ Controllers::MotionController& motionController;
+
+ lv_task_t* taskRefresh;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index cd56c145..97faaa79 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -40,7 +40,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
static constexpr uint8_t barHeight = 20 + innerDistance;
@@ -124,7 +124,7 @@ QuickSettings::~QuickSettings() {
void QuickSettings::UpdateScreen() {
lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str());
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining()));
}
void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
diff --git a/src/displayapp/screens/settings/SettingBluetooth.cpp b/src/displayapp/screens/settings/SettingBluetooth.cpp
new file mode 100644
index 00000000..ab1af223
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingBluetooth.cpp
@@ -0,0 +1,93 @@
+#include "displayapp/screens/settings/SettingBluetooth.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/Messages.h"
+#include "displayapp/screens/Styles.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void OnBluetoothDisabledEvent(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
+ screen->OnBluetoothDisabled(obj, event);
+ }
+
+ static void OnBluetoothEnabledEvent(lv_obj_t* obj, lv_event_t event) {
+ auto* screen = static_cast<SettingBluetooth*>(obj->user_data);
+ screen->OnBluetoothEnabled(obj, event);
+ }
+}
+
+SettingBluetooth::SettingBluetooth(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
+ : Screen(app), settingsController {settingsController} {
+
+ lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr);
+
+ lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
+ lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10);
+ lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5);
+ lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0);
+
+ lv_obj_set_pos(container1, 10, 60);
+ lv_obj_set_width(container1, LV_HOR_RES - 20);
+ lv_obj_set_height(container1, LV_VER_RES - 50);
+ lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT);
+
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(title, "Bluetooth");
+ lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15);
+
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_label_set_text_static(icon, Symbols::bluetooth);
+ lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
+
+ cbEnabled = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text(cbEnabled, " Enabled");
+ cbEnabled->user_data = this;
+ lv_obj_set_event_cb(cbEnabled, OnBluetoothEnabledEvent);
+ SetRadioButtonStyle(cbEnabled);
+
+ cbDisabled = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text(cbDisabled, " Disabled");
+ cbDisabled->user_data = this;
+ lv_obj_set_event_cb(cbDisabled, OnBluetoothDisabledEvent);
+ SetRadioButtonStyle(cbDisabled);
+
+ if (settingsController.GetBleRadioEnabled()) {
+ lv_checkbox_set_checked(cbEnabled, true);
+ priorMode = true;
+ } else {
+ lv_checkbox_set_checked(cbDisabled, true);
+ priorMode = false;
+ }
+}
+
+SettingBluetooth::~SettingBluetooth() {
+ lv_obj_clean(lv_scr_act());
+ // Do not call SaveSettings - see src/components/settings/Settings.h
+ if (priorMode != settingsController.GetBleRadioEnabled()) {
+ app->PushMessage(Pinetime::Applications::Display::Messages::BleRadioEnableToggle);
+ }
+}
+
+void SettingBluetooth::OnBluetoothDisabled(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ lv_checkbox_set_checked(cbEnabled, false);
+ lv_checkbox_set_checked(cbDisabled, true);
+ settingsController.SetBleRadioEnabled(false);
+ }
+}
+
+void SettingBluetooth::OnBluetoothEnabled(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ lv_checkbox_set_checked(cbEnabled, true);
+ lv_checkbox_set_checked(cbDisabled, false);
+ settingsController.SetBleRadioEnabled(true);
+ }
+}
+
diff --git a/src/displayapp/screens/settings/SettingBluetooth.h b/src/displayapp/screens/settings/SettingBluetooth.h
new file mode 100644
index 00000000..12bb459a
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingBluetooth.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <array>
+#include <cstdint>
+#include <lvgl/lvgl.h>
+
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingBluetooth : public Screen {
+ public:
+ SettingBluetooth(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingBluetooth() override;
+
+ void OnBluetoothEnabled(lv_obj_t* object, lv_event_t event);
+ void OnBluetoothDisabled(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ lv_obj_t* cbEnabled;
+ lv_obj_t* cbDisabled;
+ bool priorMode;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingChimes.h b/src/displayapp/screens/settings/SettingChimes.h
index 653f87f7..a251e95b 100644
--- a/src/displayapp/screens/settings/SettingChimes.h
+++ b/src/displayapp/screens/settings/SettingChimes.h
@@ -20,7 +20,7 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
uint8_t optionsTotal;
- lv_obj_t* cbOption[2];
+ lv_obj_t* cbOption[3];
};
}
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index 1791b550..c354bdc4 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -1,4 +1,4 @@
-#include "SettingShakeThreshold.h"
+#include "displayapp/screens/settings/SettingShakeThreshold.h"
#include <lvgl/lvgl.h>
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/Screen.h"
@@ -57,7 +57,7 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
lv_obj_align(calButton, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btn_set_checkable(calButton, true);
calLabel = lv_label_create(calButton, NULL);
- lv_label_set_text(calLabel, "Calibrate");
+ lv_label_set_text_static(calLabel, "Calibrate");
lv_arc_set_value(positionArc, settingsController.GetShakeThreshold());
@@ -91,7 +91,7 @@ void SettingShakeThreshold::Refresh() {
calibrating = 2;
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_RED);
- lv_label_set_text(calLabel, "Shake!!");
+ lv_label_set_text_static(calLabel, "Shake!");
}
}
if (calibrating == 2) {
@@ -121,14 +121,14 @@ void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
lv_arc_set_value(positionArc, 0);
calibrating = 1;
vCalTime = xTaskGetTickCount();
- lv_label_set_text(calLabel, "Ready!");
+ lv_label_set_text_static(calLabel, "Ready!");
lv_obj_set_click(positionArc, false);
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
lv_obj_set_style_local_bg_color(calButton, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
} else if (lv_btn_get_state(calButton) == LV_BTN_STATE_RELEASED) {
calibrating = 0;
lv_obj_set_click(positionArc, true);
- lv_label_set_text(calLabel, "Calibrate");
+ lv_label_set_text_static(calLabel, "Calibrate");
}
break;
}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
index b9ddd8b4..37f4a65e 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.h
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -5,6 +5,7 @@
#include "components/settings/Settings.h"
#include "displayapp/screens/Screen.h"
#include <components/motion/MotionController.h>
+#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Applications {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp
index a24eaa15..50085925 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.cpp
+++ b/src/displayapp/screens/settings/SettingWatchFace.cpp
@@ -14,7 +14,7 @@ namespace {
}
}
-constexpr std::array<const char*, 3> SettingWatchFace::options;
+constexpr std::array<const char*, 4> SettingWatchFace::options;
SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
: Screen(app), settingsController {settingsController} {
diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h
index ccba7d13..62427b4f 100644
--- a/src/displayapp/screens/settings/SettingWatchFace.h
+++ b/src/displayapp/screens/settings/SettingWatchFace.h
@@ -20,7 +20,7 @@ namespace Pinetime {
void UpdateSelected(lv_obj_t* object, lv_event_t event);
private:
- static constexpr std::array<const char*, 3> options = {" Digital face", " Analog face", " PineTimeStyle"};
+ static constexpr std::array<const char*, 4> options = {" Digital face", " Analog face", " PineTimeStyle", " Terminal"};
Controllers::Settings& settingsController;
lv_obj_t* cbOption[options.size()];
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 7bc90b47..bc7efcc2 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -21,7 +21,11 @@ Settings::Settings(Pinetime::Applications::DisplayApp* app, Pinetime::Controller
},
[this]() -> std::unique_ptr<Screen> {
return CreateScreen3();
- }},
+ },
+ [this]() -> std::unique_ptr<Screen> {
+ return CreateScreen4();
+ },
+ },
Screens::ScreenListModes::UpDown} {
}
@@ -34,7 +38,6 @@ bool Settings::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
}
std::unique_ptr<Screen> Settings::CreateScreen1() {
-
std::array<Screens::List::Applications, 4> applications {{
{Symbols::sun, "Display", Apps::SettingDisplay},
{Symbols::eye, "Wake Up", Apps::SettingWakeUp},
@@ -42,17 +45,17 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::home, "Watch face", Apps::SettingWatchFace},
}};
- return std::make_unique<Screens::List>(0, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(0, 4, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::shoe, "Steps", Apps::SettingSteps},
+ {Symbols::clock, "Set date", Apps::SettingSetDate},
+ {Symbols::clock, "Set time", Apps::SettingSetTime},
+ {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
- std::array<Screens::List::Applications, 4> applications {{{Symbols::shoe, "Steps", Apps::SettingSteps},
- {Symbols::clock, "Set date", Apps::SettingSetDate},
- {Symbols::clock, "Set time", Apps::SettingSetTime},
- {Symbols::batteryHalf, "Battery", Apps::BatteryInfo}}};
-
- return std::make_unique<Screens::List>(1, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(1, 4, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen3() {
@@ -61,8 +64,20 @@ std::unique_ptr<Screen> Settings::CreateScreen3() {
{Symbols::clock, "Chimes", Apps::SettingChimes},
{Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::list, "About", Apps::SysInfo}
+ {Symbols::bluetooth, "Bluetooth", Apps::SettingBluetooth}
+ }};
+
+ return std::make_unique<Screens::List>(2, 4, app, settingsController, applications);
+}
+
+std::unique_ptr<Screen> Settings::CreateScreen4() {
+
+ std::array<Screens::List::Applications, 4> applications {{
+ {Symbols::list, "About", Apps::SysInfo},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None},
+ {Symbols::none, "None", Apps::None}
}};
- return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);
+ return std::make_unique<Screens::List>(3, 4, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 6c54cdeb..be090075 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -19,11 +19,12 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
- ScreenList<3> screens;
+ ScreenList<4> screens;
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
std::unique_ptr<Screen> CreateScreen3();
+ std::unique_ptr<Screen> CreateScreen4();
};
}
}