1
0
Fork 0

Merge pull request #1 from thyttan/supaclk

supaclk: misc suggested fixes and changes
master
Tom Wallroth 2024-06-01 20:29:52 +02:00 committed by GitHub
commit 46b3556cd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,6 @@
{ // must be inside our own scope here so that when we are unloaded everything disappears { // must be inside our own scope here so that when we are unloaded everything disappears
// we also define functions using 'let fn = function() {..}' for the same reason. function decls are global // we also define functions using 'let fn = function() {..}' for the same reason. function decls are globalj
let removeHasNotRun = true;
let drawTimeout; let drawTimeout;
const supaClockImg = { const supaClockImg = {
@ -35,6 +36,7 @@ let drawSplashScreen = function (frame, total) {
} }
// for fast startup-feeling, draw the splash screen once directly once // for fast startup-feeling, draw the splash screen once directly once
g.clear()
drawSplashScreen(0, 20); drawSplashScreen(0, 20);
let splashScreen = function () { let splashScreen = function () {
@ -42,9 +44,11 @@ let splashScreen = function () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let frame = 0; let frame = 0;
function tick() { function tick() {
drawSplashScreen(frame, 20); if (removeHasNotRun) drawSplashScreen(frame, 20);
frame += 1; frame += 1;
if (frame < 20) { if (!removeHasNotRun) {
reject();
} else if (frame < 20) {
setTimeout(tick, 50); setTimeout(tick, 50);
} else { } else {
resolve(); resolve();
@ -118,7 +122,7 @@ let clockInfoDraw = (itm, info, options) => {
g.drawImage(info.img, options.x+1,options.y+2); g.drawImage(info.img, options.x+1,options.y+2);
} }
var text = info.text.toString().toUpperCase(); var text = info.text.toString().toUpperCase();
if (g.setFontPlayfairDisplaySm().stringWidth(text)+24-2>options.w) g.setFont("8x12"); if (g.setFontPlayfairDisplaySm().stringWidth(text)+24-2>options.w) g.setFont("4x6:2");
g.setFontAlign(-1,-1).drawString(text, options.x+24+3, options.y+6); g.setFontAlign(-1,-1).drawString(text, options.x+24+3, options.y+6);
}; };
@ -131,7 +135,7 @@ let clockInfoDrawR = (itm, info, options) => {
g.drawImage(info.img, options.x + options.w-1-24,options.y+2); g.drawImage(info.img, options.x + options.w-1-24,options.y+2);
} }
var text = info.text.toString().toUpperCase(); var text = info.text.toString().toUpperCase();
if (g.setFontPlayfairDisplaySm().stringWidth(text)+24-2>options.w) g.setFont("8x12"); if (g.setFontPlayfairDisplaySm().stringWidth(text)+24-2>options.w) g.setFont("4x6:2");
g.setFontAlign(1,-1).drawString(text, options.x+options.w-24-3, options.y+6); g.setFontAlign(1,-1).drawString(text, options.x+options.w-24-3, options.y+6);
}; };
@ -146,19 +150,15 @@ let clockInfoMenu4;
Bangle.setUI({ Bangle.setUI({
mode : "clock", mode : "clock",
remove : function() { // for fastloading, clear the app memory remove : function() { // for fastloading, clear the app memory
removeHasNotRun = false;
if (drawTimeout) clearTimeout(drawTimeout); if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined; drawTimeout = undefined;
delete Graphics.prototype.setFontPlayfairDisplay delete Graphics.prototype.setFontPlayfairDisplay
delete Graphics.prototype.setFontPlayfairDisplaySm delete Graphics.prototype.setFontPlayfairDisplaySm
delete clockInfoItems; clockInfoMenu1&&clockInfoMenu1.remove();
clockInfoMenu1.remove(); clockInfoMenu2&&clockInfoMenu2.remove();
delete clockInfoMenu1; clockInfoMenu3&&clockInfoMenu3.remove();
clockInfoMenu2.remove(); clockInfoMenu4&&clockInfoMenu4.remove();
delete clockInfoMenu2;
clockInfoMenu3.remove();
delete clockInfoMenu3;
clockInfoMenu4.remove();
delete clockInfoMenu4;
}}); }});
Bangle.loadWidgets(); Bangle.loadWidgets();
@ -190,6 +190,6 @@ splashScreen().then(() => {
} }
} }
}, 1); }, 1);
}); },() => {});
} }