diff --git a/apps.json b/apps.json index b7d1bb3a8..4a1e164bb 100644 --- a/apps.json +++ b/apps.json @@ -773,5 +773,18 @@ {"name":"pipboy.app.js","url":"app.js"}, {"name":"pipboy.img","url":"app-icon.js","evaluate":true} ] + }, + { "id": "torch", + "name": "Torch", + "shortName":"Torch", + "icon": "app.png", + "version":"0.01", + "description": "Turns screen white to help you see in the dark. Select from the launcher or press BTN3 four times in quick succession to start when in normal clock mode", + "tags": "tool,torch", + "storage": [ + {"name":"torch.app.js","url":"app.js"}, + {"name":"torch.wid.js","url":"widget.js"}, + {"name":"torch.img","url":"app-icon.js","evaluate":true} + ] } ] diff --git a/apps/torch/ChangeLog b/apps/torch/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/torch/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/torch/app-icon.js b/apps/torch/app-icon.js new file mode 100644 index 000000000..13fc792fe --- /dev/null +++ b/apps/torch/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4Acq0yF1tWlksF10yqwuuSVIuGSVF/FwySm5nM0YuGSUovBGAIuGAgIukGAQuGAgIvlSQozEF0iSEeowvlGAT1HF0iSDeo4vlegSShF5fMv4uFSLQkC0QACSRguevErld4GBKSDFz4ABF5CSBLsIvLdDK7GFwiPIF0AvEFw4tbFwztKFrguDF4gADFkAuFF44unF4wuoGAouqAAwu/ABtWqwutmUsmQutF4JhKF0iSJdT4uFAoIwGFz4wCFwgECF0qRCFwo3BF0qSDMQiSBF0owCFwgFBF86SBF1qSFF1SSDF1gA/AH4A1A")) diff --git a/apps/torch/app.js b/apps/torch/app.js new file mode 100644 index 000000000..28aa00bd6 --- /dev/null +++ b/apps/torch/app.js @@ -0,0 +1,8 @@ +Bangle.setLCDPower(1); +Bangle.setLCDTimeout(0); +g.reset(); +g.fillRect(0,0,g.getWidth(),g.getHeight()); +// Any button turns off +setWatch(()=>load(), BTN1); +setWatch(()=>load(), BTN2); +setWatch(()=>load(), BTN3); diff --git a/apps/torch/app.png b/apps/torch/app.png new file mode 100644 index 000000000..a02a835f0 Binary files /dev/null and b/apps/torch/app.png differ diff --git a/apps/torch/widget.js b/apps/torch/widget.js new file mode 100644 index 000000000..c17d203e1 --- /dev/null +++ b/apps/torch/widget.js @@ -0,0 +1,16 @@ +var clickTimes = []; +var CLICK_COUNT = 4; // number of taps +var CLICK_PERIOD = 1; // second + +Bangle.on("lcdPower",function(on) { + // First click (that turns LCD on) isn't given to + // setWatch, so handle it here + if (on) clickTimes=[getTime()]; +}); +setWatch(function(e) { + while (clickTimes.length>=CLICK_COUNT) clickTimes.shift(); + clickTimes.push(e.time); + var clickPeriod = e.time-clickTimes[0]; + if (clickTimes.length==CLICK_COUNT && clickPeriod