Torch: Change start sequence to BTN1/3/1/3 to avoid accidental turning on (fix #342)
parent
bf5bf91967
commit
a389ed5dbe
|
|
@ -921,8 +921,8 @@
|
||||||
"name": "Torch",
|
"name": "Torch",
|
||||||
"shortName":"Torch",
|
"shortName":"Torch",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version":"0.01",
|
"version":"0.02",
|
||||||
"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",
|
"description": "Turns screen white to help you see in the dark. Select from the launcher or press BTN1,BTN3,BTN1,BTN3 quickly to start when in any app that shows widgets",
|
||||||
"tags": "tool,torch",
|
"tags": "tool,torch",
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"torch.app.js","url":"app.js"},
|
{"name":"torch.app.js","url":"app.js"},
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
|
0.02: Change start sequence to BTN1/3/1/3 to avoid accidental turning on (fix #342)
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,26 @@
|
||||||
|
(function() {
|
||||||
var clickTimes = [];
|
var clickTimes = [];
|
||||||
var CLICK_COUNT = 4; // number of taps
|
var clickPattern = "";
|
||||||
var CLICK_PERIOD = 1; // second
|
var TAPS = 4; // number of taps
|
||||||
|
var PERIOD = 1; // seconds
|
||||||
|
|
||||||
// we don't actually create/draw a widget here at all...
|
// we don't actually create/draw a widget here at all...
|
||||||
|
|
||||||
Bangle.on("lcdPower",function(on) {
|
Bangle.on("lcdPower",function(on) {
|
||||||
// First click (that turns LCD on) isn't given to
|
// First click (that turns LCD on) isn't given to
|
||||||
// setWatch, so handle it here
|
// setWatch, so handle it here
|
||||||
if (on) clickTimes=[getTime()];
|
if (!on) return;
|
||||||
|
clickTimes=[getTime()];
|
||||||
|
clickPattern="x";
|
||||||
});
|
});
|
||||||
setWatch(function(e) {
|
function tap(e,c) {
|
||||||
while (clickTimes.length>=CLICK_COUNT) clickTimes.shift();
|
clickPattern = clickPattern.substr(-3)+c;
|
||||||
|
while (clickTimes.length>=TAPS) clickTimes.shift();
|
||||||
clickTimes.push(e.time);
|
clickTimes.push(e.time);
|
||||||
var clickPeriod = e.time-clickTimes[0];
|
var clickPeriod = e.time-clickTimes[0];
|
||||||
if (clickTimes.length==CLICK_COUNT && clickPeriod<CLICK_PERIOD)
|
if (clickPeriod<PERIOD && clickPattern.match(/.313/)) {
|
||||||
load("torch.app.js");
|
load("torch.app.js");
|
||||||
}, BTN3, {repeat:true, edge:"rising"});
|
}
|
||||||
|
}
|
||||||
|
setWatch(function(e) { tap(e,"1"); }, BTN1, {repeat:true, edge:"rising"});
|
||||||
|
setWatch(function(e) { tap(e,"3"); }, BTN3, {repeat:true, edge:"rising"});
|
||||||
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue