summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2021-06-20 15:09:24 (GMT)
committerGitea <gitea@fake.local>2021-06-20 15:09:24 (GMT)
commitd96395c81021778af35b8b4bf965bfe8663eb081 (patch)
tree979e75d716bca8bcd69b86f24a2f2d0270a274d0 /src/displayapp
parentfb133a0167f7ea4281bca45be6efc928720d4f82 (diff)
parent20a24f8cf56551eae1202f8dc5733bd0cf61adbf (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/Apps.h1
-rw-r--r--src/displayapp/DisplayApp.cpp81
-rw-r--r--src/displayapp/DisplayApp.h10
-rw-r--r--src/displayapp/DisplayAppRecovery.cpp10
-rw-r--r--src/displayapp/DisplayAppRecovery.h2
-rw-r--r--src/displayapp/DummyLittleVgl.h4
-rw-r--r--src/displayapp/LittleVgl.cpp4
-rw-r--r--src/displayapp/LittleVgl.h2
-rw-r--r--src/displayapp/lv_pinetime_theme.c13
-rw-r--r--src/displayapp/screens/ApplicationList.cpp2
-rw-r--r--src/displayapp/screens/Clock.cpp30
-rw-r--r--src/displayapp/screens/Clock.h4
-rw-r--r--src/displayapp/screens/FlashLight.cpp4
-rw-r--r--src/displayapp/screens/HeartRate.cpp8
-rw-r--r--src/displayapp/screens/Metronome.cpp169
-rw-r--r--src/displayapp/screens/Metronome.h34
-rw-r--r--src/displayapp/screens/Navigation.cpp137
-rw-r--r--src/displayapp/screens/Navigation.h101
-rw-r--r--src/displayapp/screens/ScreenList.h13
-rw-r--r--src/displayapp/screens/StopWatch.cpp41
-rw-r--r--src/displayapp/screens/SystemInfo.cpp43
-rw-r--r--src/displayapp/screens/SystemInfo.h7
-rw-r--r--src/displayapp/screens/settings/QuickSettings.cpp4
-rw-r--r--src/displayapp/screens/settings/Settings.cpp4
-rw-r--r--src/displayapp/screens/settings/Settings.h1
25 files changed, 509 insertions, 220 deletions
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 2df517f..684e3a4 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -21,6 +21,7 @@ namespace Pinetime {
HeartRate,
Navigation,
StopWatch,
+ Metronome,
Motion,
Steps,
QuickSettings,
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 419b9f6..de93428 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -18,6 +18,7 @@
#include "displayapp/screens/Paddle.h"
#include "displayapp/screens/StopWatch.h"
#include "displayapp/screens/Meter.h"
+#include "displayapp/screens/Metronome.h"
#include "displayapp/screens/Music.h"
#include "displayapp/screens/Navigation.h"
#include "displayapp/screens/Notifications.h"
@@ -32,6 +33,7 @@
#include "drivers/St7789.h"
#include "drivers/Watchdog.h"
#include "systemtask/SystemTask.h"
+#include "systemtask/Messages.h"
#include "displayapp/screens/settings/QuickSettings.h"
#include "displayapp/screens/settings/Settings.h"
@@ -44,6 +46,12 @@
using namespace Pinetime::Applications;
using namespace Pinetime::Applications::Display;
+namespace {
+ static inline bool in_isr(void) {
+ return (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) != 0;
+ }
+}
+
DisplayApp::DisplayApp(Drivers::St7789& lcd,
Components::LittleVgl& lvgl,
Drivers::Cst816S& touchPanel,
@@ -51,7 +59,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
@@ -65,19 +72,20 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
bleController {bleController},
dateTimeController {dateTimeController},
watchdog {watchdog},
- systemTask {systemTask},
notificationManager {notificationManager},
heartRateController {heartRateController},
settingsController {settingsController},
motorController {motorController},
motionController {motionController},
timerController {timerController} {
+}
+
+void DisplayApp::Start() {
msgQueue = xQueueCreate(queueSize, itemSize);
+
// Start clock when smartwatch boots
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
-}
-void DisplayApp::Start() {
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
@@ -130,7 +138,7 @@ void DisplayApp::Refresh() {
vTaskDelay(100);
}
lcd.DisplayOff();
- systemTask.PushMessage(System::SystemTask::Messages::OnDisplayTaskSleeping);
+ PushMessageToSystemTask(Pinetime::System::Messages::OnDisplayTaskSleeping);
state = States::Idle;
break;
case Messages::GoToRunning:
@@ -139,7 +147,7 @@ void DisplayApp::Refresh() {
state = States::Running;
break;
case Messages::UpdateTimeOut:
- systemTask.PushMessage(System::SystemTask::Messages::UpdateTimeOut);
+ PushMessageToSystemTask(System::Messages::UpdateTimeOut);
break;
case Messages::UpdateBleConnection:
// clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected :
@@ -153,7 +161,7 @@ void DisplayApp::Refresh() {
break;
case Messages::TimerDone:
if (currentApp == Apps::Timer) {
- auto *timer = dynamic_cast<Screens::Timer*>(currentScreen.get());
+ auto *timer = static_cast<Screens::Timer*>(currentScreen.get());
timer->setDone();
} else {
LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
@@ -176,7 +184,7 @@ void DisplayApp::Refresh() {
LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim);
break;
case TouchEvents::DoubleTap:
- systemTask.PushMessage(System::SystemTask::Messages::GoToSleep);
+ PushMessageToSystemTask(System::Messages::GoToSleep);
break;
default:
break;
@@ -188,7 +196,7 @@ void DisplayApp::Refresh() {
} break;
case Messages::ButtonPushed:
if (currentApp == Apps::Clock) {
- systemTask.PushMessage(System::SystemTask::Messages::GoToSleep);
+ PushMessageToSystemTask(System::Messages::GoToSleep);
} else {
if (!currentScreen->OnButtonPushed()) {
LoadApp(returnToApp, returnDirection);
@@ -206,6 +214,11 @@ void DisplayApp::Refresh() {
}
}
+ if(nextApp != Apps::None) {
+ LoadApp(nextApp, nextDirection);
+ nextApp = Apps::None;
+ }
+
if (state != States::Idle && touchMode == TouchModes::Polling) {
auto info = touchPanel.GetTouchInfo();
if (info.action == 2) { // 2 = contact
@@ -224,7 +237,8 @@ void DisplayApp::RunningState() {
}
void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) {
- LoadApp(app, direction);
+ nextApp = app;
+ nextDirection = direction;
}
void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) {
@@ -267,12 +281,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Normal);
+ this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Normal);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::NotificationsPreview:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask.nimble().alertService(), Screens::Notifications::Modes::Preview);
+ this, notificationManager, systemTask->nimble().alertService(), Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::Timer:
@@ -305,7 +319,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- case Apps::SettingSteps:
+ case Apps::SettingSteps:
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
@@ -315,13 +329,11 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
break;
case Apps::SysInfo:
currentScreen =
- std::make_unique<Screens::SystemInfo>(this, dateTimeController, batteryController, brightnessController, bleController, watchdog);
+ std::make_unique<Screens::SystemInfo>(this, dateTimeController, batteryController, brightnessController, bleController, watchdog, motionController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- //
-
case Apps::FlashLight:
- currentScreen = std::make_unique<Screens::FlashLight>(this, systemTask, brightnessController);
+ currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
break;
case Apps::StopWatch:
@@ -337,18 +349,21 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::Paddle>(this, lvgl);
break;
case Apps::Music:
- currentScreen = std::make_unique<Screens::Music>(this, systemTask.nimble().music());
+ currentScreen = std::make_unique<Screens::Music>(this, systemTask->nimble().music());
break;
case Apps::Navigation:
- currentScreen = std::make_unique<Screens::Navigation>(this, systemTask.nimble().navigation());
+ currentScreen = std::make_unique<Screens::Navigation>(this, systemTask->nimble().navigation());
break;
case Apps::HeartRate:
- currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, systemTask);
+ currentScreen = std::make_unique<Screens::HeartRate>(this, heartRateController, *systemTask);
+ break;
+ case Apps::Metronome:
+ currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
break;
case Apps::Motion:
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
break;
- case Apps::Steps:
+ case Apps::Steps:
currentScreen = std::make_unique<Screens::Steps>(this, motionController, settingsController);
break;
}
@@ -359,12 +374,15 @@ void DisplayApp::IdleState() {
}
void DisplayApp::PushMessage(Messages msg) {
- BaseType_t xHigherPriorityTaskWoken;
- xHigherPriorityTaskWoken = pdFALSE;
- xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
- if (xHigherPriorityTaskWoken) {
- /* Actual macro used here is port specific. */
- // TODO : should I do something here?
+ if(in_isr()) {
+ BaseType_t xHigherPriorityTaskWoken;
+ xHigherPriorityTaskWoken = pdFALSE;
+ xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
+ if (xHigherPriorityTaskWoken) {
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ }
+ } else {
+ xQueueSend(msgQueue, &msg, portMAX_DELAY);
}
}
@@ -425,3 +443,12 @@ void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) {
void DisplayApp::SetTouchMode(DisplayApp::TouchModes mode) {
touchMode = mode;
}
+
+void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) {
+ if(systemTask != nullptr)
+ systemTask->PushMessage(message);
+}
+
+void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
+ this->systemTask = systemTask;
+}
diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h
index 0c7bd21..73a7cc3 100644
--- a/src/displayapp/DisplayApp.h
+++ b/src/displayapp/DisplayApp.h
@@ -4,6 +4,7 @@
#include <queue.h>
#include <task.h>
#include <memory>
+#include <systemtask/Messages.h>
#include "Apps.h"
#include "LittleVgl.h"
#include "TouchEvents.h"
@@ -49,7 +50,6 @@ namespace Pinetime {
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
@@ -64,6 +64,8 @@ namespace Pinetime {
void SetFullRefresh(FullRefreshDirections direction);
void SetTouchMode(TouchModes mode);
+ void Register(Pinetime::System::SystemTask* systemTask);
+
private:
Pinetime::Drivers::St7789& lcd;
Pinetime::Components::LittleVgl& lvgl;
@@ -72,7 +74,7 @@ namespace Pinetime {
Pinetime::Controllers::Ble& bleController;
Pinetime::Controllers::DateTime& dateTimeController;
Pinetime::Drivers::WatchdogView& watchdog;
- Pinetime::System::SystemTask& systemTask;
+ Pinetime::System::SystemTask* systemTask = nullptr;
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::HeartRateController& heartRateController;
Pinetime::Controllers::Settings& settingsController;
@@ -108,6 +110,10 @@ namespace Pinetime {
void Refresh();
void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent);
void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction);
+ void PushMessageToSystemTask(Pinetime::System::Messages message);
+
+ Apps nextApp = Apps::None;
+ DisplayApp::FullRefreshDirections nextDirection;
};
}
}
diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp
index 856eafd..fd517b1 100644
--- a/src/displayapp/DisplayAppRecovery.cpp
+++ b/src/displayapp/DisplayAppRecovery.cpp
@@ -14,7 +14,6 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
@@ -22,10 +21,11 @@ DisplayApp::DisplayApp(Drivers::St7789& lcd,
Pinetime::Controllers::MotionController& motionController,
Pinetime::Controllers::TimerController& timerController)
: lcd {lcd}, bleController {bleController} {
- msgQueue = xQueueCreate(queueSize, itemSize);
+
}
void DisplayApp::Start() {
+ msgQueue = xQueueCreate(queueSize, itemSize);
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 512, this, 0, &taskHandle))
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
@@ -113,4 +113,8 @@ void DisplayApp::PushMessage(Display::Messages msg) {
/* Actual macro used here is port specific. */
// TODO : should I do something here?
}
-} \ No newline at end of file
+}
+
+void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
+
+}
diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h
index 2c5a36f..638c007 100644
--- a/src/displayapp/DisplayAppRecovery.h
+++ b/src/displayapp/DisplayAppRecovery.h
@@ -39,7 +39,6 @@ namespace Pinetime {
Controllers::Ble& bleController,
Controllers::DateTime& dateTimeController,
Drivers::WatchdogView& watchdog,
- System::SystemTask& systemTask,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::HeartRateController& heartRateController,
Controllers::Settings& settingsController,
@@ -48,6 +47,7 @@ namespace Pinetime {
Pinetime::Controllers::TimerController& timerController);
void Start();
void PushMessage(Pinetime::Applications::Display::Messages msg);
+ void Register(Pinetime::System::SystemTask* systemTask);
private:
TaskHandle_t taskHandle;
diff --git a/src/displayapp/DummyLittleVgl.h b/src/displayapp/DummyLittleVgl.h
index 96cf153..016165b 100644
--- a/src/displayapp/DummyLittleVgl.h
+++ b/src/displayapp/DummyLittleVgl.h
@@ -19,6 +19,10 @@ namespace Pinetime {
LittleVgl(LittleVgl&&) = delete;
LittleVgl& operator=(LittleVgl&&) = delete;
+ void Init() {
+
+ }
+
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p) {
}
bool GetTouchPadInfo(lv_indev_data_t* ptr) {
diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp
index 36df51b..c069afa 100644
--- a/src/displayapp/LittleVgl.cpp
+++ b/src/displayapp/LittleVgl.cpp
@@ -23,6 +23,10 @@ bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) {
LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel)
: lcd {lcd}, touchPanel {touchPanel}, previousClick {0, 0} {
+
+}
+
+void LittleVgl::Init() {
lv_init();
InitTheme();
InitDisplay();
diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h
index 7f7b76e..41f934a 100644
--- a/src/displayapp/LittleVgl.h
+++ b/src/displayapp/LittleVgl.h
@@ -19,6 +19,8 @@ namespace Pinetime {
LittleVgl(LittleVgl&&) = delete;
LittleVgl& operator=(LittleVgl&&) = delete;
+ void Init();
+
void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
bool GetTouchPadInfo(lv_indev_data_t* ptr);
void SetFullRefresh(FullRefreshDirections direction);
diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c
index b003a41..1b8b198 100644
--- a/src/displayapp/lv_pinetime_theme.c
+++ b/src/displayapp/lv_pinetime_theme.c
@@ -48,6 +48,7 @@ static lv_style_t style_sw_bg;
static lv_style_t style_sw_indic;
static lv_style_t style_sw_knob;
static lv_style_t style_arc_bg;
+static lv_style_t style_arc_knob;
static lv_style_t style_arc_indic;
static lv_style_t style_table_cell;
static lv_style_t style_pad_small;
@@ -191,6 +192,7 @@ static void basic_init(void) {
lv_style_set_text_line_space(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 25);
lv_style_set_shadow_width(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 20);
lv_style_set_shadow_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
+ lv_style_set_bg_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
style_init_reset(&style_ddlist_selected);
lv_style_set_bg_opa(&style_ddlist_selected, LV_STATE_DEFAULT, LV_OPA_COVER);
@@ -239,6 +241,13 @@ static void basic_init(void) {
lv_style_set_line_color(&style_arc_bg, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_line_width(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(25));
lv_style_set_line_rounded(&style_arc_bg, LV_STATE_DEFAULT, true);
+ lv_style_set_pad_all(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(5));
+
+ lv_style_reset(&style_arc_knob);
+ lv_style_set_radius(&style_arc_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
+ lv_style_set_bg_opa(&style_arc_knob, LV_STATE_DEFAULT, LV_OPA_COVER);
+ lv_style_set_bg_color(&style_arc_knob, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY);
+ lv_style_set_pad_all(&style_arc_knob, LV_STATE_DEFAULT, LV_DPX(5));
style_init_reset(&style_table_cell);
lv_style_set_border_color(&style_table_cell, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
@@ -447,6 +456,10 @@ static void theme_apply(lv_obj_t* obj, lv_theme_style_t name) {
lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC);
list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC);
_lv_style_list_add_style(list, &style_arc_indic);
+
+ lv_obj_clean_style_list(obj, LV_ARC_PART_KNOB);
+ list = lv_obj_get_style_list(obj, LV_ARC_PART_KNOB);
+ _lv_style_list_add_style(list, &style_arc_knob);
break;
case LV_THEME_SWITCH:
diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp
index d599f5c..d434c17 100644
--- a/src/displayapp/screens/ApplicationList.cpp
+++ b/src/displayapp/screens/ApplicationList.cpp
@@ -63,7 +63,7 @@ std::unique_ptr<Screen> ApplicationList::CreateScreen2() {
{Symbols::paddle, Apps::Paddle},
{"2", Apps::Twos},
{"M", Apps::Motion},
- {"", Apps::None},
+ {"b", Apps::Metronome},
{"", Apps::None},
}};
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 1429984..05e47a3 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -33,21 +33,17 @@ Clock::Clock(DisplayApp* app,
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController},
- screens {app,
- settingsController.GetClockFace(),
- {
- [this]() -> std::unique_ptr<Screen> {
- return WatchFaceDigitalScreen();
- },
- [this]() -> std::unique_ptr<Screen> {
- return WatchFaceAnalogScreen();
- },
- // Examples for more watch faces
- //[this]() -> std::unique_ptr<Screen> { return WatchFaceMinimalScreen(); },
- //[this]() -> std::unique_ptr<Screen> { return WatchFaceCustomScreen(); }
- },
- Screens::ScreenListModes::LongPress} {
-
+ screen {[this, &settingsController]() {
+ switch (settingsController.GetClockFace()) {
+ case 0:
+ return WatchFaceDigitalScreen();
+ break;
+ case 1:
+ return WatchFaceAnalogScreen();
+ break;
+ }
+ return WatchFaceDigitalScreen();
+ }()} {
settingsController.SetAppMenu(0);
}
@@ -56,12 +52,12 @@ Clock::~Clock() {
}
bool Clock::Refresh() {
- screens.Refresh();
+ screen->Refresh();
return running;
}
bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
- return screens.OnTouchEvent(event);
+ return screen->OnTouchEvent(event);
}
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 9879985..174c73b 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -4,8 +4,8 @@
#include <chrono>
#include <cstdint>
#include <memory>
+#include <components/heartrate/HeartRateController.h>
#include "Screen.h"
-#include "ScreenList.h"
#include "components/datetime/DateTimeController.h"
namespace Pinetime {
@@ -47,7 +47,7 @@ namespace Pinetime {
Controllers::HeartRateController& heartRateController;
Controllers::MotionController& motionController;
- ScreenList<2> screens;
+ std::unique_ptr<Screen> screen;
std::unique_ptr<Screen> WatchFaceDigitalScreen();
std::unique_ptr<Screen> WatchFaceAnalogScreen();
diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp
index 4568db4..7db2c6c 100644
--- a/src/displayapp/screens/FlashLight.cpp
+++ b/src/displayapp/screens/FlashLight.cpp
@@ -39,14 +39,14 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app,
backgroundAction->user_data = this;
lv_obj_set_event_cb(backgroundAction, event_handler);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
}
FlashLight::~FlashLight() {
lv_obj_clean(lv_scr_act());
lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
brightness.Restore();
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) {
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 90f6bc2..5689b63 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -63,12 +63,12 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
label_startStop = lv_label_create(btn_startStop, nullptr);
UpdateStartStopButton(isHrRunning);
if (isHrRunning)
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
}
HeartRate::~HeartRate() {
lv_obj_clean(lv_scr_act());
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
}
bool HeartRate::Refresh() {
@@ -95,12 +95,12 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) {
heartRateController.Start();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::DisableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN);
} else {
heartRateController.Stop();
UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped);
- systemTask.PushMessage(Pinetime::System::SystemTask::Messages::EnableSleeping);
+ systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping);
lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
}
}
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
new file mode 100644
index 0000000..7bfbccb
--- /dev/null
+++ b/src/displayapp/screens/Metronome.cpp
@@ -0,0 +1,169 @@
+#include "Metronome.h"
+
+#include "Screen.h"
+#include "Symbols.h"
+#include "lvgl/lvgl.h"
+#include "FreeRTOSConfig.h"
+#include "task.h"
+
+#include <string>
+#include <tuple>
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ float calculateDelta(const TickType_t startTime, const TickType_t currentTime) {
+ TickType_t delta = 0;
+ // Take care of overflow
+ if (startTime > currentTime) {
+ delta = 0xffffffff - startTime;
+ delta += (currentTime + 1);
+ } else {
+ delta = currentTime - startTime;
+ }
+ return static_cast<float>(delta) / static_cast<float>(configTICK_RATE_HZ);
+ }
+
+ static void eventHandler(lv_obj_t* obj, lv_event_t event) {
+ Metronome* screen = static_cast<Metronome*>(obj->user_data);
+ screen->OnEvent(obj, event);
+ }
+
+ lv_obj_t* createLabel(const char* name, lv_obj_t* reference, lv_align_t align, lv_font_t* font, uint8_t x = 0, uint8_t y = 0) {
+ lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_font(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font);
+ lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
+ lv_label_set_text(label, name);
+ lv_obj_align(label, reference, align, x, y);
+
+ return label;
+ }
+}
+
+Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask)
+ : Screen(app), running {true}, currentState {States::Stopped}, startTime {}, motorController {motorController}, systemTask {systemTask} {
+
+ bpmArc = lv_arc_create(lv_scr_act(), nullptr);
+ bpmArc->user_data = this;
+ lv_obj_set_event_cb(bpmArc, eventHandler);
+ lv_arc_set_bg_angles(bpmArc, 0, 270);
+ lv_arc_set_rotation(bpmArc, 135);
+ lv_arc_set_range(bpmArc, 40, 220);
+ lv_arc_set_value(bpmArc, bpm);
+ lv_obj_set_size(bpmArc, 210, 210);
+ lv_arc_set_adjustable(bpmArc, true);
+ lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 7);
+
+ bpmValue = createLabel(std::to_string(lv_arc_get_value(bpmArc)).c_str(), bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55);
+ bpmLegend = createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0);
+
+ bpmTap = lv_btn_create(lv_scr_act(), nullptr);
+ bpmTap->user_data = this;
+ lv_obj_set_event_cb(bpmTap, eventHandler);
+ lv_obj_set_style_local_bg_opa(bpmTap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
+ lv_obj_set_height(bpmTap, 80);
+ lv_obj_align(bpmTap, bpmValue, LV_ALIGN_IN_TOP_MID, 0, 0);
+
+ bpbDropdown = lv_dropdown_create(lv_scr_act(), nullptr);
+ bpbDropdown->user_data = this;
+ lv_obj_set_event_cb(bpbDropdown, eventHandler);
+ lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_MAIN, LV_STATE_DEFAULT, 20);
+ lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_LIST, LV_STATE_DEFAULT, 20);
+ lv_obj_align(bpbDropdown, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 15, -4);
+ lv_dropdown_set_options(bpbDropdown, "1\n2\n3\n4\n5\n6\n7\n8\n9");
+ lv_dropdown_set_selected(bpbDropdown, bpb - 1);
+ bpbLegend = lv_label_create(bpbDropdown, nullptr);
+ lv_label_set_text(bpbLegend, "bpb");
+ lv_obj_align(bpbLegend, bpbDropdown, LV_ALIGN_IN_RIGHT_MID, -15, 0);
+
+ playPause = lv_btn_create(lv_scr_act(), nullptr);
+ playPause->user_data = this;
+ lv_obj_set_event_cb(playPause, eventHandler);
+ lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -15, -10);
+ lv_obj_set_height(playPause, 39);
+ playPauseLabel = lv_label_create(playPause, nullptr);
+ lv_label_set_text(playPauseLabel, Symbols::play);
+
+ app->SetTouchMode(DisplayApp::TouchModes::Polling);
+}
+
+Metronome::~Metronome() {
+ app->SetTouchMode(DisplayApp::TouchModes::Gestures);
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ lv_obj_clean(lv_scr_act());
+}
+
+bool Metronome::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
+ return true;
+}
+
+bool Metronome::Refresh() {
+ switch (currentState) {
+ case States::Stopped: {
+ break;
+ }
+ case States::Running: {
+ if (calculateDelta(startTime, xTaskGetTickCount()) >= (60.0 / bpm)) {
+ counter--;
+ startTime -= 60.0 / bpm;
+ startTime = xTaskGetTickCount();
+ if (counter == 0) {
+ counter = bpb;
+ motorController.SetDuration(90);
+ } else {
+ motorController.SetDuration(30);
+ }
+ }
+ break;
+ }
+ }
+ return running;
+}
+
+void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
+ switch (event) {
+ case LV_EVENT_VALUE_CHANGED: {
+ if (obj == bpmArc) {
+ bpm = lv_arc_get_value(bpmArc);
+ lv_label_set_text_fmt(bpmValue, "%03d", bpm);
+ } else if (obj == bpbDropdown) {
+ bpb = lv_dropdown_get_selected(obj) + 1;
+ }
+ break;
+ }
+ case LV_EVENT_PRESSED: {
+ if (obj == bpmTap) {
+ float timeDelta = calculateDelta(tappedTime, xTaskGetTickCount());
+ if (tappedTime == 0 || timeDelta > 3) {
+ tappedTime = xTaskGetTickCount();
+ } else {
+ bpm = ceil(60.0 / timeDelta);
+ lv_arc_set_value(bpmArc, bpm);
+ lv_label_set_text_fmt(bpmValue, "%03d", bpm);
+ tappedTime = xTaskGetTickCount();
+ }
+ }
+ break;
+ }
+ case LV_EVENT_CLICKED: {
+ if (obj == playPause) {
+ currentState = (currentState == States::Stopped ? States::Running : States::Stopped);
+ switch (currentState) {
+ case States::Stopped: {
+ lv_label_set_text(playPauseLabel, Symbols::play);
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ break;
+ }
+ case States::Running: {
+ lv_label_set_text(playPauseLabel, Symbols::pause);
+ systemTask.PushMessage(System::Messages::DisableSleeping);
+ startTime = xTaskGetTickCount();
+ counter = 1;
+ break;
+ }
+ }
+ }
+ break;
+ }
+ }
+}
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
new file mode 100644
index 0000000..3a1f108
--- /dev/null
+++ b/src/displayapp/screens/Metronome.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "systemtask/SystemTask.h"
+#include "components/motor/MotorController.h"
+
+#include <array>
+
+namespace Pinetime::Applications::Screens {
+
+ class Metronome : public Screen {
+ public:
+ Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask);
+ ~Metronome() override;
+ bool Refresh() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ void OnEvent(lv_obj_t* obj, lv_event_t event);
+ enum class States { Running, Stopped };
+
+ private:
+ bool running;
+ States currentState;
+ TickType_t startTime;
+ TickType_t tappedTime = 0;
+ Controllers::MotorController& motorController;
+ System::SystemTask& systemTask;
+ uint16_t bpm = 120;
+ uint8_t bpb = 4;
+ uint8_t counter = 1;
+
+ lv_obj_t *bpmArc, *bpmTap, *bpmValue, *bpmLegend;
+ lv_obj_t *bpbDropdown, *bpbLegend;
+ lv_obj_t *playPause, *playPauseLabel;
+ };
+}
diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp
index b5ce8b8..79b04e2 100644
--- a/src/displayapp/screens/Navigation.cpp
+++ b/src/displayapp/screens/Navigation.cpp
@@ -24,6 +24,106 @@ using namespace Pinetime::Applications::Screens;
LV_FONT_DECLARE(lv_font_navi_80)
+namespace {
+ constexpr std::array<std::pair<const char*, const char*>, 86> m_iconMap = {{
+ {"arrive-left", "\xEE\xA4\x81"},
+ {"arrive-right", "\xEE\xA4\x82"},
+ {"arrive-straight", "\xEE\xA4\x80"},
+ {"arrive", "\xEE\xA4\x80"},
+ {"close", "\xEE\xA4\x83"},
+ {"continue-left", "\xEE\xA4\x85"},
+ {"continue-right", "\xEE\xA4\x86"},
+ {"continue-slight-left", "\xEE\xA4\x87"},
+ {"continue-slight-right", "\xEE\xA4\x88"},
+ {"continue-straight", "\xEE\xA4\x84"},
+ {"continue-uturn", "\xEE\xA4\x89"},
+ {"continue", "\xEE\xA4\x84"},
+ {"depart-left", "\xEE\xA4\x8B"},
+ {"depart-right", "\xEE\xA4\x8C"},
+ {"depart-straight", "\xEE\xA4\x8A"},
+ {"end-of-road-left", "\xEE\xA4\x8D"},
+ {"end-of-road-right", "\xEE\xA4\x8E"},
+ {"ferry", "\xEE\xA4\x8F"},
+ {"flag", "\xEE\xA4\x90"},
+ {"fork-left", "\xEE\xA4\x92"},
+ {"fork-right", "\xEE\xA4\x93"},
+ {"fork-slight-left", "\xEE\xA4\x94"},
+ {"fork-slight-right", "\xEE\xA4\x95"},
+ {"fork-straight", "\xEE\xA4\x96"},
+ {"invalid", "\xEE\xA4\x84"},
+ {"invalid-left", "\xEE\xA4\x85"},
+ {"invalid-right", "\xEE\xA4\x86"},
+ {"invalid-slight-left", "\xEE\xA4\x87"},
+ {"invalid-slight-right", "\xEE\xA4\x88"},
+ {"invalid-straight", "\xEE\xA4\x84"},
+ {"invalid-uturn", "\xEE\xA4\x89"},
+ {"merge-left", "\xEE\xA4\x97"},
+ {"merge-right", "\xEE\xA4\x98"},
+ {"merge-slight-left", "\xEE\xA4\x99"},
+ {"merge-slight-right", "\xEE\xA4\x9A"},
+ {"merge-straight", "\xEE\xA4\x84"},
+ {"new-name-left", "\xEE\xA4\x85"},
+ {"new-name-right", "\xEE\xA4\x86"},
+ {"new-name-sharp-left", "\xEE\xA4\x9B"},
+ {"new-name-sharp-right", "\xEE\xA4\x9C"},
+ {"new-name-slight-left", "\xEE\xA4\x87"},
+ {"new-name-slight-right", "\xEE\xA4\x88"},
+ {"new-name-straight", "\xEE\xA4\x84"},
+ {"notification-left", "\xEE\xA4\x85"},
+ {"notification-right", "\xEE\xA4\x86"},
+ {"notification-sharp-left", "\xEE\xA4\x9B"},
+ {"notification-sharp-right", "\xEE\xA4\xA5"},
+ {"notification-slight-left", "\xEE\xA4\x87"},
+ {"notification-slight-right", "\xEE\xA4\x88"},
+ {"notification-straight", "\xEE\xA4\x84"},
+ {"off-ramp-left", "\xEE\xA4\x9D"},
+ {"off-ramp-right", "\xEE\xA4\x9E"},
+ {"off-ramp-slight-left", "\xEE\xA4\x9F"},
+ {"off-ramp-slight-right", "\xEE\xA4\xA0"},
+ {"on-ramp-left", "\xEE\xA4\x85"},
+ {"on-ramp-right", "\xEE\xA4\x86"},
+ {"on-ramp-sharp-left", "\xEE\xA4\x9B"},
+ {"on-ramp-sharp-right", "\xEE\xA4\xA5"},
+ {"on-ramp-slight-left", "\xEE\xA4\x87"},
+ {"on-ramp-slight-right", "\xEE\xA4\x88"},
+ {"on-ramp-straight", "\xEE\xA4\x84"},
+ {"rotary", "\xEE\xA4\xA1"},
+ {"rotary-left", "\xEE\xA4\xA2"},
+ {"rotary-right", "\xEE\xA4\xA3"},
+ {"rotary-sharp-left", "\xEE\xA4\xA4"},
+ {"rotary-sharp-right", "\xEE\xA4\xA5"},
+ {"rotary-slight-left", "\xEE\xA4\xA6"},
+ {"rotary-slight-right", "\xEE\xA4\xA7"},
+ {"rotary-straight", "\xEE\xA4\xA8"},
+ {"roundabout", "\xEE\xA4\xA1"},
+ {"roundabout-left", "\xEE\xA4\xA2"},
+ {"roundabout-right", "\xEE\xA4\xA3"},
+ {"roundabout-sharp-left", "\xEE\xA4\xA4"},
+ {"roundabout-sharp-right", "\xEE\xA4\xA5"},
+ {"roundabout-slight-left", "\xEE\xA4\xA6"},
+ {"roundabout-slight-right", "\xEE\xA4\xA7"},
+ {"roundabout-straight", "\xEE\xA4\xA8"},
+ {"turn-left", "\xEE\xA4\x85"},
+ {"turn-right", "\xEE\xA4\x86"},
+ {"turn-sharp-left", "\xEE\xA4\x9B"},
+ {"turn-sharp-right", "\xEE\xA4\xA5"},
+ {"turn-slight-left", "\xEE\xA4\x87"},
+ {"turn-slight-right", "\xEE\xA4\x88"},
+ {"turn-straight", "\xEE\xA4\x84"},
+ {"updown", "\xEE\xA4\xA9"},
+ {"uturn", "\xEE\xA4\x89"},
+ }};
+
+ const char* iconForName(const std::string& icon) {
+ for (auto iter : m_iconMap) {
+ if (iter.first == icon) {
+ return iter.second;
+ }
+ }
+ return "\xEE\xA4\x90";
+ }
+}
+
/**
* Navigation watchapp
*
@@ -68,27 +168,25 @@ Navigation::~Navigation() {
}
bool Navigation::Refresh() {
-
- if (m_flag != navService.getFlag()) {
- m_flag = navService.getFlag();
- lv_label_set_text(imgFlag, iconForName(m_flag));
- // lv_img_set_src_arr(imgFlag, iconForName(m_flag));
+ if (flag != navService.getFlag()) {
+ flag = navService.getFlag();
+ lv_label_set_text(imgFlag, iconForName(flag));
}
- if (m_narrative != navService.getNarrative()) {
- m_narrative = navService.getNarrative();
- lv_label_set_text(txtNarrative, m_narrative.data());
+ if (narrative != navService.getNarrative()) {
+ narrative = navService.getNarrative();
+ lv_label_set_text(txtNarrative, narrative.data());
}
- if (m_manDist != navService.getManDist()) {
- m_manDist = navService.getManDist();
- lv_label_set_text(txtManDist, m_manDist.data());
+ if (manDist != navService.getManDist()) {
+ manDist = navService.getManDist();
+ lv_label_set_text(txtManDist, manDist.data());
}
- if (m_progress != navService.getProgress()) {
- m_progress = navService.getProgress();
- lv_bar_set_value(barProgress, m_progress, LV_ANIM_OFF);
- if (m_progress > 90) {
+ if (progress != navService.getProgress()) {
+ progress = navService.getProgress();
+ lv_bar_set_value(barProgress, progress, LV_ANIM_OFF);
+ if (progress > 90) {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
} else {
lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
@@ -98,11 +196,4 @@ bool Navigation::Refresh() {
return running;
}
-const char* Navigation::iconForName(std::string icon) {
- for (auto iter : m_iconMap) {
- if (iter.first == icon) {
- return iter.second;
- }
- }
- return "\xEE\xA4\x90";
-}
+
diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h
index 46816c3..eb7e00c 100644
--- a/src/displayapp/screens/Navigation.h
+++ b/src/displayapp/screens/Navigation.h
@@ -45,103 +45,10 @@ namespace Pinetime {
Pinetime::Controllers::NavigationService& navService;
- std::string m_flag;
- std::string m_narrative;
- std::string m_manDist;
- int m_progress;
-
- /** Watchapp */
-
- const char* iconForName(std::string icon);
-
- std::array<std::pair<std::string, const char*>, 89> m_iconMap = {{
- {"arrive-left", "\xEE\xA4\x81"},
- {"arrive-right", "\xEE\xA4\x82"},
- {"arrive-straight", "\xEE\xA4\x80"},
- {"arrive", "\xEE\xA4\x80"},
- {"close", "\xEE\xA4\x83"},
- {"continue-left", "\xEE\xA4\x85"},
- {"continue-right", "\xEE\xA4\x86"},
- {"continue-slight-left", "\xEE\xA4\x87"},
- {"continue-slight-right", "\xEE\xA4\x88"},
- {"continue-straight", "\xEE\xA4\x84"},
- {"continue-uturn", "\xEE\xA4\x89"},
- {"continue", "\xEE\xA4\x84"},
- {"depart-left", "\xEE\xA4\x8B"},
- {"depart-right", "\xEE\xA4\x8C"},
- {"depart-straight", "\xEE\xA4\x8A"},
- {"end-of-road-left", "\xEE\xA4\x8D"},
- {"end-of-road-right", "\xEE\xA4\x8E"},
- {"ferry", "\xEE\xA4\x8F"},
- {"flag", "\xEE\xA4\x90"},
- {"fork-left", "\xEE\xA4\x92"},
- {"fork-right", "\xEE\xA4\x93"},
- {"fork-slight-left", "\xEE\xA4\x94"},
- {"fork-slight-right", "\xEE\xA4\x95"},
- {"fork-straight", "\xEE\xA4\x96"},
- {"invalid", "\xEE\xA4\x84"},
- {"invalid-left", "\xEE\xA4\x85"},
- {"invalid-right", "\xEE\xA4\x86"},
- {"invalid-slight-left", "\xEE\xA4\x87"},
- {"invalid-slight-right", "\xEE\xA4\x88"},
- {"invalid-straight", "\xEE\xA4\x84"},
- {"invalid-uturn", "\xEE\xA4\x89"},
- {"merge-left", "\xEE\xA4\x97"},
- {"merge-right", "\xEE\xA4\x98"},
- {"merge-slight-left", "\xEE\xA4\x99"},
- {"merge-slight-right", "\xEE\xA4\x9A"},
- {"merge-straight", "\xEE\xA4\x84"},
- {"new-name-left", "\xEE\xA4\x85"},
- {"new-name-right", "\xEE\xA4\x86"},
- {"new-name-sharp-left", "\xEE\xA4\x9B"},
- {"new-name-sharp-right", "\xEE\xA4\x9C"},
- {"new-name-slight-left", "\xEE\xA4\x87"},
- {"new-name-slight-right", "\xEE\xA4\x88"},
- {"new-name-straight", "\xEE\xA4\x84"},
- {"notification-left", "\xEE\xA4\x85"},
- {"notification-right", "\xEE\xA4\x86"},
- {"notification-sharp-left", "\xEE\xA4\x9B"},
- {"notification-sharp-right", "\xEE\xA4\xA5"},
- {"notification-slight-left", "\xEE\xA4\x87"},
- {"notification-slight-right", "\xEE\xA4\x88"},
- {"notification-straight", "\xEE\xA4\x84"},
- {"off-ramp-left", "\xEE\xA4\x9D"},
- {"off-ramp-right", "\xEE\xA4\x9E"},
- {"off-ramp-slight-left", "\xEE\xA4\x9F"},
- {"off-ramp-slight-right", "\xEE\xA4\xA0"},
- {"on-ramp-left", "\xEE\xA4\x85"},
- {"on-ramp-right", "\xEE\xA4\x86"},
- {"on-ramp-sharp-left", "\xEE\xA4\x9B"},
- {"on-ramp-sharp-right", "\xEE\xA4\xA5"},
- {"on-ramp-slight-left", "\xEE\xA4\x87"},
- {"on-ramp-slight-right", "\xEE\xA4\x88"},
- {"on-ramp-straight", "\xEE\xA4\x84"},
- {"rotary", "\xEE\xA4\xA1"},
- {"rotary-left", "\xEE\xA4\xA2"},
- {"rotary-right", "\xEE\xA4\xA3"},
- {"rotary-sharp-left", "\xEE\xA4\xA4"},
- {"rotary-sharp-right", "\xEE\xA4\xA5"},
- {"rotary-slight-left", "\xEE\xA4\xA6"},
- {"rotary-slight-right", "\xEE\xA4\xA7"},
- {"rotary-straight", "\xEE\xA4\xA8"},
- {"roundabout", "\xEE\xA4\xA1"},
- {"roundabout-left", "\xEE\xA4\xA2"},
- {"roundabout-right", "\xEE\xA4\xA3"},
- {"roundabout-sharp-left", "\xEE\xA4\xA4"},
- {"roundabout-sharp-right", "\xEE\xA4\xA5"},
- {"roundabout-slight-left", "\xEE\xA4\xA6"},
- {"roundabout-slight-right", "\xEE\xA4\xA7"},
- {"roundabout-straight", "\xEE\xA4\xA8"},
- {"turn-left", "\xEE\xA4\x85"},
- {"turn-right", "\xEE\xA4\x86"},
- {"turn-sharp-left", "\xEE\xA4\x9B"},
- {"turn-sharp-right", "\xEE\xA4\xA5"},
- {"turn-slight-left", "\xEE\xA4\x87"},
- {"turn-slight-right", "\xEE\xA4\x88"},
- {"turn-straight", "\xEE\xA4\x84"},
- {"updown", "\xEE\xA4\xA9"},
- {"uturn", "\xEE\xA4\x89"},
- }};
+ std::string flag;
+ std::string narrative;
+ std::string manDist;
+ int progress;
};
}
}
diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h
index 73ea461..ea66bfb 100644
--- a/src/displayapp/screens/ScreenList.h
+++ b/src/displayapp/screens/ScreenList.h
@@ -15,12 +15,17 @@ namespace Pinetime {
public:
ScreenList(DisplayApp* app,
uint8_t initScreen,
- std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
+ const std::array<std::function<std::unique_ptr<Screen>()>, N>&& screens,
ScreenListModes mode)
- : Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, current {this->screens[initScreen]()} {
- screenIndex = initScreen;
+ : Screen(app), initScreen {initScreen}, screens {std::move(screens)}, mode {mode}, screenIndex{initScreen}, current {this->screens[initScreen]()} {
+
}
+ ScreenList(const ScreenList&) = delete;
+ ScreenList& operator=(const ScreenList&) = delete;
+ ScreenList(ScreenList&&) = delete;
+ ScreenList& operator=(ScreenList&&) = delete;
+
~ScreenList() override {
lv_obj_clean(lv_scr_act());
}
@@ -97,7 +102,7 @@ namespace Pinetime {
private:
uint8_t initScreen = 0;
- std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
+ const std::array<std::function<std::unique_ptr<Screen>()>, N> screens;
ScreenListModes mode = ScreenListModes::UpDown;
uint8_t screenIndex = 0;
diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp
index d7cd20c..7c128d1 100644
--- a/src/displayapp/screens/StopWatch.cpp
+++ b/src/displayapp/screens/StopWatch.cpp
@@ -61,22 +61,36 @@ StopWatch::StopWatch(DisplayApp* app)
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_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -45);
+ 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_obj_align(msecTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 108, 3);
+ lv_obj_align(msecTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 3);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
lv_obj_set_event_cb(btnPlayPause, play_pause_event_handler);
- lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, -10);
- lv_obj_set_height(btnPlayPause, 40);
+ lv_obj_set_height(btnPlayPause, 50);
+ 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);
+ btnStopLap = lv_btn_create(lv_scr_act(), nullptr);
+ btnStopLap->user_data = this;
+ lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler);
+ lv_obj_set_height(btnStopLap, 50);
+ lv_obj_set_width(btnStopLap, 115);
+ lv_obj_align(btnStopLap, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ 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_obj_set_state(btnStopLap, LV_STATE_DISABLED);
+ lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
+
lapOneText = lv_label_create(lv_scr_act(), nullptr);
// 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);
@@ -88,9 +102,6 @@ StopWatch::StopWatch(DisplayApp* app)
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, "");
-
- // We don't want this button in the init state
- btnStopLap = nullptr;
}
StopWatch::~StopWatch() {
@@ -115,10 +126,6 @@ bool StopWatch::Refresh() {
// Init state when an user first opens the app
// and when a stop/reset button is pressed
case States::Init: {
- if (btnStopLap != nullptr) {
- lv_obj_del(btnStopLap);
- btnStopLap = nullptr;
- }
// The initial default value
lv_label_set_text(time, "00:00");
lv_label_set_text(msecTime, "00");
@@ -129,16 +136,14 @@ bool StopWatch::Refresh() {
lapNr = 0;
if (currentEvent == Events::Play) {
- btnStopLap = lv_btn_create(lv_scr_act(), nullptr);
- btnStopLap->user_data = this;
- lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler);
- lv_obj_align(btnStopLap, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
- lv_obj_set_height(btnStopLap, 40);
- txtStopLap = lv_label_create(btnStopLap, nullptr);
- lv_label_set_text(txtStopLap, Symbols::lapsFlag);
+ lv_obj_set_state(btnStopLap, LV_STATE_DEFAULT);
+ lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT);
startTime = xTaskGetTickCount();
currentState = States::Running;
+ } else {
+ lv_obj_set_state(btnStopLap, LV_STATE_DISABLED);
+ lv_obj_set_state(txtStopLap, LV_STATE_DISABLED);
}
break;
}
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index e4ef691..0b16d63 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -7,22 +7,37 @@
#include "components/ble/BleController.h"
#include "components/brightness/BrightnessController.h"
#include "components/datetime/DateTimeController.h"
+#include "components/motion/MotionController.h"
#include "drivers/Watchdog.h"
using namespace Pinetime::Applications::Screens;
+namespace {
+ const char* ToString(const Pinetime::Controllers::MotionController::DeviceTypes deviceType) {
+ switch (deviceType) {
+ case Pinetime::Controllers::MotionController::DeviceTypes::BMA421:
+ return "BMA421";
+ case Pinetime::Controllers::MotionController::DeviceTypes::BMA425:
+ return "BMA425";
+ }
+ return "???";
+ }
+}
+
SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::DateTime& dateTimeController,
Pinetime::Controllers::Battery& batteryController,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::Ble& bleController,
- Pinetime::Drivers::WatchdogView& watchdog)
+ Pinetime::Drivers::WatchdogView& watchdog,
+ Pinetime::Controllers::MotionController& motionController)
: Screen(app),
dateTimeController {dateTimeController},
batteryController {batteryController},
brightnessController {brightnessController},
bleController {bleController},
watchdog {watchdog},
+ motionController{motionController},
screens {app,
0,
{[this]() -> std::unique_ptr<Screen> {
@@ -81,7 +96,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
__TIME__);
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
+ return std::make_unique<Screens::Label>(0, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
@@ -132,9 +147,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
// hack to not use the flot functions from printf
uint8_t batteryVoltageBytes[2];
batteryVoltageBytes[1] = static_cast<uint8_t>(batteryVoltage); // truncate whole numbers
- batteryVoltageBytes[0] =
- static_cast<uint8_t>((batteryVoltage - batteryVoltageBytes[1]) * 100); // remove whole part of flt and shift 2 places over
- //
+ batteryVoltageBytes[0] = static_cast<uint8_t>((batteryVoltage - batteryVoltageBytes[1]) * 100); // remove whole part of flt and shift 2 places over
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label, true);
@@ -144,7 +157,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
"#444444 Uptime#\n %02lud %02lu:%02lu:%02lu\n"
"#444444 Battery# %d%%/%1i.%02iv\n"
"#444444 Backlight# %s\n"
- "#444444 Last reset# %s\n",
+ "#444444 Last reset# %s\n"
+ "#444444 Accel.# %s\n",
dateTimeController.Day(),
static_cast<uint8_t>(dateTimeController.Month()),
dateTimeController.Year(),
@@ -159,9 +173,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
batteryVoltageBytes[1],
batteryVoltageBytes[0],
brightnessController.ToString(),
- resetReason);
+ resetReason,
+ ToString(motionController.DeviceType()));
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(1, 4, app, label));
+ return std::make_unique<Screens::Label>(1, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@@ -175,8 +190,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
"#444444 BLE MAC#\n"
" %02x:%02x:%02x:%02x:%02x:%02x"
"\n"
- "#444444 Memory#\n"
+ "#444444 LVGL Memory#\n"
" #444444 used# %d (%d%%)\n"
+ " #444444 max used# %d\n"
" #444444 frag# %d%%\n"
" #444444 free# %d"
"\n"
@@ -189,14 +205,15 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
bleAddr[0],
(int) mon.total_size - mon.free_size,
mon.used_pct,
+ mon.max_used,
mon.frag_pct,
(int) mon.free_biggest_size,
0);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(2, 5, app, label));
+ return std::make_unique<Screens::Label>(2, 5, app, label);
}
-bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
+bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
return lhs.xTaskNumber < rhs.xTaskNumber;
}
@@ -227,7 +244,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
}
}
- return std::unique_ptr<Screen>(new Screens::Label(3, 5, app, infoTask));
+ return std::make_unique<Screens::Label>(3, 5, app, infoTask);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
@@ -243,5 +260,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"#FFFF00 JF002/InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(4, 5, app, label));
+ 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 c0c6555..9d471f6 100644
--- a/src/displayapp/screens/SystemInfo.h
+++ b/src/displayapp/screens/SystemInfo.h
@@ -27,7 +27,8 @@ namespace Pinetime {
Pinetime::Controllers::Battery& batteryController,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::Ble& bleController,
- Pinetime::Drivers::WatchdogView& watchdog);
+ Pinetime::Drivers::WatchdogView& watchdog,
+ Pinetime::Controllers::MotionController& motionController);
~SystemInfo() override;
bool Refresh() override;
bool OnButtonPushed() override;
@@ -41,8 +42,12 @@ namespace Pinetime {
Pinetime::Controllers::BrightnessController& brightnessController;
Pinetime::Controllers::Ble& bleController;
Pinetime::Drivers::WatchdogView& watchdog;
+ Pinetime::Controllers::MotionController& motionController;
ScreenList<5> screens;
+
+ static bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs);
+
std::unique_ptr<Screen> CreateScreen1();
std::unique_ptr<Screen> CreateScreen2();
std::unique_ptr<Screen> CreateScreen3();
diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp
index 3994794..5db7468 100644
--- a/src/displayapp/screens/settings/QuickSettings.cpp
+++ b/src/displayapp/screens/settings/QuickSettings.cpp
@@ -7,12 +7,12 @@ using namespace Pinetime::Applications::Screens;
namespace {
static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) {
- QuickSettings* screen = static_cast<QuickSettings*>(obj->user_data);
+ auto* screen = static_cast<QuickSettings*>(obj->user_data);
screen->OnButtonEvent(obj, event);
}
static void lv_update_task(struct _lv_task_t* task) {
- auto user_data = static_cast<QuickSettings*>(task->user_data);
+ auto* user_data = static_cast<QuickSettings*>(task->user_data);
user_data->UpdateScreen();
}
}
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 2c72c83..e63a358 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -46,7 +46,7 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
{Symbols::clock, "Watch face", Apps::SettingWatchFace},
}};
- return std::unique_ptr<Screen>(new Screens::List(0, 2, app, settingsController, applications));
+ return std::make_unique<Screens::List>(0, 2, app, settingsController, applications);
}
std::unique_ptr<Screen> Settings::CreateScreen2() {
@@ -58,5 +58,5 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
{Symbols::list, "About", Apps::SysInfo},
}};
- return std::unique_ptr<Screen>(new Screens::List(1, 2, app, settingsController, applications));
+ return std::make_unique<Screens::List>(1, 2, app, settingsController, applications);
}
diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h
index 7e332df..711a6be 100644
--- a/src/displayapp/screens/settings/Settings.h
+++ b/src/displayapp/screens/settings/Settings.h
@@ -16,7 +16,6 @@ namespace Pinetime {
bool Refresh() override;
- void OnButtonEvent(lv_obj_t* object, lv_event_t event);
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
private: