Skip to content

Commit 3ee4876

Browse files
committed
Toggle notifications only, keep vibrations.
1 parent cdf5801 commit 3ee4876

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
@@ -8,9 +8,6 @@ APP_TIMER_DEF(longVibTimer);
88

99
using namespace Pinetime::Controllers;
1010

11-
MotorController::MotorController(Controllers::Settings& settingsController) : settingsController {settingsController} {
12-
}
13-
1411
void MotorController::Init() {
1512
nrf_gpio_cfg_output(pinMotor);
1613
nrf_gpio_pin_set(pinMotor);
@@ -26,18 +23,11 @@ void MotorController::Ring(void* p_context) {
2623
}
2724

2825
void MotorController::RunForDuration(uint8_t motorDuration) {
29-
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
30-
return;
31-
}
32-
3326
nrf_gpio_pin_clear(pinMotor);
3427
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
3528
}
3629

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

src/components/motor/MotorController.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22

33
#include <cstdint>
44
#include "app_timer.h"
5-
#include "components/settings/Settings.h"
65

76
namespace Pinetime {
87
namespace Controllers {
98
static constexpr uint8_t pinMotor = 16;
109

1110
class MotorController {
1211
public:
13-
MotorController(Controllers::Settings& settingsController);
12+
MotorController() = default;
13+
1414
void Init();
1515
void RunForDuration(uint8_t motorDuration);
1616
void StartRinging();
1717
static void StopRinging();
1818

1919
private:
2020
static void Ring(void* p_context);
21-
Controllers::Settings& settingsController;
2221
static void StopMotor(void* p_context);
2322
};
2423
}

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
@@ -123,7 +123,7 @@ Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
123123

124124
Pinetime::Controllers::FS fs {spiNorFlash};
125125
Pinetime::Controllers::Settings settingsController {fs};
126-
Pinetime::Controllers::MotorController motorController {settingsController};
126+
Pinetime::Controllers::MotorController motorController {};
127127

128128

129129
Pinetime::Applications::DisplayApp displayApp(lcd,

src/systemtask/SystemTask.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ void SystemTask::Work() {
263263
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
264264
break;
265265
case Messages::OnNewNotification:
266-
if (isSleeping && !isWakingUp) {
267-
GoToRunning();
266+
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
267+
if (isSleeping && !isWakingUp) {
268+
GoToRunning();
269+
}
270+
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
268271
}
269-
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
270272
break;
271273
case Messages::OnTimerDone:
272274
if (isSleeping && !isWakingUp) {

0 commit comments

Comments
 (0)