Wrote basic code for a modular app design
This commit is contained in:
parent
220fd9ee42
commit
4300a4bfe8
@ -0,0 +1,26 @@
|
||||
// Some initialization
|
||||
Bangle.setGPSPower(true);
|
||||
g.clear();
|
||||
|
||||
// variables
|
||||
var firstRun = true;
|
||||
const text_y = 80;
|
||||
const font = "Vector";
|
||||
var STOR = require("Storage");
|
||||
var FACES = [];
|
||||
STOR.list(/\.trailsense\.js$/).forEach(face=>FACES.push(eval(require("Storage").read(face))));
|
||||
var currentFace = 0;
|
||||
|
||||
|
||||
|
||||
FACES[currentFace].drawFace();
|
||||
|
||||
Bangle.setUI("updown", (upOrDown) => {
|
||||
if(!firstRun) FACES[currentFace].stop();
|
||||
firstRun = false; // loop ran once; firstRun has to be false
|
||||
if(isNaN(upOrDown)) upOrDown = 0;
|
||||
currentFace += upOrDown;
|
||||
if(currentFace > FACES.length-1) { currentFace = 0; }
|
||||
if(currentFace < 0) { currentFace = FACES.length-1; }
|
||||
FACES[currentFace].drawFace();
|
||||
});
|
Loading…
Reference in New Issue
Block a user