diff --git a/libs/js/banglejs/Bangle_setUI_F18.js b/libs/js/banglejs/Bangle_setUI_F18.js index 9ce50f875..4a5894425 100644 --- a/libs/js/banglejs/Bangle_setUI_F18.js +++ b/libs/js/banglejs/Bangle_setUI_F18.js @@ -33,15 +33,15 @@ if (!mode) return; if (mode=="updown") { Bangle.btnWatches = [ - setWatch(function() { cb(-1); }, BTN1, {repeat:1,edge:"falling"}), - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}), - setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"falling"}) + 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:"falling"}), - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}), - setWatch(function() { cb(); }, BTN2, {repeat:1,edge:"falling"}) + 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); @@ -50,38 +50,43 @@ } else if (mode=="clock") { Bangle.CLOCK=1; Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) + 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:"falling"}), - setWatch(function() { cb(1); }, BTN3, {repeat:1,edge:"falling"}), - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) + 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.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 = [ - 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"}) - ]; - } else if (options.clock) { + if (options.clock) { Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) + 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 @@ -96,7 +101,7 @@ btnWatch = setWatch(function() { btnWatch = undefined; options.back(); - }, BTN3, {edge:"falling"}); + }, 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),