mirror of https://github.com/espruino/BangleApps
improved handling of missing firmware features
parent
40851ec0c4
commit
2a40de9f4c
|
@ -3085,8 +3085,8 @@
|
|||
{ "id": "kitchen",
|
||||
"name": "Kitchen Combo",
|
||||
"icon": "kitchen.png",
|
||||
"version":"0.07",
|
||||
"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",
|
||||
"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",
|
||||
"tags": "tool,outdoors,gps",
|
||||
"type":"clock",
|
||||
"readme": "README.md",
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
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.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;
|
||||
CALIBDATA = undefined;
|
||||
wp = undefined;
|
||||
if (Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
||||
if (Bangle.isCompassOn !== undefined && Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
||||
showMem("compass freeResources() END");
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
log_debug("startTimer()");
|
||||
if (!Bangle.isCompassOn()) Bangle.setCompassPower(1);
|
||||
if (Bangle.isCompassOn !== undefined && !Bangle.isCompassOn()) Bangle.setCompassPower(1);
|
||||
resetPrevious();
|
||||
draw();
|
||||
intervalRefSec = setInterval(draw, 500);
|
||||
|
@ -63,8 +63,8 @@
|
|||
|
||||
function stopTimer() {
|
||||
log_debug("stopTimer()");
|
||||
if(intervalRefSec) {intervalRefSec=clearInterval(intervalRefSec);}
|
||||
if (Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
||||
if (intervalRefSec) {intervalRefSec=clearInterval(intervalRefSec);}
|
||||
if (Bangle.isCompassOn !== undefined && Bangle.isCompassOn()) Bangle.setCompassPower(0);
|
||||
}
|
||||
|
||||
function showMem(msg) {
|
||||
|
@ -177,10 +177,16 @@
|
|||
function draw() {
|
||||
log_debug("draw()");
|
||||
|
||||
g.setFontAlign(0,0);
|
||||
g.setColor(1,1,1);
|
||||
g.setFont("Vector", 24);
|
||||
|
||||
if (Bangle.isCompassOn === undefined) {
|
||||
g.drawString("E-FW", 120, 120);
|
||||
return
|
||||
}
|
||||
|
||||
if (CALIBDATA === undefined || CALIBDATA === null) {
|
||||
g.setFontAlign(0,0);
|
||||
g.setColor(1,1,1);
|
||||
g.setFont("Vector", 24);
|
||||
g.drawString("E-CALIB", 120, 120);
|
||||
return
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
const INFO_NONE = 0;
|
||||
const INFO_BATT = 1;
|
||||
const INFO_MEM = 2;
|
||||
const INFO_FW = 3;
|
||||
const Y_TIME = 30;
|
||||
const Y_ACTIVITY = 116;
|
||||
const Y_MODELINE = 200;
|
||||
|
@ -98,6 +99,9 @@
|
|||
infoMode = INFO_MEM
|
||||
break;
|
||||
case INFO_MEM:
|
||||
infoMode = INFO_FW
|
||||
break;
|
||||
case INFO_FW:
|
||||
default:
|
||||
infoMode = INFO_NONE;
|
||||
break;
|
||||
|
@ -111,17 +115,21 @@
|
|||
let col = 0x07FF; // cyan
|
||||
|
||||
switch(infoMode) {
|
||||
case INFO_NONE:
|
||||
col = 0x0000;
|
||||
str = "";
|
||||
break;
|
||||
case INFO_MEM:
|
||||
val = process.memory();
|
||||
str = "Memory: " + Math.round(val.usage*100/val.total) + "%";
|
||||
break;
|
||||
case INFO_BATT:
|
||||
default:
|
||||
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
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
g.setColor(0xFFC0);
|
||||
g.setFontAlign(0, -1);
|
||||
|
||||
if (!checkFirmware(2,8,187)) {
|
||||
if (Bangle.isGPSOn === undefined) {
|
||||
g.setColor(1,1,1);
|
||||
g.drawString("E-FW", 120, Y_ACTIVITY);
|
||||
return;
|
||||
|
@ -179,18 +179,6 @@
|
|||
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,
|
||||
onButtonShort:onButtonShort, onButtonLong:onButtonLong};
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ GPS.prototype.determineGPSState = function() {
|
|||
}
|
||||
} else {
|
||||
if (this.listenerCount > 0) {
|
||||
Bangle.removeListener("GPS", this.processFix);
|
||||
Bangle.removeListener("GPS", processFix);
|
||||
this.listenerCount--;
|
||||
this.log_debug("listener removed " + this.listenerCount);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue