widhrtplus - renamed id to widhrtplus
parent
b469b0ba01
commit
bae348703c
|
|
@ -1,14 +0,0 @@
|
||||||
# Heart Rate Widget+
|
|
||||||
|
|
||||||
A simple widget that shows the on/off status of the Heart Rate
|
|
||||||
Monitor and the last measured value.
|
|
||||||
|
|
||||||
- Shows in red when the HRM is on
|
|
||||||
- Shows in black or white (foreground colour) when the HRM is off
|
|
||||||
- Does not power the HRM on or off. Relies on the Health app to do that.
|
|
||||||
- Resizes widget based on value of heart rate
|
|
||||||
- Uses Lato font so looks consistant with Lato Pedometer and Yet Another Battery Widget
|
|
||||||
|
|
||||||
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.
|
Before Width: | Height: | Size: 5.3 KiB |
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"id": "widhrt2",
|
|
||||||
"name": "HRM Widget+",
|
|
||||||
"icon": "widget.png",
|
|
||||||
"screenshots": [{"url":"screenshot.png"}],
|
|
||||||
"version":"0.01",
|
|
||||||
"type": "widget",
|
|
||||||
"supports": ["BANGLEJS2"],
|
|
||||||
"readme": "README.md",
|
|
||||||
"description": "Widget to display heart rate and status of Heart Rate Monitor",
|
|
||||||
"tags": "widget",
|
|
||||||
"storage": [
|
|
||||||
{"name":"widhrt2.wid.js","url":"widget.js"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB |
|
|
@ -1,49 +0,0 @@
|
||||||
(function(){
|
|
||||||
if (!Bangle.isHRMOn) return; // old firmware
|
|
||||||
var hp = Bangle.setHRMPower;
|
|
||||||
Bangle.setHRMPower = () => {
|
|
||||||
hp.apply(Bangle, arguments);
|
|
||||||
WIDGETS.widhrt.draw();
|
|
||||||
};
|
|
||||||
|
|
||||||
var bp = Math.round(Bangle.getHealthStatus().bpm||Bangle.getHealthStatus("last").bpm);
|
|
||||||
|
|
||||||
Bangle.on('HRM',(e)=>{
|
|
||||||
//console.log('onHrm');
|
|
||||||
if (e && e.confidence>60) bp = Math.round(e.bpm);
|
|
||||||
if (bp == 0) bp = Math.round(Bangle.getHealthStatus().bpm||Bangle.getHealthStatus("last").bpm);
|
|
||||||
WIDGETS["widhrt"].draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
WIDGETS.widhrt={area:"tr",sortorder:9,width:56,draw:function() {
|
|
||||||
g.reset();
|
|
||||||
// Lato from fonts.google.com, Actual height 17 (17 - 1), Numeric only
|
|
||||||
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+(1<<8)+(1<<16));
|
|
||||||
//console.log("hrm=" + bp);
|
|
||||||
|
|
||||||
var text_w = g.stringWidth(bp);
|
|
||||||
var hw = 20; // heart image width
|
|
||||||
var w = text_w + 3 + hw + 2;
|
|
||||||
// we need this to be able to shrink or grow on the 3,2,1 digit bpm
|
|
||||||
if (w != this.width) {this.width = w; setTimeout(() => Bangle.drawWidgets(),10); return;}
|
|
||||||
//var h = 12; // height
|
|
||||||
|
|
||||||
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);
|
|
||||||
g.setFontAlign(-1, 0);
|
|
||||||
g.drawString(bp, this.x, this.y + 12);
|
|
||||||
var x = this.x + text_w + 3;
|
|
||||||
|
|
||||||
// draw image
|
|
||||||
if (Bangle.isHRMOn()) {
|
|
||||||
g.setColor('#f00'); // on = red
|
|
||||||
} else {
|
|
||||||
g.setColor(g.theme.dark ? '#fff' : '#000'); // off
|
|
||||||
}
|
|
||||||
|
|
||||||
// image converter https://www.espruino.com/Image+Converter ; settings to get a fillable image
|
|
||||||
// 1 bit bw, transparency? Y, transparent bg, white heart (must be white for color fill)
|
|
||||||
g.drawImage(atob("FBSBAAAAAAAAAAAB+fg//8f//n//5//+f//n//5//+P//D//wf/4D/8Af+AB+AAPAABgAAAA"), x, 1+this.y);
|
|
||||||
}};
|
|
||||||
})();
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in New Issue