-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3004 from joyrider3774/add_widhrm
Add widhr (Last announced heartrate BPM Widget)
- Loading branch information
Showing
6 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.01: First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; |