mirror of https://github.com/espruino/BangleApps
merge
commit
d4d44bcc72
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
|
||||||
var __assign = Object.assign;
|
var __assign = Object.assign;
|
||||||
var Layout = require("Layout");
|
var Layout = require("Layout");
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
0.01: New clkinfo!
|
0.01: New clkinfo!
|
||||||
|
0.02: Added format option, reduced battery usage
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"use strict";
|
|
||||||
(function () {
|
(function () {
|
||||||
var durationOnPause = "---";
|
var durationOnPause = "---";
|
||||||
var redrawInterval;
|
var redrawInterval;
|
||||||
var startTime;
|
var startTime;
|
||||||
|
var _a = (require("Storage").readJSON("clkinfostopw.setting.json", true) || {}).format, format = _a === void 0 ? 0 : _a;
|
||||||
var unqueueRedraw = function () {
|
var unqueueRedraw = function () {
|
||||||
if (redrawInterval)
|
if (redrawInterval)
|
||||||
clearInterval(redrawInterval);
|
clearInterval(redrawInterval);
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
var queueRedraw = function () {
|
var queueRedraw = function () {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
unqueueRedraw();
|
unqueueRedraw();
|
||||||
redrawInterval = setInterval(function () { return _this.emit('redraw'); }, 100);
|
redrawInterval = setInterval(function () { return _this.emit('redraw'); }, 1000);
|
||||||
};
|
};
|
||||||
var pad2 = function (s) { return ('0' + s.toFixed(0)).slice(-2); };
|
var pad2 = function (s) { return ('0' + s.toFixed(0)).slice(-2); };
|
||||||
var duration = function (start) {
|
var duration = function (start) {
|
||||||
|
@ -21,10 +21,14 @@
|
||||||
var mins = seconds / 60;
|
var mins = seconds / 60;
|
||||||
seconds %= 60;
|
seconds %= 60;
|
||||||
if (mins < 60)
|
if (mins < 60)
|
||||||
return "".concat(pad2(mins), "m").concat(pad2(seconds), "s");
|
return format === 0
|
||||||
|
? "".concat(pad2(mins), "m").concat(pad2(seconds), "s")
|
||||||
|
: "".concat(mins.toFixed(0), ":").concat(pad2(seconds));
|
||||||
var hours = mins / 60;
|
var hours = mins / 60;
|
||||||
mins %= 60;
|
mins %= 60;
|
||||||
return "".concat(Math.round(hours), "h").concat(pad2(mins), "m").concat(pad2(seconds), "s");
|
return format === 0
|
||||||
|
? "".concat(hours.toFixed(0), "h").concat(pad2(mins), "m").concat(pad2(seconds), "s")
|
||||||
|
: "".concat(hours.toFixed(0), ":").concat(pad2(mins), ":").concat(pad2(seconds));
|
||||||
};
|
};
|
||||||
var img = function () { return atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA=="); };
|
var img = function () { return atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA=="); };
|
||||||
return {
|
return {
|
||||||
|
@ -39,7 +43,14 @@
|
||||||
: durationOnPause,
|
: durationOnPause,
|
||||||
img: img(),
|
img: img(),
|
||||||
}); },
|
}); },
|
||||||
show: queueRedraw,
|
show: function () {
|
||||||
|
if (startTime) {
|
||||||
|
queueRedraw.call(this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.emit('redraw');
|
||||||
|
}
|
||||||
|
},
|
||||||
hide: unqueueRedraw,
|
hide: unqueueRedraw,
|
||||||
run: function () {
|
run: function () {
|
||||||
if (startTime) {
|
if (startTime) {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
let durationOnPause = "---";
|
let durationOnPause = "---";
|
||||||
let redrawInterval: number | undefined;
|
let redrawInterval: number | undefined;
|
||||||
let startTime: number | undefined;
|
let startTime: number | undefined;
|
||||||
|
let { format = StopWatchFormat.HMS }: StopWatchSettings
|
||||||
|
= require("Storage").readJSON("clkinfostopw.setting.json", true) || {};
|
||||||
|
|
||||||
const unqueueRedraw = () => {
|
const unqueueRedraw = () => {
|
||||||
if (redrawInterval) clearInterval(redrawInterval);
|
if (redrawInterval) clearInterval(redrawInterval);
|
||||||
|
@ -10,7 +12,7 @@
|
||||||
|
|
||||||
const queueRedraw = function(this: ClockInfo.MenuItem) {
|
const queueRedraw = function(this: ClockInfo.MenuItem) {
|
||||||
unqueueRedraw();
|
unqueueRedraw();
|
||||||
redrawInterval = setInterval(() => this.emit('redraw'), 100);
|
redrawInterval = setInterval(() => this.emit('redraw'), 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const pad2 = (s: number) => ('0' + s.toFixed(0)).slice(-2);
|
const pad2 = (s: number) => ('0' + s.toFixed(0)).slice(-2);
|
||||||
|
@ -25,12 +27,16 @@
|
||||||
seconds %= 60;
|
seconds %= 60;
|
||||||
|
|
||||||
if (mins < 60)
|
if (mins < 60)
|
||||||
return `${pad2(mins)}m${pad2(seconds)}s`;
|
return format === StopWatchFormat.HMS
|
||||||
|
? `${pad2(mins)}m${pad2(seconds)}s`
|
||||||
|
: `${mins.toFixed(0)}:${pad2(seconds)}`;
|
||||||
|
|
||||||
let hours = mins / 60;
|
let hours = mins / 60;
|
||||||
mins %= 60;
|
mins %= 60;
|
||||||
|
|
||||||
return `${Math.round(hours)}h${pad2(mins)}m${pad2(seconds)}s`;
|
return format === StopWatchFormat.HMS
|
||||||
|
? `${hours.toFixed(0)}h${pad2(mins)}m${pad2(seconds)}s`
|
||||||
|
: `${hours.toFixed(0)}:${pad2(mins)}:${pad2(seconds)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const img = () => atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA==");
|
const img = () => atob("GBiBAAAAAAB+AAB+AAAAAAB+AAH/sAOB8AcA4A4YcAwYMBgYGBgYGBg8GBg8GBgYGBgAGAwAMA4AcAcA4AOBwAH/gAB+AAAAAAAAAA==");
|
||||||
|
@ -47,7 +53,13 @@
|
||||||
: durationOnPause,
|
: durationOnPause,
|
||||||
img: img(),
|
img: img(),
|
||||||
}),
|
}),
|
||||||
show: queueRedraw,
|
show: function(this: ClockInfo.MenuItem) {
|
||||||
|
if(startTime){ // only queue if active
|
||||||
|
queueRedraw.call(this);
|
||||||
|
}else{
|
||||||
|
this.emit('redraw')
|
||||||
|
}
|
||||||
|
},
|
||||||
hide: unqueueRedraw,
|
hide: unqueueRedraw,
|
||||||
run: function() { // tapped
|
run: function() { // tapped
|
||||||
if (startTime) {
|
if (startTime) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"readme":"README.md",
|
"readme":"README.md",
|
||||||
"allow_emulator": true,
|
"allow_emulator": true,
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"stopw.clkinfo.js","url":"clkinfo.js"}
|
{"name":"stopw.clkinfo.js","url":"clkinfo.js"},
|
||||||
|
{"name":"stopw.settings.js","url":"settings.js"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
(function (back) {
|
||||||
|
var _a;
|
||||||
|
var SETTINGS_FILE = "clkinfostopw.setting.json";
|
||||||
|
var storage = require("Storage");
|
||||||
|
var settings = storage.readJSON(SETTINGS_FILE, true) || {};
|
||||||
|
(_a = settings.format) !== null && _a !== void 0 ? _a : (settings.format = 0);
|
||||||
|
var save = function () {
|
||||||
|
storage.writeJSON(SETTINGS_FILE, settings);
|
||||||
|
};
|
||||||
|
E.showMenu({
|
||||||
|
"": { "title": "stopwatch" },
|
||||||
|
"< Back": back,
|
||||||
|
"Format": {
|
||||||
|
value: settings.format,
|
||||||
|
min: 0,
|
||||||
|
max: 1,
|
||||||
|
format: function (v) { return v === 0 ? "12m34s" : "12:34"; },
|
||||||
|
onchange: function (v) {
|
||||||
|
settings.format = v;
|
||||||
|
save();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,34 @@
|
||||||
|
const enum StopWatchFormat {
|
||||||
|
HMS,
|
||||||
|
Colon,
|
||||||
|
}
|
||||||
|
type StopWatchSettings = {
|
||||||
|
format: StopWatchFormat,
|
||||||
|
};
|
||||||
|
|
||||||
|
((back: () => void) => {
|
||||||
|
const SETTINGS_FILE = "clkinfostopw.setting.json";
|
||||||
|
|
||||||
|
const storage = require("Storage");
|
||||||
|
const settings: StopWatchSettings = storage.readJSON(SETTINGS_FILE, true) || {};
|
||||||
|
settings.format ??= StopWatchFormat.HMS;
|
||||||
|
|
||||||
|
const save = () => {
|
||||||
|
storage.writeJSON(SETTINGS_FILE, settings)
|
||||||
|
};
|
||||||
|
|
||||||
|
E.showMenu({
|
||||||
|
"": { "title": "stopwatch" },
|
||||||
|
"< Back": back,
|
||||||
|
"Format": {
|
||||||
|
value: settings.format,
|
||||||
|
min: StopWatchFormat.HMS,
|
||||||
|
max: StopWatchFormat.Colon,
|
||||||
|
format: v => v === StopWatchFormat.HMS ? "12m34s" : "12:34",
|
||||||
|
onchange: v => {
|
||||||
|
settings.format = v;
|
||||||
|
save();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})
|
|
@ -7,3 +7,4 @@
|
||||||
1.3: icon changed
|
1.3: icon changed
|
||||||
1.4: new management of events implemented; removed code no longer used (from now the music will be managed by the Messagesgui app)
|
1.4: new management of events implemented; removed code no longer used (from now the music will be managed by the Messagesgui app)
|
||||||
1.5: Fix graphic bug; View via popup while there are other open apps
|
1.5: Fix graphic bug; View via popup while there are other open apps
|
||||||
|
1.6: fix for #2689; ( white screen )
|
|
@ -467,7 +467,7 @@ const updateTimeout = function(){
|
||||||
if (settings.timeOut!="Off"){
|
if (settings.timeOut!="Off"){
|
||||||
removeTimeout();
|
removeTimeout();
|
||||||
if( callInProgress) return; //c'è una chiamata in corso -> no timeout
|
if( callInProgress) return; //c'è una chiamata in corso -> no timeout
|
||||||
if( music!=undefined && EventQueue.length==0 ) return; //ho aperto l'interfaccia della musica e non ho messaggi davanti -> no timeout
|
//if( typeof music !== 'undefined' && EventQueue.length==0 ) return; //ho aperto l'interfaccia della musica e non ho messaggi davanti -> no timeout
|
||||||
|
|
||||||
|
|
||||||
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
|
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "messages_light",
|
"id": "messages_light",
|
||||||
"name": "Messages Light",
|
"name": "Messages Light",
|
||||||
"version": "1.5",
|
"version": "1.6",
|
||||||
"description": "A light implementation of messages App (display notifications from iOS and Gadgetbridge/Android)",
|
"description": "A light implementation of messages App (display notifications from iOS and Gadgetbridge/Android)",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "app",
|
"type": "app",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
|
||||||
(function () {
|
(function () {
|
||||||
var icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA'));
|
var icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA'));
|
||||||
var iconWidth = 18;
|
var iconWidth = 18;
|
||||||
|
|
|
@ -9,3 +9,4 @@
|
||||||
0.06: Remember next alarm to reduce calculation amount
|
0.06: Remember next alarm to reduce calculation amount
|
||||||
Redraw only every hour when no alarm in next 24h
|
Redraw only every hour when no alarm in next 24h
|
||||||
0.07: Fix when no alarms are present
|
0.07: Fix when no alarms are present
|
||||||
|
0.08: Selectable font. Allow to disable hour padding.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "widalarmeta",
|
"id": "widalarmeta",
|
||||||
"name": "Alarm & Timer ETA",
|
"name": "Alarm & Timer ETA",
|
||||||
"shortName": "Alarm ETA",
|
"shortName": "Alarm ETA",
|
||||||
"version": "0.07",
|
"version": "0.08",
|
||||||
"description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).",
|
"description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
const settings = Object.assign({
|
const settings = Object.assign({
|
||||||
maxhours: 24,
|
maxhours: 24,
|
||||||
drawBell: false,
|
drawBell: false,
|
||||||
|
padHours: true,
|
||||||
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
|
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
|
||||||
|
font: 0, // 0=segment style font, 1=teletest font, 2=4x5
|
||||||
}, require("Storage").readJSON(CONFIGFILE,1) || {});
|
}, require("Storage").readJSON(CONFIGFILE,1) || {});
|
||||||
|
|
||||||
function writeSettings() {
|
function writeSettings() {
|
||||||
|
@ -40,5 +42,21 @@
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/*LANG*/'Pad hours': {
|
||||||
|
value: !!settings.padHours,
|
||||||
|
onchange: v => {
|
||||||
|
settings.padHours = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/*LANG*/'Font': {
|
||||||
|
value: settings.font,
|
||||||
|
min: 0, max: 2,
|
||||||
|
format: v => [/*LANG*/"Segment", /*LANG*/"Teletext", /*LANG*/"4x5"][v || 0],
|
||||||
|
onchange: v => {
|
||||||
|
settings.font = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
(() => {
|
(() => {
|
||||||
require("Font5x9Numeric7Seg").add(Graphics);
|
require("Font5x9Numeric7Seg").add(Graphics);
|
||||||
|
require("FontTeletext5x9Ascii").add(Graphics);
|
||||||
|
require("Font4x5").add(Graphics);
|
||||||
const config = Object.assign({
|
const config = Object.assign({
|
||||||
maxhours: 24,
|
maxhours: 24,
|
||||||
drawBell: false,
|
drawBell: false,
|
||||||
|
padHours: true,
|
||||||
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
|
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
|
||||||
|
font: 0, // 0=segment style font, 1=teletest font, 2=4x5
|
||||||
}, require("Storage").readJSON("widalarmeta.json",1) || {});
|
}, require("Storage").readJSON("widalarmeta.json",1) || {});
|
||||||
|
|
||||||
function getNextAlarm(date) {
|
function getNextAlarm(date) {
|
||||||
|
@ -46,20 +50,30 @@
|
||||||
drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60);
|
drawSeconds = (config.showSeconds & 0b01 && !Bangle.isLocked()) || (config.showSeconds & 0b10 && next <= 1000*60);
|
||||||
|
|
||||||
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
||||||
g.setFontAlign(0,0); // center fonts
|
g.setFontAlign(-1,0); // center font in y direction
|
||||||
g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23);
|
g.clearRect(this.x, this.y, this.x+this.width-1, this.y+23);
|
||||||
|
|
||||||
var text = hours.padStart(2, '0') + ":" + minutes.padStart(2, '0');
|
var text = "";
|
||||||
|
if (config.padHours) {
|
||||||
|
text += hours.padStart(2, '0');
|
||||||
|
} else {
|
||||||
|
text += hours;
|
||||||
|
}
|
||||||
|
text += ":" + minutes.padStart(2, '0');
|
||||||
if (drawSeconds) {
|
if (drawSeconds) {
|
||||||
text += ":" + seconds.padStart(2, '0');
|
text += ":" + seconds.padStart(2, '0');
|
||||||
}
|
}
|
||||||
|
if (config.font == 1) {
|
||||||
|
g.setFont("Teletext5x9Ascii:1x2");
|
||||||
|
} else if (config.font == 2) {
|
||||||
|
g.setFont("4x5");
|
||||||
|
} else {
|
||||||
|
// Default to this if no other font is set.
|
||||||
g.setFont("5x9Numeric7Seg:1x2");
|
g.setFont("5x9Numeric7Seg:1x2");
|
||||||
g.drawString(text, this.x+this.width/2, this.y+12);
|
|
||||||
|
|
||||||
calcWidth = 5*5+2;
|
|
||||||
if (drawSeconds) {
|
|
||||||
calcWidth += 3*5;
|
|
||||||
}
|
}
|
||||||
|
g.drawString(text, this.x+1, this.y+12);
|
||||||
|
|
||||||
|
calcWidth = g.stringWidth(text) + 2; // One pixel on each side
|
||||||
this.bellVisible = false;
|
this.bellVisible = false;
|
||||||
} else if (config.drawBell && this.numActiveAlarms > 0) {
|
} else if (config.drawBell && this.numActiveAlarms > 0) {
|
||||||
calcWidth = 24;
|
calcWidth = 24;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
"use strict";
|
|
||||||
(function () {
|
(function () {
|
||||||
"ram";
|
"ram";
|
||||||
var _a;
|
var _a;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
"emitDeclarationOnly": false,
|
"emitDeclarationOnly": false,
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
|
"noImplicitUseStrict": true, // disable "use strict"
|
||||||
|
|
||||||
"newLine": "lf",
|
"newLine": "lf",
|
||||||
"noEmitHelpers": true, // we link to specific banglejs implementations
|
"noEmitHelpers": true, // we link to specific banglejs implementations
|
||||||
|
@ -35,7 +36,14 @@
|
||||||
"noImplicitOverride": true,
|
"noImplicitOverride": true,
|
||||||
"exactOptionalPropertyTypes": true,
|
"exactOptionalPropertyTypes": true,
|
||||||
"useUnknownInCatchVariables": true,
|
"useUnknownInCatchVariables": true,
|
||||||
"strict": true,
|
//"strict": true, // can't have this with noImplicitUseStrict, instead:
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"strictBindCallApply": true,
|
||||||
|
"strictFunctionTypes": true,
|
||||||
|
"strictPropertyInitialization": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"useUnknownInCatchVariables": true,
|
||||||
|
|
||||||
// simple type checking
|
// simple type checking
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
|
|
Loading…
Reference in New Issue