Merge branch 'master' of github.com:espruino/BangleApps

master
Gordon Williams 2021-10-18 11:16:06 +01:00
commit 2cfc3cab83
9 changed files with 126 additions and 11 deletions

View File

@ -1436,7 +1436,7 @@
"icon": "chrono.png",
"version":"0.01",
"description": "Single click BTN1 to add 5 minutes. Single click BTN2 to add 30 seconds. Single click BTN3 to add 5 seconds. Tap to pause or play to timer. Double click BTN1 to reset. When timer finishes the watch vibrates.",
"tags": "Tools",
"tags": "tool",
"storage": [
{"name":"chrono.app.js","url":"chrono.js"},
{"name":"chrono.img","url":"chrono-icon.js","evaluate":true}
@ -1577,7 +1577,7 @@
"icon": "app.png",
"version":"0.03",
"description": "Chronometer (timer) which runs as widget.",
"tags": "tools,widget",
"tags": "tool,widget,b2",
"readme": "README.md",
"storage": [
{"name":"chronowid.wid.js","url":"widget.js"},
@ -3517,7 +3517,7 @@
"name": "Pastel Clock",
"shortName": "Pastel",
"icon": "pastel.png",
"version":"0.03",
"version":"0.04",
"description": "A Configurable clock with custom fonts and background",
"tags": "clock,b2",
"type":"clock",
@ -3598,5 +3598,18 @@
"storage": [
{"name":"menusmall.boot.js","url":"boot.js"}
]
},
{ "id": "ffcniftya",
"name": "Nifty-A Clock",
"icon": "app.png",
"version":"0.01",
"description": "A nifty clock with time and date",
"tags":"clock,b2",
"type":"clock",
"allow_emulator":true,
"storage": [
{"name":"ffcniftya.app.js","url":"app.js"},
{"name":"ffcniftya.img","url":"app-icon.js","evaluate":true}
]
}
]

View File

@ -5,11 +5,15 @@ The advantage is, that you can still see your normal watchface and other widgets
The widget is always active, but only shown when the timer is on.
Hours, minutes, seconds and timer status can be set with an app.
Depending on when you start the timer, it may alert up to 0,999 seconds early. This is because it checks only for full seconds. When there is less than one seconds left, it buzzes. This cannot be avoided without checking more than every second, which I would like to avoid.
When there is less than one seconds left on the timer it buzzes.
The widget has been tested on Bangle 1 and Bangle 2
## Screenshots
TBD
![](chrono_with_wave.jpg)
![](chrono_with_pastel.jpg)
## Features

1
apps/ffcniftya/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New Clock Nifty A

View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwwkEIf4A5gX/+AGEn//mIWLgP/C4gGCAAMgC5UvC4sDC4YICkIhBgMQiEBE4Uxn4XDj//iEAn/yA4ICBgUikEikYXBBAIXEn/xJYURAYMygERkQHBiYLBKYIXF+AVDC4czgUSmIXBCQgED+ZeBR4YXBLYICDC5CPGC4IAIC40zmaPDC4MSLQQXK+ayCR4QXCiRoEC44ECh4bCC4MTiTDBC6ZHOC5B3NLYcvC4kBgL5BAAUikT+BfIIrB/8ykf/eYQXBkUTI4cBW4YQCgQGDmAXDkJfEC46GBAoJKCR4geCAAMRAAZRDAoIODO4UBPRIAJR5QXWgKNCTApNDC5Mv/6/DAwR3GAAyHCC4anJIo3/+bvEa4Uia4oXHkEvC4cvIgUf+YXKHYIvEAgcPC5QSGC5UBSwYXJLYQXFkUhgABBC5Ef/4mBl4XEmETmIXKgaXBmYCBC4cTkMxiQXJS4IACL4p3MgESCwJHFR5oxCiB3FkERC5cSToQXFmUyiAZFR48Bn7zCAQMjkfykQkBN4n/XgKPBAAQgCUQIfBUwYXHFgIGCdI4XDmYADmIIEkAWJAH4A4A=="))

95
apps/ffcniftya/app.js Normal file
View File

@ -0,0 +1,95 @@
const locale = require("locale");
const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
/* Clock *********************************************/
const scale = g.getWidth() / 176;
const widget = 24;
const viewport = {
width: g.getWidth(),
height: g.getHeight(),
}
const center = {
x: viewport.width / 2,
y: Math.round(((viewport.height - widget) / 2) + widget),
}
function d02(value) {
return ('0' + value).substr(-2);
}
function draw() {
g.reset();
g.clearRect(0, widget, viewport.width, viewport.height);
const now = new Date();
const hour = d02(now.getHours() - (is12Hour && now.getHours() > 12 ? 12 : 0));
const minutes = d02(now.getMinutes());
const day = d02(now.getDay());
const month = d02(now.getMonth() + 1);
const year = now.getFullYear();
const month2 = locale.month(now, 3);
const day2 = locale.dow(now, 3);
g.setFontAlign(1, 0).setFont("Vector", 90 * scale);
g.drawString(hour, center.x + 32 * scale, center.y - 31 * scale);
g.drawString(minutes, center.x + 32 * scale, center.y + 46 * scale);
g.fillRect(center.x + 30 * scale, center.y - 72 * scale, center.x + 32 * scale, center.y + 74 * scale);
g.setFontAlign(-1, 0).setFont("Vector", 16 * scale);
g.drawString(year, center.x + 40 * scale, center.y - 62 * scale);
g.drawString(month, center.x + 40 * scale, center.y - 44 * scale);
g.drawString(day, center.x + 40 * scale, center.y - 26 * scale);
g.drawString(month2, center.x + 40 * scale, center.y + 48 * scale);
g.drawString(day2, center.x + 40 * scale, center.y + 66 * scale);
}
/* Minute Ticker *************************************/
let tickTimer;
function clearTickTimer() {
if (tickTimer) {
clearTimeout(tickTimer);
tickTimer = undefined;
}
}
function queueNextTick() {
clearTickTimer();
tickTimer = setTimeout(tick, 60000 - (Date.now() % 60000));
// tickTimer = setTimeout(tick, 3000);
}
function tick() {
draw();
queueNextTick();
}
/* Init **********************************************/
// Clear the screen once, at startup
g.clear();
// Start ticking
tick();
// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower', (on) => {
if (on) {
tick(); // Start ticking
} else {
clearTickTimer(); // stop ticking
}
});
// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();
// Show launcher when middle button pressed
Bangle.setUI("clock");

BIN
apps/ffcniftya/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,3 +1,4 @@
0.01: First release
0.02: Display 12 hour clock as 12:xx not 00:xx when just into PM
0.03: Make it work with Gadgetbridge, Notifications fullscreen on a Bangle 2
0.04: Leave space at the bottom for Chrono widget, set back option at first option

View File

@ -87,19 +87,19 @@ function draw() {
// avoid flicker on a bangle 1 by comparing with previous minute
if (mm_prev != mm) {
mm_prev = mm;
g.clearRect(0, 30, w, h);
g.clearRect(0, 30, w, h - 24);
}
} else {
// on a b2 safe to just clear anyway as there is no flicker
g.clearRect(0, 30, w, h);
g.clearRect(0, 30, w, h - 24);
}
// draw a grid like graph paper
if (settings.grid && process.env.HWVERSION !=1) {
g.setColor("#0f0");
for (var gx=20; gx <= w; gx += 20)
g.drawLine(gx, 30, gx, h);
for (var gy=30; gy <= h; gy += 20)
g.drawLine(gx, 30, gx, h - 24);
for (var gy=30; gy <= h - 24; gy += 20)
g.drawLine(0, gy, w, gy);
}

View File

@ -26,6 +26,7 @@
E.showMenu({
'': { 'title': 'Pastel Clock' },
'< Back': back,
'Font': {
value: 0 | font_options.indexOf(s.font),
min: 0, max: 4,
@ -50,7 +51,6 @@
s.date = !s.date
save()
},
},
'< Back': back,
}
})
})