1
0
Fork 0

Redraw before setting intervals to minimize error

master
Martin Boonk 2022-03-01 18:36:29 +01:00
parent 7e5891d829
commit 73e05fdb5d
1 changed files with 9 additions and 9 deletions

View File

@ -757,30 +757,30 @@ var stepsgoal = 2000;
function handleLock(isLocked, forceRedraw){ function handleLock(isLocked, forceRedraw){
//print("isLocked", Bangle.isLocked()); //print("isLocked", Bangle.isLocked());
if (unlockedDrawInterval) clearInterval(unlockedDrawInterval); if (forceRedraw || !redrawEvents || redrawEvents.includes("lock")){
//print("Redrawing on lock", isLocked);
initialDraw();
}
if (lockedDrawInterval) clearInterval(lockedDrawInterval); if (lockedDrawInterval) clearInterval(lockedDrawInterval);
if (unlockedDrawInterval) clearInterval(unlockedDrawInterval);
if (!isLocked){ if (!isLocked){
Bangle.setHRMPower(1, "imageclock");
Bangle.setBarometerPower(1, 'imageclock');
setMatchedInterval(()=>{ setMatchedInterval(()=>{
//print("Redrawing on unlocked interval"); //print("Redrawing on unlocked interval");
initialDraw(); initialDraw();
},unlockedRedraw, (v)=>{ },unlockedRedraw, (v)=>{
unlockedDrawInterval = v; unlockedDrawInterval = v;
}); });
Bangle.setHRMPower(1, "imageclock");
Bangle.setBarometerPower(1, 'imageclock');
} else { } else {
Bangle.setHRMPower(0, "imageclock");
Bangle.setBarometerPower(0, 'imageclock');
setMatchedInterval(()=>{ setMatchedInterval(()=>{
//print("Redrawing on locked interval"); //print("Redrawing on locked interval");
initialDraw(); initialDraw();
},lockedRedraw, (v)=>{ },lockedRedraw, (v)=>{
lockedDrawInterval = v; lockedDrawInterval = v;
}); });
} Bangle.setHRMPower(0, "imageclock");
if (forceRedraw || !redrawEvents || redrawEvents.includes("lock")){ Bangle.setBarometerPower(0, 'imageclock');
//print("Redrawing on lock", isLocked);
initialDraw();
} }
} }