Adds enum class for chimes option

This commit is contained in:
SteveAmor 2022-01-04 19:32:29 +00:00
parent 7a0f72ed8b
commit 15c3807a76
3 changed files with 21 additions and 12 deletions

View file

@ -11,6 +11,7 @@ namespace Pinetime {
public: public:
enum class ClockType : uint8_t { H24, H12 }; enum class ClockType : uint8_t { H24, H12 };
enum class Notification : uint8_t { ON, OFF }; enum class Notification : uint8_t { ON, OFF };
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
enum class WakeUpMode : uint8_t { enum class WakeUpMode : uint8_t {
SingleTap = 0, SingleTap = 0,
DoubleTap = 1, DoubleTap = 1,
@ -40,14 +41,14 @@ namespace Pinetime {
return settings.clockFace; return settings.clockFace;
}; };
void SetChimesState(uint8_t state) { void SetChimeOption(ChimesOption chimeOption) {
if (state != settings.chimesState) { if (chimeOption != settings.chimesOption) {
settingsChanged = true; settingsChanged = true;
} }
settings.chimesState = state; settings.chimesOption = chimeOption;
}; };
uint8_t GetChimesState() const { ChimesOption GetChimeOption() const {
return settings.chimesState; return settings.chimesOption;
}; };
void SetPTSColorTime(Colors colorTime) { void SetPTSColorTime(Colors colorTime) {
@ -182,7 +183,7 @@ namespace Pinetime {
Notification notificationStatus = Notification::ON; Notification notificationStatus = Notification::ON;
uint8_t clockFace = 0; uint8_t clockFace = 0;
uint8_t chimesState = 0; ChimesOption chimesOption = ChimesOption::None;
PineTimeStyle PTS; PineTimeStyle PTS;

View file

@ -44,7 +44,7 @@ SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime::
lv_checkbox_set_text_static(cbOption[optionsTotal], " Off"); lv_checkbox_set_text_static(cbOption[optionsTotal], " Off");
cbOption[optionsTotal]->user_data = this; cbOption[optionsTotal]->user_data = this;
lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
if (settingsController.GetChimesState() == 0) { if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::None) {
lv_checkbox_set_checked(cbOption[optionsTotal], true); lv_checkbox_set_checked(cbOption[optionsTotal], true);
} }
@ -53,7 +53,7 @@ SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime::
lv_checkbox_set_text_static(cbOption[optionsTotal], " Every hour"); lv_checkbox_set_text_static(cbOption[optionsTotal], " Every hour");
cbOption[optionsTotal]->user_data = this; cbOption[optionsTotal]->user_data = this;
lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
if (settingsController.GetChimesState() == 1) { if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours) {
lv_checkbox_set_checked(cbOption[optionsTotal], true); lv_checkbox_set_checked(cbOption[optionsTotal], true);
} }
@ -62,7 +62,7 @@ SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime::
lv_checkbox_set_text_static(cbOption[optionsTotal], " Every 30 mins"); lv_checkbox_set_text_static(cbOption[optionsTotal], " Every 30 mins");
cbOption[optionsTotal]->user_data = this; cbOption[optionsTotal]->user_data = this;
lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); lv_obj_set_event_cb(cbOption[optionsTotal], event_handler);
if (settingsController.GetChimesState() == 2) { if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours) {
lv_checkbox_set_checked(cbOption[optionsTotal], true); lv_checkbox_set_checked(cbOption[optionsTotal], true);
} }
@ -79,7 +79,15 @@ void SettingChimes::UpdateSelected(lv_obj_t* object, lv_event_t event) {
for (uint8_t i = 0; i < optionsTotal; i++) { for (uint8_t i = 0; i < optionsTotal; i++) {
if (object == cbOption[i]) { if (object == cbOption[i]) {
lv_checkbox_set_checked(cbOption[i], true); lv_checkbox_set_checked(cbOption[i], true);
settingsController.SetChimesState(i); 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 { } else {
lv_checkbox_set_checked(cbOption[i], false); lv_checkbox_set_checked(cbOption[i], false);
} }

View file

@ -405,7 +405,7 @@ void SystemTask::Work() {
break; break;
case Messages::OnNewHour: case Messages::OnNewHour:
using Pinetime::Controllers::AlarmController; using Pinetime::Controllers::AlarmController;
if (settingsController.GetChimesState() == 1 && alarmController.State() != AlarmController::AlarmState::Alerting) { if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && alarmController.State() != AlarmController::AlarmState::Alerting) {
if (isSleeping && !isWakingUp) { if (isSleeping && !isWakingUp) {
GoToRunning(); GoToRunning();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock);
@ -415,7 +415,7 @@ void SystemTask::Work() {
break; break;
case Messages::OnNewHalfHour: case Messages::OnNewHalfHour:
using Pinetime::Controllers::AlarmController; using Pinetime::Controllers::AlarmController;
if (settingsController.GetChimesState() == 2 && alarmController.State() != AlarmController::AlarmState::Alerting) { if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && alarmController.State() != AlarmController::AlarmState::Alerting) {
if (isSleeping && !isWakingUp) { if (isSleeping && !isWakingUp) {
GoToRunning(); GoToRunning();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock);