1
0
Fork 0

Sitch between month / 24h

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