Update app.js

Remove unnecessary keywords.
Remove autolight, since the system once again provides this service.
Add optional autorotate while charging.
Distinguish ‘slow’ second hand from regular second hand, visually.
Tweak fonts.
master
stephenPspackman 2022-01-06 17:23:48 -08:00 committed by GitHub
parent c2646e5b9f
commit 673865b314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 111 additions and 84 deletions

View File

@ -25,8 +25,8 @@
// //
// This only works for Bangle 2. // This only works for Bangle 2.
const isString = x => typeof x === 'string'; const isString = x => typeof x === 'string',
const imageWidth = i => isString(i) ? i.charCodeAt(0) : i.width; imageWidth = i => isString(i) ? i.charCodeAt(0) : i.width;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/* System integration */ /* System integration */
@ -115,9 +115,9 @@ class RoundOptions extends Options {
onchange: x => this.calendric = x, onchange: x => this.calendric = x,
format: x => ['none', 'day', 'date', 'both', 'month', 'full'][x], format: x => ['none', 'day', 'date', 'both', 'month', 'full'][x],
}, },
'Auto-Illum.': { 'Autorotate': {
init: _ => this.autolight, init: _ => this.autorotate,
onchange: x => this.autolight = x onchange: x => this.autorotate = x
}, },
Defaults: _ => {this.reset(); this.interact();} Defaults: _ => {this.reset(); this.interact();}
}); });
@ -133,7 +133,7 @@ RoundOptions.defaults = {
calendric: 5, calendric: 5,
dayFg: '#fff', dayFg: '#fff',
nightFg: '#000', nightFg: '#000',
autolight: true, autorotate: true,
}; };
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -144,29 +144,29 @@ const dec = x => E.toString(heatshrink.decompress(atob(x)));
const y10F = [ const y10F = [
dec( dec(
'g///EAh////AA4IIBgPwgE+gAOBg/AngXB+EPAYM8gfggEfgF8D4OAj4dB8EDAYI' + 'g///EAh////AA4IIBgPwgE+gAOBg/AngXB+EPAYM8gfggEfgF8D4OAj4dB8EDAYI' +
'fBBAISBAAMOAYUB4AECnEAkAuBgEQBAPgIYX8IYX/wYDCEwIiMMgUYgECCIZ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+Aj8ASYJNB' +
'BB4JBBI45vCRYgADApEHL4pHB8AECFIPhAYLCCAggFBAgaNCYwgFEbAkAwAFEc4S' + 'BINwIIOAM4ILDAYN/wABBB4JBBI45vCRYgADApEHL4pHB8AECFIPhAYLCCAggFBA' +
'PCj/+LIKPBv6PEAoRnBFIMDFYLXCKoTLDa4YRDBYIdDh4FDMoQ1DK4ZBBMQIDBJY' + 'gaNCYwgFEbAkAwAFEc4SPCj/+LIKPBv6PEAoRnBFIMDFYLXCKoTLDa4YRDBYIdDh' +
'bWBFIMEIIQpBgxxBgZRBh8AAYN8AoQVBjgbBAoTZBvwRCvEBF4IdB+E/OIp9CJgZ' + '4FDMoQ1DK4ZBBMQIDBJYbWBFIMEIIQpBgxxBgZRBh8AAYN8AoQVBjgbBAoTZBvwR' +
'BCQQUAA=' 'CvEBF4IdB+E/OIp9CJgZBCQQUAA='
), 48, dec('hgAI'), 48 ), 48, dec('hgAI'), 48
];const y10sF = [ ];const y10sF = [
dec( dec(
@ -194,20 +194,20 @@ const y10F = [
];const d1F = [ ];const d1F = [
dec( dec(
'AB1/+AECj///4FCAgP/8EAgf/4F//EAg4CBgf8gEPwAUBn0AhwaCAYMeAoUPgEcA' + 'AB1/+AECj///4FCAgP/8EAgf/4F//EAg4CBgf8gEPwAUBn0AhwaCAYMeAoUPgEcA' +
'oUHAowRFDoopFGopBFJopZGBgIKCABlAIIcA4AFDgIFEgZBCAoMHAohVBAoY6CHg' + 'oUHAowRFDoopFGopBFJopZGBgIKCAB5BBgA1CAoMBAokDCIgTCAYRTDAoI6CHgU/' +
'U/Aol/AogADGoQFUABEMAQM/AQN8bIRZBRgJ5BLILhBgP3LIcD84rDg/HWYcPw4F' + 'Aol/Aog1GAqgAIhgCBn4CBvjZCLIKMBPIJZBcIMB+4lBMoMD84rDg/HL4cPw4FDj' +
'Dj4PBAoU+Aol8Aon4PocB+CJDgfgAoXgh/ATYX4v+AU4X//w/DbYQFCCwJ3PvDIE' + '5rEnwFEvgFE/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oYDB4ZJCUoPn' + 'N4g4EBAoPwUAIABgPnUonfQgIuC/41Dh5tDEwJGEn46EvhdJACCJDv6VDAYPDJIS' +
'VoUHwP3Y4YYBY4k+Y4h5BdILhBd4YFFCIodFFIo1FIIpNFLIplGAArMFn6oBHYMA' + 'lB86tCg+B+7HDDALHEnzHEPILpBcILvDAooRFDoopFGopBFJopZFMowAFZgs/VAI' +
'DYQFBgP5E4IFBgfgUgIFCwBZBEAL1BPYZbDA4Z7DLYRtCBYYlDBoIxCEYMBHoIvC' + '7BgAbCAoMB/InBAoMD8CkBAoWALIIgBeoJ7DLYYHDPYZbCNoQLDEoYNBGIQjBgI9' +
'HAI7Dh5PBI4X/LIX//7+Dn52Eh4QCA==' 'BF4Q4BHYcPJ4JHC/5ZC///fwc/OwkPCAQA=='
), 48, dec('ikPigAGA'), 48 ), 48, dec('ikPigAGA'), 48
];const dowF = [ ];const dowF = [
dec( dec(
@ -220,10 +220,10 @@ const y10F = [
'kDMIgeBFIQEBBYRTBCAZ3FAggAMg4zEj7LEn7LEv++AodzxwFD+ePAofjw4FVDoo' + 'kDMIgeBFIQEBBYRTBCAZ3FAggAMg4zEj7LEn7LEv++AodzxwFD+ePAofjw4FVDoo' +
'pFv+eIImcJomYLImAAoZeEAtTyBAAQFEVYIFDSQIvhAojaCFwgABh4YEngFEuAqJ' + 'pFv+eIImcJomYLImAAoZeEAtTyBAAQFEVYIFDSQIvhAojaCFwgABh4YEngFEuAqJ' +
'gPAAocDApYuEgP/fgl/+B9HAAv+Aon8HQMOIAkeAokcAohaDAoM4Aol4AohmDAoJ' + 'gPAAocDApYuEgP/fgl/+B9HAAv+Aon8HQMOIAkeAokcAohaDAoM4Aol4AohmDAoJ' +
'BDAoJsDAo7vhABbJDAo9/AojEFMYbKMArCBDFI41FWIYABggFEgbuCDYMPLIQbBj' + 'BDAoJsDAo7vhABZuBQYoFDv4FEYgpjDZRgFYGYYpHGoqxDAAMEAokDdwQbBh//DY' +
'//wBdCn0H4DZCvEBb4YZBdYZBBAofgCIQFDDoIFFDoPggYFBF4IFBGoI7B+AFCE4' + 'cf/+ALoU+g/AbIV4gLfDDILrDIIIFD8ARCAoYdBAoodB8EDAoIvBAoI1BHYPwAoQ' +
'NwCIIlCuAdBIYU4gPwn5VBjC7B/y0Dv/4YwcPCwMAjJlCAAM584FDufDCAUA8eBA' + 'nBuARBEoVwDoJDCnEB+E/KoMYXYP+Wgd//DGDh4WBgEZMoQABnPnAodz4YQCgHjw' +
'p/zC4n5EYj1BAoc//4RDU4IFDA==' 'IFP+YXE/IjEeoIFDn//CIanBAoY='
), 48, dec('kElkMljsljw='), 48 ), 48, dec('kElkMljsljw='), 48
];const mF = [ ];const mF = [
dec( dec(
@ -322,21 +322,20 @@ class Round {
this.r = this.xc - this.minR; this.r = this.xc - this.minR;
} }
reset(clear) {this.state = {}; clear && this.g.clear(true);} reset(clear) {this.state = {}; clear == null || this.g.clear(true).setRotation(clear);}
doIcons(which) { doIcons(which) {
this.state[which] = null; this.state[which] = null;
this.render(new Date()); // Not quite right, I think.
} }
enhanceUntil(t) {this.enhance = t;} enhanceUntil(t) {this.enhance = t;}
pie(f, a0, a1, invert) { pie(f, a0, a1, invert) {
if (!invert) return this.pie(f, a1, a0 + 1, true); if (!invert) return this.pie(f, a1, a0 + 1, true);
let t0 = Math.tan(a0 * 2 * Math.PI), t1 = Math.tan(a1 * 2 * Math.PI); const t0 = Math.tan(a0 * 2 * Math.PI), t1 = Math.tan(a1 * 2 * Math.PI);
let i0 = Math.floor(a0 * 4 + 0.5), i1 = Math.floor(a1 * 4 + 0.5); let i0 = Math.floor(a0 * 4 + 0.5), i1 = Math.floor(a1 * 4 + 0.5);
let x = f.getWidth() / 2, y = f.getHeight() / 2; const x = f.getWidth() / 2, y = f.getHeight() / 2;
let poly = [ const poly = [
x + (i1 & 2 ? -x : x) * (i1 & 1 ? 1 : t1), x + (i1 & 2 ? -x : x) * (i1 & 1 ? 1 : t1),
y + (i1 & 2 ? y : -y) / (i1 & 1 ? t1 : 1), y + (i1 & 2 ? y : -y) / (i1 & 1 ? t1 : 1),
x, x,
@ -348,16 +347,17 @@ class Round {
for (i0++; i0 <= i1; i0++) poly.push( for (i0++; i0 <= i1; i0++) poly.push(
3 * i0 & 2 ? f.getWidth() : 0, i0 & 2 ? f.getHeight() : 0 3 * i0 & 2 ? f.getWidth() : 0, i0 & 2 ? f.getHeight() : 0
); );
f.setColor(0).fillPoly(poly); return f.setColor(0).fillPoly(poly);
} }
hand(t, d, c0, r0, c1, r1) { hand(t, d, c0, r0, c1, r1) {
const g = this.g;
t *= Math.PI / 30; t *= Math.PI / 30;
const r = this.r; const r = this.r,
const z = 2 * r0 + 1; z = 2 * r0 + 1,
const x = this.xc + r * Math.sin(t), y = this.yc - r * Math.cos(t); x = this.xc + r * Math.sin(t), y = this.yc - r * Math.cos(t),
const x0 = x - r0, y0 = y - r0; x0 = x - r0, y0 = y - r0;
d = d ? d[0] : Graphics.createArrayBuffer(z, z, 16, {msb: true}); d = d ? d[0] : Graphics.createArrayBuffer(z, z, 4, {msb: true});
for (let i = 0; i < z; i++) for (let j = 0; j < z; j++) { for (let i = 0; i < z; i++) for (let j = 0; j < z; j++) {
d.setPixel(i, j, g.getPixel(x0 + i, y0 + j)); d.setPixel(i, j, g.getPixel(x0 + i, y0 + j));
} }
@ -366,24 +366,20 @@ class Round {
return [d, x0, y0]; return [d, x0, y0];
} }
render(d) { render(d, rate) {
const g = this.g; const g = this.g, b = this.b, bI = this.bI, c = this.c, cI = this.cI,
const b = this.b, bI = this.bI; e = d < this.enhance,
const c = this.c, cI = this.cI; state = this.state, options = this.options,
const e = d < this.enhance; cal = options.calendric, res = options.resolution,
const state = this.state; dow = (e || cal === 1 || cal > 2) && d.getDay(),
const options = this.options; ts = res < 2 && d.getSeconds(),
const cal = options.calendric; tm = (e || res < 3) && d.getMinutes() + ts / 60,
const res = options.resolution; th = d.getHours() + d.getMinutes() / 60,
const dow = (e || cal == 1 || cal > 2) && d.getDay(); dd = (e || cal > 1) && d.getDate(),
const ts = res < 2 && d.getSeconds(); dm = (e || cal > 3) && d.getMonth(),
const tm = (e || res < 3) && d.getMinutes() + ts / 60; dy = (e || cal > 4) && d.getFullYear();
const th = d.getHours() + d.getMinutes() / 60; const xc = this.xc, yc = this.yc, r = this.r,
const dd = (e || cal > 1) && d.getDate(); dlr = xc * 3/4, dlw = 8, dlhw = 4;
const dm = (e || cal > 3) && d.getMonth();
const dy = (e || cal > 4) && d.getFullYear();
const xc = this.xc, yc = this.yc, r = this.r;
const dlr = xc * 3/4, dlw = 8, dlhw = 4;
// Restore saveunders for fast-moving, overdrawing indicators. // Restore saveunders for fast-moving, overdrawing indicators.
if (state.sd) g.drawImage.apply(g, state.sd); if (state.sd) g.drawImage.apply(g, state.sd);
@ -397,10 +393,10 @@ class Round {
state.dow = dow; state.dow = dow;
} }
const locked = Bangle.isLocked(); const locked = Bangle.isLocked(),
const charging = Bangle.isCharging(); charging = Bangle.isCharging(),
const battery = E.getBattery(); battery = E.getBattery(),
const HRMOn = Bangle.isHRMOn(); HRMOn = Bangle.isHRMOn();
if (dy !== state.dy || if (dy !== state.dy ||
locked !== state.locked || locked !== state.locked ||
charging !== state.charging || charging !== state.charging ||
@ -463,6 +459,7 @@ class Round {
this.hand(tm, state.md, g.theme.bg, this.minR, g.theme.fg, this.minR - 1) : this.hand(tm, state.md, g.theme.bg, this.minR, g.theme.fg, this.minR - 1) :
null; null;
state.sd = ts === +ts ? state.sd = ts === +ts ?
rate > 1000 ? this.hand(ts, state.sd, g.theme.fg2, this.secR, g.theme.bg, 2) :
this.hand(ts, state.sd, g.theme.fg2, this.secR) : this.hand(ts, state.sd, g.theme.fg2, this.secR) :
null; null;
} }
@ -482,7 +479,18 @@ class Clock {
this.listeners = { this.listeners = {
lcdPower: on => on ? this.active() : this.inactive(), lcdPower: on => on ? this.active() : this.inactive(),
charging: () => {face.doIcons('charging'); this.active();}, charging: on => {
face.doIcons('charging');
if (on) {
this.listeners.accel =
a => this.orientation(a) === this.attitude || this.active();
Bangle.on('accel', this.listeners.accel);
} else {
Bangle.removeListener('accel', this.listeners.accel);
delete this.listeners.accel;
}
this.active();
},
lock: () => {face.doIcons('locked'); this.active();}, lock: () => {face.doIcons('locked'); this.active();},
faceUp: up => { faceUp: up => {
this.conservative = !up; this.conservative = !up;
@ -498,20 +506,23 @@ class Clock {
if (e.y - this.e0.y < -50) { if (e.y - this.e0.y < -50) {
this.options.resolution > 0 && this.options.resolution--; this.options.resolution > 0 && this.options.resolution--;
this.rates.clock = this.timescales[this.options.resolution]; this.rates.clock = this.timescales[this.options.resolution];
this.ack();
this.active(); this.active();
} else if (e.y - this.e0.y > 50) { } else if (e.y - this.e0.y > 50) {
this.options.resolution < this.timescales.length - 1 && this.options.resolution < this.timescales.length - 1 &&
this.options.resolution++; this.options.resolution++;
this.rates.clock = this.timescales[this.options.resolution]; this.rates.clock = this.timescales[this.options.resolution];
this.ack();
this.active(); this.active();
} else if (this.yX - this.yN < 20) { } else if (this.yX - this.yN < 20) {
const now = new Date(); const now = new Date();
if (now - this.t0 < 250) { if (now - this.t0 < 250) {
this.ack();
face.enhanceUntil(now + 30000); face.enhanceUntil(now + 30000);
face.render(now); this.active();
} else if (now - this.t0 > 500) { } else if (now - this.t0 > 500) {
this.stop(); this.stop();
this.options.interact(); this.ack().then(_ => this.options.interact());
} }
} }
this.t0 = null; this.t0 = null;
@ -524,9 +535,25 @@ class Clock {
}; };
} }
ack() {
return Bangle.buzz(33);
}
orientation(a) {
return Math.abs(a.z) < 0.85 ?
Math.abs(a.y) > Math.abs(a.x) ? a.y < 0 ? 0 : 2 : a.x > 0 ? 1 : 3 :
0;
}
rotation() {
return this.options.autorotate && Bangle.isCharging() ?
this.orientation(Bangle.getAccel()) :
0;
}
redraw(rate) { redraw(rate) {
const now = this.updated = new Date(); const now = this.updated = new Date();
if (this.refresh) this.face.reset(true); if (this.refresh) this.face.reset(this.attitude = this.rotation());
this.refresh = false; this.refresh = false;
rate = this.face.render(now, rate); rate = this.face.render(now, rate);
if (rate !== this.rates.face) { if (rate !== this.rates.face) {
@ -541,13 +568,13 @@ class Clock {
this.exception && clearTimeout(this.exception); this.exception && clearTimeout(this.exception);
this.interval && clearInterval(this.interval); this.interval && clearInterval(this.interval);
this.timeout = this.exception = this.interval = this.rate = null; this.timeout = this.exception = this.interval = this.rate = null;
this.face.reset(false); // Cancel any ongoing background rendering this.face.reset(); // Cancel any ongoing background rendering
return this; return this;
} }
active() { active() {
const prev = this.rate; const prev = this.rate,
const now = Date.now(); now = Date.now();
let rate = Infinity; let rate = Infinity;
for (const k in this.rates) { for (const k in this.rates) {
let r = this.rates[k]; let r = this.rates[k];