mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 15:11:51 +02:00
start to add timer info on WatchFaceMeow
This commit is contained in:
parent
5e19e042c0
commit
b7263ed795
|
@ -146,6 +146,7 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
|
|||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::AlarmController& alarmController,
|
||||
Controllers::Timer& timerController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
|
@ -155,6 +156,7 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
|
|||
batteryController {batteryController},
|
||||
bleController {bleController},
|
||||
alarmController {alarmController},
|
||||
timerController {timerController},
|
||||
notificationManager {notificationManager},
|
||||
settingsController {settingsController},
|
||||
motionController {motionController} {
|
||||
|
@ -294,6 +296,26 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
|
|||
lv_obj_set_hidden(labelTimeAmPmAlarm, true);
|
||||
}
|
||||
|
||||
// text
|
||||
labelTimer = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(labelTimer, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
|
||||
lv_obj_set_style_local_text_font(labelTimer, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
//lv_obj_align(labelAlarm, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, -10, 0);
|
||||
lv_obj_align(labelAlarm, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||
lv_label_set_text_static(labelTimer, "00:00");
|
||||
|
||||
// symbol
|
||||
timerIcon = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(timerIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
|
||||
lv_label_set_text_static(timerIcon, Symbols::hourGlass);
|
||||
lv_obj_align(timerIcon, labelTimer, LV_ALIGN_OUT_LEFT_MID, -3, 0);
|
||||
|
||||
// don't show the icons jsut set if we don't show alarm status
|
||||
if (!settingsController.GetInfineatShowAlarmStatus()) {
|
||||
lv_obj_set_hidden(labelTimer, true);
|
||||
lv_obj_set_hidden(timerIcon, true);
|
||||
}
|
||||
|
||||
stepValue = lv_label_create(lv_scr_act(), nullptr);
|
||||
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
|
||||
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
|
@ -549,38 +571,51 @@ void WatchFaceMeow::Refresh() {
|
|||
// AlarmState is an enum type in class AlarmController that is in namespace controllers
|
||||
if (settingsController.GetInfineatShowAlarmStatus()) {
|
||||
alarmState = alarmController.State()==Pinetime::Controllers::AlarmController::AlarmState::Set;
|
||||
// sets the icon as bird or bed
|
||||
const char* alarmSymbol = Symbols::zzz;
|
||||
if(alarmState) {
|
||||
alarmSymbol = Symbols::bird;
|
||||
}
|
||||
lv_label_set_text_static(alarmIcon, alarmSymbol);
|
||||
//displays the time of the alarm or nothing if the alarm is not set
|
||||
if (alarmState) {
|
||||
uint8_t alarmHours = alarmController.Hours();
|
||||
uint8_t alarmMinutes = alarmController.Minutes();
|
||||
//handles the am pm format.
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (alarmHours == 0) {
|
||||
alarmHours = 12;
|
||||
} else if (alarmHours == 12) {
|
||||
ampmChar[0]='P';
|
||||
} else if (alarmHours > 12) {
|
||||
alarmHours = alarmHours - 12;
|
||||
ampmChar[0]='P';
|
||||
}
|
||||
lv_label_set_text(labelTimeAmPmAlarm, ampmChar);
|
||||
lv_obj_set_style_local_text_font(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(labelTimeAmPmAlarm, labelAlarm, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
|
||||
timerRunning = Pinetime::Controllers::Timer::timerController.IsRunning()
|
||||
if(!timerRunning)
|
||||
// sets the icon as bird or bed
|
||||
const char* alarmSymbol = Symbols::zzz;
|
||||
if(alarmState) {
|
||||
alarmSymbol = Symbols::bird;
|
||||
}
|
||||
lv_label_set_text_static(alarmIcon, alarmSymbol);
|
||||
//displays the time of the alarm or nothing if the alarm is not set
|
||||
if (alarmState) {
|
||||
uint8_t alarmHours = alarmController.Hours();
|
||||
uint8_t alarmMinutes = alarmController.Minutes();
|
||||
//handles the am pm format.
|
||||
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
|
||||
char ampmChar[3] = "AM";
|
||||
if (alarmHours == 0) {
|
||||
alarmHours = 12;
|
||||
} else if (alarmHours == 12) {
|
||||
ampmChar[0]='P';
|
||||
} else if (alarmHours > 12) {
|
||||
alarmHours = alarmHours - 12;
|
||||
ampmChar[0]='P';
|
||||
}
|
||||
lv_label_set_text(labelTimeAmPmAlarm, ampmChar);
|
||||
lv_obj_set_style_local_text_font(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
|
||||
lv_obj_align(labelTimeAmPmAlarm, labelAlarm, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
|
||||
}
|
||||
|
||||
lv_label_set_text_fmt(labelAlarm, "%02d:%02d", alarmHours, alarmMinutes);
|
||||
lv_label_set_text_fmt(labelAlarm, "%02d:%02d", alarmHours, alarmMinutes);
|
||||
|
||||
lv_obj_align(alarmIcon, labelAlarm, LV_ALIGN_OUT_LEFT_MID, -3, 0);
|
||||
lv_obj_align(labelAlarm, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, -10, 0);
|
||||
lv_obj_align(labelAlarm, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||
lv_obj_align(alarmIcon, labelAlarm, LV_ALIGN_OUT_LEFT_MID, -3, 0);
|
||||
lv_obj_align(labelAlarm, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, -10, 0);
|
||||
lv_obj_align(labelAlarm, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||
else{ //timer is running, display timer instead of alarm
|
||||
const char* timerSymbol = Symbols::hourGlass;
|
||||
lv_label_set_text_static(timerIcon, timerSymbol);
|
||||
auto secondsRemaining = std::chrono::duration_cast<std::chrono::seconds>(timer.GetTimeRemaining())/1000;
|
||||
timerMinutes = secondsRemaining.count() / 60;
|
||||
timerSeconds = secondsRemaining.count() % 60;
|
||||
lv_label_set_text_fmt(labelTimer, "%02d:%02d", timerMinutes, timerSeconds);
|
||||
|
||||
lv_obj_align(timerIcon, labelTimer, LV_ALIGN_OUT_LEFT_MID, -3, 0);
|
||||
lv_obj_align(labelTimer, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, -10, 0);
|
||||
lv_obj_align(labelTimer, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_label_set_text_static(labelAlarm, Symbols::none);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <displayapp/Controllers.h>
|
||||
#include "displayapp/screens/Screen.h"
|
||||
#include "components/datetime/DateTimeController.h"
|
||||
#include "displayapp/screens/Timer.h"
|
||||
#include "utility/DirtyValue.h"
|
||||
#include "displayapp/apps/Apps.h"
|
||||
|
||||
|
@ -29,6 +30,7 @@ namespace Pinetime {
|
|||
const Controllers::Battery& batteryController,
|
||||
const Controllers::Ble& bleController,
|
||||
Controllers::AlarmController& alarmController,
|
||||
Controllers::Timer& timerController,
|
||||
Controllers::NotificationManager& notificationManager,
|
||||
Controllers::Settings& settingsController,
|
||||
Controllers::MotionController& motionController,
|
||||
|
@ -55,6 +57,7 @@ namespace Pinetime {
|
|||
Utility::DirtyValue<bool> bleRadioEnabled {};
|
||||
bool alarmState {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
|
||||
bool timerRunning {};
|
||||
Utility::DirtyValue<uint32_t> stepCount {};
|
||||
Utility::DirtyValue<bool> notificationState {};
|
||||
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
|
||||
|
@ -76,6 +79,8 @@ namespace Pinetime {
|
|||
lv_obj_t* labelAlarm;
|
||||
lv_obj_t* labelTimeAmPmAlarm;
|
||||
lv_obj_t* alarmIcon;
|
||||
lv_obj_t* labelTimer;
|
||||
lv_obj_t* timerIcon;
|
||||
lv_obj_t* pawIcon;
|
||||
lv_obj_t* stepValue;
|
||||
lv_obj_t* notificationIcon;
|
||||
|
@ -95,6 +100,7 @@ namespace Pinetime {
|
|||
const Controllers::Battery& batteryController;
|
||||
const Controllers::Ble& bleController;
|
||||
Controllers::AlarmController& alarmController;
|
||||
Controllers::Timer& timerController;
|
||||
Controllers::NotificationManager& notificationManager;
|
||||
Controllers::Settings& settingsController;
|
||||
Controllers::MotionController& motionController;
|
||||
|
@ -120,6 +126,7 @@ namespace Pinetime {
|
|||
controllers.batteryController,
|
||||
controllers.bleController,
|
||||
controllers.alarmController,
|
||||
controllers.timer,
|
||||
controllers.notificationManager,
|
||||
controllers.settingsController,
|
||||
controllers.motionController,
|
||||
|
|
Loading…
Reference in a new issue