diff --git a/ChangeLog b/ChangeLog index c57ad8e06..794d51817 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ STM32F4: Update stm32f4xx_ll_usb to fix over-buffered USB CDC tx after being woken from deep sleep Waveform: Add 'npin' option to allow +/- output on two pins Waveform: Add ability to play directly from Storage + Bangle.js2: Pass the modified touch event on through both E.showScroller and E.showMenu (to enable more complex interaction with menus). 2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()' Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off) diff --git a/libs/banglejs/jswrap_bangle.c b/libs/banglejs/jswrap_bangle.c index 3369dc5dc..17db634e8 100644 --- a/libs/banglejs/jswrap_bangle.c +++ b/libs/banglejs/jswrap_bangle.c @@ -5904,6 +5904,8 @@ On Bangle.js there are a few additions over the standard `graphical_menu`: menu is removed * (Bangle.js 2) `scroll : int` - an integer specifying how much the initial menu should be scrolled by + * `onchange : function(value, touch) {}` - on Bangle.js 2 this function can + consider ~how~ the entry was touched. See `E.showScroller` for more info. * The object returned by `E.showMenu` contains: * (Bangle.js 2) `scroller` - the object returned by `E.showScroller` - `scroller.scroll` returns the amount the menu is currently scrolled by @@ -6046,6 +6048,7 @@ Supply an object containing: draw : function(idx, rect) { ... } // a function to call when the item is selected, touch parameter is only relevant // for Bangle.js 2 and contains the coordinates touched inside the selected item + // as well as the type of the touch - see `Bangle.touch`. select : function(idx, touch) { ... } // optional function to be called when 'back' is tapped back : function() { ...} diff --git a/libs/js/banglejs/E_showMenu_Q3.js b/libs/js/banglejs/E_showMenu_Q3.js index 96f493656..7b73dfded 100644 --- a/libs/js/banglejs/E_showMenu_Q3.js +++ b/libs/js/banglejs/E_showMenu_Q3.js @@ -38,11 +38,11 @@ g.setColor(g.theme.fg2).setFont("12x20").setFontAlign(-1,0).drawString((item.format) ? item.format(v,1) : v, r.x+12, r.y+H/2); g.drawImage(/* 20x20 */atob(v==item.value?"FBSBAAH4AH/gHgeDgBww8MY/xmf+bH/jz/88//PP/zz/88f+Nn/mY/xjDww4AcHgeAf+AB+A":"FBSBAAH4AH/gHgeDgBwwAMYABmAAbAADwAA8AAPAADwAA8AANgAGYABjAAw4AcHgeAf+AB+A"), r.x+r.w-32, r.y+H/2-10); }, - select : function(idx) { + select : function(idx, touch) { if (idx<0) return; // TITLE Bangle.buzz(20); item.value = item.min + idx*step; - if (item.onchange) item.onchange(item.value); + if (item.onchange) item.onchange(item.value, touch); scr.scroll = l.scroller.scroll; // set scroll to prev position show(); // redraw original menu } @@ -133,11 +133,11 @@ l = g.setFont("6x15").wrapString(title,r.w-pad); g.setFontAlign(-1,0).drawString(l.join("\n"), r.x+12, r.y+H/2); }, - select : function(idx) { + select : function(idx, touch) { if (idx<0) return back&&back(); // title var item = menu[keys[idx]]; Bangle.buzz(20); - if ("function" == typeof item) item(l); + if ("function" == typeof item) item(l, touch); else if ("object" == typeof item) { // if a bool, just toggle it if ("number" == typeof item.value) { @@ -145,7 +145,7 @@ } else { if ("boolean"==typeof item.value) item.value=!item.value; - if (item.onchange) item.onchange(item.value); + if (item.onchange) item.onchange(item.value, touch); if (l.scroller.isActive()) l.scroller.drawItem(idx); } } diff --git a/libs/js/banglejs/E_showScroller_Q3.js b/libs/js/banglejs/E_showScroller_Q3.js index f2d0c207a..4a7897c57 100644 --- a/libs/js/banglejs/E_showScroller_Q3.js +++ b/libs/js/banglejs/E_showScroller_Q3.js @@ -82,7 +82,7 @@ Bangle.setUI({ } if ((menuScrollMin<0 || i>=0) && i