• Wrote a small test program for the bangle.js emulator testing the buttons... pretty neat!

    Proceed as follows:

    • start emulator https://www.espruino.com/ide/emulator.ht­ml
    • paste code into emulator editor pane (right-hand pane)
    • upload code
    • run it with typing r() into console (left-hand pane)
    • click on button 1,2,3 -to the right of the graphics area
    • click into the left or right half side of the graphics

      var btns = [BTN1,BTN2,BTN3,BTN4,BTN5], wIds;
      function onInit() {
      if (wIds) return;
      wIds = [];
      btns.forEach(function(btn,i) {
        var lab = "BTN"+(i+1);
        wIds.push(setWatch(function(e) {
            e.btn=lab;
            console.log(e);
          },btn,{repeat:true,edge:"both"}));
      });
      Bangle.on("swipe",function(dir) { // ???
      console.log((dir) ? "-->" : "<--"); });
      }
      function h() {
      if (wIds) wIds.forEach(function(wId) {
          clearWatch(wId); });
      wIds = null;
      }
      function r() { onInit(); } // r() : run
      function h() { halt();   } // h() : halt
      

    Results:

    • a) activities on BTN5 also falsely(?) reports BTN4 activities
    • b) 'swipe' - moving pointer with mousedown not supported

    Would be nice to see the swipe working... with setWatche()-s on the buttons 4 and 5 AND with - for example - Bangle.on("swipe",function(dir){...} (or alike).

    Output 'formatted' to fit:

    { "state": true,  "lastTime": undefined, "time": ...721999, "btn": "BTN1" }
    { "state": false, "lastTime": ...721999, "time": ...946000, "btn": "BTN1" }
    { "state": true,  "lastTime": undefined, "time": ...456000, "btn": "BTN2" }
    { "state": false, "lastTime": ...456000, "time": ...673000, "btn": "BTN2" }
    { "state": true,  "lastTime": undefined, "time": ...539999, "btn": "BTN3" }
    { "state": false, "lastTime": ...539999, "time": ...747999, "btn": "BTN3" }
    { "state": true,  "lastTime": undefined, "time": ...798000, "btn": "BTN4" }
    { "state": false, "lastTime": ...798000, "time": ...990999, "btn": "BTN4" }
    { "state": true,  "lastTime": undefined, "time": ...267999, "btn": "BTN5" }
    { "state": true,  "lastTime": ...990999, "time": ...267999, "btn": "BTN4" }
    { "state": false, "lastTime": ...267999, "time": ...460000, "btn": "BTN5" }
    { "state": false, "lastTime": ...267999, "time": ...460999, "btn": "BTN4" }
    
    

    1 Attachment

    • bangleEmul_Btn_Test.png
About

Avatar for allObjects @allObjects started