From f7bd9b05283c4f6dab9d90afb112e0555dfdb292 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 5 Mar 2025 09:45:40 +0000 Subject: [PATCH] remove setuichange app as this is all built into firmware now - fix #3435 --- apps/setuichange/ChangeLog | 4 - apps/setuichange/README.md | 24 ----- apps/setuichange/app.png | Bin 990 -> 0 bytes apps/setuichange/boot-b1.js | 118 ------------------------- apps/setuichange/boot-b2.js | 154 --------------------------------- apps/setuichange/metadata.json | 14 --- 6 files changed, 314 deletions(-) delete mode 100644 apps/setuichange/ChangeLog delete mode 100644 apps/setuichange/README.md delete mode 100644 apps/setuichange/app.png delete mode 100644 apps/setuichange/boot-b1.js delete mode 100644 apps/setuichange/boot-b2.js delete mode 100644 apps/setuichange/metadata.json diff --git a/apps/setuichange/ChangeLog b/apps/setuichange/ChangeLog deleted file mode 100644 index 8a8e53131..000000000 --- a/apps/setuichange/ChangeLog +++ /dev/null @@ -1,4 +0,0 @@ -0.01: New App! -0.02: Fix case where we tried to push to Bangle.btnWatches but it wasn't defined. -0.03: Throw exception if trying to add custom drag handler on mode updown and leftright. -0.04: Bangle.js 1 support. No change to Bangle.js 2. diff --git a/apps/setuichange/README.md b/apps/setuichange/README.md deleted file mode 100644 index 024ec9971..000000000 --- a/apps/setuichange/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# setUI Proposals Preview - -Try out changes to setUI that may or may not eventually en up in the Bangle.js firmware. - -## Usage - -Just install it and it modifies setUI at boot time. - -## Features - -- Add custom handlers on top of the standard modes as well. Previously this was only possible for mode == "custom". - - The goal here is to make it possible to move all input handling inside `setUI` where today some apps add on extra handlers outside of `setUI` calls. -- Change the default behaviour of the hardware button to act immediately on press down. Previously it has been acting on button release. - - This makes the interaction slightly snappier. - - In addition to the existing `btn` key a new `btnRelease` key can now be specified. `btnRelease` will let you listen to the rising edge of the hardware button. - -## Requests - -Please report your experience and thoughts on this issue: -[ Discussion: HW buttons should act on 'rising' edge #3435 ](https://github.com/espruino/BangleApps/issues/3435) or on the related forum conversation [Making Bangle.js more responsive](https://forum.espruino.com/conversations/397606/). - -## Creator - -The changes done here were done by thyttan with help from Gordon Williams. diff --git a/apps/setuichange/app.png b/apps/setuichange/app.png deleted file mode 100644 index 78bea6c3bf4e9d0035c4b03b9b2bf55c8269cc6e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 990 zcmV<410np0P)J$W@gItalXwKFC#bLNyp zE!2dlg+@)p4ijqy^k&Wz3N6G$8zVDlv{WQfV~vH4mV&S|5J9|KGh7UJ`+x&s7vlYr zui1RF`TjTGYY%`DB}$a|Pq8B==HrM6J7?Si9UbeyS^>qM*Ubf=vxChqYQb7zf1ICn z3NUg18L%2L3BQ0a7bfOyjm@vh&A7N~5z{t~hUTTTkp$RZC@9_)}i)ph(Tx)E8R<6w? zyj?%@yb;Wwh9)2Mi$T-rZ-Q}l66y8GCB;w|(Xs-w2g*UOEyx8INK?%OSKtPLl z09FeqKJYLY=X^{eMpk5yK{j#9V9G8qs!n?O>U98N{z$I} zxix`b_F5$lVE)r2{Nn7ofq9!=KM)=`4^{$$%5IkcCcBC~uNODu5YR-#X%G~UsX?az zNY&e7&+FA0IR#)*v+RLZrY0+#&#IFX`wS{)+&5s&RHr8PI{jnmADi88wj(AHV|j%- zzU&hhCarpd%B;cE7o9ROHgPyg)jfmBj63+hbs#g4$|UTyY9UpZAd{~lmA_(1*#rW` zwj*9?vSg!bNWU|%_@hj0$-wp6~eervvRi`RHpm zs2p&ngf3X%gYGmQHPffl5d=vzE$bjtpZy9_7p(J4`CV%pWb&I&;lKBq>MMqBc?-8u zmC!k_P5<(K!RHBo2Z926q{2TBGOCUTCIHxWWT9cUsNk6z47`}5%xW;G{0*7>Xi#;d zicK~^D(~urZJueHF_Q95b#k&^pUIt-*KScPk-+5?&8TBjkkW@2fz+vy)@ z@fM5zc=1S+H(;$`FxlmiKH>d)uvqj5yh}hzomljXN|Y#30<2~J0GkKWWu}`dNB{r; M07*qoM6N<$f;wHrH~;_u diff --git a/apps/setuichange/boot-b1.js b/apps/setuichange/boot-b1.js deleted file mode 100644 index df2bde62e..000000000 --- a/apps/setuichange/boot-b1.js +++ /dev/null @@ -1,118 +0,0 @@ -Bangle.setUI = (function(mode, cb) { - var options = {}; - if ("object"==typeof mode) { - options = mode; - mode = options.mode; - if (!mode) throw new Error("Missing mode in setUI({...})"); - } - var redraw = true; - if (global.WIDGETS && WIDGETS.back) { - redraw = false; - WIDGETS.back.remove(mode && options.back); - } - if (Bangle.btnWatches) { - Bangle.btnWatches.forEach(clearWatch); - delete Bangle.btnWatches; - } - if (Bangle.swipeHandler) { - Bangle.removeListener("swipe", Bangle.swipeHandler); - delete Bangle.swipeHandler; - } - if (Bangle.touchHandler) { - Bangle.removeListener("touch", Bangle.touchHandler); - delete Bangle.touchHandler; - } - delete Bangle.uiRedraw; - delete Bangle.CLOCK; - if (Bangle.uiRemove) { - let r = Bangle.uiRemove; - delete Bangle.uiRemove; // stop recursion if setUI is called inside uiRemove - r(); - } - g.reset();// reset graphics state, just in case - if (!mode) return; - if (mode=="updown") { - Bangle.btnWatches = [ - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}), - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}), - setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"rising"}) - ]; - } else if (mode=="leftright") { - Bangle.btnWatches = [ - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}), - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}), - setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"rising"}) - ]; - Bangle.swipeHandler = d => {cb(d);}; - Bangle.on("swipe", Bangle.swipeHandler); - Bangle.touchHandler = d => {cb();}; - Bangle.on("touch", Bangle.touchHandler); - } else if (mode=="clock") { - Bangle.CLOCK=1; - Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"}) - ]; - } else if (mode=="clockupdown") { - Bangle.CLOCK=1; - Bangle.btnWatches = [ - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"rising"}), - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"rising"}), - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"}) - ]; - } else if (mode=="custom") { - if (options.clock) { - Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"rising"}) - ]; - } - } else - throw new Error("Unknown UI mode "+E.toJS(mode)); - if (options.clock) Bangle.CLOCK=1; - if (options.touch) { - Bangle.touchHandler = options.touch; - Bangle.on("touch", Bangle.touchHandler); - } - if (options.swipe) { - Bangle.swipeHandler = options.swipe; - Bangle.on("swipe", Bangle.swipeHandler); - } - if ((options.btn || options.btnRelease) && !Bangle.btnWatches) Bangle.btnWatches = []; - if (options.btn) Bangle.btnWatches.push( - setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"rising"}), - setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"rising"}), - setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"rising"}) - ); - if (options.btnRelease) Bangle.btnWatches.push( - setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}), - setWatch(function() { options.btn(2); }, BTN2, {repeat:1,edge:"falling"}), - setWatch(function() { options.btn(3); }, BTN3, {repeat:1,edge:"falling"}) - ); - if (options.remove) // handler for removing the UI (intervals/etc) - Bangle.uiRemove = options.remove; - if (options.redraw) // handler for redrawing the UI - Bangle.uiRedraw = options.redraw; - if (options.back) { - var touchHandler = (z) => { - if (z==1) options.back(); - }; - Bangle.on("touch", touchHandler); - var btnWatch; - if (Bangle.btnWatches===undefined) // only add back button handler if there's no existing watch on BTN1 - btnWatch = setWatch(function() { - btnWatch = undefined; - options.back(); - }, BTN3, {edge:"rising"}); - WIDGETS = Object.assign({back:{ - area:"tl", width:24, - draw:e=>g.reset().setColor("#f00").drawImage(atob("GBiBAAAYAAH/gAf/4A//8B//+D///D///H/P/n+H/n8P/n4f/vwAP/wAP34f/n8P/n+H/n/P/j///D///B//+A//8Af/4AH/gAAYAA=="),e.x,e.y), - remove:(noclear)=>{ - if (btnWatch) clearWatch(btnWatch); - Bangle.removeListener("touch", touchHandler); - if (!noclear) g.reset().clearRect({x:WIDGETS.back.x, y:WIDGETS.back.y, w:24,h:24}); - delete WIDGETS.back; - if (!noclear) Bangle.drawWidgets(); - } - }},global.WIDGETS); - if (redraw) Bangle.drawWidgets(); - } -}) diff --git a/apps/setuichange/boot-b2.js b/apps/setuichange/boot-b2.js deleted file mode 100644 index d9df3566f..000000000 --- a/apps/setuichange/boot-b2.js +++ /dev/null @@ -1,154 +0,0 @@ -Bangle.setUI = (function(mode, cb) { - var options = {}; - if ("object"==typeof mode) { - options = mode; - mode = options.mode; - if (!mode) throw new Error("Missing mode in setUI({...})"); - } - var redraw = true; - if (global.WIDGETS && WIDGETS.back) { - redraw = false; - WIDGETS.back.remove(mode && options.back); - } - if (Bangle.btnWatches) { - Bangle.btnWatches.forEach(clearWatch); - delete Bangle.btnWatches; - } - if (Bangle.swipeHandler) { - Bangle.removeListener("swipe", Bangle.swipeHandler); - delete Bangle.swipeHandler; - } - if (Bangle.dragHandler) { - Bangle.removeListener("drag", Bangle.dragHandler); - delete Bangle.dragHandler; - } - if (Bangle.touchHandler) { - Bangle.removeListener("touch", Bangle.touchHandler); - delete Bangle.touchHandler; - } - delete Bangle.uiRedraw; - delete Bangle.CLOCK; - if (Bangle.uiRemove) { - let r = Bangle.uiRemove; - delete Bangle.uiRemove; // stop recursion if setUI is called inside uiRemove - r(); - } - g.reset();// reset graphics state, just in case - if (!mode) return; - function b() { - try{Bangle.buzz(30);}catch(e){} - } - if (mode=="updown") { - if (options.drag) throw new Error("Custom drag handler not supported in mode updown!") - var dy = 0; - Bangle.dragHandler = e=>{ - dy += e.dy; - if (!e.b) dy=0; - while (Math.abs(dy)>32) { - if (dy>0) { dy-=32; cb(1) } - else { dy+=32; cb(-1) } - Bangle.buzz(20); - } - }; - Bangle.on('drag',Bangle.dragHandler); - Bangle.touchHandler = d => {b();cb();}; - Bangle.btnWatches = [ - setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}), - ]; - } else if (mode=="leftright") { - if (options.drag) throw new Error("Custom drag handler not supported in mode leftright!") - var dx = 0; - Bangle.dragHandler = e=>{ - dx += e.dx; - if (!e.b) dx=0; - while (Math.abs(dx)>32) { - if (dx>0) { dx-=32; cb(1) } - else { dx+=32; cb(-1) } - Bangle.buzz(20); - } - }; - Bangle.on('drag',Bangle.dragHandler); - Bangle.touchHandler = d => {b();cb();}; - Bangle.btnWatches = [ - setWatch(function() { b();cb(); }, BTN1, {repeat:1, edge:"rising"}), - ]; - } else if (mode=="clock") { - Bangle.CLOCK=1; - Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"}) - ]; - } else if (mode=="clockupdown") { - Bangle.CLOCK=1; - Bangle.touchHandler = (d,e) => { - if (e.x < 120) return; - b();cb((e.y > 88) ? 1 : -1); - }; - Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"}) - ]; - } else if (mode=="custom") { - if (options.clock) { - Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"rising"}) - ]; - } - } else - throw new Error("Unknown UI mode "+E.toJS(mode)); - if (options.clock) Bangle.CLOCK=1; - if (options.touch) - Bangle.touchHandler = options.touch; - if (options.drag) { - Bangle.dragHandler = options.drag; - Bangle.on("drag", Bangle.dragHandler); - } - if (options.swipe) { - Bangle.swipeHandler = options.swipe; - Bangle.on("swipe", Bangle.swipeHandler); - } - if ((options.btn || options.btnRelease) && !Bangle.btnWatches) Bangle.btnWatches = []; - if (options.btn) Bangle.btnWatches.push(setWatch(options.btn.bind(options), BTN1, {repeat:1,edge:"rising"})) - if (options.btnRelease) Bangle.btnWatches.push(setWatch(options.btnRelease.bind(options), BTN1, {repeat:1,edge:"falling"})) - if (options.remove) // handler for removing the UI (intervals/etc) - Bangle.uiRemove = options.remove; - if (options.redraw) // handler for redrawing the UI - Bangle.uiRedraw = options.redraw; - if (options.back) { - var touchHandler = (_,e) => { - if (e.y<36 && e.x<48) { - e.handled = true; - E.stopEventPropagation(); - options.back(); - } - }; - Bangle.on("touch", touchHandler); - // If a touch handler was needed for setUI, add it - but ignore touches if they've already gone to the 'back' handler - if (Bangle.touchHandler) { - var uiTouchHandler = Bangle.touchHandler; - Bangle.touchHandler = (_,e) => { - if (!e.handled) uiTouchHandler(_,e); - }; - Bangle.on("touch", Bangle.touchHandler); - } - var btnWatch; - if (Bangle.btnWatches===undefined) // only add back button handler if there's no existing watch on BTN1 - btnWatch = setWatch(function() { - btnWatch = undefined; - options.back(); - }, BTN1, {edge:"rising"}); - WIDGETS = Object.assign({back:{ - area:"tl", width:24, - draw:e=>g.reset().setColor("#f00").drawImage(atob("GBiBAAAYAAH/gAf/4A//8B//+D///D///H/P/n+H/n8P/n4f/vwAP/wAP34f/n8P/n+H/n/P/j///D///B//+A//8Af/4AH/gAAYAA=="),e.x,e.y), - remove:(noclear)=>{ - if (btnWatch) clearWatch(btnWatch); - Bangle.removeListener("touch", touchHandler); - if (!noclear) g.reset().clearRect({x:WIDGETS.back.x, y:WIDGETS.back.y, w:24,h:24}); - delete WIDGETS.back; - if (!noclear) Bangle.drawWidgets(); - } - }},global.WIDGETS); - if (redraw) Bangle.drawWidgets(); - } else { // If a touch handler was needed for setUI, add it - if (Bangle.touchHandler) - Bangle.on("touch", Bangle.touchHandler); - } -}) diff --git a/apps/setuichange/metadata.json b/apps/setuichange/metadata.json deleted file mode 100644 index f21c784ec..000000000 --- a/apps/setuichange/metadata.json +++ /dev/null @@ -1,14 +0,0 @@ -{ "id": "setuichange", - "name": "SetUI Proposals preview", - "version":"0.04", - "description": "Try out potential future changes to `Bangle.setUI`. Makes hardware button interaction snappier. Makes it possible to set custom event handlers on any type/mode, not just `\"custom\"`. Please provide feedback - see `Read more...` below.", - "icon": "app.png", - "tags": "", - "type": "bootloader", - "supports" : ["BANGLEJS","BANGLEJS2"], - "readme": "README.md", - "storage": [ - {"name":"setuichange.0.boot.js","url":"boot-b1.js", "supports": ["BANGLEJS"]}, - {"name":"setuichange.0.boot.js","url":"boot-b2.js", "supports": ["BANGLEJS2"]} - ] -}