This commit is contained in:
Eve1374 2024-10-02 17:56:38 +00:00 committed by GitHub
commit 65d2da7918
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 357 additions and 3 deletions

1
.gitignore vendored
View file

@ -11,6 +11,7 @@ cmake_install.cmake
Makefile
build
tools
node_modules
# Resulting binary files
*.a

View file

@ -0,0 +1,22 @@
# [InfiniTime : show alarm status on infineat watchface](https://github.com/Eve1374/InfiniTime/tree/alarm-status-on-infineat)
- I forked from [InfiniTime](https://github.com/InfiniTimeOrg/InfiniTime) and added a branch alarm-status-on-infineat
- I modified the watchface settings to have the possibility to show alarm status on watchface
Here are pictures with alarm set in 12 and 24hrs format :
![alarm set and shown, 12hrs format](infineat_alarm_set_12hrs.png "alarm set and shown, 12hrs format")
![alarm set and shown, 24hrs format](infineat_alarm_set_24hrs.png "alarm set and shown, 24hrs format")
Alarm not set :
![alarm shown and not set](infineat_alarm_notset.png "alarm shown and not set")
Settings view :
![settings](infineat_settings.png "settings modified with a button to turn on or off alarm display")
## Possible further development :
- Move this setting to the Alarm app and include alarm display in all watchfaces ?

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

183
package-lock.json generated Normal file
View file

@ -0,0 +1,183 @@
{
"name": "InfiniTime",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"lv_font_conv": "^1.5.2"
}
},
"node_modules/lv_font_conv": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/lv_font_conv/-/lv_font_conv-1.5.2.tgz",
"integrity": "sha512-0UapRSTkVP/pnB8Z4r2HDHx5p2dJx/xUG1+14u/WXo59mwuC7BahR+Bnx/66jKoDrG1wFQwn9ZzoyMxRHOD9bg==",
"bundleDependencies": [
"argparse",
"bit-buffer",
"debug",
"make-error",
"mkdirp",
"opentype.js",
"pngjs"
],
"dependencies": {
"argparse": "^2.0.0",
"bit-buffer": "^0.2.5",
"debug": "^4.1.1",
"make-error": "^1.3.5",
"mkdirp": "^1.0.4",
"opentype.js": "^1.1.0",
"pngjs": "^6.0.0"
},
"bin": {
"lv_font_conv": "lv_font_conv.js"
}
},
"node_modules/lv_font_conv/node_modules/argparse": {
"version": "2.0.1",
"inBundle": true,
"license": "Python-2.0"
},
"node_modules/lv_font_conv/node_modules/bit-buffer": {
"version": "0.2.5",
"inBundle": true,
"license": "MIT"
},
"node_modules/lv_font_conv/node_modules/debug": {
"version": "4.3.1",
"inBundle": true,
"license": "MIT",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/lv_font_conv/node_modules/make-error": {
"version": "1.3.6",
"inBundle": true,
"license": "ISC"
},
"node_modules/lv_font_conv/node_modules/mkdirp": {
"version": "1.0.4",
"inBundle": true,
"license": "MIT",
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/lv_font_conv/node_modules/ms": {
"version": "2.1.2",
"inBundle": true,
"license": "MIT"
},
"node_modules/lv_font_conv/node_modules/opentype.js": {
"version": "1.3.3",
"inBundle": true,
"license": "MIT",
"dependencies": {
"string.prototype.codepointat": "^0.2.1",
"tiny-inflate": "^1.0.3"
},
"bin": {
"ot": "bin/ot"
},
"engines": {
"node": ">= 8.0.0"
}
},
"node_modules/lv_font_conv/node_modules/pngjs": {
"version": "6.0.0",
"inBundle": true,
"license": "MIT",
"engines": {
"node": ">=12.13.0"
}
},
"node_modules/lv_font_conv/node_modules/string.prototype.codepointat": {
"version": "0.2.1",
"inBundle": true,
"license": "MIT"
},
"node_modules/lv_font_conv/node_modules/tiny-inflate": {
"version": "1.0.3",
"inBundle": true,
"license": "MIT"
}
},
"dependencies": {
"lv_font_conv": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/lv_font_conv/-/lv_font_conv-1.5.2.tgz",
"integrity": "sha512-0UapRSTkVP/pnB8Z4r2HDHx5p2dJx/xUG1+14u/WXo59mwuC7BahR+Bnx/66jKoDrG1wFQwn9ZzoyMxRHOD9bg==",
"requires": {
"argparse": "^2.0.0",
"bit-buffer": "^0.2.5",
"debug": "^4.1.1",
"make-error": "^1.3.5",
"mkdirp": "^1.0.4",
"opentype.js": "^1.1.0",
"pngjs": "^6.0.0"
},
"dependencies": {
"argparse": {
"version": "2.0.1",
"bundled": true
},
"bit-buffer": {
"version": "0.2.5",
"bundled": true
},
"debug": {
"version": "4.3.1",
"bundled": true,
"requires": {
"ms": "2.1.2"
}
},
"make-error": {
"version": "1.3.6",
"bundled": true
},
"mkdirp": {
"version": "1.0.4",
"bundled": true
},
"ms": {
"version": "2.1.2",
"bundled": true
},
"opentype.js": {
"version": "1.3.3",
"bundled": true,
"requires": {
"string.prototype.codepointat": "^0.2.1",
"tiny-inflate": "^1.0.3"
}
},
"pngjs": {
"version": "6.0.0",
"bundled": true
},
"string.prototype.codepointat": {
"version": "0.2.1",
"bundled": true
},
"tiny-inflate": {
"version": "1.0.3",
"bundled": true
}
}
}
}
}

5
package.json Normal file
View file

@ -0,0 +1,5 @@
{
"dependencies": {
"lv_font_conv": "^1.5.2"
}
}

View file

@ -371,6 +371,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/StopWatch.cpp
displayapp/screens/BatteryIcon.cpp
displayapp/screens/BleIcon.cpp
displayapp/screens/AlarmIcon.cpp
displayapp/screens/NotificationIcon.cpp
displayapp/screens/SystemInfo.cpp
displayapp/screens/Label.cpp

View file

@ -47,7 +47,8 @@ namespace Pinetime {
struct WatchFaceInfineat {
bool showSideCover = true;
int colorIndex = 0;
bool showAlarmStatus = true;
int colorIndex = 0;
};
Settings(Pinetime::Controllers::FS& fs);
@ -123,6 +124,17 @@ namespace Pinetime {
return settings.watchFaceInfineat.showSideCover;
};
void SetInfineatShowAlarmStatus(bool show) {
if (show != settings.watchFaceInfineat.showAlarmStatus) {
settings.watchFaceInfineat.showAlarmStatus = show;
settingsChanged = true;
}
};
bool GetInfineatShowAlarmStatus() const {
return settings.watchFaceInfineat.showAlarmStatus;
};
void SetInfineatColorIndex(int index) {
if (index != settings.watchFaceInfineat.colorIndex) {
settings.watchFaceInfineat.colorIndex = index;

View file

@ -7,7 +7,7 @@
},
{
"file": "FontAwesome5-Solid+Brands+Regular.woff",
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743"
"range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf0f3, 0xf522, 0xf743, 0xf0f3, 0xf1f6"
}
],
"bpp": 1,

View file

@ -0,0 +1,11 @@
#include "displayapp/screens/AlarmIcon.h"
#include "displayapp/screens/Symbols.h"
using namespace Pinetime::Applications::Screens;
const char* AlarmIcon::GetIcon(bool isSet) {
if (isSet) {
return Symbols::bell;
}
return Symbols::notbell;
}

View file

@ -0,0 +1,14 @@
#pragma once
#include "components/alarm/AlarmController.h"
namespace Pinetime {
namespace Applications {
namespace Screens {
class AlarmIcon {
public:
static const char* GetIcon(bool isSet);
};
}
}
}

View file

@ -12,6 +12,7 @@ namespace Pinetime {
static constexpr const char* shoe = "\xEF\x95\x8B";
static constexpr const char* clock = "\xEF\x80\x97";
static constexpr const char* bell = "\xEF\x83\xB3";
static constexpr const char* notbell = "\xEF\x87\xB6";
static constexpr const char* info = "\xEF\x84\xA9";
static constexpr const char* list = "\xEF\x80\xBA";
static constexpr const char* sun = "\xEF\x86\x85";

View file

@ -4,9 +4,11 @@
#include <cstdio>
#include "displayapp/screens/Symbols.h"
#include "displayapp/screens/BleIcon.h"
#include "displayapp/screens/AlarmIcon.h"
#include "components/settings/Settings.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/alarm/AlarmController.h"
#include "components/ble/NotificationManager.h"
#include "components/motion/MotionController.h"
@ -122,6 +124,7 @@ namespace {
WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::AlarmController& alarmController,
Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
Controllers::MotionController& motionController,
@ -130,6 +133,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
dateTimeController {dateTimeController},
batteryController {batteryController},
bleController {bleController},
alarmController {alarmController},
notificationManager {notificationManager},
settingsController {settingsController},
motionController {motionController} {
@ -144,6 +148,7 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
font_bebas = lv_font_load("F:/fonts/bebas.bin");
}
// Side Cover
static constexpr lv_point_t linePoints[nLines][2] = {{{30, 25}, {68, -8}},
{{26, 167}, {43, 216}},
@ -230,6 +235,31 @@ WatchFaceInfineat::WatchFaceInfineat(Controllers::DateTime& dateTimeController,
lv_label_set_text_static(bleIcon, Symbols::bluetooth);
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
labelAlarm = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(labelAlarm, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
lv_obj_set_style_local_text_font(labelAlarm, 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(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, grayColor);
lv_obj_align(labelTimeAmPmAlarm, labelAlarm, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
alarmIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(alarmIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
lv_label_set_text_static(alarmIcon, Symbols::notbell);
lv_obj_align(alarmIcon, labelAlarm, 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(labelAlarm, true);
lv_obj_set_hidden(alarmIcon, true);
lv_obj_set_hidden(labelTimeAmPmAlarm, true);
}
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, grayColor);
lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font_teko);
@ -275,7 +305,7 @@ WatchFaceInfineat::WatchFaceInfineat(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);
@ -283,6 +313,17 @@ WatchFaceInfineat::WatchFaceInfineat(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;
@ -332,6 +373,7 @@ void WatchFaceInfineat::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 WatchFaceInfineat::OnButtonPushed() {
@ -346,6 +388,7 @@ void WatchFaceInfineat::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);
@ -353,6 +396,7 @@ void WatchFaceInfineat::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();
@ -368,6 +412,18 @@ void WatchFaceInfineat::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);
@ -452,6 +508,43 @@ void WatchFaceInfineat::Refresh() {
lv_obj_align(bleIcon, dateContainer, LV_ALIGN_OUT_BOTTOM_MID, 0, 3);
}
if (settingsController.GetInfineatShowAlarmStatus()) {
alarmState = alarmController.State()==Pinetime::Controllers::AlarmController::AlarmState::Set;
// sets the icon as bell or barred bell
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);
}
}
stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get());

View file

@ -28,6 +28,7 @@ namespace Pinetime {
WatchFaceInfineat(Controllers::DateTime& dateTimeController,
const Controllers::Battery& batteryController,
const Controllers::Ble& bleController,
Controllers::AlarmController& alarmController,
Controllers::NotificationManager& notificationManager,
Controllers::Settings& settingsController,
Controllers::MotionController& motionController,
@ -52,6 +53,7 @@ namespace Pinetime {
Utility::DirtyValue<bool> isCharging {};
Utility::DirtyValue<bool> bleState {};
Utility::DirtyValue<bool> bleRadioEnabled {};
bool alarmState {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::minutes>> currentDateTime {};
Utility::DirtyValue<uint32_t> stepCount {};
Utility::DirtyValue<bool> notificationState {};
@ -71,22 +73,28 @@ namespace Pinetime {
lv_obj_t* dateContainer;
lv_obj_t* labelDate;
lv_obj_t* bleIcon;
lv_obj_t* labelAlarm;
lv_obj_t* labelTimeAmPmAlarm;
lv_obj_t* alarmIcon;
lv_obj_t* stepIcon;
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;
lv_obj_t* btnClose;
lv_obj_t* btnNextColor;
lv_obj_t* btnToggleCover;
lv_obj_t* btnToggleAlarm;
lv_obj_t* btnPrevColor;
lv_obj_t* btnSettings;
lv_obj_t* labelBtnSettings;
lv_obj_t* lblToggle;
lv_obj_t* lblAlarm;
lv_obj_t* lines[nLines];
Controllers::DateTime& dateTimeController;
const Controllers::Battery& batteryController;
const Controllers::Ble& bleController;
Controllers::AlarmController& alarmController;
Controllers::NotificationManager& notificationManager;
Controllers::Settings& settingsController;
Controllers::MotionController& motionController;
@ -94,6 +102,8 @@ namespace Pinetime {
void SetBatteryLevel(uint8_t batteryPercent);
void ToggleBatteryIndicatorColor(bool showSideCover);
void ToggleShowAlarmStatus(bool showAlarmStatus);
lv_task_t* taskRefresh;
lv_font_t* font_teko = nullptr;
lv_font_t* font_bebas = nullptr;
@ -109,6 +119,7 @@ namespace Pinetime {
return new Screens::WatchFaceInfineat(controllers.dateTimeController,
controllers.batteryController,
controllers.bleController,
controllers.alarmController,
controllers.notificationManager,
controllers.settingsController,
controllers.motionController,