From 4300a4bfe84104e17d9b237fd79ef463d4b5b4b6 Mon Sep 17 00:00:00 2001 From: Blue Fox Date: Sun, 5 Jun 2022 09:51:20 +0200 Subject: [PATCH] Wrote basic code for a modular app design --- trailsense.app.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/trailsense.app.js b/trailsense.app.js index e69de29..4951270 100644 --- a/trailsense.app.js +++ b/trailsense.app.js @@ -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(); +});