Merge branch 'espruino:master' into master

pull/1814/head
sir-indy 2022-05-05 21:16:32 +01:00 committed by GitHub
commit aaa3338f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 35 additions and 36 deletions

View File

@ -5,3 +5,5 @@
0.05: Update calendar weekend colors for start on Sunday
0.06: Use larger font for dates
0.07: Fix off-by-one-error on previous month
0.08: Do not register as watch, manually start clock on button
read start of week from system settings

View File

@ -18,8 +18,7 @@ const blue = "#0000ff";
const yellow = "#ffff00";
let settings = require('Storage').readJSON("calendar.json", true) || {};
if (settings.startOnSun === undefined)
settings.startOnSun = false;
let startOnSun = ((require("Storage").readJSON("setting.json", true) || {}).firstDayOfWeek || 0) === 0;
if (settings.ndColors === undefined)
if (process.env.HWVERSION == 2) {
settings.ndColors = true;
@ -50,14 +49,14 @@ function getDowLbls(locale) {
case "de_AT":
case "de_CH":
case "de_DE":
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
} else {
dowLbls = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"];
}
break;
case "nl_NL":
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["zo", "ma", "di", "wo", "do", "vr", "za"];
} else {
dowLbls = ["ma", "di", "wo", "do", "vr", "za", "zo"];
@ -66,14 +65,14 @@ function getDowLbls(locale) {
case "fr_BE":
case "fr_CH":
case "fr_FR":
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"];
} else {
dowLbls = ["Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di"];
}
break;
case "sv_SE":
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"];
} else {
dowLbls = ["Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di"];
@ -81,21 +80,21 @@ function getDowLbls(locale) {
break;
case "it_CH":
case "it_IT":
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"];
} else {
dowLbls = ["Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"];
}
break;
case "oc_FR":
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["dg", "dl", "dm", "dc", "dj", "dv", "ds"];
} else {
dowLbls = ["dl", "dm", "dc", "dj", "dv", "ds", "dg"];
}
break;
default:
if (settings.startOnSun) {
if (startOnSun) {
dowLbls = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
} else {
dowLbls = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
@ -110,7 +109,7 @@ function drawCalendar(date) {
g.clearRect(0, 0, maxX, maxY);
g.setBgColor(bgColorMonth);
g.clearRect(0, 0, maxX, headerH);
if (settings.startOnSun){
if (startOnSun){
g.setBgColor(bgColorWeekend);
g.clearRect(0, headerH + rowH, colW, maxY);
g.setBgColor(bgColorDow);
@ -150,7 +149,7 @@ function drawCalendar(date) {
});
date.setDate(1);
const dow = date.getDay() + (settings.startOnSun ? 1 : 0);
const dow = date.getDay() + (startOnSun ? 1 : 0);
const dowNorm = dow === 0 ? 7 : dow;
const monthMaxDayMap = {
@ -242,5 +241,5 @@ Bangle.on("touch", area => {
});
// Show launcher when button pressed
Bangle.setUI("clock"); // TODO: ideally don't set 'clock' mode
setWatch(() => load(), process.env.HWVERSION === 2 ? BTN : BTN3, { repeat: false, edge: "falling" });
// No space for widgets!

View File

@ -1,7 +1,7 @@
{
"id": "calendar",
"name": "Calendar",
"version": "0.07",
"version": "0.08",
"description": "Simple calendar",
"icon": "calendar.png",
"screenshots": [{"url":"screenshot_calendar.png"}],

View File

@ -1,8 +1,6 @@
(function (back) {
var FILE = "calendar.json";
var settings = require('Storage').readJSON(FILE, true) || {};
if (settings.startOnSun === undefined)
settings.startOnSun = false;
if (settings.ndColors === undefined)
if (process.env.HWVERSION == 2) {
settings.ndColors = true;
@ -17,14 +15,6 @@
E.showMenu({
"": { "title": "Calendar" },
"< Back": () => back(),
'Start Sunday': {
value: settings.startOnSun,
format: v => v ? "Yes" : "No",
onchange: v => {
settings.startOnSun = v;
writeSettings();
}
},
'B2 Colors': {
value: settings.ndColors,
format: v => v ? "Yes" : "No",

View File

@ -1,4 +1,5 @@
0.01: Launch app.
0.02: 12k steps are 360 degrees - improves readability of steps.
0.03: Battery improvements through sleep (no minute updates) and partial updates of drawing.
0.04: Use alarm for timer instead of own alarm implementation.
0.04: Use alarm for timer instead of own alarm implementation.
0.05: Use internal step counter if no widget is available.

View File

@ -3,7 +3,7 @@
"name": "Not Analog",
"shortName":"Not Analog",
"icon": "notanalog.png",
"version":"0.04",
"version":"0.05",
"readme": "README.md",
"supports": ["BANGLEJS2"],
"description": "An analog watch face for people that can not read analog watch faces.",

View File

@ -88,20 +88,22 @@ Graphics.prototype.setNormalFont = function(scale) {
};
function getSteps() {
var steps = 0;
try{
if (WIDGETS.wpedom !== undefined) {
return WIDGETS.wpedom.getSteps();
steps = WIDGETS.wpedom.getSteps();
} else if (WIDGETS.activepedom !== undefined) {
return WIDGETS.activepedom.getSteps();
steps = WIDGETS.activepedom.getSteps();
} else {
steps = Bangle.getHealthStatus("day").steps;
}
} catch(ex) {
// In case we failed, we can only show 0 steps.
}
return 0;
}
return steps;
}
function drawBackground() {
@ -289,6 +291,9 @@ function drawSleep(){
function draw(fastUpdate){
// Queue draw in one minute
queueDraw();
// Execute handlers
handleState(fastUpdate);
@ -320,9 +325,6 @@ function draw(fastUpdate){
drawState();
drawTime();
drawData();
// Queue draw in one minute
queueDraw();
}

View File

@ -6,4 +6,4 @@
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()

View File

@ -15,7 +15,12 @@ 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))).sort((a,b)=>a.t-b.t);
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);
}
// Set an alarm object based on ID. Leave 'alarm' undefined to remove it
exports.setAlarm = function(id, alarm) {

View File

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