Skip to content

Commit 186d0b6

Browse files
committed
hrm 0.14: Ensure we reset graphics so other apps can't mess up the background color
1 parent 37dcceb commit 186d0b6

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

apps/hrm/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
0.11: Automatic translation of strings.
1212
0.12: Minor code improvements
1313
0.13: Minor code improvements
14+
0.14: Ensure we reset graphics so other apps can't mess up the background color

apps/hrm/heartrate.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function onHRM(h) {
1414
// the first time we're called remove
1515
// the countdown
1616
counter = undefined;
17-
g.clearRect(0,24,g.getWidth(),g.getHeight());
17+
g.reset().clearRect(0,24,g.getWidth(),g.getHeight());
1818
}
1919
hrmInfo = h;
2020
/* On 2v09 and earlier firmwares the only solution for realtime
@@ -35,7 +35,7 @@ Bangle.on('HRM', onHRM);
3535

3636
function updateHrm(){
3737
var px = g.getWidth()/2;
38-
g.setFontAlign(0,-1);
38+
g.reset().setFontAlign(0,-1);
3939
g.clearRect(0,24,g.getWidth(),80);
4040
g.setFont("6x8").drawString(/*LANG*/"Confidence "+(hrmInfo.confidence || "--")+"%", px, 70);
4141

@@ -62,6 +62,7 @@ var scale = 2000;
6262
HRM events as they happen */
6363
Bangle.on('HRM-raw', function(v) {
6464
hrmOffset++;
65+
g.reset();
6566
if (hrmOffset>g.getWidth()) {
6667
let thousands = Math.round(rawMax / 1000) * 1000;
6768
if (thousands > scale) scale = thousands;
@@ -91,11 +92,11 @@ Bangle.on('HRM-raw', function(v) {
9192
var counter = 5;
9293
function countDown() {
9394
if (counter) {
94-
g.drawString(counter--,g.getWidth()/2,g.getHeight()/2, true);
95+
g.reset().drawString(counter--,g.getWidth()/2,g.getHeight()/2, true);
9596
setTimeout(countDown, 1000);
9697
}
9798
}
98-
g.clear();
99+
g.clear(1);
99100
Bangle.loadWidgets();
100101
Bangle.drawWidgets();
101102
g.setColor(g.theme.fg);
@@ -111,7 +112,7 @@ var hrmInfo;
111112

112113
function readHRM() {
113114
if (!hrmInfo) return;
114-
115+
g.reset();
115116
if (hrmOffset==0) {
116117
g.clearRect(0,100,g.getWidth(),g.getHeight());
117118
lastHrmPt = [-100,0];

apps/hrm/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "hrm",
33
"name": "Heart Rate Monitor",
4-
"version": "0.13",
5-
"author": "ra100",
4+
"version": "0.14",
5+
"author": "gfwilliams",
66
"description": "Measure your heart rate and see live sensor data",
77
"icon": "heartrate.png",
88
"screenshots" : [ { "url":"screenshot.png" } ],

0 commit comments

Comments
 (0)