Sitch between month / 24h

pull/1141/head
David Peer 2021-12-22 12:28:01 +01:00
parent 0de5a23736
commit 1cf197df6f
1 changed files with 76 additions and 37 deletions

View File

@ -31,6 +31,7 @@ let lcarsViewPos = 0;
let drag;
let hrmValue = 0;
var connected = NRF.getSecurityStatus().connected;
var plotWeek = false;
/*
* Requirements and globals
@ -270,6 +271,7 @@ function drawPosition1(){
}
// Plot HRM graph
if(plotWeek){
var data = new Uint16Array(32);
var cnt = new Uint8Array(32);
health.readDailySummaries(new Date(), h=>{
@ -279,7 +281,7 @@ function drawPosition1(){
require("graph").drawBar(g, data, {
axes : true,
minx: 1,
gridx : 4,
gridx : 5,
gridy : 100,
width : 140,
height : 50,
@ -293,7 +295,7 @@ function drawPosition1(){
require("graph").drawBar(g, data, {
axes : true,
minx: 1,
gridx : 4,
gridx : 5,
gridy : 5,
width : 140,
height : 50,
@ -301,6 +303,40 @@ function drawPosition1(){
y: 115
});
// Plot day
} else {
var data = new Uint16Array(24);
var cnt = new Uint8Array(24);
health.readDay(new Date(), h=>{
data[h.hr]+=h.bpm;
if (h.bpm) cnt[h.hr]++;
});
require("graph").drawBar(g, data, {
axes : true,
minx: 1,
gridx : 4,
gridy : 100,
width : 140,
height : 50,
x: 5,
y: 25
});
// Plot step graph
var data = new Uint16Array(24);
health.readDay(new Date(), h=>data[h.hr]+=h.steps);
require("graph").drawBar(g, data, {
axes : true,
minx: 1,
gridx : 4,
gridy : 1000,
width : 140,
height : 50,
x: 5,
y: 115
});
}
g.setFontAntonioMedium();
g.setColor(cWhite);
g.drawString("HRM", 122, 9);
@ -394,13 +430,14 @@ Bangle.on('lcdPower',on=>{
// health failed. Therefore, we update and read data from
// health iff the connection state did not change.
if(connected == NRF.getSecurityStatus().connected) {
draw(); // draw immediately, queue redraw
draw();
}
connected = NRF.getSecurityStatus().connected
} else { // stop draw timer
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
}
connected = NRF.getSecurityStatus().connected
});
Bangle.on('lock', function(isLocked) {
@ -456,10 +493,7 @@ Bangle.on("drag", e => {
// Vertical swipe
} else if (Math.abs(dy)>Math.abs(dx)+10) {
if(lcarsViewPos != 0){
return;
}
if(lcarsViewPos == 0){
if(dy > 0){
decreaseAlarm();
} else {
@ -467,6 +501,11 @@ Bangle.on("drag", e => {
}
}
if(lcarsViewPos == 1){
plotWeek = dy < 0
}
}
draw();
}
});