diff --git a/libs/js/banglejs/Bangle_setUI_F18.js b/libs/js/banglejs/Bangle_setUI_F18.js index 9ce50f875..44c903730 100644 --- a/libs/js/banglejs/Bangle_setUI_F18.js +++ b/libs/js/banglejs/Bangle_setUI_F18.js @@ -60,28 +60,33 @@ setWatch(Bangle.showLauncher, BTN2, {repeat:1,edge:"falling"}) ]; } 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"}) ]; } } 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