Skip to content

Commit 8a2b86d

Browse files
authored
Merge pull request #664 from Riksu9000/disable_notif_only
Toggle notifications only, keep vibrations.
2 parents 1c3c3c8 + 93d240a commit 8a2b86d

9 files changed

Lines changed: 19 additions & 43 deletions

File tree

src/components/ble/NotificationManager.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ bool NotificationManager::AreNewNotificationsAvailable() {
7979
return newNotification;
8080
}
8181

82-
bool NotificationManager::IsVibrationEnabled() {
83-
return vibrationEnabled;
84-
}
85-
86-
void NotificationManager::ToggleVibrations() {
87-
vibrationEnabled = !vibrationEnabled;
88-
}
89-
9082
bool NotificationManager::ClearNewNotificationFlag() {
9183
return newNotification.exchange(false);
9284
}

src/components/ble/NotificationManager.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ namespace Pinetime {
4444
Notification GetPrevious(Notification::Id id);
4545
bool ClearNewNotificationFlag();
4646
bool AreNewNotificationsAvailable();
47-
bool IsVibrationEnabled();
48-
void ToggleVibrations();
4947

5048
static constexpr size_t MaximumMessageSize() {
5149
return MessageSize;
@@ -60,7 +58,6 @@ namespace Pinetime {
6058
uint8_t writeIndex = 0;
6159
bool empty = true;
6260
std::atomic<bool> newNotification {false};
63-
bool vibrationEnabled = true;
6461
};
6562
}
66-
}
63+
}

src/components/motor/MotorController.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ APP_TIMER_DEF(longVibTimer);
99

1010
using namespace Pinetime::Controllers;
1111

12-
MotorController::MotorController(Controllers::Settings& settingsController) : settingsController {settingsController} {
13-
}
14-
1512
void MotorController::Init() {
1613
nrf_gpio_cfg_output(PinMap::Motor);
1714
nrf_gpio_pin_set(PinMap::Motor);
@@ -27,18 +24,11 @@ void MotorController::Ring(void* p_context) {
2724
}
2825

2926
void MotorController::RunForDuration(uint8_t motorDuration) {
30-
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
31-
return;
32-
}
33-
3427
nrf_gpio_pin_clear(PinMap::Motor);
3528
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
3629
}
3730

3831
void MotorController::StartRinging() {
39-
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
40-
return;
41-
}
4232
Ring(this);
4333
app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this);
4434
}

src/components/motor/MotorController.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
#pragma once
22

33
#include <cstdint>
4-
#include "components/settings/Settings.h"
54

65
namespace Pinetime {
76
namespace Controllers {
87

98
class MotorController {
109
public:
11-
MotorController(Controllers::Settings& settingsController);
10+
MotorController() = default;
11+
1212
void Init();
1313
void RunForDuration(uint8_t motorDuration);
1414
void StartRinging();
1515
static void StopRinging();
1616

1717
private:
1818
static void Ring(void* p_context);
19-
Controllers::Settings& settingsController;
2019
static void StopMotor(void* p_context);
2120
};
2221
}

src/components/settings/Settings.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Pinetime {
1111
class Settings {
1212
public:
1313
enum class ClockType : uint8_t { H24, H12 };
14-
enum class Vibration : uint8_t { ON, OFF };
14+
enum class Notification : uint8_t { ON, OFF };
1515
enum class WakeUpMode : uint8_t {
1616
SingleTap = 0,
1717
DoubleTap = 1,
@@ -93,14 +93,14 @@ namespace Pinetime {
9393
return settings.clockType;
9494
};
9595

96-
void SetVibrationStatus(Vibration status) {
97-
if (status != settings.vibrationStatus) {
96+
void SetNotificationStatus(Notification status) {
97+
if (status != settings.notificationStatus) {
9898
settingsChanged = true;
9999
}
100-
settings.vibrationStatus = status;
100+
settings.notificationStatus = status;
101101
};
102-
Vibration GetVibrationStatus() const {
103-
return settings.vibrationStatus;
102+
Notification GetNotificationStatus() const {
103+
return settings.notificationStatus;
104104
};
105105

106106
void SetScreenTimeOut(uint32_t timeout) {
@@ -170,7 +170,7 @@ namespace Pinetime {
170170
uint32_t screenTimeOut = 15000;
171171

172172
ClockType clockType = ClockType::H24;
173-
Vibration vibrationStatus = Vibration::ON;
173+
Notification notificationStatus = Notification::ON;
174174

175175
uint8_t clockFace = 0;
176176

src/displayapp/screens/Notifications.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
129129
alertNotificationService);
130130
}
131131
return true;
132-
case Pinetime::Applications::TouchEvents::LongTap: {
133-
// notificationManager.ToggleVibrations();
134-
return true;
135-
}
136132
default:
137133
return false;
138134
}

src/displayapp/screens/settings/QuickSettings.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
8888
btn3_lvl = lv_label_create(btn3, nullptr);
8989
lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
9090

91-
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::ON) {
91+
if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) {
9292
lv_obj_add_state(btn3, LV_STATE_CHECKED);
9393
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
9494
} else {
@@ -142,11 +142,11 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) {
142142
} else if (object == btn3 && event == LV_EVENT_VALUE_CHANGED) {
143143

144144
if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) {
145-
settingsController.SetVibrationStatus(Controllers::Settings::Vibration::ON);
145+
settingsController.SetNotificationStatus(Controllers::Settings::Notification::ON);
146146
motorController.RunForDuration(35);
147147
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
148148
} else {
149-
settingsController.SetVibrationStatus(Controllers::Settings::Vibration::OFF);
149+
settingsController.SetNotificationStatus(Controllers::Settings::Notification::OFF);
150150
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
151151
}
152152

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
113113

114114
Pinetime::Controllers::FS fs {spiNorFlash};
115115
Pinetime::Controllers::Settings settingsController {fs};
116-
Pinetime::Controllers::MotorController motorController {settingsController};
116+
Pinetime::Controllers::MotorController motorController {};
117117

118118
Pinetime::Applications::DisplayApp displayApp(lcd,
119119
lvgl,

src/systemtask/SystemTask.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,12 @@ void SystemTask::Work() {
269269
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
270270
break;
271271
case Messages::OnNewNotification:
272-
if (isSleeping && !isWakingUp) {
273-
GoToRunning();
272+
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
273+
if (isSleeping && !isWakingUp) {
274+
GoToRunning();
275+
}
276+
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
274277
}
275-
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
276278
break;
277279
case Messages::OnTimerDone:
278280
if (isSleeping && !isWakingUp) {

0 commit comments

Comments
 (0)