diff --git a/apps/widhr/ChangeLog b/apps/widhr/ChangeLog new file mode 100644 index 0000000000..7b83706bf8 --- /dev/null +++ b/apps/widhr/ChangeLog @@ -0,0 +1 @@ +0.01: First release diff --git a/apps/widhr/README.md b/apps/widhr/README.md new file mode 100644 index 0000000000..23f99f4889 --- /dev/null +++ b/apps/widhr/README.md @@ -0,0 +1,10 @@ +# Last announced heartrate BPM Widget + +* Displays the last announced bpm measurement from Bangle.on('HRM', ...); +* it does not enable the heartrate sensor to do measurements it waits on such annoucement. I use it to view the last read value when letting the system take a reading every 10 minutes. +* saves last read value to a file so it can display that last value between app starts / reboots + +![](screenshot_widhr.png) + +Code based on Lato Pedometer Written by: [Hugh Barney](https://github.com/hughbarney) +Code Modified by: [Willems Davy](https://github.com/joyrider3774) diff --git a/apps/widhr/metadata.json b/apps/widhr/metadata.json new file mode 100644 index 0000000000..eecc721829 --- /dev/null +++ b/apps/widhr/metadata.json @@ -0,0 +1,19 @@ +{ + "id": "widhr", + "name": "Last announced heartrate BPM Widget", + "shortName":"Last Heartrate BPM", + "icon": "widhr.icon.png", + "screenshots": [{"url":"screenshot_widhr.png"}], + "version":"0.01", + "type": "widget", + "supports": ["BANGLEJS2"], + "readme": "README.md", + "description": "Displays the last announced heartrate BPM from `Bangle.on(\"HRM\", ...);` (it does not enable the hrm sensor it expects the system or other app todo so)", + "tags": "widget", + "data": [ + {"name":"widhr.data.json"} + ], + "storage": [ + {"name":"widhr.wid.js","url":"widhr.wid.js"} + ] + } diff --git a/apps/widhr/screenshot_widhr.png b/apps/widhr/screenshot_widhr.png new file mode 100644 index 0000000000..e1911f9a32 Binary files /dev/null and b/apps/widhr/screenshot_widhr.png differ diff --git a/apps/widhr/widhr.icon.png b/apps/widhr/widhr.icon.png new file mode 100644 index 0000000000..ba61a15d8a Binary files /dev/null and b/apps/widhr/widhr.icon.png differ diff --git a/apps/widhr/widhr.wid.js b/apps/widhr/widhr.wid.js new file mode 100644 index 0000000000..bcc8628d36 --- /dev/null +++ b/apps/widhr/widhr.wid.js @@ -0,0 +1,30 @@ +function widhr_hrm(hrm) { + require("Storage").writeJSON("widhr.data.json", {"bpm":hrm.bpm}); + WIDGETS["widhr"].draw(); +} + +Bangle.on('HRM', widhr_hrm); + +function widhr_draw() { + var json = require("Storage").readJSON("widhr.data.json"); + var bpm = json === undefined ? 0 : json.bpm; + //3x6 from bpm text in 6x8 font + var w = (bpm.toString().length)*8 > 3 * 6 ? (bpm.toString().length)*8 : 3 * 6; + 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); + g.setFont("6x8:1"); + g.setFontAlign(-1, 0); + g.drawString("bpm", this.x, this.y + 5); + g.setFont("4x6:2"); + g.setFontAlign(-1, 0); + g.drawString(bpm, this.x, this.y + 17); +} + +WIDGETS["widhr"]={area:"tl",sortorder:-1,width:13,draw:widhr_draw}; \ No newline at end of file