Toggle notifications only, keep vibrations.
This commit is contained in:
parent
cdf5801efe
commit
3ee4876214
9 changed files with 19 additions and 43 deletions
|
@ -79,14 +79,6 @@ bool NotificationManager::AreNewNotificationsAvailable() {
|
||||||
return newNotification;
|
return newNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotificationManager::IsVibrationEnabled() {
|
|
||||||
return vibrationEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotificationManager::ToggleVibrations() {
|
|
||||||
vibrationEnabled = !vibrationEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NotificationManager::ClearNewNotificationFlag() {
|
bool NotificationManager::ClearNewNotificationFlag() {
|
||||||
return newNotification.exchange(false);
|
return newNotification.exchange(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,6 @@ namespace Pinetime {
|
||||||
Notification GetPrevious(Notification::Id id);
|
Notification GetPrevious(Notification::Id id);
|
||||||
bool ClearNewNotificationFlag();
|
bool ClearNewNotificationFlag();
|
||||||
bool AreNewNotificationsAvailable();
|
bool AreNewNotificationsAvailable();
|
||||||
bool IsVibrationEnabled();
|
|
||||||
void ToggleVibrations();
|
|
||||||
|
|
||||||
static constexpr size_t MaximumMessageSize() {
|
static constexpr size_t MaximumMessageSize() {
|
||||||
return MessageSize;
|
return MessageSize;
|
||||||
|
@ -60,7 +58,6 @@ namespace Pinetime {
|
||||||
uint8_t writeIndex = 0;
|
uint8_t writeIndex = 0;
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
std::atomic<bool> newNotification {false};
|
std::atomic<bool> newNotification {false};
|
||||||
bool vibrationEnabled = true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,9 +8,6 @@ APP_TIMER_DEF(longVibTimer);
|
||||||
|
|
||||||
using namespace Pinetime::Controllers;
|
using namespace Pinetime::Controllers;
|
||||||
|
|
||||||
MotorController::MotorController(Controllers::Settings& settingsController) : settingsController {settingsController} {
|
|
||||||
}
|
|
||||||
|
|
||||||
void MotorController::Init() {
|
void MotorController::Init() {
|
||||||
nrf_gpio_cfg_output(pinMotor);
|
nrf_gpio_cfg_output(pinMotor);
|
||||||
nrf_gpio_pin_set(pinMotor);
|
nrf_gpio_pin_set(pinMotor);
|
||||||
|
@ -26,18 +23,11 @@ void MotorController::Ring(void* p_context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotorController::RunForDuration(uint8_t motorDuration) {
|
void MotorController::RunForDuration(uint8_t motorDuration) {
|
||||||
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nrf_gpio_pin_clear(pinMotor);
|
nrf_gpio_pin_clear(pinMotor);
|
||||||
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
|
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotorController::StartRinging() {
|
void MotorController::StartRinging() {
|
||||||
if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Ring(this);
|
Ring(this);
|
||||||
app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this);
|
app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "app_timer.h"
|
#include "app_timer.h"
|
||||||
#include "components/settings/Settings.h"
|
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
@ -10,7 +9,8 @@ namespace Pinetime {
|
||||||
|
|
||||||
class MotorController {
|
class MotorController {
|
||||||
public:
|
public:
|
||||||
MotorController(Controllers::Settings& settingsController);
|
MotorController() = default;
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void RunForDuration(uint8_t motorDuration);
|
void RunForDuration(uint8_t motorDuration);
|
||||||
void StartRinging();
|
void StartRinging();
|
||||||
|
@ -18,7 +18,6 @@ namespace Pinetime {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void Ring(void* p_context);
|
static void Ring(void* p_context);
|
||||||
Controllers::Settings& settingsController;
|
|
||||||
static void StopMotor(void* p_context);
|
static void StopMotor(void* p_context);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Pinetime {
|
||||||
class Settings {
|
class Settings {
|
||||||
public:
|
public:
|
||||||
enum class ClockType : uint8_t { H24, H12 };
|
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 {
|
enum class WakeUpMode : uint8_t {
|
||||||
SingleTap = 0,
|
SingleTap = 0,
|
||||||
DoubleTap = 1,
|
DoubleTap = 1,
|
||||||
|
@ -93,14 +93,14 @@ namespace Pinetime {
|
||||||
return settings.clockType;
|
return settings.clockType;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetVibrationStatus(Vibration status) {
|
void SetNotificationStatus(Notification status) {
|
||||||
if (status != settings.vibrationStatus) {
|
if (status != settings.notificationStatus) {
|
||||||
settingsChanged = true;
|
settingsChanged = true;
|
||||||
}
|
}
|
||||||
settings.vibrationStatus = status;
|
settings.notificationStatus = status;
|
||||||
};
|
};
|
||||||
Vibration GetVibrationStatus() const {
|
Notification GetNotificationStatus() const {
|
||||||
return settings.vibrationStatus;
|
return settings.notificationStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetScreenTimeOut(uint32_t timeout) {
|
void SetScreenTimeOut(uint32_t timeout) {
|
||||||
|
@ -170,7 +170,7 @@ namespace Pinetime {
|
||||||
uint32_t screenTimeOut = 15000;
|
uint32_t screenTimeOut = 15000;
|
||||||
|
|
||||||
ClockType clockType = ClockType::H24;
|
ClockType clockType = ClockType::H24;
|
||||||
Vibration vibrationStatus = Vibration::ON;
|
Notification notificationStatus = Notification::ON;
|
||||||
|
|
||||||
uint8_t clockFace = 0;
|
uint8_t clockFace = 0;
|
||||||
|
|
||||||
|
|
|
@ -129,10 +129,6 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
alertNotificationService);
|
alertNotificationService);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Pinetime::Applications::TouchEvents::LongTap: {
|
|
||||||
// notificationManager.ToggleVibrations();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
|
||||||
btn3_lvl = lv_label_create(btn3, nullptr);
|
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);
|
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_obj_add_state(btn3, LV_STATE_CHECKED);
|
||||||
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
|
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
|
||||||
} else {
|
} 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) {
|
} else if (object == btn3 && event == LV_EVENT_VALUE_CHANGED) {
|
||||||
|
|
||||||
if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) {
|
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);
|
motorController.RunForDuration(35);
|
||||||
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
|
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn);
|
||||||
} else {
|
} else {
|
||||||
settingsController.SetVibrationStatus(Controllers::Settings::Vibration::OFF);
|
settingsController.SetNotificationStatus(Controllers::Settings::Notification::OFF);
|
||||||
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
|
lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ Pinetime::Controllers::TouchHandler touchHandler(touchPanel, lvgl);
|
||||||
|
|
||||||
Pinetime::Controllers::FS fs {spiNorFlash};
|
Pinetime::Controllers::FS fs {spiNorFlash};
|
||||||
Pinetime::Controllers::Settings settingsController {fs};
|
Pinetime::Controllers::Settings settingsController {fs};
|
||||||
Pinetime::Controllers::MotorController motorController {settingsController};
|
Pinetime::Controllers::MotorController motorController {};
|
||||||
|
|
||||||
|
|
||||||
Pinetime::Applications::DisplayApp displayApp(lcd,
|
Pinetime::Applications::DisplayApp displayApp(lcd,
|
||||||
|
|
|
@ -263,10 +263,12 @@ void SystemTask::Work() {
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime);
|
||||||
break;
|
break;
|
||||||
case Messages::OnNewNotification:
|
case Messages::OnNewNotification:
|
||||||
|
if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) {
|
||||||
if (isSleeping && !isWakingUp) {
|
if (isSleeping && !isWakingUp) {
|
||||||
GoToRunning();
|
GoToRunning();
|
||||||
}
|
}
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::NewNotification);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::OnTimerDone:
|
case Messages::OnTimerDone:
|
||||||
if (isSleeping && !isWakingUp) {
|
if (isSleeping && !isWakingUp) {
|
||||||
|
|
Loading…
Reference in a new issue