1
0
Fork 0

Merge branch 'espruino:master' into sleeplog_v0.10_beta

master
storm64 2022-05-21 12:25:28 +02:00 committed by GitHub
commit b571accc65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 72 additions and 56 deletions

View File

@ -27,3 +27,4 @@
0.25: Fix redrawing selected Alarm/Timer entry inside edit submenu
0.26: Add support for Monday as first day of the week (#1780)
0.27: New UI!
0.28: Fix bug with alarms not firing when configured to fire only once

View File

@ -50,7 +50,7 @@ function showMainMenu() {
alarms.forEach((e, index) => {
var label = e.timer
? require("time_utils").formatDuration(e.timer)
: require("time_utils").formatTime(e.t) + (e.dow > 0 ? (" " + decodeDOW(e)) : "");
: require("time_utils").formatTime(e.t) + (e.rp ? ` ${decodeDOW(e)}` : "");
menu[label] = {
value: e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff),
onchange: () => setTimeout(e.timer ? showEditTimerMenu : showEditAlarmMenu, 10, e, index)
@ -111,8 +111,8 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex) {
},
/*LANG*/"Repeat": {
value: decodeDOW(alarm),
onchange: () => setTimeout(showEditRepeatMenu, 100, alarm.dow, dow => {
alarm.rp = dow > 0;
onchange: () => setTimeout(showEditRepeatMenu, 100, alarm.rp, alarm.dow, (repeat, dow) => {
alarm.rp = repeat;
alarm.dow = dow;
alarm.t = require("time_utils").encodeTime(time);
setTimeout(showEditAlarmMenu, 10, alarm, alarmIndex);
@ -178,42 +178,46 @@ function decodeDOW(alarm) {
: "Once"
}
function showEditRepeatMenu(dow, dowChangeCallback) {
function showEditRepeatMenu(repeat, dow, dowChangeCallback) {
var originalRepeat = repeat;
var originalDow = dow;
var isCustom = dow > 0 && dow != WORKDAYS && dow != WEEKEND && dow != EVERY_DAY;
var isCustom = repeat && dow != WORKDAYS && dow != WEEKEND && dow != EVERY_DAY;
const menu = {
"": { "title": /*LANG*/"Repeat Alarm" },
"< Back": () => dowChangeCallback(dow),
/*LANG*/"Once": { // No days set: the alarm will fire once
value: dow == 0,
onchange: () => dowChangeCallback(0)
"< Back": () => dowChangeCallback(repeat, dow),
/*LANG*/"Once": {
// The alarm will fire once. Internally it will be saved
// as "fire every days" BUT the repeat flag is false so
// we avoid messing up with the scheduler.
value: !repeat,
onchange: () => dowChangeCallback(false, EVERY_DAY)
},
/*LANG*/"Workdays": {
value: dow == WORKDAYS,
onchange: () => dowChangeCallback(WORKDAYS)
value: repeat && dow == WORKDAYS,
onchange: () => dowChangeCallback(true, WORKDAYS)
},
/*LANG*/"Weekends": {
value: dow == WEEKEND,
onchange: () => dowChangeCallback(WEEKEND)
value: repeat && dow == WEEKEND,
onchange: () => dowChangeCallback(true, WEEKEND)
},
/*LANG*/"Every Day": {
value: dow == EVERY_DAY,
onchange: () => dowChangeCallback(EVERY_DAY)
value: repeat && dow == EVERY_DAY,
onchange: () => dowChangeCallback(true, EVERY_DAY)
},
/*LANG*/"Custom": {
value: isCustom ? decodeDOW({ rp: true, dow: dow }) : false,
onchange: () => setTimeout(showCustomDaysMenu, 10, isCustom ? dow : EVERY_DAY, dowChangeCallback, originalDow)
onchange: () => setTimeout(showCustomDaysMenu, 10, isCustom ? dow : EVERY_DAY, dowChangeCallback, originalRepeat, originalDow)
}
};
E.showMenu(menu);
}
function showCustomDaysMenu(dow, dowChangeCallback, originalDow) {
function showCustomDaysMenu(dow, dowChangeCallback, originalRepeat, originalDow) {
const menu = {
"": { "title": /*LANG*/"Custom Days" },
"< Back": () => dowChangeCallback(dow),
"< Back": () => dowChangeCallback(true, dow),
};
require("date_utils").dows(firstDayOfWeek).forEach((day, i) => {
@ -223,7 +227,7 @@ function showCustomDaysMenu(dow, dowChangeCallback, originalDow) {
};
});
menu[/*LANG*/"Cancel"] = () => setTimeout(showEditRepeatMenu, 10, originalDow, dowChangeCallback)
menu[/*LANG*/"Cancel"] = () => setTimeout(showEditRepeatMenu, 10, originalRepeat, originalDow, dowChangeCallback)
E.showMenu(menu);
}

View File

@ -2,7 +2,7 @@
"id": "alarm",
"name": "Alarms & Timers",
"shortName": "Alarms",
"version": "0.27",
"version": "0.28",
"description": "Set alarms and timers on your Bangle",
"icon": "app.png",
"tags": "tool,alarm,widget",

View File

@ -1 +1,2 @@
0.01: New face :)
0.02: Color image compressed

View File

@ -1,7 +1,17 @@
# About this Watchface
# Poketch Clock
Based on the electronic device from the Pokemon game.
A clock based on the Poketch electronic device found in Sinnoh
# Features
![](https://user-images.githubusercontent.com/44651387/157491789-1b608c11-8af2-4519-a90f-41b8a58a9a14.png)
## Features
Has a dark mode
## Requests
If you have any issues or would like to suggest a feature, click here to send a message -> [here](https://github.com/elykittytee/BangleApps/issues/new?title=Poketch%20Clock%20Bug).
## Creator
Eleanor Tayam

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"id": "pokeclk",
"name": "Poketch Clock",
"shortName":"Poketch Clock",
"version": "0.01",
"version": "0.02",
"description": "A clock based on the Poketch electronic device found in Sinnoh",
"icon": "app.png",
"type": "clock",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -6,6 +6,7 @@
0.06: Refactor some methods to library
0.07: Update settings
Correct `decodeTime(t)` to return a more likely expected time
0.08: add day of week check to getActiveAlarms()
0.08: Add day of week check to getActiveAlarms()
0.09: Move some functions to new time_utils module
0.10: Default to sched.js if custom js not found
0.11: Fix default dow

View File

@ -8,12 +8,12 @@
var time = new Date();
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000);
var d = time.getDate();
var active = alarms.filter(
a=>a.on && // enabled
a.last!=d && // not already fired today
a.t+60000>currentTime && // is not in the past by >1 minute
(a.dow>>time.getDay())&1 && // is allowed on this day of the week
(!a.date || a.date==time.toISOString().substr(0,10)) // is allowed on this date
var active = alarms.filter(a =>
a.on // enabled
&& (a.last != d) // not already fired today
&& (a.t + 60000 > currentTime) // is not in the past by >1 minute
&& (a.dow >> time.getDay() & 1) // is allowed on this day of the week
&& (!a.date || a.date == time.toISOString().substr(0, 10)) // is allowed on this date
);
if (active.length) {
active = active.sort((a,b)=>a.t-b.t); // sort by time

View File

@ -11,16 +11,19 @@ exports.getAlarm = function(id) {
return exports.getAlarms().find(a=>a.id==id);
};
// Given a list of alarms from getAlarms, return a list of active alarms for the given time (or current time if time not specified)
exports.getActiveAlarms = function(alarms, time) {
exports.getActiveAlarms = function (alarms, time) {
if (!time) time = new Date();
var currentTime = (time.getHours()*3600000)+(time.getMinutes()*60000)+(time.getSeconds()*1000)
+10000;// get current time - 10s in future to ensure we alarm if we've started the app a tad early
return alarms.filter(a=>a.on
&&(a.t<currentTime)
&&(a.last!=time.getDate())
&& (!a.date || a.date==time.toISOString().substr(0,10))
&& a.dow >> (time).getDay() & 1)
.sort((a,b)=>a.t-b.t);
// get current time 10s in future to ensure we alarm if we've started the app a tad early
var currentTime = (time.getHours() * 3600000) + (time.getMinutes() * 60000) + (time.getSeconds() * 1000) + 10000;
return alarms
.filter(a =>
a.on // enabled
&& (a.last != time.getDate()) // not already fired today
&& (a.t < currentTime)
&& (a.dow >> time.getDay() & 1) // is allowed on this day of the week
&& (!a.date || a.date == time.toISOString().substr(0, 10)) // is allowed on this date
)
.sort((a, b) => a.t - b.t);
}
// Set an alarm object based on ID. Leave 'alarm' undefined to remove it
exports.setAlarm = function(id, alarm) {
@ -66,7 +69,7 @@ exports.newDefaultAlarm = function () {
on: true,
rp: settings.defaultRepeat,
as: settings.defaultAutoSnooze,
dow: settings.defaultRepeat ? 0b1111111 : 0b0000000,
dow: 0b1111111,
last: 0,
vibrate: settings.defaultAlarmPattern,
};

View File

@ -1,7 +1,7 @@
{
"id": "sched",
"name": "Scheduler",
"version": "0.10",
"version": "0.11",
"description": "Scheduling library for alarms and timers",
"icon": "app.png",
"type": "scheduler",