Added alarm 12 hour interface
This commit is contained in:
parent
ae0724c28c
commit
2daa5dcbee
|
@ -379,7 +379,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
|||
currentScreen = std::make_unique<Screens::Timer>(this, timerController);
|
||||
break;
|
||||
case Apps::Alarm:
|
||||
currentScreen = std::make_unique<Screens::Alarm>(this, alarmController);
|
||||
currentScreen = std::make_unique<Screens::Alarm>(this, alarmController, settingsController);
|
||||
break;
|
||||
|
||||
// Settings
|
||||
|
@ -425,7 +425,7 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
|||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||
break;
|
||||
case Apps::SettingShakeThreshold:
|
||||
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController,motionController,*systemTask);
|
||||
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask);
|
||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
||||
break;
|
||||
case Apps::BatteryInfo:
|
||||
|
|
|
@ -27,8 +27,8 @@ static void btnEventHandler(lv_obj_t* obj, lv_event_t event) {
|
|||
screen->OnButtonEvent(obj, event);
|
||||
}
|
||||
|
||||
Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
|
||||
: Screen(app), running {true}, alarmController {alarmController} {
|
||||
Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController, Pinetime::Controllers::Settings& settingsController)
|
||||
: Screen(app), running {true}, alarmController {alarmController}, settingsController {settingsController} {
|
||||
|
||||
time = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76);
|
||||
|
@ -40,6 +40,13 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
|
|||
|
||||
lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25);
|
||||
|
||||
lblampm = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_font(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20);
|
||||
lv_obj_set_style_local_text_color(lblampm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
|
||||
lv_label_set_text_static(lblampm, " ");
|
||||
lv_label_set_align(lblampm, LV_LABEL_ALIGN_CENTER);
|
||||
lv_obj_align(lblampm, lv_scr_act(), LV_ALIGN_CENTER, 0, 30);
|
||||
|
||||
btnHoursUp = lv_btn_create(lv_scr_act(), nullptr);
|
||||
btnHoursUp->user_data = this;
|
||||
lv_obj_set_event_cb(btnHoursUp, btnEventHandler);
|
||||
|
@ -95,6 +102,8 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController)
|
|||
lv_obj_align(btnInfo, lv_scr_act(), LV_ALIGN_CENTER, 0, -85);
|
||||
txtInfo = lv_label_create(btnInfo, nullptr);
|
||||
lv_label_set_text_static(txtInfo, "i");
|
||||
|
||||
UpdateAlarmTime();
|
||||
}
|
||||
|
||||
Alarm::~Alarm() {
|
||||
|
@ -180,7 +189,28 @@ bool Alarm::OnButtonPushed() {
|
|||
}
|
||||
|
||||
void Alarm::UpdateAlarmTime() {
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
switch (alarmHours) {
|
||||
case 0:
|
||||
lv_label_set_text_static(lblampm, "AM");
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes);
|
||||
break;
|
||||
case 1 ... 11:
|
||||
lv_label_set_text_static(lblampm, "AM");
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
|
||||
break;
|
||||
case 12:
|
||||
lv_label_set_text_static(lblampm, "PM");
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", 12, alarmMinutes);
|
||||
break;
|
||||
case 13 ... 23:
|
||||
lv_label_set_text_static(lblampm, "PM");
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours - 12, alarmMinutes);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
lv_label_set_text_fmt(time, "%02d:%02d", alarmHours, alarmMinutes);
|
||||
}
|
||||
alarmController.SetAlarmTime(alarmHours, alarmMinutes);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Pinetime {
|
|||
namespace Screens {
|
||||
class Alarm : public Screen {
|
||||
public:
|
||||
Alarm(DisplayApp* app, Controllers::AlarmController& alarmController);
|
||||
Alarm(DisplayApp* app, Controllers::AlarmController& alarmController, Pinetime::Controllers::Settings& settingsController);
|
||||
~Alarm() override;
|
||||
void SetAlerting();
|
||||
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
||||
|
@ -38,9 +38,10 @@ namespace Pinetime {
|
|||
uint8_t alarmHours;
|
||||
uint8_t alarmMinutes;
|
||||
Controllers::AlarmController& alarmController;
|
||||
Controllers::Settings& settingsController;
|
||||
|
||||
lv_obj_t *time, *btnEnable, *txtEnable, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp, *txtMinDown,
|
||||
*txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo;
|
||||
lv_obj_t *time, *lblampm, *btnEnable, *txtEnable, *btnMinutesUp, *btnMinutesDown, *btnHoursUp, *btnHoursDown, *txtMinUp,
|
||||
*txtMinDown, *txtHrUp, *txtHrDown, *btnRecur, *txtRecur, *btnInfo, *txtInfo;
|
||||
lv_obj_t* txtMessage = nullptr;
|
||||
lv_obj_t* btnMessage = nullptr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user