improved handling of missing firmware features
parent
40851ec0c4
commit
2a40de9f4c
|
|
@ -3085,8 +3085,8 @@
|
||||||
{ "id": "kitchen",
|
{ "id": "kitchen",
|
||||||
"name": "Kitchen Combo",
|
"name": "Kitchen Combo",
|
||||||
"icon": "kitchen.png",
|
"icon": "kitchen.png",
|
||||||
"version":"0.07",
|
"version":"0.08",
|
||||||
"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",
|
"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",
|
"tags": "tool,outdoors,gps",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@
|
||||||
0.05: Stopwatch, hide hours if 0, fixed flicker when stopped, updated README issues
|
0.05: Stopwatch, hide hours if 0, fixed flicker when stopped, updated README issues
|
||||||
0.06: Reduced memory footprint of compass, used direct screen access rather than arrayBuffer
|
0.06: Reduced memory footprint of compass, used direct screen access rather than arrayBuffer
|
||||||
0.07: Added error codes if dependancies are missing
|
0.07: Added error codes if dependancies are missing
|
||||||
|
0.08: Improved error handling for missing firmware features, added template app.kit.js
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
// simple template
|
||||||
|
(() => {
|
||||||
|
function getFace(){
|
||||||
|
var intervalRefSec;
|
||||||
|
var prevTime;
|
||||||
|
|
||||||
|
const Y_TIME = 30;
|
||||||
|
const Y_ACTIVITY = 116;
|
||||||
|
|
||||||
|
function init(gps,sw) {
|
||||||
|
prevTime = "";
|
||||||
|
g.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
function freeResources() {
|
||||||
|
prevTime = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTimer() {
|
||||||
|
draw();
|
||||||
|
intervalRefSec = setInterval(draw, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopTimer() {
|
||||||
|
if (intervalRefSec) { intervalRefSec = clearInterval(intervalRefSec); }
|
||||||
|
}
|
||||||
|
|
||||||
|
function onButtonShort(btn) {}
|
||||||
|
function onButtonLong(btn) {}
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
var d = new Date();
|
||||||
|
var da = d.toString().split(" ");
|
||||||
|
var time = da[4].substr(0,5);
|
||||||
|
|
||||||
|
if (time !== prevTime) {
|
||||||
|
prevTime = time;
|
||||||
|
g.setColor(0);
|
||||||
|
g.fillRect(0, Y_TIME, 239, Y_ACTIVITY -1);
|
||||||
|
g.setColor(1,1,1);
|
||||||
|
g.setFont("Vector",80);
|
||||||
|
g.setFontAlign(0,-1);
|
||||||
|
g.drawString(time, 120, Y_TIME);
|
||||||
|
|
||||||
|
g.setFont("Vector",26);
|
||||||
|
g.drawString("Hello World", 120, Y_ACTIVITY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {init:init, freeResources:freeResources, startTimer:startTimer, stopTimer:stopTimer,
|
||||||
|
onButtonShort:onButtonShort, onButtonLong:onButtonLong};
|
||||||
|
}
|
||||||
|
|
||||||
|
return getFace;
|
||||||
|
})();
|
||||||
|
|
@ -49,13 +49,13 @@
|
||||||
loc = undefined;
|
loc = undefined;
|
||||||
CALIBDATA = undefined;
|
CALIBDATA = undefined;
|
||||||
wp = undefined;
|
wp = undefined;
|
||||||
if (Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
if (Bangle.isCompassOn !== undefined && Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
||||||
showMem("compass freeResources() END");
|
showMem("compass freeResources() END");
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTimer() {
|
function startTimer() {
|
||||||
log_debug("startTimer()");
|
log_debug("startTimer()");
|
||||||
if (!Bangle.isCompassOn()) Bangle.setCompassPower(1);
|
if (Bangle.isCompassOn !== undefined && !Bangle.isCompassOn()) Bangle.setCompassPower(1);
|
||||||
resetPrevious();
|
resetPrevious();
|
||||||
draw();
|
draw();
|
||||||
intervalRefSec = setInterval(draw, 500);
|
intervalRefSec = setInterval(draw, 500);
|
||||||
|
|
@ -63,8 +63,8 @@
|
||||||
|
|
||||||
function stopTimer() {
|
function stopTimer() {
|
||||||
log_debug("stopTimer()");
|
log_debug("stopTimer()");
|
||||||
if(intervalRefSec) {intervalRefSec=clearInterval(intervalRefSec);}
|
if (intervalRefSec) {intervalRefSec=clearInterval(intervalRefSec);}
|
||||||
if (Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
if (Bangle.isCompassOn !== undefined && Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMem(msg) {
|
function showMem(msg) {
|
||||||
|
|
@ -177,10 +177,16 @@
|
||||||
function draw() {
|
function draw() {
|
||||||
log_debug("draw()");
|
log_debug("draw()");
|
||||||
|
|
||||||
if (CALIBDATA === undefined || CALIBDATA === null) {
|
|
||||||
g.setFontAlign(0,0);
|
g.setFontAlign(0,0);
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
g.setFont("Vector", 24);
|
g.setFont("Vector", 24);
|
||||||
|
|
||||||
|
if (Bangle.isCompassOn === undefined) {
|
||||||
|
g.drawString("E-FW", 120, 120);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CALIBDATA === undefined || CALIBDATA === null) {
|
||||||
g.drawString("E-CALIB", 120, 120);
|
g.drawString("E-CALIB", 120, 120);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
const INFO_NONE = 0;
|
const INFO_NONE = 0;
|
||||||
const INFO_BATT = 1;
|
const INFO_BATT = 1;
|
||||||
const INFO_MEM = 2;
|
const INFO_MEM = 2;
|
||||||
|
const INFO_FW = 3;
|
||||||
const Y_TIME = 30;
|
const Y_TIME = 30;
|
||||||
const Y_ACTIVITY = 116;
|
const Y_ACTIVITY = 116;
|
||||||
const Y_MODELINE = 200;
|
const Y_MODELINE = 200;
|
||||||
|
|
@ -98,6 +99,9 @@
|
||||||
infoMode = INFO_MEM
|
infoMode = INFO_MEM
|
||||||
break;
|
break;
|
||||||
case INFO_MEM:
|
case INFO_MEM:
|
||||||
|
infoMode = INFO_FW
|
||||||
|
break;
|
||||||
|
case INFO_FW:
|
||||||
default:
|
default:
|
||||||
infoMode = INFO_NONE;
|
infoMode = INFO_NONE;
|
||||||
break;
|
break;
|
||||||
|
|
@ -111,17 +115,21 @@
|
||||||
let col = 0x07FF; // cyan
|
let col = 0x07FF; // cyan
|
||||||
|
|
||||||
switch(infoMode) {
|
switch(infoMode) {
|
||||||
case INFO_NONE:
|
|
||||||
col = 0x0000;
|
|
||||||
str = "";
|
|
||||||
break;
|
|
||||||
case INFO_MEM:
|
case INFO_MEM:
|
||||||
val = process.memory();
|
val = process.memory();
|
||||||
str = "Memory: " + Math.round(val.usage*100/val.total) + "%";
|
str = "Memory: " + Math.round(val.usage*100/val.total) + "%";
|
||||||
break;
|
break;
|
||||||
case INFO_BATT:
|
case INFO_BATT:
|
||||||
default:
|
|
||||||
str = "Battery: " + E.getBattery() + "%";
|
str = "Battery: " + E.getBattery() + "%";
|
||||||
|
break;
|
||||||
|
case INFO_FW:
|
||||||
|
str = "Fw: " + process.env.VERSION;
|
||||||
|
break;
|
||||||
|
case INFO_NONE:
|
||||||
|
default:
|
||||||
|
col = 0x0000;
|
||||||
|
str = "";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we need to draw, avoid flicker
|
// check if we need to draw, avoid flicker
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
g.setColor(0xFFC0);
|
g.setColor(0xFFC0);
|
||||||
g.setFontAlign(0, -1);
|
g.setFontAlign(0, -1);
|
||||||
|
|
||||||
if (!checkFirmware(2,8,187)) {
|
if (Bangle.isGPSOn === undefined) {
|
||||||
g.setColor(1,1,1);
|
g.setColor(1,1,1);
|
||||||
g.drawString("E-FW", 120, Y_ACTIVITY);
|
g.drawString("E-FW", 120, Y_ACTIVITY);
|
||||||
return;
|
return;
|
||||||
|
|
@ -179,18 +179,6 @@
|
||||||
drawGPSData();
|
drawGPSData();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkFirmware(maj,min,bld) {
|
|
||||||
var major = process.env.VERSION.split(".")[0].split("v")[0];
|
|
||||||
var minor = process.env.VERSION.split(".")[0].split("v")[1];
|
|
||||||
var build = process.env.VERSION.split(".")[1];
|
|
||||||
|
|
||||||
if (major > maj) return true;
|
|
||||||
if (major == 2 && minor > min) return true;
|
|
||||||
if (major == 2 && minor == min && build >= bld) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {init:init, freeResources:freeResources, startTimer:startTimer, stopTimer:stopTimer,
|
return {init:init, freeResources:freeResources, startTimer:startTimer, stopTimer:stopTimer,
|
||||||
onButtonShort:onButtonShort, onButtonLong:onButtonLong};
|
onButtonShort:onButtonShort, onButtonLong:onButtonLong};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ GPS.prototype.determineGPSState = function() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.listenerCount > 0) {
|
if (this.listenerCount > 0) {
|
||||||
Bangle.removeListener("GPS", this.processFix);
|
Bangle.removeListener("GPS", processFix);
|
||||||
this.listenerCount--;
|
this.listenerCount--;
|
||||||
this.log_debug("listener removed " + this.listenerCount);
|
this.log_debug("listener removed " + this.listenerCount);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue