forked from FOSS/BangleApps
commit
b597245f16
|
@ -12,3 +12,4 @@
|
||||||
0.30: Added options to show widgets and date on twist and tap. New fonts.
|
0.30: Added options to show widgets and date on twist and tap. New fonts.
|
||||||
0.31: Bugfix, no more freeze.
|
0.31: Bugfix, no more freeze.
|
||||||
0.32: Minor code improvements
|
0.32: Minor code improvements
|
||||||
|
0.33: Messages would sometimes halt the clock. This should be fixed now.
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
{
|
{
|
||||||
let drawTimeout;
|
let drawTimeout;
|
||||||
let extrasTimeout;
|
let extrasTimer=0;
|
||||||
let onLock;
|
|
||||||
//let onTap;
|
|
||||||
//let onTwist;
|
|
||||||
let settings = require('Storage').readJSON("contourclock.json", true) || {};
|
let settings = require('Storage').readJSON("contourclock.json", true) || {};
|
||||||
if (settings.fontIndex == undefined) {
|
if (settings.fontIndex == undefined) {
|
||||||
settings.fontIndex = 0;
|
settings.fontIndex = 0;
|
||||||
|
@ -16,9 +13,9 @@
|
||||||
require('Storage').writeJSON("contourclock.json", settings);
|
require('Storage').writeJSON("contourclock.json", settings);
|
||||||
}
|
}
|
||||||
require("FontTeletext10x18Ascii").add(Graphics);
|
require("FontTeletext10x18Ascii").add(Graphics);
|
||||||
let extrasShown = (!settings.hidewhenlocked) && (!Bangle.isLocked());
|
|
||||||
let installedFonts = require('Storage').readJSON("contourclock-install.json") || {};
|
let installedFonts = require('Storage').readJSON("contourclock-install.json") || {};
|
||||||
if (installedFonts.n > 0) { //New install - check for unused font files
|
// New install - check for unused font files. This should probably be handled by the installer instead
|
||||||
|
if (installedFonts.n > 0) {
|
||||||
settings.fontIndex = E.clip(settings.fontIndex, -installedFonts.n + 1, installedFonts.n - 1);
|
settings.fontIndex = E.clip(settings.fontIndex, -installedFonts.n + 1, installedFonts.n - 1);
|
||||||
require('Storage').writeJSON("contourclock.json", settings);
|
require('Storage').writeJSON("contourclock.json", settings);
|
||||||
for (let n = installedFonts.n;; n++) {
|
for (let n = installedFonts.n;; n++) {
|
||||||
|
@ -27,14 +24,22 @@
|
||||||
}
|
}
|
||||||
require("Storage").erase("contourclock-install.json");
|
require("Storage").erase("contourclock-install.json");
|
||||||
}
|
}
|
||||||
let showExtras = function() { //show extras for a limited time
|
let onLock = function(locked) {if (!locked) showExtras();};
|
||||||
|
let showExtras = function() { //show extras for 5s
|
||||||
drawExtras();
|
drawExtras();
|
||||||
if (extrasTimeout) clearTimeout(extrasTimeout);
|
extrasTimer = 5000-60000-(Date.now()%60000);
|
||||||
extrasTimeout = setTimeout(() => {
|
if (extrasTimer<0) { //schedule next redraw early to hide extras
|
||||||
extrasTimeout = undefined;
|
if (drawTimeout) clearTimeout(drawTimeout);
|
||||||
hideExtras();
|
drawTimeout = setTimeout(function() {
|
||||||
}, 5000);
|
drawTimeout = undefined;
|
||||||
extrasShown = false;
|
draw();
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let hideExtras = function() {
|
||||||
|
g.reset();
|
||||||
|
g.clearRect(0, 138, g.getWidth() - 1, 176);
|
||||||
|
if (settings.widgets) require("widget_utils").hide();
|
||||||
};
|
};
|
||||||
let drawExtras = function() { //draw date, day of the week and widgets
|
let drawExtras = function() { //draw date, day of the week and widgets
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
@ -43,38 +48,27 @@
|
||||||
g.setFont("Teletext10x18Ascii").setFontAlign(0, 1);
|
g.setFont("Teletext10x18Ascii").setFontAlign(0, 1);
|
||||||
if (settings.weekday) g.drawString(require("locale").dow(date).toUpperCase(), g.getWidth() / 2, g.getHeight() - 18);
|
if (settings.weekday) g.drawString(require("locale").dow(date).toUpperCase(), g.getWidth() / 2, g.getHeight() - 18);
|
||||||
if (settings.date) g.drawString(require('locale').date(date, 1), g.getWidth() / 2, g.getHeight());
|
if (settings.date) g.drawString(require('locale').date(date, 1), g.getWidth() / 2, g.getHeight());
|
||||||
require("widget_utils").show();
|
if (settings.widgets) require("widget_utils").show();
|
||||||
extrasShown = true;
|
|
||||||
};
|
|
||||||
let hideExtras = function() {
|
|
||||||
if (extrasTimeout) clearTimeout(extrasTimeout);
|
|
||||||
extrasTimeout = undefined; //NEW
|
|
||||||
g.reset();
|
|
||||||
g.clearRect(0, 138, g.getWidth() - 1, 176);
|
|
||||||
require("widget_utils").hide();
|
|
||||||
extrasShown = false; ///NEW
|
|
||||||
};
|
};
|
||||||
let draw = function() {
|
let draw = function() {
|
||||||
if (drawTimeout) clearTimeout(drawTimeout); //NEW
|
if (extrasTimer>0) { //schedule next draw early to remove extras
|
||||||
drawTimeout = setTimeout(function() {
|
drawTimeout = setTimeout(function() {
|
||||||
drawTimeout = undefined;
|
drawTimeout = undefined;
|
||||||
draw();
|
draw();
|
||||||
}, 60000 - (Date.now() % 60000));
|
}, extrasTimer);
|
||||||
|
extrasTimer=0;
|
||||||
|
} else {
|
||||||
|
if (settings.hideWhenLocked) hideExtras();
|
||||||
|
drawTimeout = setTimeout(function() {
|
||||||
|
drawTimeout = undefined;
|
||||||
|
draw();
|
||||||
|
}, 60000 - (Date.now() % 60000));
|
||||||
|
}
|
||||||
g.reset();
|
g.reset();
|
||||||
if (extrasShown) drawExtras();
|
if (!settings.hideWhenLocked) drawExtras();
|
||||||
else hideExtras();
|
|
||||||
require('contourclock').drawClock(settings.fontIndex);
|
require('contourclock').drawClock(settings.fontIndex);
|
||||||
};
|
};
|
||||||
if (settings.hideWhenLocked) {
|
if (settings.hideWhenLocked) {
|
||||||
onLock = locked => {
|
|
||||||
if (!locked) {
|
|
||||||
require("widget_utils").show();
|
|
||||||
drawExtras();
|
|
||||||
} else {
|
|
||||||
require("widget_utils").hide();
|
|
||||||
hideExtras();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Bangle.on('lock', onLock);
|
Bangle.on('lock', onLock);
|
||||||
if (settings.tapToShow) Bangle.on('tap', showExtras);
|
if (settings.tapToShow) Bangle.on('tap', showExtras);
|
||||||
if (settings.twistToShow) Bangle.on('twist', showExtras);
|
if (settings.twistToShow) Bangle.on('twist', showExtras);
|
||||||
|
@ -82,14 +76,16 @@
|
||||||
Bangle.setUI({
|
Bangle.setUI({
|
||||||
mode: "clock",
|
mode: "clock",
|
||||||
remove: function() {
|
remove: function() {
|
||||||
Bangle.removeListener('lock', onLock);
|
if (settings.hideWhenLocked) {
|
||||||
Bangle.removeListener('tap', showExtras);
|
Bangle.removeListener('lock', onLock);
|
||||||
Bangle.removeListener('twist', showExtras);
|
if (settings.tapToShow) Bangle.removeListener('tap', showExtras);
|
||||||
if (drawTimeout) clearTimeout(drawTimeout);
|
if (settings.twistToShow) Bangle.removeListener('twist', showExtras);
|
||||||
if (extrasTimeout) clearTimeout(extrasTimeout);
|
}
|
||||||
drawTimeout = undefined;
|
if (drawTimeout) {
|
||||||
extrasTimeout = undefined;
|
clearTimeout(drawTimeout);
|
||||||
if (settings.hideWhenLocked) require("widget_utils").show();
|
drawTimeout = undefined;
|
||||||
|
}
|
||||||
|
if (settings.hideWhenLocked && settings.widgets) require("widget_utils").show();
|
||||||
g.reset();
|
g.reset();
|
||||||
g.clear();
|
g.clear();
|
||||||
}
|
}
|
||||||
|
@ -97,7 +93,8 @@
|
||||||
g.clear();
|
g.clear();
|
||||||
if (settings.widgets) {
|
if (settings.widgets) {
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
setTimeout(Bangle.drawWidgets,0); //NEW
|
Bangle.drawWidgets();
|
||||||
}
|
}
|
||||||
draw();
|
draw();
|
||||||
|
if (!settings.hideWhenLocked || !Bangle.isLocked()) showExtras();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "contourclock",
|
{ "id": "contourclock",
|
||||||
"name": "Contour Clock",
|
"name": "Contour Clock",
|
||||||
"shortName" : "Contour Clock",
|
"shortName" : "Contour Clock",
|
||||||
"version": "0.32",
|
"version": "0.33",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"description": "A Minimalist clockface with large Digits.",
|
"description": "A Minimalist clockface with large Digits.",
|
||||||
|
|
Loading…
Reference in New Issue