summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
authorEli Weiss <eliwss0@gmail.com>2022-01-16 09:40:23 -0500
committerJF <JF002@users.noreply.github.com>2022-01-31 20:42:48 +0100
commit2daa5dcbeeecc0d6940906dadc42df1bd10b9b7e (patch)
treeff32a409202ee94bc3dd21e03d783f245519353b /src/displayapp
parentae0724c28c33cf99886aae7df1997ed5a23f0684 (diff)
Added alarm 12 hour interface
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/DisplayApp.cpp4
-rw-r--r--src/displayapp/screens/Alarm.cpp36
-rw-r--r--src/displayapp/screens/Alarm.h7
3 files changed, 39 insertions, 8 deletions
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 1b77e87d..672bcb34 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -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:
diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp
index 537ac0e0..b8eaa6d5 100644
--- a/src/displayapp/screens/Alarm.cpp
+++ b/src/displayapp/screens/Alarm.cpp
@@ -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);
}
diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h
index 4b301ce1..d45fb96c 100644
--- a/src/displayapp/screens/Alarm.h
+++ b/src/displayapp/screens/Alarm.h
@@ -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;