Merge pull request #2197 from myxor/circlesclock_v0.15

Circlesclock v0.15
pull/2199/head
Gordon Williams 2022-10-26 15:23:37 +01:00 committed by GitHub
commit a897cbb38d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 17 deletions

View File

@ -27,3 +27,4 @@
0.13: Load step goal from Bangle health app as fallback
Memory optimizations
0.14: Support to show big weather info
0.15: Use Bangle.setUI({remove:...}) to allow loading the launcher without a full reset on 2v16

View File

@ -29,6 +29,9 @@ if (settings.stepGoal == undefined) {
}
}
let timerHrm;
let drawTimeout;
/*
* Read location from myLocation app
*/
@ -156,6 +159,8 @@ function draw() {
drawCircle(2);
drawCircle(3);
if (circleCount >= 4) drawCircle(4);
queueDraw();
}
function drawCircle(index) {
@ -822,7 +827,7 @@ function getPressureValue(type) {
});
}
Bangle.on('lock', function(isLocked) {
function onLock(isLocked) {
if (!isLocked) {
draw();
if (isCircleEnabled("hr")) {
@ -831,11 +836,10 @@ Bangle.on('lock', function(isLocked) {
} else {
Bangle.setHRMPower(0, "circleclock");
}
});
}
Bangle.on('lock', onLock);
let timerHrm;
Bangle.on('HRM', function(hrm) {
function onHRM(hrm) {
if (isCircleEnabled("hr")) {
if (hrm.confidence >= (settings.confidence)) {
hrtValue = hrm.bpm;
@ -852,23 +856,48 @@ Bangle.on('HRM', function(hrm) {
}, settings.hrmValidity * 1000);
}
}
});
}
Bangle.on('HRM', onHRM);
Bangle.on('charging', function(charging) {
function onCharging(charging) {
if (isCircleEnabled("battery")) drawBattery();
});
}
Bangle.on('charging', onCharging);
if (isCircleEnabled("hr")) {
enableHRMSensor();
}
Bangle.setUI("clock");
Bangle.setUI({
mode : "clock",
remove : function() {
// Called to unload all of the clock app
Bangle.removeListener('charging', onCharging);
Bangle.removeListener('lock', onLock);
Bangle.removeListener('HRM', onHRM);
Bangle.setHRMPower(0, "circleclock");
if (timerHrm) clearTimeout(timerHrm);
timerHrm = undefined;
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFontRobotoRegular50NumericOnly;
delete Graphics.prototype.setFontRobotoRegular21;
}});
Bangle.loadWidgets();
// schedule a draw for the next minute
setTimeout(function() {
// draw in interval
setInterval(draw, settings.updateInterval * 1000);
}, 60000 - (Date.now() % 60000));
// schedule a draw for the next second or minute
function queueDraw() {
let queueMillis = settings.updateInterval * 1000;
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, queueMillis - (Date.now() % queueMillis));
}
draw();

View File

@ -1,7 +1,7 @@
{ "id": "circlesclock",
"name": "Circles clock",
"shortName":"Circles clock",
"version":"0.14",
"version":"0.15",
"description": "A clock with three or four circles for different data at the bottom in a probably familiar style",
"icon": "app.png",
"screenshots": [{"url":"screenshot-dark.png"}, {"url":"screenshot-light.png"}, {"url":"screenshot-dark-4.png"}, {"url":"screenshot-light-4.png"}],