primtime lato, added debug feature

pull/2348/head
Hugh Barney 2022-11-27 19:03:15 +00:00
parent 02f91e1bd0
commit 3a45f15574
4 changed files with 41 additions and 5 deletions

View File

@ -1,2 +1,3 @@
0.01: first release 0.01: first release
0.02: added option to buzz on prime, with settings 0.02: added option to buzz on prime, with settings
0.03: added option to debug settings and test fw 2.15.93 load speed ups

View File

@ -2,6 +2,7 @@ const h = g.getHeight();
const w = g.getWidth(); const w = g.getWidth();
const SETTINGS_FILE = "primetimelato.json"; const SETTINGS_FILE = "primetimelato.json";
let settings; let settings;
let setStr = 'U';
Graphics.prototype.setFontLato = function(scale) { Graphics.prototype.setFontLato = function(scale) {
// Actual height 41 (43 - 3) // Actual height 41 (43 - 3)
@ -28,6 +29,22 @@ Graphics.prototype.setFontLatoSmall = function(scale) {
function loadSettings() { function loadSettings() {
settings = require("Storage").readJSON(SETTINGS_FILE,1)||{}; settings = require("Storage").readJSON(SETTINGS_FILE,1)||{};
settings.buzz_on_prime = (settings.buzz_on_prime === undefined ? false : settings.buzz_on_prime); settings.buzz_on_prime = (settings.buzz_on_prime === undefined ? false : settings.buzz_on_prime);
settings.debug = (settings.debug === undefined ? false : settings.debug);
switch(settings.buzz_on_prime) {
case true:
setStr = 'T';
break;
case false:
setStr = 'F';
break;
case undefined:
default:
setStr = 'U';
break;
}
} }
// creates a list of prime factors of n and outputs them as a string, if n is prime outputs "Prime Time!" // creates a list of prime factors of n and outputs them as a string, if n is prime outputs "Prime Time!"
@ -69,9 +86,16 @@ function draw() {
g.setColor(0,0,0); g.setColor(0,0,0);
g.fillRect(Bangle.appRect); g.fillRect(Bangle.appRect);
g.setColor(100,100,100);
if (settings.debug) {
g.setFontLatoSmall();
g.setFontAlign(0, 0);
g.drawString(setStr, w/2, h/4);
}
g.setFontLato(); g.setFontLato();
g.setFontAlign(0, 0); g.setFontAlign(0, 0);
g.setColor(100,100,100);
g.drawString(timeStr, w/2, h/2); g.drawString(timeStr, w/2, h/2);
g.setFontLatoSmall(); g.setFontLatoSmall();

View File

@ -1,6 +1,6 @@
{ "id": "primetimelato", { "id": "primetimelato",
"name": "Prime Time Lato Clock", "name": "Prime Time Lato",
"version": "0.02", "version": "0.03",
"type": "clock", "type": "clock",
"description": "A clock that tells you the primes of the time in the Lato font", "description": "A clock that tells you the primes of the time in the Lato font",
"icon": "app.png", "icon": "app.png",

View File

@ -3,7 +3,8 @@
// initialize with default settings... // initialize with default settings...
let s = { let s = {
'buzz_on_prime': true 'buzz_on_prime': true,
'debug': false
} }
// ...and overwrite them with any saved values // ...and overwrite them with any saved values
@ -29,6 +30,16 @@
s.buzz_on_prime = v; s.buzz_on_prime = v;
save(); save();
}, },
},
'Debug': {
value: !!s.debug,
onchange: v => {
s.debug = v;
save();
},
} }
}) })
}) })