added debug object to write to debug.log

master
hughbarney 2021-05-08 19:42:41 +01:00
parent 9a4c90da69
commit 061766e470
1 changed files with 26 additions and 0 deletions

View File

@ -33,8 +33,10 @@ function nextFace(){
// when you feel the buzzer you know you have done a long press // when you feel the buzzer you know you have done a long press
function longPressCheck() { function longPressCheck() {
Bangle.buzz(); Bangle.buzz();
debugObj.log("long PressCheck()");
if (pressTimer) { if (pressTimer) {
clearInterval(pressTimer); clearInterval(pressTimer);
debugObj.log("clear pressTimer 2");
pressTimer = undefined; pressTimer = undefined;
} }
} }
@ -45,6 +47,11 @@ function buttonPressed(btn) {
nextFace(); nextFace();
} else { } else {
firstPress = getTime(); firstPress = getTime();
if (pressTimer) {
debugObj.log("clear pressTimer 1");
clearInterval(pressTimer);
}
debugObj.log("set pressTimer 1");
pressTimer = setInterval(longPressCheck, 1500); pressTimer = setInterval(longPressCheck, 1500);
} }
} }
@ -53,6 +60,7 @@ function buttonPressed(btn) {
function buttonReleased(btn) { function buttonReleased(btn) {
var dur = getTime() - firstPress; var dur = getTime() - firstPress;
if (pressTimer) { if (pressTimer) {
debugObj.log("clear pressTimer 3");
clearInterval(pressTimer); clearInterval(pressTimer);
pressTimer = undefined; pressTimer = undefined;
} }
@ -248,6 +256,7 @@ GPS.prototype.processFix = function(fix) {
this.gpsState = this.GPS_RUNNING; this.gpsState = this.GPS_RUNNING;
if (!this.last_fix.fix && !(require("Storage").readJSON("setting.json", 1) || {}).quiet) { if (!this.last_fix.fix && !(require("Storage").readJSON("setting.json", 1) || {}).quiet) {
Bangle.buzz(); // buzz on first position Bangle.buzz(); // buzz on first position
debugObj.log("GPS fix buzz");
} }
this.last_fix = fix; this.last_fix = fix;
} }
@ -708,6 +717,23 @@ function onHRM(hrm) {
hrmObj.onHRM(hrm); hrmObj.onHRM(hrm);
} }
/*****************************************************************************
Debug Object
******************************************************************************/
function DEBUG() {
this.logfile = require("Storage").open("debug.log","a");
}
DEBUG.prototype.log = function(msg) {
let timestamp = new Date().toString().split(" ")[4];
let line = timestamp + ", " + msg + "\n";
this.logfile.write(line);
}
debugObj = new DEBUG();
/***************************************************************************** /*****************************************************************************