summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/Apps.h5
-rw-r--r--src/displayapp/DisplayApp.cpp26
-rw-r--r--src/displayapp/Messages.h3
-rw-r--r--src/displayapp/screens/Clock.cpp4
-rw-r--r--src/displayapp/screens/Clock.h1
-rw-r--r--src/displayapp/screens/InfiniPaint.cpp2
-rw-r--r--src/displayapp/screens/Metronome.cpp15
-rw-r--r--src/displayapp/screens/Metronome.h2
-rw-r--r--src/displayapp/screens/Music.cpp14
-rw-r--r--src/displayapp/screens/Notifications.cpp52
-rw-r--r--src/displayapp/screens/Notifications.h10
-rw-r--r--src/displayapp/screens/PineTimeStyle.cpp403
-rw-r--r--src/displayapp/screens/PineTimeStyle.h25
-rw-r--r--src/displayapp/screens/Steps.cpp49
-rw-r--r--src/displayapp/screens/Steps.h6
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp105
-rw-r--r--src/displayapp/screens/WatchFaceDigital.h3
-rw-r--r--src/displayapp/screens/settings/SettingChimes.cpp100
-rw-r--r--src/displayapp/screens/settings/SettingChimes.h27
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.cpp318
-rw-r--r--src/displayapp/screens/settings/SettingPineTimeStyle.h56
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp137
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.h36
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.cpp8
-rw-r--r--src/displayapp/screens/settings/SettingWakeUp.h2
-rw-r--r--src/displayapp/screens/settings/Settings.cpp16
26 files changed, 867 insertions, 558 deletions
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index b2f55ccd..b876020e 100644
--- a/src/displayapp/Apps.h
+++ b/src/displayapp/Apps.h
@@ -34,10 +34,11 @@ namespace Pinetime {
SettingDisplay,
SettingWakeUp,
SettingSteps,
- SettingPineTimeStyle,
SettingSetDate,
SettingSetTime,
- Error,
+ SettingChimes,
+ SettingShakeThreshold,
+ Error
};
}
}
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 233f433d..cc544fdb 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -45,9 +45,10 @@
#include "displayapp/screens/settings/SettingWakeUp.h"
#include "displayapp/screens/settings/SettingDisplay.h"
#include "displayapp/screens/settings/SettingSteps.h"
-#include "displayapp/screens/settings/SettingPineTimeStyle.h"
#include "displayapp/screens/settings/SettingSetDate.h"
#include "displayapp/screens/settings/SettingSetTime.h"
+#include "displayapp/screens/settings/SettingChimes.h"
+#include "displayapp/screens/settings/SettingShakeThreshold.h"
#include "libs/lv_conf.h"
@@ -255,10 +256,10 @@ void DisplayApp::Refresh() {
}
} break;
case Messages::ButtonPushed:
- if (currentApp == Apps::Clock) {
- PushMessageToSystemTask(System::Messages::GoToSleep);
- } else {
- if (!currentScreen->OnButtonPushed()) {
+ if (!currentScreen->OnButtonPushed()) {
+ if (currentApp == Apps::Clock) {
+ PushMessageToSystemTask(System::Messages::GoToSleep);
+ } else {
LoadApp(returnToApp, returnDirection);
brightnessController.Set(settingsController.GetBrightness());
brightnessController.Backup();
@@ -293,6 +294,9 @@ void DisplayApp::Refresh() {
// Added to remove warning
// What should happen here?
break;
+ case Messages::Clock:
+ LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
+ break;
}
}
@@ -363,12 +367,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Notifications:
currentScreen = std::make_unique<Screens::Notifications>(
- this, notificationManager, systemTask->nimble().alertService(), motorController, Screens::Notifications::Modes::Normal);
+ this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, 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(), motorController, Screens::Notifications::Modes::Preview);
+ this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Preview);
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
break;
case Apps::Timer:
@@ -416,8 +420,12 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
- case Apps::SettingPineTimeStyle:
- currentScreen = std::make_unique<Screens::SettingPineTimeStyle>(this, settingsController);
+ case Apps::SettingChimes:
+ currentScreen = std::make_unique<Screens::SettingChimes>(this, settingsController);
+ ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
+ break;
+ case Apps::SettingShakeThreshold:
+ currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController,motionController,*systemTask);
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
break;
case Apps::BatteryInfo:
diff --git a/src/displayapp/Messages.h b/src/displayapp/Messages.h
index b22d6c3c..a3a78cc9 100644
--- a/src/displayapp/Messages.h
+++ b/src/displayapp/Messages.h
@@ -20,7 +20,8 @@ namespace Pinetime {
DimScreen,
RestoreBrightness,
ShowPairingKey,
- AlarmTriggered
+ AlarmTriggered,
+ Clock
};
}
}
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp
index 96d8e5b0..1415e8ec 100644
--- a/src/displayapp/screens/Clock.cpp
+++ b/src/displayapp/screens/Clock.cpp
@@ -55,6 +55,10 @@ bool Clock::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screen->OnTouchEvent(event);
}
+bool Clock::OnButtonPushed() {
+ return screen->OnButtonPushed();
+}
+
std::unique_ptr<Screen> Clock::WatchFaceDigitalScreen() {
return std::make_unique<Screens::WatchFaceDigital>(app,
dateTimeController,
diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h
index 2fad1e21..fcecc6b3 100644
--- a/src/displayapp/screens/Clock.h
+++ b/src/displayapp/screens/Clock.h
@@ -32,6 +32,7 @@ namespace Pinetime {
~Clock() override;
bool OnTouchEvent(TouchEvents event) override;
+ bool OnButtonPushed() override;
private:
Controllers::DateTime& dateTimeController;
diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp
index 93c3c4a0..d279fafc 100644
--- a/src/displayapp/screens/InfiniPaint.cpp
+++ b/src/displayapp/screens/InfiniPaint.cpp
@@ -2,6 +2,8 @@
#include "displayapp/DisplayApp.h"
#include "displayapp/LittleVgl.h"
+#include <algorithm> // std::fill
+
using namespace Pinetime::Applications::Screens;
InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp* app,
diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp
index 8347e1bb..f6f269dc 100644
--- a/src/displayapp/screens/Metronome.cpp
+++ b/src/displayapp/screens/Metronome.cpp
@@ -113,9 +113,16 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
lv_label_set_text_fmt(bpmValue, "%03d", bpm);
}
tappedTime = xTaskGetTickCount();
+ allowExit = true;
}
break;
}
+ case LV_EVENT_RELEASED:
+ case LV_EVENT_PRESS_LOST:
+ if (obj == bpmTap) {
+ allowExit = false;
+ }
+ break;
case LV_EVENT_CLICKED: {
if (obj == playPause) {
metronomeStarted = !metronomeStarted;
@@ -135,3 +142,11 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
break;
}
}
+
+bool Metronome::OnTouchEvent(TouchEvents event) {
+ if (event == TouchEvents::SwipeDown && allowExit) {
+ running = false;
+ return true;
+ }
+ return false;
+}
diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h
index 373c884c..6e6589fe 100644
--- a/src/displayapp/screens/Metronome.h
+++ b/src/displayapp/screens/Metronome.h
@@ -14,6 +14,7 @@ namespace Pinetime {
~Metronome() override;
void Refresh() override;
void OnEvent(lv_obj_t* obj, lv_event_t event);
+ bool OnTouchEvent(TouchEvents event) override;
private:
TickType_t startTime = 0;
@@ -25,6 +26,7 @@ namespace Pinetime {
uint8_t counter = 1;
bool metronomeStarted = false;
+ bool allowExit = false;
lv_obj_t *bpmArc, *bpmTap, *bpmValue;
lv_obj_t *bpbDropdown, *currentBpbText;
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index 8a01a6fe..9f17b956 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -277,12 +277,14 @@ bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return true;
}
case TouchEvents::SwipeDown: {
- lv_obj_set_hidden(btnNext, false);
- lv_obj_set_hidden(btnPrev, false);
-
- lv_obj_set_hidden(btnVolDown, true);
- lv_obj_set_hidden(btnVolUp, true);
- return true;
+ if (lv_obj_get_hidden(btnNext)) {
+ lv_obj_set_hidden(btnNext, false);
+ lv_obj_set_hidden(btnPrev, false);
+ lv_obj_set_hidden(btnVolDown, true);
+ lv_obj_set_hidden(btnVolUp, true);
+ return true;
+ }
+ return false;
}
case TouchEvents::SwipeLeft: {
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 569c422b..8fe08a82 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -12,8 +12,13 @@ Notifications::Notifications(DisplayApp* app,
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
+ System::SystemTask& systemTask,
Modes mode)
- : Screen(app), notificationManager {notificationManager}, alertNotificationService {alertNotificationService}, mode {mode} {
+ : Screen(app),
+ notificationManager {notificationManager},
+ alertNotificationService {alertNotificationService},
+ systemTask {systemTask},
+ mode {mode} {
notificationManager.ClearNewNotificationFlag();
auto notification = notificationManager.GetLastNotification();
if (notification.valid) {
@@ -37,20 +42,22 @@ Notifications::Notifications(DisplayApp* app,
}
if (mode == Modes::Preview) {
+ systemTask.PushMessage(System::Messages::DisableSleeping);
if (notification.category == Controllers::NotificationManager::Categories::IncomingCall) {
motorController.StartRinging();
} else {
motorController.RunForDuration(35);
- timeoutLine = lv_line_create(lv_scr_act(), nullptr);
+ }
- lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
- lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
+ timeoutLine = lv_line_create(lv_scr_act(), nullptr);
- lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
- timeoutTickCountStart = xTaskGetTickCount();
- timeoutTickCountEnd = timeoutTickCountStart + (5 * 1024);
- }
+ lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
+ lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
+ lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true);
+
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ timeoutTickCountStart = xTaskGetTickCount();
+ interacted = false;
}
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -60,23 +67,40 @@ Notifications::~Notifications() {
lv_task_del(taskRefresh);
// make sure we stop any vibrations before exiting
Controllers::MotorController::StopRinging();
+ systemTask.PushMessage(System::Messages::EnableSleeping);
lv_obj_clean(lv_scr_act());
}
void Notifications::Refresh() {
if (mode == Modes::Preview && timeoutLine != nullptr) {
- auto tick = xTaskGetTickCount();
- int32_t pos = 240 - ((tick - timeoutTickCountStart) / ((timeoutTickCountEnd - timeoutTickCountStart) / 240));
- if (pos < 0)
+ TickType_t tick = xTaskGetTickCount();
+ int32_t pos = 240 - ((tick - timeoutTickCountStart) / (timeoutLength / 240));
+ if (pos <= 0) {
running = false;
+ } else {
+ timeoutLinePoints[1].x = pos;
+ lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+ }
+ }
+ running = currentItem->IsRunning() && running;
+}
- timeoutLinePoints[1].x = pos;
- lv_line_set_points(timeoutLine, timeoutLinePoints, 2);
+void Notifications::OnPreviewInteraction() {
+ systemTask.PushMessage(System::Messages::EnableSleeping);
+ Controllers::MotorController::StopRinging();
+ if (timeoutLine != nullptr) {
+ lv_obj_del(timeoutLine);
+ timeoutLine = nullptr;
}
}
bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
if (mode != Modes::Normal) {
+ if (!interacted && event == TouchEvents::Tap) {
+ interacted = true;
+ OnPreviewInteraction();
+ return true;
+ }
return false;
}
diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h
index cbb7af6c..2f444c7c 100644
--- a/src/displayapp/screens/Notifications.h
+++ b/src/displayapp/screens/Notifications.h
@@ -1,11 +1,13 @@
#pragma once
#include <lvgl/lvgl.h>
+#include <FreeRTOS.h>
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
#include "components/ble/NotificationManager.h"
#include "components/motor/MotorController.h"
+#include "systemtask/SystemTask.h"
namespace Pinetime {
namespace Controllers {
@@ -21,11 +23,13 @@ namespace Pinetime {
Pinetime::Controllers::NotificationManager& notificationManager,
Pinetime::Controllers::AlertNotificationService& alertNotificationService,
Pinetime::Controllers::MotorController& motorController,
+ System::SystemTask& systemTask,
Modes mode);
~Notifications() override;
void Refresh() override;
bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override;
+ void OnPreviewInteraction();
class NotificationItem {
public:
@@ -62,6 +66,7 @@ namespace Pinetime {
};
Pinetime::Controllers::NotificationManager& notificationManager;
Pinetime::Controllers::AlertNotificationService& alertNotificationService;
+ System::SystemTask& systemTask;
Modes mode = Modes::Normal;
std::unique_ptr<NotificationItem> currentItem;
Controllers::NotificationManager::Notification::Id currentId;
@@ -69,8 +74,9 @@ namespace Pinetime {
lv_point_t timeoutLinePoints[2] {{0, 1}, {239, 1}};
lv_obj_t* timeoutLine = nullptr;
- uint32_t timeoutTickCountStart;
- uint32_t timeoutTickCountEnd;
+ TickType_t timeoutTickCountStart;
+ static const TickType_t timeoutLength = pdMS_TO_TICKS(7000);
+ bool interacted = true;
lv_task_t* taskRefresh;
};
diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp
index d4368691..7ce0bc0d 100644
--- a/src/displayapp/screens/PineTimeStyle.cpp
+++ b/src/displayapp/screens/PineTimeStyle.cpp
@@ -37,6 +37,13 @@
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);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
PineTimeStyle::PineTimeStyle(DisplayApp* app,
Controllers::DateTime& dateTimeController,
Controllers::Battery& batteryController,
@@ -53,16 +60,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
settingsController {settingsController},
motionController {motionController} {
- // This sets the watchface number to return to after leaving the menu
- settingsController.SetClockFace(2);
-
- displayedChar[0] = 0;
- displayedChar[1] = 0;
- displayedChar[2] = 0;
- displayedChar[3] = 0;
- displayedChar[4] = 0;
-
- //Create a 200px wide background rectangle
+ // Create a 200px wide background rectangle
timebar = lv_obj_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
@@ -73,19 +71,19 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
timeDD1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD1, "00");
+ lv_label_set_text_static(timeDD1, "00");
lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
timeDD2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD2, "00");
+ lv_label_set_text_static(timeDD2, "00");
lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
timeAMPM = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
- lv_label_set_text(timeAMPM, "");
+ lv_label_set_text_static(timeAMPM, "");
lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
// Create a 40px wide bar down the right side of the screen
@@ -97,74 +95,78 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
// Display icons
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
lv_obj_set_auto_realign(batteryIcon, true);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(bleIcon, "");
+ lv_label_set_text_static(bleIcon, "");
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(notificationIcon, "");
+ lv_label_set_text_static(notificationIcon, "");
// Calendar icon
calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarOuter, 34, 34);
lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
calendarInner = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
+ lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarInner, 27, 27);
lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarBar1, 3, 12);
lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarBar2, 3, 12);
lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarCrossBar1, 8, 3);
lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
+ lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
lv_obj_set_size(calendarCrossBar2, 8, 3);
lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
// Display date
dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDayOfWeek, "THU");
+ lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(dateDayOfWeek, "THU");
lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
dateDay = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDay, "25");
+ lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(dateDay, "25");
lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
dateMonth = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateMonth, "MAR");
+ lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
+ lv_label_set_text_static(dateMonth, "MAR");
lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
// Step count gauge
- needle_colors[0] = LV_COLOR_WHITE;
+ if (settingsController.GetPTSColorBar() == Pinetime::Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
lv_obj_set_size(stepGauge, 40, 40);
@@ -191,7 +193,101 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
+
+ btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextTime->user_data = this;
+ lv_obj_set_size(btnNextTime, 60, 60);
+ lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
+ lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextTime, event_handler);
+ lv_obj_set_hidden(btnNextTime, true);
+
+ btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevTime->user_data = this;
+ lv_obj_set_size(btnPrevTime, 60, 60);
+ lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
+ lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevTime, event_handler);
+ lv_obj_set_hidden(btnPrevTime, true);
+
+ btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBar->user_data = this;
+ lv_obj_set_size(btnNextBar, 60, 60);
+ lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
+ lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBar, event_handler);
+ lv_obj_set_hidden(btnNextBar, true);
+
+ btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBar->user_data = this;
+ lv_obj_set_size(btnPrevBar, 60, 60);
+ lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
+ lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBar, event_handler);
+ lv_obj_set_hidden(btnPrevBar, true);
+
+ btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnNextBG->user_data = this;
+ lv_obj_set_size(btnNextBG, 60, 60);
+ lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
+ lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
+ lv_obj_set_event_cb(btnNextBG, event_handler);
+ lv_obj_set_hidden(btnNextBG, true);
+
+ btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
+ btnPrevBG->user_data = this;
+ lv_obj_set_size(btnPrevBG, 60, 60);
+ lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
+ lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
+ lv_obj_set_event_cb(btnPrevBG, event_handler);
+ lv_obj_set_hidden(btnPrevBG, true);
+
+ btnReset = lv_btn_create(lv_scr_act(), nullptr);
+ btnReset->user_data = this;
+ lv_obj_set_size(btnReset, 60, 60);
+ lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
+ lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
+ lv_obj_set_event_cb(btnReset, event_handler);
+ lv_obj_set_hidden(btnReset, true);
+
+ btnRandom = lv_btn_create(lv_scr_act(), nullptr);
+ btnRandom->user_data = this;
+ lv_obj_set_size(btnRandom, 60, 60);
+ lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
+ lv_obj_set_event_cb(btnRandom, event_handler);
+ lv_obj_set_hidden(btnRandom, true);
+
+ btnClose = lv_btn_create(lv_scr_act(), nullptr);
+ btnClose->user_data = this;
+ lv_obj_set_size(btnClose, 60, 60);
+ lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80);
+ lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_style_local_value_str(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "X");
+ lv_obj_set_event_cb(btnClose, event_handler);
+ lv_obj_set_hidden(btnClose, true);
+
+ btnSet = lv_btn_create(lv_scr_act(), nullptr);
+ btnSet->user_data = this;
+ lv_obj_set_height(btnSet, 150);
+ lv_obj_set_width(btnSet, 150);
+ lv_obj_align(btnSet, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_radius(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 30);
+ lv_obj_set_style_local_bg_opa(btnSet, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
+ lv_obj_set_event_cb(btnSet, event_handler);
+ lbl_btnSet = lv_label_create(btnSet, nullptr);
+ lv_obj_set_style_local_text_font(lbl_btnSet, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
+ lv_label_set_text_static(lbl_btnSet, Symbols::settings);
+ lv_obj_set_hidden(btnSet, true);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
@@ -202,9 +298,42 @@ PineTimeStyle::~PineTimeStyle() {
lv_obj_clean(lv_scr_act());
}
+bool PineTimeStyle::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();
+ return true;
+ }
+ if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnRandom) == false)) {
+ return true;
+ }
+ return false;
+}
+
+void PineTimeStyle::CloseMenu() {
+ settingsController.SaveSettings();
+ lv_obj_set_hidden(btnNextTime, true);
+ lv_obj_set_hidden(btnPrevTime, true);
+ lv_obj_set_hidden(btnNextBar, true);
+ lv_obj_set_hidden(btnPrevBar, true);
+ lv_obj_set_hidden(btnNextBG, true);
+ lv_obj_set_hidden(btnPrevBG, true);
+ lv_obj_set_hidden(btnReset, true);
+ lv_obj_set_hidden(btnRandom, true);
+ lv_obj_set_hidden(btnClose, true);
+}
+
+bool PineTimeStyle::OnButtonPushed() {
+ if (!lv_obj_get_hidden(btnClose)) {
+ CloseMenu();
+ return true;
+ }
+ return false;
+}
+
void PineTimeStyle::SetBatteryIcon() {
auto batteryPercent = batteryPercentRemaining.Get();
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
void PineTimeStyle::AlignIcons() {
@@ -222,7 +351,7 @@ void PineTimeStyle::Refresh() {
isCharging = batteryController.IsCharging();
if (isCharging.IsUpdated()) {
if (isCharging.Get()) {
- lv_label_set_text(batteryIcon, Symbols::plug);
+ lv_label_set_text_static(batteryIcon, Symbols::plug);
} else {
SetBatteryIcon();
}
@@ -236,13 +365,13 @@ void PineTimeStyle::Refresh() {
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
AlignIcons();
}
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
AlignIcons();
}
@@ -259,45 +388,31 @@ void PineTimeStyle::Refresh() {
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
- int hour = time.hours().count();
- auto minute = time.minutes().count();
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
- char minutesChar[3];
- sprintf(minutesChar, "%02d", static_cast<int>(minute));
-
- char hoursChar[3];
- char ampmChar[5];
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
- } else {
- if (hour == 0 && hour != 12) {
- hour = 12;
- sprintf(ampmChar, "A\nM");
- } else if (hour == 12 && hour != 0) {
- hour = 12;
- sprintf(ampmChar, "P\nM");
- } else if (hour < 12 && hour != 0) {
- sprintf(ampmChar, "A\nM");
- } else if (hour > 12 && hour != 0) {
- hour = hour - 12;
- sprintf(ampmChar, "P\nM");
- }
- sprintf(hoursChar, "%02d", hour);
- }
-
- if (hoursChar[0] != displayedChar[0] or hoursChar[1] != displayedChar[1] or minutesChar[0] != displayedChar[2] or
- minutesChar[1] != displayedChar[3]) {
- displayedChar[0] = hoursChar[0];
- displayedChar[1] = hoursChar[1];
- displayedChar[2] = minutesChar[0];
- displayedChar[3] = minutesChar[1];
+ if (displayedHour != hour || displayedMinute != minute) {
+ displayedHour = hour;
+ displayedMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ char ampmChar[4] = "A\nM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
+ }
lv_label_set_text(timeAMPM, ampmChar);
+ // Should be padded with blank spaces, but the space character doesn't exist in the font
+ lv_label_set_text_fmt(timeDD1, "%02d", hour);
+ lv_label_set_text_fmt(timeDD2, "%02d", minute);
+ } else {
+ lv_label_set_text_fmt(timeDD1, "%02d", hour);
+ lv_label_set_text_fmt(timeDD2, "%02d", minute);
}
-
- lv_label_set_text_fmt(timeDD1, "%s", hoursChar);
- lv_label_set_text_fmt(timeDD2, "%s", minutesChar);
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
@@ -323,4 +438,154 @@ void PineTimeStyle::Refresh() {
lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
}
+ if (!lv_obj_get_hidden(btnSet)) {
+ if ((savedTick > 0) && (lv_tick_get() - savedTick > 3000)) {
+ lv_obj_set_hidden(btnSet, true);
+ savedTick = 0;
+ }
+ }
+}
+
+void PineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ auto valueTime = settingsController.GetPTSColorTime();
+ auto valueBar = settingsController.GetPTSColorBar();
+ auto valueBG = settingsController.GetPTSColorBG();
+
+ if (event == LV_EVENT_CLICKED) {
+ if (object == btnNextTime) {
+ valueTime = GetNext(valueTime);
+ if (valueTime == valueBG) {
+ valueTime = GetNext(valueTime);
+ }
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnPrevTime) {
+ valueTime = GetPrevious(valueTime);
+ if (valueTime == valueBG) {
+ valueTime = GetPrevious(valueTime);
+ }
+ settingsController.SetPTSColorTime(valueTime);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ }
+ if (object == btnNextBar) {
+ valueBar = GetNext(valueBar);
+ if (valueBar == Controllers::Settings::Colors::Black) {
+ valueBar = GetNext(valueBar);
+ }
+ if (valueBar == Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnPrevBar) {
+ valueBar = GetPrevious(valueBar);
+ if (valueBar == Controllers::Settings::Colors::Black) {
+ valueBar = GetPrevious(valueBar);
+ }
+ if (valueBar == Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
+ settingsController.SetPTSColorBar(valueBar);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ }
+ if (object == btnNextBG) {
+ valueBG = GetNext(valueBG);
+ if (valueBG == valueTime) {
+ valueBG = GetNext(valueBG);
+ }
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnPrevBG) {
+ valueBG = GetPrevious(valueBG);
+ if (valueBG == valueTime) {
+ valueBG = GetPrevious(valueBG);
+ }
+ settingsController.SetPTSColorBG(valueBG);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnReset) {
+ needle_colors[0] = LV_COLOR_WHITE;
+ settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
+ settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
+ }
+ if (object == btnRandom) {
+ valueTime = static_cast<Controllers::Settings::Colors>(rand() % 17);
+ valueBar = static_cast<Controllers::Settings::Colors>(rand() % 17);
+ valueBG = static_cast<Controllers::Settings::Colors>(rand() % 17);
+ if (valueTime == valueBG) {
+ valueBG = GetNext(valueBG);
+ }
+ if (valueBar == Controllers::Settings::Colors::Black) {
+ valueBar = GetPrevious(valueBar);
+ }
+ if (valueBar == Controllers::Settings::Colors::White) {
+ needle_colors[0] = LV_COLOR_BLACK;
+ } else {
+ needle_colors[0] = LV_COLOR_WHITE;
+ }
+ settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(valueTime));
+ lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
+ settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(valueBar));
+ lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
+ settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(valueBG));
+ lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
+ }
+ if (object == btnClose) {
+ CloseMenu();
+ }
+ if (object == btnSet) {
+ lv_obj_set_hidden(btnSet, true);
+ lv_obj_set_hidden(btnNextTime, false);
+ lv_obj_set_hidden(btnPrevTime, false);
+ lv_obj_set_hidden(btnNextBar, false);
+ lv_obj_set_hidden(btnPrevBar, false);
+ lv_obj_set_hidden(btnNextBG, false);
+ lv_obj_set_hidden(btnPrevBG, false);
+ lv_obj_set_hidden(btnReset, false);
+ lv_obj_set_hidden(btnRandom, false);
+ lv_obj_set_hidden(btnClose, false);
+ }
+ }
+}
+
+Pinetime::Controllers::Settings::Colors PineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors nextColor;
+ if (colorAsInt < 16) {
+ nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
+ } else {
+ nextColor = static_cast<Controllers::Settings::Colors>(0);
+ }
+ return nextColor;
+}
+
+Pinetime::Controllers::Settings::Colors PineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
+ auto colorAsInt = static_cast<uint8_t>(color);
+ Pinetime::Controllers::Settings::Colors prevColor;
+
+ if (colorAsInt > 0) {
+ prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
+ } else {
+ prevColor = static_cast<Controllers::Settings::Colors>(16);
+ }
+ return prevColor;
}
diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h
index 8382c53c..1b972ce1 100644
--- a/src/displayapp/screens/PineTimeStyle.h
+++ b/src/displayapp/screens/PineTimeStyle.h
@@ -5,6 +5,7 @@
#include <cstdint>
#include <memory>
#include "displayapp/screens/Screen.h"
+#include "displayapp/Colors.h"
#include "components/datetime/DateTimeController.h"
namespace Pinetime {
@@ -30,15 +31,22 @@ namespace Pinetime {
Controllers::MotionController& motionController);
~PineTimeStyle() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ bool OnButtonPushed() override;
+
void Refresh() override;
+ void UpdateSelected(lv_obj_t *object, lv_event_t event);
+
private:
- char displayedChar[5];
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown;
uint8_t currentDay = 0;
+ uint32_t savedTick = 0;
DirtyValue<uint8_t> batteryPercentRemaining {};
DirtyValue<bool> isCharging {};
@@ -48,6 +56,18 @@ namespace Pinetime {
DirtyValue<uint32_t> stepCount {};
DirtyValue<bool> notificationState {};
+ static Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
+ static Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
+
+ lv_obj_t* btnNextTime;
+ lv_obj_t* btnPrevTime;
+ lv_obj_t* btnNextBar;
+ lv_obj_t* btnPrevBar;
+ lv_obj_t* btnNextBG;
+ lv_obj_t* btnPrevBG;
+ lv_obj_t* btnReset;
+ lv_obj_t* btnRandom;
+ lv_obj_t* btnClose;
lv_obj_t* timebar;
lv_obj_t* sidebar;
lv_obj_t* timeDD1;
@@ -67,6 +87,8 @@ namespace Pinetime {
lv_obj_t* calendarCrossBar2;
lv_obj_t* notificationIcon;
lv_obj_t* stepGauge;
+ lv_obj_t* btnSet;
+ lv_obj_t* lbl_btnSet;
lv_color_t needle_colors[1];
Controllers::DateTime& dateTimeController;
@@ -77,6 +99,7 @@ namespace Pinetime {
Controllers::MotionController& motionController;
void SetBatteryIcon();
+ void CloseMenu();
void AlignIcons();
lv_task_t* taskRefresh;
diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp
index 916138ed..3e7f8201 100644
--- a/src/displayapp/screens/Steps.cpp
+++ b/src/displayapp/screens/Steps.cpp
@@ -5,6 +5,11 @@
using namespace Pinetime::Applications::Screens;
+static void lap_event_handler(lv_obj_t* obj, lv_event_t event) {
+ auto* steps = static_cast<Steps*>(obj->user_data);
+ steps->lapBtnEventHandler(event);
+}
+
Steps::Steps(Pinetime::Applications::DisplayApp* app,
Controllers::MotionController& motionController,
Controllers::Settings& settingsController)
@@ -17,11 +22,12 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_style_local_radius(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
lv_obj_set_style_local_line_color(stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0x0000FF));
lv_arc_set_end_angle(stepsArc, 200);
- lv_obj_set_size(stepsArc, 220, 220);
+ lv_obj_set_size(stepsArc, 240, 240);
lv_arc_set_range(stepsArc, 0, 500);
lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0);
stepsCount = motionController.NbSteps();
+ currentTripSteps = stepsCount - motionController.GetTripSteps();
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
@@ -29,18 +35,18 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42);
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
- lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
+ lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111));
lv_label_set_text_static(lstepsL, "Steps");
- lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
+ lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN);
- lv_label_set_text_fmt(lstepsGoal, "Goal\n%lu", settingsController.GetStepsGoal());
+ lv_label_set_text_fmt(lstepsGoal, "Goal: %5lu", settingsController.GetStepsGoal());
lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60);
+ lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 40);
lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
@@ -48,6 +54,22 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app,
lv_obj_set_pos(backgroundLabel, 0, 0);
lv_label_set_text_static(backgroundLabel, "");
+ resetBtn = lv_btn_create(lv_scr_act(), nullptr);
+ resetBtn->user_data = this;
+ lv_obj_set_event_cb(resetBtn, lap_event_handler);
+ lv_obj_set_height(resetBtn, 50);
+ 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");
+
+ currentTripSteps = motionController.GetTripSteps();
+
+ tripLabel = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(tripLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
+ lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps);
+ lv_obj_align(tripLabel, lstepsGoal, LV_ALIGN_IN_LEFT_MID, 0, 20);
+
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
@@ -58,9 +80,24 @@ Steps::~Steps() {
void Steps::Refresh() {
stepsCount = motionController.NbSteps();
+ currentTripSteps = motionController.GetTripSteps();
lv_label_set_text_fmt(lSteps, "%li", stepsCount);
- lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20);
+ lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -40);
+ if (currentTripSteps < 100000) {
+ lv_label_set_text_fmt(tripLabel, "Trip: %5li", currentTripSteps);
+ } else {
+ lv_label_set_text_fmt(tripLabel, "Trip: 99999+");
+ }
lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal()));
}
+
+void Steps::lapBtnEventHandler(lv_event_t event) {
+ if (event != LV_EVENT_CLICKED) {
+ return;
+ }
+ stepsCount = motionController.NbSteps();
+ motionController.ResetTrip();
+ Refresh();
+}
diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h
index 68daf16d..f109e0f2 100644
--- a/src/displayapp/screens/Steps.h
+++ b/src/displayapp/screens/Steps.h
@@ -20,14 +20,20 @@ namespace Pinetime {
~Steps() override;
void Refresh() override;
+ void lapBtnEventHandler(lv_event_t event);
private:
Controllers::MotionController& motionController;
Controllers::Settings& settingsController;
+ uint32_t currentTripSteps = 0;
+
lv_obj_t* lSteps;
lv_obj_t* lStepsIcon;
lv_obj_t* stepsArc;
+ lv_obj_t* resetBtn;
+ lv_obj_t* resetButtonLabel;
+ lv_obj_t* tripLabel;
uint32_t stepsCount;
diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp
index 87695793..b3cb0f91 100644
--- a/src/displayapp/screens/WatchFaceDigital.cpp
+++ b/src/displayapp/screens/WatchFaceDigital.cpp
@@ -35,22 +35,22 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
settingsController.SetClockFace(0);
batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
+ lv_label_set_text_static(batteryIcon, Symbols::batteryFull);
lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
batteryPlug = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000));
- lv_label_set_text(batteryPlug, Symbols::plug);
+ lv_label_set_text_static(batteryPlug, Symbols::plug);
lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
bleIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0000FF));
- lv_label_set_text(bleIcon, Symbols::bluetooth);
+ lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC));
+ lv_label_set_text_static(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00));
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
label_date = lv_label_create(lv_scr_act(), nullptr);
@@ -71,26 +71,26 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app,
lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
lv_obj_set_size(backgroundLabel, 240, 240);
lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
+ lv_label_set_text_static(backgroundLabel, "");
heartbeatIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_text(heartbeatIcon, Symbols::heartBeat);
+ lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat);
lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B));
- lv_label_set_text(heartbeatValue, "");
+ lv_label_set_text_static(heartbeatValue, "");
lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
- lv_label_set_text(stepValue, "0");
+ lv_label_set_text_static(stepValue, "0");
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
stepIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7));
- lv_label_set_text(stepIcon, Symbols::shoe);
+ lv_label_set_text_static(stepIcon, Symbols::shoe);
lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
@@ -105,7 +105,7 @@ WatchFaceDigital::~WatchFaceDigital() {
void WatchFaceDigital::Refresh() {
powerPresent = batteryController.IsPowerPresent();
if (powerPresent.IsUpdated()) {
- lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
+ lv_label_set_text_static(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get()));
}
batteryPercentRemaining = batteryController.PercentRemaining();
@@ -116,20 +116,20 @@ void WatchFaceDigital::Refresh() {
} else {
lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
}
- lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
+ lv_label_set_text_static(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent));
}
bleState = bleController.IsConnected();
if (bleState.IsUpdated()) {
- lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get()));
+ lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
}
- lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0);
- lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_realign(batteryIcon);
+ lv_obj_realign(batteryPlug);
+ lv_obj_realign(bleIcon);
notificationState = notificatioManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
- lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
+ lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get()));
}
currentDateTime = dateTimeController.CurrentDateTime();
@@ -146,62 +146,41 @@ void WatchFaceDigital::Refresh() {
auto day = static_cast<unsigned>(yearMonthDay.day());
auto dayOfWeek = static_cast<Pinetime::Controllers::DateTime::Days>(date::weekday(yearMonthDay).iso_encoding());
- int hour = time.hours().count();
- auto minute = time.minutes().count();
-
- char minutesChar[3];
- sprintf(minutesChar, "%02d", static_cast<int>(minute));
-
- char hoursChar[3];
- char ampmChar[3];
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- sprintf(hoursChar, "%02d", hour);
- } else {
- if (hour == 0 && hour != 12) {
- hour = 12;
- sprintf(ampmChar, "AM");
- } else if (hour == 12 && hour != 0) {
- hour = 12;
- sprintf(ampmChar, "PM");
- } else if (hour < 12 && hour != 0) {
- sprintf(ampmChar, "AM");
- } else if (hour > 12 && hour != 0) {
- hour = hour - 12;
- sprintf(ampmChar, "PM");
- }
- sprintf(hoursChar, "%02d", hour);
- }
+ uint8_t hour = time.hours().count();
+ uint8_t minute = time.minutes().count();
- if ((hoursChar[0] != displayedChar[0]) or (hoursChar[1] != displayedChar[1]) or (minutesChar[0] != displayedChar[2]) or
- (minutesChar[1] != displayedChar[3])) {
- displayedChar[0] = hoursChar[0];
- displayedChar[1] = hoursChar[1];
- displayedChar[2] = minutesChar[0];
- displayedChar[3] = minutesChar[1];
+ if (displayedHour != hour || displayedMinute != minute) {
+ displayedHour = hour;
+ displayedMinute = minute;
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
- lv_label_set_text(label_time_ampm, ampmChar);
- if (hoursChar[0] == '0') {
- hoursChar[0] = ' ';
+ char ampmChar[3] = "AM";
+ if (hour == 0) {
+ hour = 12;
+ } else if (hour == 12) {
+ ampmChar[0] = 'P';
+ } else if (hour > 12) {
+ hour = hour - 12;
+ ampmChar[0] = 'P';
}
- }
-
- lv_label_set_text_fmt(label_time, "%s:%s", hoursChar, minutesChar);
-
- if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
+ lv_label_set_text(label_time_ampm, ampmChar);
+ lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0);
} else {
+ lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
}
}
if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) {
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) {
- lv_label_set_text_fmt(label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
+ lv_label_set_text_fmt(
+ label_date, "%s %d %s %d", dateTimeController.DayOfWeekShortToString(), day, dateTimeController.MonthShortToString(), year);
} else {
- lv_label_set_text_fmt(label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
+ lv_label_set_text_fmt(
+ label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year);
}
- lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60);
+ lv_obj_realign(label_date);
currentYear = year;
currentMonth = month;
@@ -221,15 +200,15 @@ void WatchFaceDigital::Refresh() {
lv_label_set_text_static(heartbeatValue, "");
}
- lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
- lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
+ lv_obj_realign(heartbeatIcon);
+ lv_obj_realign(heartbeatValue);
}
stepCount = motionController.NbSteps();
motionSensorOk = motionController.IsSensorOk();
if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());
- lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
- lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0);
+ lv_obj_realign(stepValue);
+ lv_obj_realign(stepIcon);
}
}
diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h
index 627154c8..ab3a0285 100644
--- a/src/displayapp/screens/WatchFaceDigital.h
+++ b/src/displayapp/screens/WatchFaceDigital.h
@@ -35,7 +35,8 @@ namespace Pinetime {
void Refresh() override;
private:
- char displayedChar[5] {};
+ uint8_t displayedHour = -1;
+ uint8_t displayedMinute = -1;
uint16_t currentYear = 1970;
Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown;
diff --git a/src/displayapp/screens/settings/SettingChimes.cpp b/src/displayapp/screens/settings/SettingChimes.cpp
new file mode 100644
index 00000000..543b5e0e
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingChimes.cpp
@@ -0,0 +1,100 @@
+#include "displayapp/screens/settings/SettingChimes.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Styles.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ static void event_handler(lv_obj_t* obj, lv_event_t event) {
+ SettingChimes* screen = static_cast<SettingChimes*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
+SettingChimes::SettingChimes(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, "Chimes");
+ lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15);
+
+ lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE);
+ lv_label_set_text_static(icon, Symbols::clock);
+ lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);
+
+ optionsTotal = 0;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Off");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ SetRadioButtonStyle(cbOption[optionsTotal]);
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::None) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+
+ optionsTotal++;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Every hour");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ SetRadioButtonStyle(cbOption[optionsTotal]);
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+
+ optionsTotal++;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Every 30 mins");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ SetRadioButtonStyle(cbOption[optionsTotal]);
+ if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+
+ optionsTotal++;
+}
+
+SettingChimes::~SettingChimes() {
+ lv_obj_clean(lv_scr_act());
+ settingsController.SaveSettings();
+}
+
+void SettingChimes::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+ if (event == LV_EVENT_VALUE_CHANGED) {
+ for (uint8_t i = 0; i < optionsTotal; i++) {
+ if (object == cbOption[i]) {
+ lv_checkbox_set_checked(cbOption[i], true);
+ if (i == 0) {
+ settingsController.SetChimeOption(Controllers::Settings::ChimesOption::None);
+ }
+ if (i == 1) {
+ settingsController.SetChimeOption(Controllers::Settings::ChimesOption::Hours);
+ }
+ if (i == 2) {
+ settingsController.SetChimeOption(Controllers::Settings::ChimesOption::HalfHours);
+ }
+ } else {
+ lv_checkbox_set_checked(cbOption[i], false);
+ }
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingChimes.h b/src/displayapp/screens/settings/SettingChimes.h
new file mode 100644
index 00000000..653f87f7
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingChimes.h
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingChimes : public Screen {
+ public:
+ SettingChimes(DisplayApp* app, Pinetime::Controllers::Settings& settingsController);
+ ~SettingChimes() override;
+
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ uint8_t optionsTotal;
+ lv_obj_t* cbOption[2];
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
deleted file mode 100644
index f38ec3bd..00000000
--- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-#include "displayapp/screens/settings/SettingPineTimeStyle.h"
-#include <lvgl/lvgl.h>
-#include <displayapp/Colors.h>
-#include "displayapp/DisplayApp.h"
-#include "displayapp/screens/Symbols.h"
-
-using namespace Pinetime::Applications::Screens;
-
-namespace {
- static void event_handler(lv_obj_t* obj, lv_event_t event) {
- SettingPineTimeStyle* screen = static_cast<SettingPineTimeStyle*>(obj->user_data);
- screen->UpdateSelected(obj, event);
- }
-}
-
-SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController)
- : Screen(app), settingsController {settingsController} {
- timebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG()));
- lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(timebar, 200, 240);
- lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0);
-
- // Display the time
-
- timeDD1 = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD1, "12");
- lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5);
-
- timeDD2 = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light);
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_label_set_text(timeDD2, "34");
- lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5);
-
- timeAMPM = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime()));
- lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3);
- lv_label_set_text(timeAMPM, "A\nM");
- lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20);
-
- // Create a 40px wide bar down the right side of the screen
-
- sidebar = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar()));
- lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(sidebar, 40, 240);
- lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0);
-
- // Display icons
-
- batteryIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(batteryIcon, Symbols::batteryFull);
- lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2);
-
- bleIcon = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(bleIcon, Symbols::bluetooth);
- lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25);
-
- // Calendar icon
-
- calendarOuter = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarOuter, 34, 34);
- lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0);
-
- calendarInner = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff));
- lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarInner, 27, 27);
- lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0);
-
- calendarBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarBar1, 3, 12);
- lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3);
-
- calendarBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarBar2, 3, 12);
- lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3);
-
- calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarCrossBar1, 8, 3);
- lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
-
- calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0);
- lv_obj_set_size(calendarCrossBar2, 8, 3);
- lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
-
- // Display date
-
- dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDayOfWeek, "THU");
- lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34);
-
- dateDay = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateDay, "25");
- lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3);
-
- dateMonth = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000));
- lv_label_set_text(dateMonth, "MAR");
- lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32);
-
- // Step count gauge
- needle_colors[0] = LV_COLOR_WHITE;
- stepGauge = lv_gauge_create(lv_scr_act(), nullptr);
- lv_gauge_set_needle_count(stepGauge, 1, needle_colors);
- lv_obj_set_size(stepGauge, 40, 40);
- lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
- lv_gauge_set_scale(stepGauge, 360, 11, 0);
- lv_gauge_set_angle_offset(stepGauge, 180);
- lv_gauge_set_critical_value(stepGauge, (100));
- lv_gauge_set_range(stepGauge, 0, (100));
- lv_gauge_set_value(stepGauge, 0, 0);
-
- lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4);
- lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
- lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER);
- lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3);
- lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4);
-
- backgroundLabel = lv_label_create(lv_scr_act(), nullptr);
- lv_obj_set_click(backgroundLabel, true);
- lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP);
- lv_obj_set_size(backgroundLabel, 240, 240);
- lv_obj_set_pos(backgroundLabel, 0, 0);
- lv_label_set_text(backgroundLabel, "");
-
- btnNextTime = lv_btn_create(lv_scr_act(), nullptr);
- btnNextTime->user_data = this;
- lv_obj_set_size(btnNextTime, 60, 60);
- lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80);
- lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
- lv_obj_set_event_cb(btnNextTime, event_handler);
-
- btnPrevTime = lv_btn_create(lv_scr_act(), nullptr);
- btnPrevTime->user_data = this;
- lv_obj_set_size(btnPrevTime, 60, 60);
- lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80);
- lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
- lv_obj_set_event_cb(btnPrevTime, event_handler);
-
- btnNextBar = lv_btn_create(lv_scr_act(), nullptr);
- btnNextBar->user_data = this;
- lv_obj_set_size(btnNextBar, 60, 60);
- lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0);
- lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
- lv_obj_set_event_cb(btnNextBar, event_handler);
-
- btnPrevBar = lv_btn_create(lv_scr_act(), nullptr);
- btnPrevBar->user_data = this;
- lv_obj_set_size(btnPrevBar, 60, 60);
- lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0);
- lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
- lv_obj_set_event_cb(btnPrevBar, event_handler);
-
- btnNextBG = lv_btn_create(lv_scr_act(), nullptr);
- btnNextBG->user_data = this;
- lv_obj_set_size(btnNextBG, 60, 60);
- lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80);
- lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">");
- lv_obj_set_event_cb(btnNextBG, event_handler);
-
- btnPrevBG = lv_btn_create(lv_scr_act(), nullptr);
- btnPrevBG->user_data = this;
- lv_obj_set_size(btnPrevBG, 60, 60);
- lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80);
- lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<");
- lv_obj_set_event_cb(btnPrevBG, event_handler);
-
- btnReset = lv_btn_create(lv_scr_act(), nullptr);
- btnReset->user_data = this;
- lv_obj_set_size(btnReset, 60, 60);
- lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
- lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst");
- lv_obj_set_event_cb(btnReset, event_handler);
-
- btnRandom = lv_btn_create(lv_scr_act(), nullptr);
- btnRandom->user_data = this;
- lv_obj_set_size(btnRandom, 60, 60);
- lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30);
- lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd");
- lv_obj_set_event_cb(btnRandom, event_handler);
-}
-
-SettingPineTimeStyle::~SettingPineTimeStyle() {
- lv_obj_clean(lv_scr_act());
- settingsController.SaveSettings();
-}
-
-void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) {
- auto valueTime = settingsController.GetPTSColorTime();
- auto valueBar = settingsController.GetPTSColorBar();
- auto valueBG = settingsController.GetPTSColorBG();
-
- if (event == LV_EVENT_CLICKED) {
- if (object == btnNextTime) {
- valueTime = GetNext(valueTime);
-
- settingsController.SetPTSColorTime(valueTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- }
- if (object == btnPrevTime) {
- valueTime = GetPrevious(valueTime);
- settingsController.SetPTSColorTime(valueTime);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime));
- }
- if (object == btnNextBar) {
- valueBar = GetNext(valueBar);
- if(valueBar == Controllers::Settings::Colors::Black)
- valueBar = GetNext(valueBar);
- settingsController.SetPTSColorBar(valueBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
- }
- if (object == btnPrevBar) {
- valueBar = GetPrevious(valueBar);
- if(valueBar == Controllers::Settings::Colors::Black)
- valueBar = GetPrevious(valueBar);
- settingsController.SetPTSColorBar(valueBar);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar));
- }
- if (object == btnNextBG) {
- valueBG = GetNext(valueBG);
- settingsController.SetPTSColorBG(valueBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
- }
- if (object == btnPrevBG) {
- valueBG = GetPrevious(valueBG);
- settingsController.SetPTSColorBG(valueBG);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG));
- }
- if (object == btnReset) {
- settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal);
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal);
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal));
- settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black);
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black));
- }
- if (object == btnRandom) {
- uint8_t randTime = rand() % 17;
- uint8_t randBar = rand() % 17;
- uint8_t randBG = rand() % 17;
- // Check if the time color is the same as its background, or if the sidebar is black. If so, change them to more useful values.
- if (randTime == randBG) {
- randBG += 1;
- }
- if (randBar == 3) {
- randBar -= 1;
- }
- settingsController.SetPTSColorTime(static_cast<Controllers::Settings::Colors>(randTime));
- lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
- lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
- lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randTime)));
- settingsController.SetPTSColorBar(static_cast<Controllers::Settings::Colors>(randBar));
- lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBar)));
- settingsController.SetPTSColorBG(static_cast<Controllers::Settings::Colors>(randBG));
- lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast<Controllers::Settings::Colors>(randBG)));
- }
- }
-}
-
-Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetNext(Pinetime::Controllers::Settings::Colors color) {
- auto colorAsInt = static_cast<uint8_t>(color);
- Pinetime::Controllers::Settings::Colors nextColor;
- if (colorAsInt < 16) {
- nextColor = static_cast<Controllers::Settings::Colors>(colorAsInt + 1);
- } else {
- nextColor = static_cast<Controllers::Settings::Colors>(0);
- }
- return nextColor;
-}
-
-Pinetime::Controllers::Settings::Colors SettingPineTimeStyle::GetPrevious(Pinetime::Controllers::Settings::Colors color) {
- auto colorAsInt = static_cast<uint8_t>(color);
- Pinetime::Controllers::Settings::Colors prevColor;
-
- if (colorAsInt > 0) {
- prevColor = static_cast<Controllers::Settings::Colors>(colorAsInt - 1);
- } else {
- prevColor = static_cast<Controllers::Settings::Colors>(16);
- }
- return prevColor;
-}
diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h
deleted file mode 100644
index 397bd86d..00000000
--- a/src/displayapp/screens/settings/SettingPineTimeStyle.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#pragma once
-
-#include <cstdint>
-#include <lvgl/lvgl.h>
-#include "components/settings/Settings.h"
-#include "displayapp/screens/Screen.h"
-
-namespace Pinetime {
-
- namespace Applications {
- namespace Screens {
-
- class SettingPineTimeStyle : public Screen{
- public:
- SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController);
- ~SettingPineTimeStyle() override;
-
- void UpdateSelected(lv_obj_t *object, lv_event_t event);
-
- private:
- Controllers::Settings& settingsController;
-
- Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color);
- Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color);
-
- lv_obj_t * btnNextTime;
- lv_obj_t * btnPrevTime;
- lv_obj_t * btnNextBar;
- lv_obj_t * btnPrevBar;
- lv_obj_t * btnNextBG;
- lv_obj_t * btnPrevBG;
- lv_obj_t * btnReset;
- lv_obj_t * btnRandom;
- lv_obj_t * timebar;
- lv_obj_t * sidebar;
- lv_obj_t * timeDD1;
- lv_obj_t * timeDD2;
- lv_obj_t * timeAMPM;
- lv_obj_t * dateDayOfWeek;
- lv_obj_t * dateDay;
- lv_obj_t * dateMonth;
- lv_obj_t * backgroundLabel;
- lv_obj_t * batteryIcon;
- lv_obj_t * bleIcon;
- lv_obj_t * calendarOuter;
- lv_obj_t * calendarInner;
- lv_obj_t * calendarBar1;
- lv_obj_t * calendarBar2;
- lv_obj_t * calendarCrossBar1;
- lv_obj_t * calendarCrossBar2;
- lv_obj_t * stepGauge;
- lv_color_t needle_colors[1];
- };
- }
- }
-}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
new file mode 100644
index 00000000..1791b550
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -0,0 +1,137 @@
+#include "SettingShakeThreshold.h"
+#include <lvgl/lvgl.h>
+#include "displayapp/DisplayApp.h"
+#include "displayapp/screens/Screen.h"
+#include "displayapp/screens/Symbols.h"
+
+using namespace Pinetime::Applications::Screens;
+
+namespace {
+ void event_handler(lv_obj_t* obj, lv_event_t event) {
+ SettingShakeThreshold* screen = static_cast<SettingShakeThreshold*>(obj->user_data);
+ screen->UpdateSelected(obj, event);
+ }
+}
+
+SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
+ Controllers::Settings& settingsController,
+ Controllers::MotionController& motionController,
+ System::SystemTask& systemTask)
+ : Screen(app), settingsController {settingsController}, motionController {motionController}, systemTask {systemTask} {
+
+ lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_text_static(title, "Wake Sensitivity");
+ lv_label_set_align(title, LV_LABEL_ALIGN_CENTER);
+ lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0);
+
+ positionArc = lv_arc_create(lv_scr_act(), nullptr);
+ positionArc->user_data = this;
+
+ lv_obj_set_event_cb(positionArc, event_handler);
+ lv_arc_set_bg_angles(positionArc, 180, 360);
+ lv_arc_set_range(positionArc, 0, 4095);
+ lv_arc_set_adjustable(positionArc, true);
+ lv_obj_set_width(positionArc, lv_obj_get_width(lv_scr_act()) - 10);
+ lv_obj_set_height(positionArc, 240);
+ lv_obj_align(positionArc, title, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
+
+ animArc = lv_arc_create(positionArc, positionArc);
+ lv_arc_set_adjustable(animArc, false);
+ lv_obj_set_width(animArc, lv_obj_get_width(positionArc));
+ lv_obj_set_height(animArc, lv_obj_get_height(positionArc));
+ lv_obj_align_mid(animArc, positionArc, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0);
+ lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_OPA_70);
+ lv_obj_set_style_local_line_opa(animArc, LV_ARC_PART_KNOB, LV_STATE_DEFAULT, LV_OPA_0);
+ lv_obj_set_style_local_line_color(animArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED);
+ lv_obj_set_style_local_bg_color(animArc, LV_ARC_PART_BG, LV_STATE_CHECKED, LV_COLOR_TRANSP);
+
+ animArc->user_data = this;
+ lv_obj_set_click(animArc, false);
+
+ calButton = lv_btn_create(lv_scr_act(), nullptr);
+ calButton->user_data = this;
+ lv_obj_set_event_cb(calButton, event_handler);
+ lv_obj_set_height(calButton, 80);
+ lv_obj_set_width(calButton, 200);
+ 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_arc_set_value(positionArc, settingsController.GetShakeThreshold());
+
+ vDecay = xTaskGetTickCount();
+ calibrating = false;
+ EnableForCal = false;
+ if(!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)){
+ EnableForCal = true;
+ settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,true);
+ }
+ refreshTask = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
+}
+
+SettingShakeThreshold::~SettingShakeThreshold() {
+ settingsController.SetShakeThreshold(lv_arc_get_value(positionArc));
+
+ if(EnableForCal){
+ settingsController.setWakeUpMode(Pinetime::Controllers::Settings::WakeUpMode::Shake,false);
+ EnableForCal = false;
+ }
+ lv_task_del(refreshTask);
+ settingsController.SaveSettings();
+ lv_obj_clean(lv_scr_act());
+}
+
+void SettingShakeThreshold::Refresh() {
+
+ if (calibrating == 1) {
+ if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(2000)) {
+ vCalTime = xTaskGetTickCount();
+ 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!!");
+ }
+ }
+ if (calibrating == 2) {
+
+ if ((motionController.currentShakeSpeed() - 300) > lv_arc_get_value(positionArc)) {
+ lv_arc_set_value(positionArc, (int16_t) motionController.currentShakeSpeed() - 300);
+ }
+ if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(7500)) {
+ lv_btn_set_state(calButton, LV_STATE_DEFAULT);
+ lv_event_send(calButton, LV_EVENT_VALUE_CHANGED, NULL);
+ }
+ }
+ if (motionController.currentShakeSpeed() - 300 > lv_arc_get_value(animArc)) {
+ lv_arc_set_value(animArc, (uint16_t) motionController.currentShakeSpeed() - 300);
+ vDecay = xTaskGetTickCount();
+ } else if ((xTaskGetTickCount() - vDecay) > pdMS_TO_TICKS(1500)) {
+ lv_arc_set_value(animArc, lv_arc_get_value(animArc) - 25);
+ }
+}
+
+void SettingShakeThreshold::UpdateSelected(lv_obj_t* object, lv_event_t event) {
+
+ switch (event) {
+ case LV_EVENT_VALUE_CHANGED: {
+ if (object == calButton) {
+ if (lv_btn_get_state(calButton) == LV_BTN_STATE_CHECKED_RELEASED && calibrating == 0) {
+ lv_arc_set_value(positionArc, 0);
+ calibrating = 1;
+ vCalTime = xTaskGetTickCount();
+ lv_label_set_text(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");
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.h b/src/displayapp/screens/settings/SettingShakeThreshold.h
new file mode 100644
index 00000000..b9ddd8b4
--- /dev/null
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include "components/settings/Settings.h"
+#include "displayapp/screens/Screen.h"
+#include <components/motion/MotionController.h>
+namespace Pinetime {
+
+ namespace Applications {
+ namespace Screens {
+
+ class SettingShakeThreshold : public Screen {
+ public:
+ SettingShakeThreshold(DisplayApp* app,
+ Pinetime::Controllers::Settings& settingsController,
+ Controllers::MotionController& motionController,
+ System::SystemTask& systemTask);
+
+ ~SettingShakeThreshold() override;
+ void Refresh() override;
+ void UpdateSelected(lv_obj_t* object, lv_event_t event);
+
+ private:
+ Controllers::Settings& settingsController;
+ Controllers::MotionController& motionController;
+ System::SystemTask& systemTask;
+ uint8_t calibrating;
+ bool EnableForCal;
+ uint32_t vDecay,vCalTime;
+ lv_obj_t *positionArc, *animArc,*calButton, *calLabel;
+ lv_task_t* refreshTask;
+ };
+ }
+ }
+}
diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp
index 8339d9ad..e1b6e36e 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.cpp
+++ b/src/displayapp/screens/settings/SettingWakeUp.cpp
@@ -65,6 +65,14 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::
lv_checkbox_set_checked(cbOption[optionsTotal], true);
}
optionsTotal++;
+ cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr);
+ lv_checkbox_set_text_static(cbOption[optionsTotal], " Shake Wake");
+ cbOption[optionsTotal]->user_data = this;
+ lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
+ if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)) {
+ lv_checkbox_set_checked(cbOption[optionsTotal], true);
+ }
+ optionsTotal++;
}
SettingWakeUp::~SettingWakeUp() {
diff --git a/src/displayapp/screens/settings/SettingWakeUp.h b/src/displayapp/screens/settings/SettingWakeUp.h
index b9a31dc9..cd244ae5 100644
--- a/src/displayapp/screens/settings/SettingWakeUp.h
+++ b/src/displayapp/screens/settings/SettingWakeUp.h
@@ -20,7 +20,7 @@ namespace Pinetime {
private:
Controllers::Settings& settingsController;
uint8_t optionsTotal;
- lv_obj_t* cbOption[4];
+ lv_obj_t* cbOption[5];
// When UpdateSelected is called, it uses lv_checkbox_set_checked,
// which can cause extra events to be fired,
// which might trigger UpdateSelected again, causing a loop.
diff --git a/src/displayapp/screens/settings/Settings.cpp b/src/displayapp/screens/settings/Settings.cpp
index 392c12e0..7bc90b47 100644
--- a/src/displayapp/screens/settings/Settings.cpp
+++ b/src/displayapp/screens/settings/Settings.cpp
@@ -47,12 +47,10 @@ std::unique_ptr<Screen> Settings::CreateScreen1() {
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);
}
@@ -60,10 +58,10 @@ std::unique_ptr<Screen> Settings::CreateScreen2() {
std::unique_ptr<Screen> Settings::CreateScreen3() {
std::array<Screens::List::Applications, 4> applications {{
- {Symbols::paintbrush, "PTS Colors", Apps::SettingPineTimeStyle},
+ {Symbols::clock, "Chimes", Apps::SettingChimes},
+ {Symbols::tachometer, "Shake Calib.", Apps::SettingShakeThreshold},
{Symbols::check, "Firmware", Apps::FirmwareValidation},
- {Symbols::list, "About", Apps::SysInfo},
- {Symbols::none, "None", Apps::None},
+ {Symbols::list, "About", Apps::SysInfo}
}};
return std::make_unique<Screens::List>(2, 3, app, settingsController, applications);