From e57ff28231cf0ace25c114b8768174087f288dc7 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 29 Aug 2021 12:40:48 +0300 Subject: [PATCH 01/16] Let lvgl control queueTimeout --- src/displayapp/DisplayApp.cpp | 24 ++++-------------------- src/displayapp/DisplayApp.h | 2 -- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index d6100ece..675162a1 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -141,19 +141,15 @@ uint32_t count = 0; bool toggle = true; void DisplayApp::Refresh() { TickType_t queueTimeout; - TickType_t delta; switch (state) { case States::Idle: - IdleState(); queueTimeout = portMAX_DELAY; break; case States::Running: - RunningState(); - delta = xTaskGetTickCount() - lastWakeTime; - if (delta > LV_DISP_DEF_REFR_PERIOD) { - delta = LV_DISP_DEF_REFR_PERIOD; + if (!currentScreen->IsRunning()) { + LoadApp(returnToApp, returnDirection); } - queueTimeout = LV_DISP_DEF_REFR_PERIOD - delta; + queueTimeout = lv_task_handler(); break; default: queueTimeout = portMAX_DELAY; @@ -161,9 +157,7 @@ void DisplayApp::Refresh() { } Messages msg; - bool messageReceived = xQueueReceive(msgQueue, &msg, queueTimeout); - lastWakeTime = xTaskGetTickCount(); - if (messageReceived) { + if (xQueueReceive(msgQueue, &msg, queueTimeout)) { switch (msg) { case Messages::DimScreen: // Backup brightness is the brightness to return to after dimming or sleeping @@ -275,13 +269,6 @@ void DisplayApp::Refresh() { } } -void DisplayApp::RunningState() { - if (!currentScreen->IsRunning()) { - LoadApp(returnToApp, returnDirection); - } - lv_task_handler(); -} - void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) { nextApp = app; nextDirection = direction; @@ -423,9 +410,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) currentApp = app; } -void DisplayApp::IdleState() { -} - void DisplayApp::PushMessage(Messages msg) { if (in_isr()) { BaseType_t xHigherPriorityTaskWoken; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index 96951d1c..b9e471bd 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -103,8 +103,6 @@ namespace Pinetime { TouchEvents returnTouchEvent = TouchEvents::None; TouchEvents GetGesture(); - void RunningState(); - void IdleState(); static void Process(void* instance); void InitHw(); void Refresh(); From fd52ca8fe6f42226ec32a001f4c61dc100ead94a Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 3 Sep 2021 14:35:38 +0300 Subject: [PATCH 02/16] Detect full charge and improve watchface display --- src/components/battery/BatteryController.cpp | 10 +++++-- src/components/battery/BatteryController.h | 9 +++++- src/displayapp/screens/BatteryInfo.cpp | 4 +-- src/displayapp/screens/PineTimeStyle.cpp | 31 +++++++++++--------- src/displayapp/screens/PineTimeStyle.h | 4 ++- src/displayapp/screens/WatchFaceAnalog.cpp | 28 +++++++++++++++--- src/displayapp/screens/WatchFaceAnalog.h | 2 ++ src/displayapp/screens/WatchFaceDigital.cpp | 12 ++++++-- src/displayapp/screens/WatchFaceDigital.h | 1 + 9 files changed, 75 insertions(+), 26 deletions(-) diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index f8a64ecd..619e227c 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -19,6 +19,12 @@ void Battery::Update() { isCharging = !nrf_gpio_pin_read(chargingPin); isPowerPresent = !nrf_gpio_pin_read(powerPresentPin); + if (isPowerPresent && !isCharging) { + isFull = true; + } else if (!isPowerPresent) { + isFull = false; + } + if (isReading) { return; } @@ -65,12 +71,12 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { // p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024 voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024; - if (voltage > battery_max) { + if (isFull) { percentRemaining = 100; } else if (voltage < battery_min) { percentRemaining = 0; } else { - percentRemaining = (voltage - battery_min) * 100 / (battery_max - battery_min); + percentRemaining = std::min((voltage - battery_min) * 100 / (battery_max - battery_min), 99); } nrfx_saadc_uninit(); diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 6f09b737..164057c4 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -23,13 +23,19 @@ namespace Pinetime { } bool IsCharging() const { - return isCharging; + // isCharging will go up and down when fully charged + // isFull makes sure this returns false while fully charged. + return isCharging && !isFull; } bool IsPowerPresent() const { return isPowerPresent; } + bool IsFull() const { + return isFull; + } + private: static Battery* instance; nrf_saadc_value_t saadc_value; @@ -40,6 +46,7 @@ namespace Pinetime { uint16_t voltage = 0; uint8_t percentRemaining = 0; + bool isFull = false; bool isCharging = false; bool isPowerPresent = false; diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 91c26512..4dcf29c5 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -60,10 +60,10 @@ void BatteryInfo::Refresh() { batteryPercent = batteryController.PercentRemaining(); batteryVoltage = batteryController.Voltage(); - if (batteryController.IsCharging() and batteryPercent < 100) { + if (batteryController.IsCharging()) { lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); lv_label_set_text_static(status, "Charging"); - } else if (batteryPercent == 100) { + } else if (batteryController.IsFull()) { lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_label_set_text_static(status, "Fully charged"); } else if (batteryPercent < 10) { diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 7a712f43..6766ecb0 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -100,10 +100,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); lv_label_set_text(batteryIcon, Symbols::batteryFull); lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); - - batteryPlug = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_align(batteryPlug, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); + lv_obj_set_auto_realign(batteryIcon, true); bleIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); @@ -205,18 +202,24 @@ PineTimeStyle::~PineTimeStyle() { lv_obj_clean(lv_scr_act()); } +void PineTimeStyle::SetBatteryIcon() { + auto batteryPercent = batteryPercentRemaining.Get(); + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); +} + void PineTimeStyle::Refresh() { - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated()) { - auto batteryPercent = batteryPercentRemaining.Get(); - if (batteryController.IsCharging()) { - auto isCharging = batteryController.IsCharging() || batteryController.IsPowerPresent(); - lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging)); - lv_obj_realign(batteryPlug); - lv_label_set_text(batteryIcon, ""); + isCharging = batteryController.IsCharging(); + if (isCharging.IsUpdated()) { + if (isCharging.Get()) { + lv_label_set_text(batteryIcon, Symbols::plug); } else { - lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); - lv_label_set_text(batteryPlug, ""); + SetBatteryIcon(); + } + } + if (!isCharging.Get()) { + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { + SetBatteryIcon(); } } diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index cb74ead5..ba473806 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -41,6 +41,7 @@ namespace Pinetime { uint8_t currentDay = 0; DirtyValue batteryPercentRemaining {}; + DirtyValue isCharging {}; DirtyValue bleState {}; DirtyValue> currentDateTime {}; DirtyValue motionSensorOk {}; @@ -58,7 +59,6 @@ namespace Pinetime { lv_obj_t* backgroundLabel; lv_obj_t* batteryIcon; lv_obj_t* bleIcon; - lv_obj_t* batteryPlug; lv_obj_t* calendarOuter; lv_obj_t* calendarInner; lv_obj_t* calendarBar1; @@ -76,6 +76,8 @@ namespace Pinetime { Controllers::Settings& settingsController; Controllers::MotionController& motionController; + void SetBatteryIcon(); + lv_task_t* taskRefresh; }; } diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 75e35c1b..843e557c 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -176,11 +176,31 @@ void WatchFaceAnalog::UpdateClock() { } } +void WatchFaceAnalog::SetBatteryIcon() { + auto batteryPercent = batteryPercentRemaining.Get(); + if (batteryPercent == 100) { + lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + } else { + lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + } + lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); +} + void WatchFaceAnalog::Refresh() { - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated()) { - auto batteryPercent = batteryPercentRemaining.Get(); - lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); + isCharging = batteryController.IsCharging(); + if (isCharging.IsUpdated()) { + if (isCharging.Get()) { + lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_label_set_text(batteryIcon, Symbols::plug); + } else { + SetBatteryIcon(); + } + } + if (!isCharging.Get()) { + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { + SetBatteryIcon(); + } } notificationState = notificationManager.AreNewNotificationsAvailable(); diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 406f4d50..001414a6 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -49,6 +49,7 @@ namespace Pinetime { uint8_t currentDay = 0; DirtyValue batteryPercentRemaining {0}; + DirtyValue isCharging {}; DirtyValue> currentDateTime; DirtyValue notificationState {false}; @@ -81,6 +82,7 @@ namespace Pinetime { Controllers::Settings& settingsController; void UpdateClock(); + void SetBatteryIcon(); lv_task_t* taskRefresh; }; diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 58ab6190..3e755f8e 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -102,12 +102,20 @@ WatchFaceDigital::~WatchFaceDigital() { } void WatchFaceDigital::Refresh() { + isCharging = batteryController.IsCharging(); + if (isCharging.IsUpdated()) { + lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging.Get())); + } + batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); + if (batteryPercent == 100) { + lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + } else { + lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + } lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); - auto isCharging = batteryController.IsCharging() or batteryController.IsPowerPresent(); - lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging)); } bleState = bleController.IsConnected(); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 48dc1373..69a6067d 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -44,6 +44,7 @@ namespace Pinetime { uint8_t currentDay = 0; DirtyValue batteryPercentRemaining {}; + DirtyValue isCharging {}; DirtyValue bleState {}; DirtyValue> currentDateTime {}; DirtyValue motionSensorOk {}; From ac2ccaeff6e713b0121b39a6ae5dfce15ea8680c Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 3 Sep 2021 14:57:07 +0300 Subject: [PATCH 03/16] Auto realign battery icon in Analog watch face --- src/displayapp/screens/WatchFaceAnalog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 843e557c..53e7faf7 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -68,6 +68,7 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app, batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(batteryIcon, Symbols::batteryHalf); lv_obj_align(batteryIcon, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0); + lv_obj_set_auto_realign(batteryIcon, true); notificationIcon = lv_label_create(lv_scr_act(), NULL); lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); From b31b2425f8afd5022173852f5a78592b37104c39 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Fri, 3 Sep 2021 16:57:00 +0300 Subject: [PATCH 04/16] Use percentage instead of IsFull --- src/components/battery/BatteryController.h | 4 ---- src/displayapp/screens/BatteryInfo.cpp | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 164057c4..b66da5e4 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -32,10 +32,6 @@ namespace Pinetime { return isPowerPresent; } - bool IsFull() const { - return isFull; - } - private: static Battery* instance; nrf_saadc_value_t saadc_value; diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 4dcf29c5..25fd1efa 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -63,7 +63,7 @@ void BatteryInfo::Refresh() { if (batteryController.IsCharging()) { lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); lv_label_set_text_static(status, "Charging"); - } else if (batteryController.IsFull()) { + } else if (batteryPercent == 100) { lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_label_set_text_static(status, "Fully charged"); } else if (batteryPercent < 10) { From 3ee4876214b70c107cabbb54f865e646e99f0d73 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Sun, 12 Sep 2021 11:08:25 +0300 Subject: [PATCH 05/16] Toggle notifications only, keep vibrations. --- src/components/ble/NotificationManager.cpp | 8 -------- src/components/ble/NotificationManager.h | 5 +---- src/components/motor/MotorController.cpp | 10 ---------- src/components/motor/MotorController.h | 5 ++--- src/components/settings/Settings.h | 14 +++++++------- src/displayapp/screens/Notifications.cpp | 4 ---- src/displayapp/screens/settings/QuickSettings.cpp | 6 +++--- src/main.cpp | 2 +- src/systemtask/SystemTask.cpp | 8 +++++--- 9 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp index b1b0e6b2..7ffed300 100644 --- a/src/components/ble/NotificationManager.cpp +++ b/src/components/ble/NotificationManager.cpp @@ -79,14 +79,6 @@ bool NotificationManager::AreNewNotificationsAvailable() { return newNotification; } -bool NotificationManager::IsVibrationEnabled() { - return vibrationEnabled; -} - -void NotificationManager::ToggleVibrations() { - vibrationEnabled = !vibrationEnabled; -} - bool NotificationManager::ClearNewNotificationFlag() { return newNotification.exchange(false); } diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h index d4072cc2..40f174ea 100644 --- a/src/components/ble/NotificationManager.h +++ b/src/components/ble/NotificationManager.h @@ -44,8 +44,6 @@ namespace Pinetime { Notification GetPrevious(Notification::Id id); bool ClearNewNotificationFlag(); bool AreNewNotificationsAvailable(); - bool IsVibrationEnabled(); - void ToggleVibrations(); static constexpr size_t MaximumMessageSize() { return MessageSize; @@ -60,7 +58,6 @@ namespace Pinetime { uint8_t writeIndex = 0; bool empty = true; std::atomic newNotification {false}; - bool vibrationEnabled = true; }; } -} \ No newline at end of file +} diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp index b25e6bc8..c79ecdd2 100644 --- a/src/components/motor/MotorController.cpp +++ b/src/components/motor/MotorController.cpp @@ -8,9 +8,6 @@ APP_TIMER_DEF(longVibTimer); using namespace Pinetime::Controllers; -MotorController::MotorController(Controllers::Settings& settingsController) : settingsController {settingsController} { -} - void MotorController::Init() { nrf_gpio_cfg_output(pinMotor); nrf_gpio_pin_set(pinMotor); @@ -26,18 +23,11 @@ void MotorController::Ring(void* p_context) { } void MotorController::RunForDuration(uint8_t motorDuration) { - if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) { - return; - } - nrf_gpio_pin_clear(pinMotor); app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr); } void MotorController::StartRinging() { - if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) { - return; - } Ring(this); app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this); } diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h index d2c9fe5f..574b86c8 100644 --- a/src/components/motor/MotorController.h +++ b/src/components/motor/MotorController.h @@ -2,7 +2,6 @@ #include #include "app_timer.h" -#include "components/settings/Settings.h" namespace Pinetime { namespace Controllers { @@ -10,7 +9,8 @@ namespace Pinetime { class MotorController { public: - MotorController(Controllers::Settings& settingsController); + MotorController() = default; + void Init(); void RunForDuration(uint8_t motorDuration); void StartRinging(); @@ -18,7 +18,6 @@ namespace Pinetime { private: static void Ring(void* p_context); - Controllers::Settings& settingsController; static void StopMotor(void* p_context); }; } diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index a294ab78..cb7555f3 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -11,7 +11,7 @@ namespace Pinetime { class Settings { public: enum class ClockType : uint8_t { H24, H12 }; - enum class Vibration : uint8_t { ON, OFF }; + enum class Notification : uint8_t { ON, OFF }; enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, @@ -93,14 +93,14 @@ namespace Pinetime { return settings.clockType; }; - void SetVibrationStatus(Vibration status) { - if (status != settings.vibrationStatus) { + void SetNotificationStatus(Notification status) { + if (status != settings.notificationStatus) { settingsChanged = true; } - settings.vibrationStatus = status; + settings.notificationStatus = status; }; - Vibration GetVibrationStatus() const { - return settings.vibrationStatus; + Notification GetNotificationStatus() const { + return settings.notificationStatus; }; void SetScreenTimeOut(uint32_t timeout) { @@ -170,7 +170,7 @@ namespace Pinetime { uint32_t screenTimeOut = 15000; ClockType clockType = ClockType::H24; - Vibration vibrationStatus = Vibration::ON; + Notification notificationStatus = Notification::ON; uint8_t clockFace = 0; diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 22eb290e..3f20d38a 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -129,10 +129,6 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { alertNotificationService); } return true; - case Pinetime::Applications::TouchEvents::LongTap: { - // notificationManager.ToggleVibrations(); - return true; - } default: return false; } diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 22b56360..691c40c8 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -88,7 +88,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, btn3_lvl = lv_label_create(btn3, nullptr); lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); - if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::ON) { + if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) { lv_obj_add_state(btn3, LV_STATE_CHECKED); lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); } else { @@ -142,11 +142,11 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { } else if (object == btn3 && event == LV_EVENT_VALUE_CHANGED) { if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) { - settingsController.SetVibrationStatus(Controllers::Settings::Vibration::ON); + settingsController.SetNotificationStatus(Controllers::Settings::Notification::ON); motorController.RunForDuration(35); lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); } else { - settingsController.SetVibrationStatus(Controllers::Settings::Vibration::OFF); + settingsController.SetNotificationStatus(Controllers::Settings::Notification::OFF); lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff); } diff --git a/src/main.cpp b/src/main.cpp index 79e2ad86..cea66bf3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,7 +123,7 @@ Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl); Pinetime::Controllers::FS fs {spiNorFlash}; Pinetime::Controllers::Settings settingsController {fs}; -Pinetime::Controllers::MotorController motorController {settingsController}; +Pinetime::Controllers::MotorController motorController {}; Pinetime::Applications::DisplayApp displayApp(lcd, diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 0617b0ce..fcff223c 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -263,10 +263,12 @@ void SystemTask::Work() { displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime); break; case Messages::OnNewNotification: - if (isSleeping && !isWakingUp) { - GoToRunning(); + if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) { + if (isSleeping && !isWakingUp) { + GoToRunning(); + } + displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification); } - displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification); break; case Messages::OnTimerDone: if (isSleeping && !isWakingUp) { From 63477fc09616b5f7df0af17dd5d990a760ba2ae4 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Mon, 13 Sep 2021 22:33:21 +0200 Subject: [PATCH 06/16] Fix unsigned/signed comparison warning in Metronome.cpp `xTaskGetTickCount()` returns a `TickType_t`, which is defined as an `uint32_t`. This is compared to the `bpm` variable, which is a `int16_t` in the range of 40 to 220 as defined in the constructor. ```cpp lv_arc_set_range(bpmArc, 40, 220); ``` Just assume that `bpm` is greater than 0, as this would result in a divison by zero or negative values, which would unintentionally underflow to a very large number. --- src/displayapp/screens/Metronome.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 884a4a51..52cb8519 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -78,7 +78,7 @@ Metronome::~Metronome() { void Metronome::Refresh() { if (metronomeStarted) { - if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) { + if (xTaskGetTickCount() - startTime > 60u * configTICK_RATE_HZ / static_cast(bpm)) { startTime += 60 * configTICK_RATE_HZ / bpm; counter--; if (counter == 0) { From f3b5da0049132f9b06ecc162039badc20e37d037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 19 Sep 2021 17:42:50 +0200 Subject: [PATCH 07/16] Fix the display of the date after a reset : when the date/time was restored from the noinit area, the date was displayed as "--" instead of the actual date. This issue was caused by DateTime::SetCurrentTime() that would not update the internal state of the class : dayOfWeek, Month, Year were not properly updated according to the current time. --- src/components/datetime/DateTimeController.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 6e426825..0756d38d 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -7,6 +7,7 @@ using namespace Pinetime::Controllers; void DateTime::SetCurrentTime(std::chrono::time_point t) { this->currentDateTime = t; + UpdateTime(previousSystickCounter); // Update internal state without updating the time } void DateTime::SetTime( From d7dfe5d4edd89d6cbc1cf02b3681811f17da774a Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Tue, 21 Sep 2021 15:36:31 +0300 Subject: [PATCH 08/16] Remove unused variable --- src/displayapp/DisplayApp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index b9e471bd..3000285c 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -112,7 +112,6 @@ namespace Pinetime { Apps nextApp = Apps::None; DisplayApp::FullRefreshDirections nextDirection; - TickType_t lastWakeTime; }; } } From 980ac173888883b34367395fdf8ee76c0aea6f72 Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 22 Sep 2021 13:58:45 +0300 Subject: [PATCH 09/16] Show plug icon while plugged in --- src/components/battery/BatteryController.cpp | 2 +- src/displayapp/screens/WatchFaceDigital.cpp | 6 +++--- src/displayapp/screens/WatchFaceDigital.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index d2ddae74..b43b229f 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -74,7 +74,7 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) { } else if (voltage < battery_min) { percentRemaining = 0; } else { - percentRemaining = std::min((voltage - battery_min) * 100 / (battery_max - battery_min), 99); + percentRemaining = std::min((voltage - battery_min) * 100 / (battery_max - battery_min), isCharging ? 99 : 100); } nrfx_saadc_uninit(); diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 3e755f8e..2ecab609 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -102,9 +102,9 @@ WatchFaceDigital::~WatchFaceDigital() { } void WatchFaceDigital::Refresh() { - isCharging = batteryController.IsCharging(); - if (isCharging.IsUpdated()) { - lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(isCharging.Get())); + powerPresent = batteryController.IsPowerPresent(); + if (powerPresent.IsUpdated()) { + lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get())); } batteryPercentRemaining = batteryController.PercentRemaining(); diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 69a6067d..e27545f3 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -44,7 +44,7 @@ namespace Pinetime { uint8_t currentDay = 0; DirtyValue batteryPercentRemaining {}; - DirtyValue isCharging {}; + DirtyValue powerPresent {}; DirtyValue bleState {}; DirtyValue> currentDateTime {}; DirtyValue motionSensorOk {}; From d7ca217872307357200e32ad679786d8f3396ca0 Mon Sep 17 00:00:00 2001 From: Daniel Jackson Date: Sat, 25 Sep 2021 23:48:53 +0100 Subject: [PATCH 10/16] Correctly return the tick at which the RF will be fully enabled. Always returning 0 (when `MYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME` is not defined), rather than a time near to the current tick, causes an issue in at least one place: `ble_ll_adv_sm_start()`, where the calculation of `delta` overflows when the system timer is at 0x80000000 or above -- causing an incorrect, huge adjustment to be made to the scheduled time, ultimately stopping adverts from being sent. --- .../nimble/controller/include/controller/ble_ll_rfmgmt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h b/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h index 37b81a88..5e2d636f 100644 --- a/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h +++ b/src/libs/mynewt-nimble/nimble/controller/include/controller/ble_ll_rfmgmt.h @@ -51,7 +51,7 @@ static inline void ble_ll_rfmgmt_reset(void) { } static inline void ble_ll_rfmgmt_scan_changed(bool e, uint32_t n) { } static inline void ble_ll_rfmgmt_sched_changed(struct ble_ll_sched_item *f) { } static inline void ble_ll_rfmgmt_release(void) { } -static inline uint32_t ble_ll_rfmgmt_enable_now(void) { return 0; } +static inline uint32_t ble_ll_rfmgmt_enable_now(void) { return os_cputime_get32(); } static inline bool ble_ll_rfmgmt_is_enabled(void) { return true; } #endif From d03db14129b4f8cc2e691dd6f9e8d8d1ed52b7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 26 Sep 2021 10:57:02 +0200 Subject: [PATCH 11/16] Set version to 1.5.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2402e57..ec582fa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(pinetime VERSION 1.4.0 LANGUAGES C CXX ASM) +project(pinetime VERSION 1.5.0 LANGUAGES C CXX ASM) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 14) From 7ba00b01577da988565094937e00f70b78e39ecc Mon Sep 17 00:00:00 2001 From: Daniel Jackson Date: Mon, 27 Sep 2021 02:42:53 +0100 Subject: [PATCH 12/16] Fix the size of the filesystem. Correct typo: 0x400000 - 0x0B4000 = 0x34C000. --- src/components/fs/FS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h index 1f2eb7e0..75ba16c8 100644 --- a/src/components/fs/FS.h +++ b/src/components/fs/FS.h @@ -53,7 +53,7 @@ namespace Pinetime { * */ static constexpr size_t startAddress = 0x0B4000; - static constexpr size_t size = 0x3C0000; + static constexpr size_t size = 0x34C000; static constexpr size_t blockSize = 4096; bool resourcesValid = false; From e9bb0b3cdd0e1b95b7bfdcfb94db5a6a0966eed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Tue, 28 Sep 2021 20:21:50 +0200 Subject: [PATCH 13/16] Set version to 1.6.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec582fa2..a8ecb81f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(pinetime VERSION 1.5.0 LANGUAGES C CXX ASM) +project(pinetime VERSION 1.6.0 LANGUAGES C CXX ASM) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 14) From 6aa945a4f5faf5f9e3ad589ebd5bd8bce4ef5dbf Mon Sep 17 00:00:00 2001 From: Sematre Date: Tue, 28 Sep 2021 21:36:24 +0200 Subject: [PATCH 14/16] Fix dead link in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d5cad93..9b9c3287 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ As of now, here is the list of achievements of this project: * **[Experimental]** [WebBLEWatch](https://hubmartin.github.io/WebBLEWatch/) Synchronize time directly from your web browser. [video](https://youtu.be/IakiuhVDdrY) * **[Experimental]** [Infini-iOS](https://github.com/xan-m/Infini-iOS) (on iOS) - OTA (Over-the-air) update via BLE - - [Bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader) based on [MCUBoot](https://juullabs-oss.github.io/mcuboot/) + - [Bootloader](https://github.com/JF002/pinetime-mcuboot-bootloader) based on [MCUBoot](https://www.mcuboot.com) ## Documentation From dafdf330627d6291acd56f16e8da8c914d19bb29 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sat, 2 Oct 2021 03:22:12 +0000 Subject: [PATCH 15/16] Remove static declartion on batteryValue preventing read attribute from updating. --- src/components/ble/BatteryInformationService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp index 7f176904..4ef02358 100644 --- a/src/components/ble/BatteryInformationService.cpp +++ b/src/components/ble/BatteryInformationService.cpp @@ -43,7 +43,7 @@ int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHand ble_gatt_access_ctxt* context) { if (attributeHandle == batteryLevelHandle) { NRF_LOG_INFO("BATTERY : handle = %d", batteryLevelHandle); - static uint8_t batteryValue = batteryController.PercentRemaining(); + uint8_t batteryValue = batteryController.PercentRemaining(); int res = os_mbuf_append(context->om, &batteryValue, 1); return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; } From 6475330048fc759a94203a006672b47481cd80ef Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 3 Oct 2021 17:26:04 +0300 Subject: [PATCH 16/16] Removed an unnecessary space and some punctuation Closes https://github.com/InfiniTimeOrg/InfiniTime/pull/233 --- doc/contribute.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/contribute.md b/doc/contribute.md index 0c34e2a5..b84d6c9c 100644 --- a/doc/contribute.md +++ b/doc/contribute.md @@ -18,18 +18,18 @@ You want to fix a bug, add a cool new functionality or improve the code? See *Ho The Pinetime is a cool open source project that deserves to be known. Talk about it around you, on social networks, on your blog,... and let people know that we are working on an open source firmware for a smartwatch! -# How to submit a pull request ? +# How to submit a pull request? ## TL;DR - - Create a branch from develop; - - Work on a single subject in this branch. Create multiple branches/pulls-requests if you want to work on multiple subjects (bugs, features,...); - - Test your modifications on the actual hardware; - - Check the code formatting against our coding conventions and [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy); - - Clean your code and remove files that are not needed; - - Write documentation related to your new feature if applicable; - - Create a pull request and write a great description about it : what does your PR do, why, how,... Add pictures and video if possible; - - Wait for someone to review your PR and take part in the review process; + - Create a branch from develop + - Work on a single subject in this branch. Create multiple branches/pulls-requests if you want to work on multiple subjects (bugs, features,...) + - Test your modifications on the actual hardware + - Check the code formatting against our coding conventions and [clang-format](../.clang-format) and [clang-tidy](../.clang-tidy) + - Clean your code and remove files that are not needed + - Write documentation related to your new feature if applicable + - Create a pull request and write a great description about it: what does your PR do, why, how,... Add pictures and video if possible + - Wait for someone to review your PR and take part in the review process - Your PR will eventually be merged :) Your contributions are more than welcome!