mirror of https://github.com/espruino/BangleApps
hrm 0.03: Fix timing issues, and use 1/2 scale to keep graph on screen
parent
86d43c3fbb
commit
a7efdb9724
|
@ -584,7 +584,7 @@
|
||||||
{ "id": "hrm",
|
{ "id": "hrm",
|
||||||
"name": "Heart Rate Monitor",
|
"name": "Heart Rate Monitor",
|
||||||
"icon": "heartrate.png",
|
"icon": "heartrate.png",
|
||||||
"version":"0.02",
|
"version":"0.03",
|
||||||
"description": "Measure your heart rate and see live sensor data",
|
"description": "Measure your heart rate and see live sensor data",
|
||||||
"tags": "health",
|
"tags": "health",
|
||||||
"storage": [
|
"storage": [
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Use HRM data and calculations from Bangle.js (don't access hardware directly)
|
0.02: Use HRM data and calculations from Bangle.js (don't access hardware directly)
|
||||||
|
0.03: Fix timing issues, and use 1/2 scale to keep graph on screen
|
||||||
|
|
|
@ -12,7 +12,10 @@ function onHRM(h) {
|
||||||
hrmInfo = h;
|
hrmInfo = h;
|
||||||
hrmOffset = 0;
|
hrmOffset = 0;
|
||||||
if (hrmInterval) clearInterval(hrmInterval);
|
if (hrmInterval) clearInterval(hrmInterval);
|
||||||
hrmInterval = setInterval(readHRM,40);
|
hrmInterval = undefined;
|
||||||
|
setTimeout(function() {
|
||||||
|
hrmInterval = setInterval(readHRM,41);
|
||||||
|
}, 40);
|
||||||
|
|
||||||
var px = g.getWidth()/2;
|
var px = g.getWidth()/2;
|
||||||
g.setFontAlign(0,0);
|
g.setFontAlign(0,0);
|
||||||
|
@ -35,7 +38,6 @@ function countDown() {
|
||||||
countDown();
|
countDown();
|
||||||
|
|
||||||
|
|
||||||
var min=0,max=0;
|
|
||||||
var wasHigh = 0, wasLow = 0;
|
var wasHigh = 0, wasLow = 0;
|
||||||
var lastHigh = getTime();
|
var lastHigh = getTime();
|
||||||
var hrmList = [];
|
var hrmList = [];
|
||||||
|
@ -51,9 +53,7 @@ function readHRM() {
|
||||||
for (var i=0;i<2;i++) {
|
for (var i=0;i<2;i++) {
|
||||||
var a = hrmInfo.raw[hrmOffset];
|
var a = hrmInfo.raw[hrmOffset];
|
||||||
hrmOffset++;
|
hrmOffset++;
|
||||||
min=Math.min(min*0.97+a*0.03,a);
|
y = E.clip(170 - (a*2),100,230);
|
||||||
max=Math.max(max*0.97+a*0.03,a);
|
|
||||||
y = E.clip(170 - (a*4),100,230);
|
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
g.lineTo(hrmOffset, y);
|
g.lineTo(hrmOffset, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue