2 Commits

Author SHA1 Message Date
7f52473337 FuckTime 2.1 2024-12-09 21:10:15 -08:00
0cae5609ae Initial draft 2024-12-06 18:53:52 -08:00
7 changed files with 330 additions and 97 deletions

50
shell.nix Normal file
View File

@@ -0,0 +1,50 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs; let
py4McuBoot = python3.withPackages (ps: with ps; [
cbor
intelhex
click
cryptography
pillow
]);
lv_img_convWrapper = pkgs.writeScriptBin "lv_img_conv" ''
npm install lv_img_conv
nodejs node_modules/lv_img_conv/lv_img_conv.js
'';
buildInfinitime = pkgs.writeScriptBin "build-infinitime" ''
mkdir -p build/
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=$ARM_NONE_EABI_TOOLCHAIN_PATH \
-DNRF5_SDK_PATH=$NRF5_SDK_PATH \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DBUILD_DFU=$BUILD_DFU \
-DBUILD_RESOURCES=$BUILD_RESOURCES \
-DTARGET_DEVICE=$TARGET_DEVICE \
-S . -B build
cmake --build build -j6
'';
in mkShell {
packages = [
gcc-arm-embedded-10
nrf5-sdk
cmake
nodePackages.lv_font_conv
lv_img_convWrapper
# lv_img_conv
nodejs
py4McuBoot
clang-tools
SDL2
libpng
adafruit-nrfutil
buildInfinitime
# watchmate # wish this worked -- use flatpak run io.gitlab.azymohliad.WatchMate
];
ARM_NONE_EABI_TOOLCHAIN_PATH="${gcc-arm-embedded-10}";
NRF5_SDK_PATH="${nrf5-sdk}/share/nRF5_SDK";
CMAKE_BUILD_TYPE="Release";
BUILD_DFU=1;
BUILD_RESOURCES=1;
TARGET_DEVICE="PINETIME";
}

View File

@@ -1,4 +1,4 @@
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20
set(FONTS jetbrains_mono_42 jetbrains_mono_76 jetbrains_mono_bold_20 jetbrains_mono_14
jetbrains_mono_extrabold_compressed lv_font_sys_48
open_sans_light fontawesome_weathericons)
find_program(LV_FONT_CONV "lv_font_conv" NO_CACHE REQUIRED

Binary file not shown.

View File

@@ -1,4 +1,18 @@
{
"jetbrains_mono_14": {
"sources": [
{
"file": "JetBrainsMono-Regular.ttf",
"range": "0x20-0x7e, 0x410-0x44f, 0xB0"
},
{
"file": "NotoSerifCJKjp-VF.ttf",
"symbols": "大雪"
}
],
"bpp": 1,
"size": 14
},
"jetbrains_mono_bold_20": {
"sources": [
{
@@ -54,6 +68,16 @@
"bpp": 1,
"size": 150
},
"noto_serif_cjk_14": {
"sources": [
{
"file": "NotoSerifCJKjp-VF.ttf",
"symbols": "大雪"
}
],
"bpp": 1,
"size": 14
},
"lv_font_sys_48": {
"sources": [
{

View File

@@ -27,41 +27,180 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
settingsController {settingsController},
heartRateController {heartRateController},
motionController {motionController} {
batteryValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(batteryValue, true);
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
connectState = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(connectState, true);
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
/*Create an array for the points of the line*/
// progress_points[0] = {0, 0};
// progress_points[1] = {0, 0};
static lv_style_t style_now_line;
lv_style_init(&style_now_line);
lv_style_set_line_width(&style_now_line, LV_STATE_DEFAULT, 1);
lv_style_set_line_color(&style_now_line, LV_STATE_DEFAULT, LV_COLOR_RED);
// lv_style_set_line_rounded(&style_now_line, LV_STATE_DEFAULT, true);
/*Create a line and apply the new style*/
now_line = lv_line_create(lv_scr_act(), NULL);
static lv_point_t line_points[] = { {40, 2}, {40, 50}};
lv_line_set_points(now_line, line_points, 2);
lv_obj_add_style(now_line, LV_LINE_PART_MAIN, &style_now_line);
lv_obj_align(now_line, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
static lv_style_t style_event;
lv_style_init(&style_event);
lv_style_set_radius(&style_event, LV_STATE_DEFAULT, 5);
lv_style_set_bg_opa(&style_event, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_bg_color(&style_event, LV_STATE_DEFAULT, LV_COLOR_MAGENTA);
lv_style_set_pad_top(&style_event, LV_STATE_DEFAULT, 2);
lv_style_set_pad_bottom(&style_event, LV_STATE_DEFAULT, 2);
lv_style_set_pad_left(&style_event, LV_STATE_DEFAULT, 5);
lv_style_set_pad_right(&style_event, LV_STATE_DEFAULT, 5);
lv_style_set_text_font(&style_event, LV_STATE_DEFAULT, &jetbrains_mono_14);
static lv_style_t style_flex;
lv_style_init(&style_flex);
lv_style_copy(&style_flex, &style_event);
lv_style_set_bg_color(&style_flex, LV_STATE_DEFAULT, LV_COLOR_PURPLE);
static lv_style_t style_season;
lv_style_init(&style_season);
lv_style_copy(&style_season, &style_event);
lv_style_set_bg_color(&style_season, LV_STATE_DEFAULT, LV_COLOR_GREEN);
static lv_style_t style_actualization;
lv_style_init(&style_actualization);
lv_style_copy(&style_actualization, &style_event);
lv_style_set_bg_color(&style_actualization, LV_STATE_DEFAULT, LV_COLOR_TEAL);
static lv_style_t style_community;
lv_style_init(&style_community);
lv_style_copy(&style_community, &style_event);
lv_style_set_bg_color(&style_community, LV_STATE_DEFAULT, LV_COLOR_OLIVE);
/* Fixed events */
// lv_obj_t* lbl_event;
// lbl_event = lv_label_create(lv_scr_act(), nullptr);
// lv_label_set_recolor(lbl_event, true);
// lv_obj_add_style(lbl_event, LV_LABEL_PART_MAIN, &style_event);
// lv_obj_align(lbl_event, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 10);
// lv_label_set_long_mode(lbl_event, LV_LABEL_LONG_BREAK);
// lv_obj_set_width(lbl_event, LV_HOR_RES/3);
// lv_label_set_text_fmt(lbl_event, "Foo Bar");
lv_obj_t* lbl_prior_event;
for(int i=0;i<sizeof(fixedtime)/sizeof(CalendarEntry);i++){
lv_obj_t* lbl_event2;
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(lbl_event2, true);
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_event);
if (i==0) {
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 10);
} else {
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
}
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
lv_obj_set_width(lbl_event2, LV_HOR_RES/3);
lv_label_set_text_fmt(lbl_event2, fixedtime[i].name);
fixedtime_labels[i] = lbl_event2;
lbl_prior_event = lbl_event2;
}
for(int i=0;i<sizeof(flextime)/sizeof(TaskEntry);i++){
lv_obj_t* lbl_event2;
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(lbl_event2, true);
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_flex);
if (i==0) {
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 60);
} else {
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
}
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
lv_obj_set_width(lbl_event2, LV_HOR_RES/3);
lv_label_set_text_fmt(lbl_event2, flextime[i].name);
lbl_prior_event = lbl_event2;
}
for(int i=0;i<sizeof(season)/sizeof(TaskEntry);i++){
lv_obj_t* lbl_event2;
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(lbl_event2, true);
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_season);
if (i==0) {
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 125);
} else {
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
}
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
lv_obj_set_width(lbl_event2, LV_HOR_RES-10);
lv_label_set_text_fmt(lbl_event2, season[i].name);
lv_label_set_align(lbl_event2, LV_LABEL_ALIGN_CENTER);
lbl_prior_event = lbl_event2;
}
for(int i=0;i<sizeof(actualization)/sizeof(TaskEntry);i++){
lv_obj_t* lbl_event2;
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(lbl_event2, true);
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_actualization);
if (i==0) {
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 155);
} else {
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
}
lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
lv_obj_set_width(lbl_event2, LV_HOR_RES/2-5);
lv_label_set_text_fmt(lbl_event2, actualization[i].name);
lbl_prior_event = lbl_event2;
}
for(int i=0;i<sizeof(community)/sizeof(TaskEntry);i++){
lv_obj_t* lbl_event2;
lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(lbl_event2, true);
lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_community);
if (i==0) {
lv_obj_align(lbl_event2, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 205);
} else {
lv_obj_align(lbl_event2, lbl_prior_event, LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
}
// lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_BREAK);
// lv_obj_set_width(lbl_event2, LV_HOR_RES*0.55);
lv_label_set_text_fmt(lbl_event2, community[i].name);
lbl_prior_event = lbl_event2;
}
// lv_obj_t* lbl_event2;
// lbl_event2 = lv_label_create(lv_scr_act(), nullptr);
// lv_label_set_recolor(lbl_event2, true);
// lv_obj_add_style(lbl_event2, LV_LABEL_PART_MAIN, &style_event);
// lv_obj_align(lbl_event2, lbl_event, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
// // lv_label_set_long_mode(lbl_event2, LV_LABEL_LONG_SROLL);
// lv_label_set_text_fmt(lbl_event2, "Baz Bing Boom");
// lv_obj_set_width(lbl_event2, LV_HOR_RES-5);
// lv_obj_set_height(label_now, 40);
// batteryValue = lv_label_create(lv_scr_act(), nullptr);
// lv_label_set_recolor(batteryValue, true);
// lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20);
// connectState = lv_label_create(lv_scr_act(), nullptr);
// lv_label_set_recolor(connectState, true);
// lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 40);
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100);
label_date = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label_date, true);
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -40);
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -80);
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60);
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
label_time = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label_time, true);
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -60);
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(heartbeatValue, true);
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 20);
stepValue = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(stepValue, true);
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
Refresh();
}
@@ -71,29 +210,41 @@ WatchFaceTerminal::~WatchFaceTerminal() {
lv_obj_clean(lv_scr_act());
}
uint32_t timeOffset = 0;
void WatchFaceTerminal::Refresh() {
powerPresent = batteryController.IsPowerPresent();
batteryPercentRemaining = batteryController.PercentRemaining();
if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) {
lv_label_set_text_fmt(batteryValue, "[BATT]#387b54 %d%%", batteryPercentRemaining.Get());
if (batteryController.IsPowerPresent()) {
lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging");
}
}
// if (currentDuration == 0) {
// lv_label_set_text_fmt(label_now, "#007fff Now:# %s",calendar[calIndex].name);
// if (calIndex+1 < sizeof(calendar)/sizeof(CalendarEntry)) {
// lv_label_set_text_fmt(label_next, "#ee3377 Next:# %s", calendar[calIndex+1].name);
// } else {
// lv_label_set_text_fmt(label_next, "");
// }
// }
bleState = bleController.IsConnected();
bleRadioEnabled = bleController.IsRadioEnabled();
if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) {
if (!bleRadioEnabled.Get()) {
lv_label_set_text_static(connectState, "[STAT]#0082fc Disabled#");
// progress_points[1] = {0,(lv_coord_t)((double)LV_VER_RES*currentDuration/calendar[calIndex].duration)};
// lv_line_set_points(progress_line, progress_points, 2); /*Set the points*/
// lv_label_set_text_fmt(batteryValue, "cI %d sO %d",calIndex, sizeof(calendar)/sizeof(CalendarEntry));
int last_width=0;
for(int i=0;i<sizeof(fixedtime_labels)/sizeof(CalendarEntry);i++){
lv_obj_set_width(fixedtime_labels[i], pow(log(fixedtime[i].duration),2)*10);
if (i > 0) {
lv_obj_align(fixedtime_labels[i], fixedtime_labels[i-1], LV_ALIGN_OUT_RIGHT_TOP, 5, 0);
} else {
if (bleState.Get()) {
lv_label_set_text_static(connectState, "[STAT]#0082fc Connected#");
} else {
lv_label_set_text_static(connectState, "[STAT]#0082fc Disconnected#");
}
lv_obj_align(fixedtime_labels[i], lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5-timeOffset, 10);
}
}
timeOffset++;
// currentDuration++;
// if (currentDuration>calendar[calIndex].duration) {
// currentDuration = 0;
// calIndex++;
// if (calIndex > sizeof(calendar)/sizeof(CalendarEntry)-1) {
// calIndex = 0;
// }
// }
notificationState = notificationManager.AreNewNotificationsAvailable();
if (notificationState.IsUpdated()) {
@@ -106,46 +257,8 @@ void WatchFaceTerminal::Refresh() {
currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(dateTimeController.CurrentDateTime());
if (currentDateTime.IsUpdated()) {
uint8_t hour = dateTimeController.Hours();
uint8_t minute = dateTimeController.Minutes();
uint8_t second = dateTimeController.Seconds();
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
char ampmChar[3] = "AM";
if (hour == 0) {
hour = 12;
} else if (hour == 12) {
ampmChar[0] = 'P';
} else if (hour > 12) {
hour = hour - 12;
ampmChar[0] = 'P';
}
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d %s#", hour, minute, second, ampmChar);
} else {
lv_label_set_text_fmt(label_time, "[TIME]#11cc55 %02d:%02d:%02d", hour, minute, second);
}
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
if (currentDate.IsUpdated()) {
uint16_t year = dateTimeController.Year();
Controllers::DateTime::Months month = dateTimeController.Month();
uint8_t day = dateTimeController.Day();
lv_label_set_text_fmt(label_date, "[DATE]#007fff %04d-%02d-%02d#", short(year), char(month), char(day));
}
}
heartbeat = heartRateController.HeartRate();
heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped;
if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) {
if (heartbeatRunning.Get()) {
lv_label_set_text_fmt(heartbeatValue, "[L_HR]#ee3311 %d bpm#", heartbeat.Get());
} else {
lv_label_set_text_static(heartbeatValue, "[L_HR]#ee3311 ---#");
}
}
stepCount = motionController.NbSteps();
if (stepCount.IsUpdated()) {
lv_label_set_text_fmt(stepValue, "[STEP]#ee3377 %lu steps#", stepCount.Get());
// uint8_t hour = dateTimeController.Hours();
// uint8_t minute = dateTimeController.Minutes();
// uint8_t second = dateTimeController.Seconds();
}
}

View File

@@ -19,6 +19,16 @@ namespace Pinetime {
class MotionController;
}
struct CalendarEntry {
char* name;
uint32_t duration;
};
struct TaskEntry {
char* name;
uint32_t priority;
};
namespace Applications {
namespace Screens {
@@ -47,15 +57,50 @@ namespace Pinetime {
Utility::DirtyValue<bool> notificationState {};
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
lv_obj_t* label_time;
lv_obj_t* label_date;
lv_obj_t* label_prompt_1;
lv_obj_t* label_prompt_2;
CalendarEntry fixedtime[14] = {
{"Present FuckTime", 30},
{"Party @ David's", 3*60},
{"Catch the L Train", 4*60},
{"Sleep", 8*60},
{"Wake up", 30},
{"Work", 4*60},
{"Eat Lunch", 60},
{"Afternoon Work", 4*60},
{"Get groceries", 20},
{"Prepare dinner", 30},
{"Eat", 60},
{"Sleep", 8*60},
{"Rave", 30},
{"Repeat", 10}
};
TaskEntry flextime[5] = {
{"Enjoy the sunset", 1},
// {"Enjoy the crisp night air", 3},
// {"Savor the moment", 5},
{"Collect leaves", 7},
{"Read southern gothic", 9},
{"Attend Food Not Bombs", 11},
{"Undermine authority", 13},
};
TaskEntry season[1] = {
{"大雪 Winter begins", 0},
};
TaskEntry actualization[2] = {
{"Become a tea monk", 1},
{"Organize BuyNothing", 3},
};
TaskEntry community[2] = {
{"Publish zines", 1},
{"Cultivate the next", 3},
};
lv_obj_t* fixedtime_labels[sizeof(fixedtime)/sizeof(CalendarEntry)];
uint32_t calIndex = 0;
uint32_t currentDuration = 0;
lv_obj_t* now_line;
lv_obj_t* batteryValue;
lv_obj_t* heartbeatValue;
lv_obj_t* stepValue;
lv_obj_t* notificationIcon;
lv_obj_t* connectState;
Controllers::DateTime& dateTimeController;
const Controllers::Battery& batteryController;

View File

@@ -417,6 +417,7 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in
LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \
LV_FONT_DECLARE(jetbrains_mono_42) \
LV_FONT_DECLARE(jetbrains_mono_76) \
LV_FONT_DECLARE(jetbrains_mono_14) \
LV_FONT_DECLARE(open_sans_light) \
LV_FONT_DECLARE(fontawesome_weathericons) \
LV_FONT_DECLARE(lv_font_sys_48)