kitchen detect missing waypoint.json file

pull/753/head
hughbarney 2021-06-02 23:30:42 +01:00
parent 41dde5ff2d
commit f7dd6badd3
7 changed files with 58 additions and 34 deletions

View File

@ -3085,7 +3085,7 @@
{ "id": "kitchen",
"name": "Kitchen Combo",
"icon": "kitchen.png",
"version":"0.10",
"version":"0.11",
"description": "Combination of the Stepo, Walkersclock, Arrow and Waypointer apps into a multiclock format. 'Everything but the kitchen sink'. Requires firmware v2.08.167 or later",
"tags": "tool,outdoors,gps",
"type":"clock",

View File

@ -36,6 +36,10 @@ charge.
*BTN3* - invokes calibration ( can be cancelled if pressed accidentally)
## Issues
* detect when calibration data is missing
## Acknowledgement
This app is based in the work done by [jeffmer](https://github.com/jeffmer/JeffsBangleAppsDev)

View File

@ -8,3 +8,4 @@
0.08: Improved error handling for missing firmware features, added template app.kit.js
0.09: Added heart rate monitor app
0.10: Converted Stepo to use direct screen writes, added a Trip Counter feature to stepo
0.11: Detect when waypoints.json is not present, error E-WPT

View File

@ -244,6 +244,7 @@ The following error codes will be displayed if one of the dependancies is not me
* E-STEPS - no pedomintor widget has been installed, please install the widpedom or the activepedom widgets
* E-CALIB - no compass calibration data was found, see 'Compass Calibration'
* E-FW - require firmware 2v08.187 or later to detect gps and compass power status
* E-WPT - missing waypoints.json file
### Issues / Future enhancements
@ -254,3 +255,5 @@ The following error codes will be displayed if one of the dependancies is not me
seconds after the LCD goes off. At present I just rely on using
the GPSSetup app and set the GPS power mode that I want.
* Add a small graph to the heart rate monitor app
* Add a facility to call the Arrow calibration process
* Maybe create waypoints.json file if missing

29
apps/kitchen/annex.js Normal file
View File

@ -0,0 +1,29 @@
// annexed code that might be worth keeping
/*****************************************************************************
Screen Buffer Object that can be shared between faces
Making into a Class like this means we allocate the memory once
and avoid fragmenting the memory when we switch in and out of faces
******************************************************************************/
function BUF() {
this.pal4color = new Uint16Array([0x0000,0xFFFF,0x7BEF,0xAFE5],0,2); // b,w,grey,greenyellow
this.pal4red = new Uint16Array([0x0000,0xFFFF,0xF800,0xAFE5],0,2); // b,w,red,greenyellow
this.buf = Graphics.createArrayBuffer(120,120,2,{msb:true});
}
BUF.prototype.flip = function(x,y) {
g.drawImage({width:120,height:120,bpp:2, buffer:this.buf.buffer, palette:this.pal4color}, x, y);
this.buf.clear();
}
BUF.prototype.flip_red = function(x,y) {
g.drawImage({width:120,height:120,bpp:2, buffer:this.buf.buffer, palette:this.pal4red}, x, y);
this.buf.clear();
}
let bufObj = new BUF();

View File

@ -17,13 +17,12 @@
}
function init(gps,sw, hrm) {
showMem("compass init() START");
gpsObject = gps;
intervalRefSec = undefined;
bearing = 0; // always point north if GPS is off
heading = 0;
oldHeading = 0;
previous = {hding:"-", bs:"-", dst:"-", wp_name:"-", course:999};
resetPrevious();
loc = require("locale");
CALIBDATA = require("Storage").readJSON("magnav.json",1)||null;
getWaypoint();
@ -34,12 +33,9 @@
*/
if (!Bangle.isCompassOn()) Bangle.setCompassPower(1);
gps.determineGPSState();
showMem("compass init() END");
}
function freeResources() {
showMem("compass freeResources() START");
gpsObject = undefined;
intervalRefSec = undefined;
previous = undefined;
@ -50,7 +46,6 @@
CALIBDATA = undefined;
wp = undefined;
if (Bangle.isCompassOn !== undefined && Bangle.isCompassOn()) Bangle.setCompassPower(0);
showMem("compass freeResources() END");
}
function startTimer() {
@ -67,12 +62,6 @@
if (Bangle.isCompassOn !== undefined && Bangle.isCompassOn()) Bangle.setCompassPower(0);
}
function showMem(msg) {
var val = process.memory();
var str = msg + " " + Math.round(val.usage*100/val.total) + "%";
log_debug(str);
}
function onButtonShort(btn) {
log_debug("onButtonShort()");
if (gpsObject.getState() !== gpsObject.GPS_RUNNING) return;
@ -206,12 +195,12 @@
drawCompass(dir, 0xFFC0); // yellow
oldHeading = dir;
}
if (gpsObject.getState() === gpsObject.GPS_RUNNING) {
drawGPSData();
} else {
drawCompassHeading();
}
}
}
// only used when acting as compass with GPS off

View File

@ -33,10 +33,10 @@ function nextFace(){
// when you feel the buzzer you know you have done a long press
function longPressCheck() {
Bangle.buzz();
debug_log("long PressCheck() buzz");
debug_log("BUZZ, long press");
if (pressTimer) {
clearInterval(pressTimer);
debug_log("clear pressTimer 2");
debug_log("CLEAR pressTimer 2");
pressTimer = undefined;
}
}
@ -48,10 +48,10 @@ function buttonPressed(btn) {
} else {
firstPress = getTime();
if (pressTimer) {
debug_log("clear pressTimer 1");
debug_log("CLEAR pressTimer 1");
clearInterval(pressTimer);
}
debug_log("set pressTimer 1");
debug_log("SET pressTimer 1");
pressTimer = setInterval(longPressCheck, 1500);
}
}
@ -60,7 +60,7 @@ function buttonPressed(btn) {
function buttonReleased(btn) {
var dur = getTime() - firstPress;
if (pressTimer) {
debug_log("clear pressTimer 3");
debug_log("CLEAR pressTimer 3");
clearInterval(pressTimer);
pressTimer = undefined;
}
@ -256,7 +256,7 @@ GPS.prototype.processFix = function(fix) {
this.gpsState = this.GPS_RUNNING;
if (!this.last_fix.fix && !(require("Storage").readJSON("setting.json", 1) || {}).quiet) {
Bangle.buzz(); // buzz on first position
debug_log("GPS fix buzz");
debug_log("BUZZ - gps fix");
}
this.last_fix = fix;
}
@ -303,7 +303,7 @@ GPS.prototype.getWPdistance = function() {
//log_debug(this.last_fix);
//log_debug(this.wp_current);
if (this.wp_current.name === "NONE" || this.wp_current.lat === undefined || this.wp_current.lat === 0)
if (this.wp_current.name === "E-WPT" || this.wp_current.name === "NONE" || this.wp_current.lat === undefined || this.wp_current.lat === 0)
return 0;
else
return this.calcDistance(this.last_fix, this.wp_current);
@ -313,14 +313,14 @@ GPS.prototype.getWPbearing = function() {
//log_debug(this.last_fix);
//log_debug(this.wp_current);
if (this.wp_current.name === "NONE" || this.wp_current.lat === undefined || this.wp_current.lat === 0)
if (this.wp_current.name === "E-WPT" || this.wp_current.name === "NONE" || this.wp_current.lat === undefined || this.wp_current.lat === 0)
return 0;
else
return this.calcBearing(this.last_fix, this.wp_current);
}
GPS.prototype.loadFirstWaypoint = function() {
var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"NONE"}];
var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"E-WPT"}];
this.wp_index = 0;
this.wp_current = waypoints[this.wp_index];
log_debug(this.wp_current);
@ -332,7 +332,7 @@ GPS.prototype.getCurrentWaypoint = function() {
}
GPS.prototype.waypointHasLocation = function() {
if (this.wp_current.name === "NONE" || this.wp_current.lat === undefined || this.wp_current.lat === 0)
if (this.wp_current.name === "E-WPT" || this.wp_current.name === "NONE" || this.wp_current.lat === undefined || this.wp_current.lat === 0)
return false;
else
return true;
@ -340,12 +340,12 @@ GPS.prototype.waypointHasLocation = function() {
GPS.prototype.markWaypoint = function() {
if(this.wp_current.name === "NONE")
if(this.wp_current.name === "E-WPT" || this.wp_current.name === "NONE")
return;
log_debug("GPS::markWaypoint()");
var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"NONE"}];
var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"E-WPT"}];
this.wp_current = waypoints[this.wp_index];
if (this.waypointHasLocation()) {
@ -360,7 +360,7 @@ GPS.prototype.markWaypoint = function() {
}
GPS.prototype.nextWaypoint = function(inc) {
var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"NONE"}];
var waypoints = require("Storage").readJSON("waypoints.json")||[{name:"E-WPT"}];
this.wp_index+=inc;
if (this.wp_index>=waypoints.length) this.wp_index=0;
if (this.wp_index<0) this.wp_index = waypoints.length-1;
@ -731,14 +731,14 @@ function TRIP() {
TRIP.prototype.resetTrip = function(steps) {
this.tripStart = (0 + steps);
console.log("resetTrip starting=" + this.tripStart);
log_debug("resetTrip starting=" + this.tripStart);
}
TRIP.prototype.getTrip = function(steps) {
let tripSteps = (0 + steps) - this.tripStart;
console.log("getTrip steps=" + steps);
console.log("getTrip tripStart=" + this.tripStart);
console.log("getTrip=" + tripSteps);
log_debug("getTrip steps=" + steps);
log_debug("getTrip tripStart=" + this.tripStart);
log_debug("getTrip=" + tripSteps);
return tripSteps;
}
@ -758,7 +758,6 @@ Debug Object
******************************************************************************/
/*
function DEBUG() {
this.logfile = require("Storage").open("debug.log","a");
}
@ -770,7 +769,6 @@ DEBUG.prototype.log = function(msg) {
}
debugObj = new DEBUG();
*/
function debug_log(m) {
//debugObj.log(m);