widpedom - added option to show steps in larger 6x8x2 font

pull/794/head
hughbarney 2021-08-29 19:04:45 +01:00
parent 760840db2e
commit 1503da2df2
4 changed files with 27 additions and 1 deletions

View File

@ -1183,7 +1183,7 @@
{ "id": "widpedom",
"name": "Pedometer widget",
"icon": "widget.png",
"version":"0.15",
"version":"0.16",
"description": "Daily pedometer widget",
"tags": "widget,b2",
"type":"widget",

View File

@ -12,3 +12,4 @@
0.13: Now use system color theme
0.14: Improve memory usage
0.15: Settings option to hide the widget icon
0.16: Settings option to show large digits in widget area

View File

@ -5,6 +5,7 @@
let s = {
'goal': 10000,
'progress': false,
'large': false,
'hide': false
}
// ...and overwrite them with any saved values
@ -42,6 +43,14 @@
save()
},
},
'Large Digits': {
value: s.large,
format: () => (s.large ? 'Yes' : 'No'),
onchange: () => {
s.large = !s.large
save()
},
},
'Hide Widget': {
value: s.hide,
format: () => (s.hide ? 'Yes' : 'No'),

View File

@ -14,6 +14,7 @@
const DEFAULTS = {
'goal': 10000,
'progress': false,
'large': false,
'hide': false
}
return (key in settings) ? settings[key] : DEFAULTS[key];
@ -48,6 +49,17 @@
}
}
// show the step count in the widget area in a readable sized font
function draw_large(st) {
var width = 12 * st.length;
g.reset();
g.clearRect(this.x, this.y, this.x + width, this.y + 16); // erase background
g.setColor(g.theme.fg);
g.setFont("6x8",2);
g.setFontAlign(-1, -1);
g.drawString(st, this.x + 4, this.y + 2);
}
// draw your widget
function draw() {
if (setting('hide')) return;
@ -56,6 +68,10 @@
stp_today = stp_today % 100000; // cap to five digits + comma = 6 characters
}
let stps = stp_today.toString();
if (setting('large')) {
draw_large.call(this, stps);
return;
}
g.reset().clearRect(this.x, this.y, this.x + width, this.y + 23); // erase background
if (setting('progress')){ drawProgress.call(this, stps); }
g.setColor(g.theme.fg);