diff --git a/apps/rtorch/ChangeLog b/apps/rtorch/ChangeLog new file mode 100644 index 000000000..13cbb6e72 --- /dev/null +++ b/apps/rtorch/ChangeLog @@ -0,0 +1,2 @@ +0.01: Cloning torch and making it red :D +0.02: Modify for setUI and Bangle 2 diff --git a/apps/rtorch/app-icon.js b/apps/rtorch/app-icon.js new file mode 100644 index 000000000..ff1265c9b --- /dev/null +++ b/apps/rtorch/app-icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEw4UA///oP4gH+t9TCQ1VAAYLpgILunoLK/4LJgf/6oLIh//+oLK/oLIhapBBZEqBYIwDBYu/GAgLE1WvGAgLF1YwEBQcC1WqGAgLGGAgLDhQLBGAdQBYwwCBQgLDGASlFlQLC3/8BYoIBGAXwBQkCFgILC4AuFBYeAFw2v/wLBBQqNCBYOgBQp1B1/qCw5dDFoxdEBQwuBAAOoBQykCHI4uXgZPBFxEP/QuJn5/CFw7DBLpILB9QuHEYP//QuHHYP//wuHKYL0HGAoLJn/8BZMP+ALJgfABRA=")) \ No newline at end of file diff --git a/apps/rtorch/app.js b/apps/rtorch/app.js new file mode 100644 index 000000000..03a50ee10 --- /dev/null +++ b/apps/rtorch/app.js @@ -0,0 +1,39 @@ +Bangle.setLCDPower(1); +Bangle.setLCDTimeout(0); +g.reset(); +c = 1; + +function setColor(delta){ + c+=delta; + c = Math.max(c,0); + c = Math.min(c,2); + if (c<1){ + g.setColor(c,0,0); + Bangle.setLCDBrightness(c >= 0.1 ? c : 0.1); + }else{ + g.setColor(1,c-1,c-1); + Bangle.setLCDBrightness(1); + } + g.fillRect(0,0,g.getWidth(),g.getHeight()); +} + +function updownHandler(direction){ + if (direction == undefined){ + c=1; + setColor(0); + } else { + setColor(-direction * 0.1); + } +} + +setColor(0); + +// Bangle 1: +// BTN1: light up toward white +// BTN3: light down to red +// BTN2: reset +// Bangle 2: +// Swipe up: light up toward white +// Swipe down: light down to red +// BTN1: reset +Bangle.setUI("updown", updownHandler); diff --git a/apps/rtorch/app.png b/apps/rtorch/app.png new file mode 100644 index 000000000..17b0f3efc Binary files /dev/null and b/apps/rtorch/app.png differ diff --git a/apps/rtorch/metadata.json b/apps/rtorch/metadata.json new file mode 100644 index 000000000..ee056ac57 --- /dev/null +++ b/apps/rtorch/metadata.json @@ -0,0 +1,16 @@ +{ + "id": "rtorch", + "name": "Red Torch", + "shortName": "RedTorch", + "version": "0.02", + "description": "Turns screen RED to help you see in the dark without breaking your night vision. Select from the launcher or on Bangle 1 press BTN3,BTN1,BTN3,BTN1 quickly to start when in any app that shows widgets", + "icon": "app.png", + "tags": "tool,torch", + "supports": ["BANGLEJS","BANGLEJS2"], + "allow_emulator": true, + "storage": [ + {"name":"rtorch.app.js","url":"app.js"}, + {"name":"rtorch.wid.js","url":"widget.js", "supports": ["BANGLEJS"]}, + {"name":"rtorch.img","url":"app-icon.js","evaluate":true} + ] +} diff --git a/apps/rtorch/widget.js b/apps/rtorch/widget.js new file mode 100644 index 000000000..89009266d --- /dev/null +++ b/apps/rtorch/widget.js @@ -0,0 +1,26 @@ +(function() { + var clickTimes = []; + var clickPattern = ""; + var TAPS = 4; // number of taps + var PERIOD = 1; // seconds + + // we don't actually create/draw a widget here at all... + Bangle.on("lcdPower",function(on) { + // First click (that turns LCD on) isn't given to + // setWatch, so handle it here + if (!on) return; + clickTimes=[getTime()]; + clickPattern="x"; + }); + function tap(e,c) { + clickPattern = clickPattern.substr(-3)+c; + while (clickTimes.length>=TAPS) clickTimes.shift(); + clickTimes.push(e.time); + var clickPeriod = e.time-clickTimes[0]; + if (clickPeriod