1
0
Fork 0

Simple Pedometer and Lato Pedometer widgets

master
hughbarney 2022-01-12 22:45:42 +00:00
parent 910c3c0b5b
commit a98a6015b1
7 changed files with 102 additions and 0 deletions

View File

@ -5577,5 +5577,37 @@
"data": [
{"name":"banglexercise.json"}
]
},
{
"id": "widpa",
"name": "Simple Pedometer",
"shortName":"Simple Pedometer",
"icon": "screenshot_widpa.png",
"screenshots": [{"url":"screenshot_widpa.png"}],
"version":"0.01",
"type": "widget",
"supports": ["BANGLEJS", "BANGLEJS2"],
"readme": "README.md",
"description": "Displays the current step count from `Bangle.getHealthStatus(\"day\").steps` in 12x16 font, requires firmware v2.11.21 or later",
"tags": "widget,battery",
"storage": [
{"name":"widpa.wid.js","url":"widpa.wid.js"}
]
},
{
"id": "widpb",
"name": "Lato Pedometer",
"shortName":"Lato Pedometer",
"icon": "screenshot_widpb.png",
"screenshots": [{"url":"screenshot_widpb.png"}],
"version":"0.01",
"type": "widget",
"supports": ["BANGLEJS", "BANGLEJS2"],
"readme": "README.md",
"description": "Displays the current step count from `Bangle.getHealthStatus(\"day\").steps` in the Lato font, requires firmware v2.11.21 or later",
"tags": "widget,battery",
"storage": [
{"name":"widpb.wid.js","url":"widpb.wid.js"}
]
}
]

16
apps/widpa/README.md Normal file
View File

@ -0,0 +1,16 @@
# Simple Pedometer Widget
*Displays the current step count from `Bangle.getHealthStatus("day").steps` in (6x8,2) font, Requires firmware v2.11.21 or later*
* Designed to be small, minimal, does one thing well, no settings
* Supports Bangle 1 and Bangle 2
## Notes
* Requires firmware v2.11.21 or later
* `Bangle.getHealthStatus("day").steps` is reset to zero if you reboot your watch with a long BTN Press
* The step count displayed may be a few steps more than that reported by widpedpm as widpedom may not always be loaded.
![](screenshot_widpa.png)
Written by: [Hugh Barney](https://github.com/hughbarney) For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/)

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

17
apps/widpa/widpa.wid.js Normal file
View File

@ -0,0 +1,17 @@
Bangle.on('step', function(s) { WIDGETS["widpa"].draw(); });
Bangle.on('lcdPower', function(on) {
if (on) WIDGETS["widpa"].draw();
});
WIDGETS["widpa"]={area:"tl",width:13,draw:function() {
if (!Bangle.isLCDOn()) return; // dont redraw if LCD is off
var steps = Bangle.getHealthStatus("day").steps;
var w = 1 + (steps.toString().length)*12;
if (w > this.width) {this.width = w; setTimeout(() => Bangle.drawWidgets(),10); return;}
g.reset();
g.setColor(g.theme.bg);
g.fillRect(this.x, this.y, this.x + this.width, this.y + 23);
g.setColor(g.theme.fg);
g.setFont('6x8',2);
g.setFontAlign(-1, 0);
g.drawString(steps, this.x, this.y + 12);
}};

17
apps/widpb/README.md Normal file
View File

@ -0,0 +1,17 @@
# Lato Pedometer Widget
*Displays the current step count from `Bangle.getHealthStatus("day").steps` in the Lato font, Requires firmware v2.11.21 or later*
* Designed to be minimal, does one thing well, no settings
* Supports Bangle 1 and Bangle 2
## Notes
* Requires firmware v2.11.21 or later
* Uses the Lato custom font, so memory footprint is 500 bytes larger than 'Simple Pedometer Widget'
* `Bangle.getHealthStatus("day").steps` is reset to zero if you reboot your watch with a long BTN Press
* The step count displayed may be a few steps more than that reported by widpedpm as widpedom may not always be loaded.
![](screenshot_widpb.png)
Written by: [Hugh Barney](https://github.com/hughbarney) For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/)

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

20
apps/widpb/widpb.wid.js Normal file
View File

@ -0,0 +1,20 @@
// on.step version
Bangle.on('step', function(s) { WIDGETS["bata"].draw(); });
Bangle.on('lcdPower', function(on) {
if (on) WIDGETS["bata"].draw();
});
WIDGETS["bata"]={area:"tl",width:13,draw:function() {
if (!Bangle.isLCDOn()) return; // dont redraw if LCD is off
var steps = Bangle.getHealthStatus("day").steps;
var w = 1 + (steps.toString().length)*12;
if (w > this.width) {this.width = w; setTimeout(() => Bangle.drawWidgets(),10); return;}
g.reset();
g.setColor(g.theme.bg);
g.fillRect(this.x, this.y, this.x + this.width, this.y + 23); // erase background
g.setColor(g.theme.fg);
// Lato from fonts.google.com, Actual height 17 (17 - 1), Numeric only
const scale = 1;
g.setFontCustom(atob("AAAAABwAAOAAAgAAHAADwAD4AB8AB8AA+AAeAADAAAAOAAP+AH/8B4DwMAGBgAwMAGBgAwOAOA//gD/4AD4AAAAAAAABgAAcAwDAGAwAwP/+B//wAAGAAAwAAGAAAAAAAAIAwHgOA4DwMA+BgOwMDmBg4wOeGA/gwDwGAAAAAAAAAGAHA8A4DwMAGBhAwMMGBjgwOcOA+/gDj4AAAAABgAAcAAHgADsAA5gAOMAHBgBwMAP/+B//wABgAAMAAAAAAAgD4OB/AwOYGBjAwMYGBjBwMe8Bh/AIHwAAAAAAAAAfAAP8AHxwB8GAdgwPMGBxgwMOOAB/gAH4AAAAAAABgAAMAABgAwMAeBgPgMHwBj4AN8AB+AAPAABAAAAAAAMfAH38B/xwMcGBhgwMMGBjgwP+OA+/gDj4AAAAAAAAOAAH4AA/gQMMGBgzwME8BhvAOPgA/4AD8AAEAAAAAAGAwA4OAHBwAAA="), 46, atob("BAgMDAwMDAwMDAwMBQ=="), 21+(scale<<8)+(1<<16));
g.setFontAlign(-1, 0);
g.drawString(steps, this.x, this.y + 12);
}};