Bangle.js automatic screen turning on

Posted on
  • The current algorithm for turning Bangle.js's screen on really isn't that good. Basically I just try and see if it's face up.

    I've been experimenting with different algorithms - for example trying to detect sudden acceleration from twisting the wrist.

    Maybe some of you could check this out and see what you think? It doesn't light up but should buzz when it would light the screen up. Any suggestions?

    var ctr = 0;
    
    Bangle.on('accel',o=>{
      g.scroll(0,-1);
      g.setPixel(120-50, 239, "#808080");
      g.setPixel(120+50, 239, "#808080");
      g.setPixel(120+o.x*100, 239, "#ff0000");
      g.setPixel(120+o.y*100, 239, "#00ff00");
      g.setPixel(120+o.z*100, 239, "#0000ff");
      g.flip();
      ctr++;
      if (o.y>0.45) ctr=0;
      if (o.y<-0.2 && ctr<10) {
        Bangle.buzz();
        ctr=100;
      }
    });
    
  • It needs a fairly snappy rotation to get it to buzz on mine. Any sort of slower rotation doesn't work. And once it's face-up, you can't do a 90 degree flick-down/flick-up to get it to buzz, you have to do a full 180 again.

    Would TensorFlow be an insane over-engineering in this case? :-D

  • Thanks! Please could you try this?

    var ctr = 0;
    var lasto = {x:0,y:0,z:0};
    
    Bangle.on('accel',o=>{
      g.scroll(0,-1);
      var dy = o.y - lasto.y;
      g.setPixel(120-50, 239, "#808080");
      g.setPixel(120+50, 239, "#808080");
      g.setColor("#ff0000");
      g.fillRect(120+o.x*100, 239, 120+lasto.x*100, 239);
      g.setColor("#00ff00");
      g.fillRect(120+o.y*100, 239, 120+lasto.y*100, 239);
      g.setColor("#0000ff");
      g.fillRect(120+o.z*100, 239, 120+lasto.z*100, 239);
      g.flip();
      ctr++;
      
      g.setPixel(120+dy*100, 239, "#ff00ff");
      
      /*if (o.y>0.45) ctr=0;
      if (o.y<-0.2 && ctr<10) {
        Bangle.buzz();
        ctr=100;
      }*/
      if (dy>0.1) ctr=0;
      if (dy<-0.1 && o.y<-0.1 && 
          Math.abs(o.x)<0.6 && ctr<10) {
        Bangle.buzz();
        ctr=100;
      }  
      lasto=o;
    });
    

    It works on the difference in acceleration (plus a few tweaks to try and stop it going off accidentally).

    Would TensorFlow be an insane over-engineering in this case? :-D

    Yes :) But nothing stops you from doing it - come up with a bunch of training data, train it, dump the file on, and add an aiGesture handler that calls Bangle.setLCDPower(1) :)

    The issue is really the snappiness of it - you want something that turns on quickly or the watch will just seem really slow. Unless you have one of those fancy always-on networks (which we don't do at the moment and which would eat power) you're going to have to wait until Bangle.js thinks the gesture is over before you even start running the Tensorflow model...

  • Seems even less responsive than the first one. Only buzzing on 1 in 4/5 attempts. Same 90 degree issue. No amount of snapping over 90 degrees causes it to buzz. Has to be ~180 degree turn.

  • Not sure I really understand the issue you're having then. I can get it to go by turning it ~40 degrees.

    There is code in there to check if the watch face isn't pointing downwards. Could that be it?

    edit: but it you find some code that works well for you, please paste it up!

  • This is on my left wrist and rotating it. From face down to face up, quickly, I get a buzz. But any other angle rarely causes a buzz, no matter how fast/suddenly I rotate.

    Would an analysis of Z help? Is it + or - 9.8 when facing up? Z graph seems very stable when facing up or facing down. So going from Z not near 9.8 to Z approx 9.8?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Bangle.js automatic screen turning on

Posted by Avatar for Gordon @Gordon

Actions