Add torch app

pull/191/head
Gordon Williams 2020-03-03 15:59:00 +00:00
parent 7823f1cc83
commit 107d8ef7e0
6 changed files with 39 additions and 0 deletions

View File

@ -773,5 +773,18 @@
{"name":"pipboy.app.js","url":"app.js"}, {"name":"pipboy.app.js","url":"app.js"},
{"name":"pipboy.img","url":"app-icon.js","evaluate":true} {"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}
]
} }
] ]

1
apps/torch/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New App!

1
apps/torch/app-icon.js Normal file
View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwxH+AH4A/AH4Acq0yF1tWlksF10yqwuuSVIuGSVF/FwySm5nM0YuGSUovBGAIuGAgIukGAQuGAgIvlSQozEF0iSEeowvlGAT1HF0iSDeo4vlegSShF5fMv4uFSLQkC0QACSRguevErld4GBKSDFz4ABF5CSBLsIvLdDK7GFwiPIF0AvEFw4tbFwztKFrguDF4gADFkAuFF44unF4wuoGAouqAAwu/ABtWqwutmUsmQutF4JhKF0iSJdT4uFAoIwGFz4wCFwgECF0qRCFwo3BF0qSDMQiSBF0owCFwgFBF86SBF1qSFF1SSDF1gA/AH4A1A"))

8
apps/torch/app.js Normal file
View File

@ -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);

BIN
apps/torch/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

16
apps/torch/widget.js Normal file
View File

@ -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<CLICK_PERIOD)
load("torch.app.js");
}, BTN3, {repeat:true, edge:"rising"});