faire en sorte que watchfacemeow et watchface infineat soient compatibles, en cours

This commit is contained in:
Eve C 2024-07-09 12:05:06 +02:00
parent 8ed1d22a48
commit 164a21218f
3 changed files with 91 additions and 28 deletions

View file

@ -544,6 +544,8 @@ void WatchFaceInfineat::Refresh() {
lv_obj_align(alarmIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
}
}
stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());

View file

@ -195,11 +195,10 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
}
//Battery indicator
logoPine = lv_img_create(lv_scr_act(), nullptr);
lv_img_set_src(logoPine, "F:/images/cat_small.bin");
lv_obj_set_pos(logoPine, 12, 108);
logoCat = lv_img_create(lv_scr_act(), nullptr);
lv_img_set_src(logoCat, "F:/images/cat_small.bin");
lv_obj_set_pos(logoCat, 12, 108);
//adjust position for cat
lineBattery = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 30);
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
@ -260,26 +259,33 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
bleIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_TOP_MID, 0, -10);
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
// Based on existing code, I understand that items on the screen (date, bluteooth status..)
// are declared here with default states, and later below the state (date, ...) is assigned
// So I do the same to add the alarm status : I put a symbol that has a default value
// and a text that has a default value
// symbol
alarmIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alarmIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
lv_label_set_text_static(alarmIcon, Symbols::paw);
lv_obj_align(alarmIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
// text
labelAlarm = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(labelAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
lv_obj_set_style_local_text_font(labelAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
lv_obj_align(labelAlarm, alarmIcon, LV_ALIGN_OUT_BOTTOM_MID, -10, 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_label_set_text_static(labelAlarm, "00:00");
labelTimeAmPmAlarm = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_font(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
lv_label_set_text_static(labelTimeAmPmAlarm, "");
lv_obj_set_style_local_text_color(labelTimeAmPmAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
lv_obj_align(labelTimeAmPmAlarm, labelAlarm, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
// symbol
alarmIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alarmIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, pinkColor);
lv_label_set_text_static(alarmIcon, Symbols::paw);
lv_obj_align(alarmIcon, labelAlarm, LV_ALIGN_OUT_LEFT_MID, -3, 0);
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);
@ -326,7 +332,7 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
btnToggleCover = lv_btn_create(lv_scr_act(), nullptr);
btnToggleCover->user_data = this;
lv_obj_set_size(btnToggleCover, 60, 60);
lv_obj_align(btnToggleCover, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
lv_obj_align(btnToggleCover, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_local_bg_opa(btnToggleCover, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
const char* labelToggle = settingsController.GetInfineatShowSideCover() ? "ON" : "OFF";
lblToggle = lv_label_create(btnToggleCover, nullptr);
@ -334,6 +340,17 @@ WatchFaceMeow::WatchFaceMeow(Controllers::DateTime& dateTimeController,
lv_obj_set_event_cb(btnToggleCover, event_handler);
lv_obj_set_hidden(btnToggleCover, true);
btnToggleAlarm = lv_btn_create(lv_scr_act(), nullptr);
btnToggleAlarm->user_data = this;
lv_obj_set_size(btnToggleAlarm, 60, 60);
lv_obj_align(btnToggleAlarm, lv_scr_act(), LV_ALIGN_CENTER, 0, 80);
lv_obj_set_style_local_bg_opa(btnToggleAlarm, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_70);
const char* labelToggleAlarm = settingsController.GetInfineatShowAlarmStatus() ? Symbols::bell : Symbols::notbell;
lblAlarm = lv_label_create(btnToggleAlarm, nullptr);
lv_label_set_text_static(lblAlarm, labelToggleAlarm);
lv_obj_set_event_cb(btnToggleAlarm, event_handler);
lv_obj_set_hidden(btnToggleAlarm, true);
// Button to access the settings
btnSettings = lv_btn_create(lv_scr_act(), nullptr);
btnSettings->user_data = this;
@ -383,6 +400,7 @@ void WatchFaceMeow::CloseMenu() {
lv_obj_set_hidden(btnNextColor, true);
lv_obj_set_hidden(btnPrevColor, true);
lv_obj_set_hidden(btnToggleCover, true);
lv_obj_set_hidden(btnToggleAlarm, true);
}
bool WatchFaceMeow::OnButtonPushed() {
@ -397,6 +415,7 @@ void WatchFaceMeow::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
bool showSideCover = settingsController.GetInfineatShowSideCover();
int colorIndex = settingsController.GetInfineatColorIndex();
bool showAlarmStatus = settingsController.GetInfineatShowAlarmStatus();
if (object == btnSettings) {
lv_obj_set_hidden(btnSettings, true);
@ -404,6 +423,7 @@ void WatchFaceMeow::UpdateSelected(lv_obj_t* object, lv_event_t event) {
lv_obj_set_hidden(btnNextColor, !showSideCover);
lv_obj_set_hidden(btnPrevColor, !showSideCover);
lv_obj_set_hidden(btnToggleCover, false);
lv_obj_set_hidden(btnToggleAlarm, false);
}
if (object == btnClose) {
CloseMenu();
@ -419,6 +439,18 @@ void WatchFaceMeow::UpdateSelected(lv_obj_t* object, lv_event_t event) {
const char* labelToggle = showSideCover ? "OFF" : "ON";
lv_label_set_text_static(lblToggle, labelToggle);
}
if (object == btnToggleAlarm) {
settingsController.SetInfineatShowAlarmStatus(!showAlarmStatus);
bool newShowAlarmStatus = settingsController.GetInfineatShowAlarmStatus();
lv_obj_set_hidden(labelAlarm, !newShowAlarmStatus);
lv_obj_set_hidden(alarmIcon, !newShowAlarmStatus);
lv_obj_set_hidden(labelTimeAmPmAlarm, !newShowAlarmStatus);
const char* labelToggleAlarm = newShowAlarmStatus ? Symbols::bell : Symbols::notbell;
lv_label_set_text_static(lblAlarm, labelToggleAlarm);
}
if (object == btnNextColor) {
colorIndex = (colorIndex + 1) % nColors;
settingsController.SetInfineatColorIndex(colorIndex);
@ -502,22 +534,47 @@ void WatchFaceMeow::Refresh() {
//bleState.Get : in displayapp/widgets/StatusIcons.cpp: bleState = bleController.IsConnected();
//dynamic icons have their definitions in displayApp/screens/BleIcon.h / cpp
lv_label_set_text_static(bleIcon, BleIcon::GetIcon(bleState.Get()));
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_TOP_MID, 0, -10);
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
}
// Add alarm state and time
// AlarmState is an enum type in class AlarmController that is in namespace controllers
// TODO Eve : Not sure if it can handle automatically am / pm format
alarmState = alarmController.State()==Pinetime::Controllers::AlarmController::AlarmState::Set;
lv_label_set_text_static(alarmIcon, AlarmIcon::GetIcon(alarmState));
lv_obj_align(alarmIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
if (alarmState) {
uint8_t alarmHours = alarmController.Hours();
uint8_t alarmMinutes = alarmController.Minutes();
lv_label_set_text_fmt(labelAlarm, "%02d:%02d", alarmHours, alarmMinutes);
}
else {
lv_label_set_text_static(labelAlarm, Symbols::none);
if (settingsController.GetInfineatShowAlarmStatus()) {
alarmState = alarmController.State()==Pinetime::Controllers::AlarmController::AlarmState::Set;
// sets the icon as bird or bed
lv_label_set_text_static(alarmIcon, AlarmIcon::GetIcon(alarmState));
//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_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 {
lv_label_set_text_static(labelAlarm, Symbols::none);
lv_obj_align(alarmIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
lv_obj_align(alarmIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
}
}
@ -545,12 +602,12 @@ void WatchFaceMeow::SetBatteryLevel(uint8_t batteryPercent) {
void WatchFaceMeow::ToggleBatteryIndicatorColor(bool showSideCover) {
if (!showSideCover) { // make indicator and notification icon color white
lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
lv_obj_set_style_local_image_recolor(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_image_recolor_opa(logoCat, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);
lv_obj_set_style_local_image_recolor(logoCat, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
} else {
lv_obj_set_style_local_image_recolor_opa(logoPine, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
lv_obj_set_style_local_image_recolor_opa(logoCat, LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
const std::array<lv_color_t, nLines>* colors = returnColor(static_cast<enum colors>(settingsController.GetInfineatColorIndex()));
lv_obj_set_style_local_line_color(lineBattery, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, (*colors)[4]);
lv_obj_set_style_local_bg_color(notificationIcon, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, (*colors)[7]);

View file

@ -0,0 +1,4 @@
compare infineat and meow .h files to make declaration correct
faire en sorte to keep bell and not bell for inifneat wf
check the orig files and the files in lib if they need to be in git