Swipe up and Swipe down functionality?

Posted on
  • Why isn't a swipe up and swipe down functionality available? I can see only swipe left and right in the API documentation.
    Thanks

  • Because there are only two touch-sensitive zones, which are the left and right half of the display, and you can only detect a swipe from one side to the other with that.

    Probably the screen is just too small to reliably provide more than that. Although I wonder if the screen itself doesn't detect touch position more precisely than that, and that information would somehow be accessible?

  • Thanks a lot!
    I used setwatch() on button2 and onclick of it, I clear the home screen and display a new screen with a message. However, this new screen doesn't stay there. It goes back to the home screen immediately. Any idea how to take care of this? Should a make a new post for my query ?
    Doesn't it work like a normal on click event of a button, do something. rather than only flashing what it needs to show and going back to home screen

    Thanks!

  • I don't know really, but I have noticed the touch buttons seem a little unreliable at times - that is, when I try to wake up the display by touch, sometimes I have to press two or three times. Haven't really understood why.

    Maybe in your case it double-triggers? Or it's just a logical error in your code.

  • Thanks a lot!
    I have no clue either.
    I will make a new post for it. Hopefully I get to know what the problem is.

  • I think I've just answered in your new post: http://forum.espruino.com/conversations/357536/#comment15689660

    But about the touch:

    It's literally just two physical touch zones in the hardware - it's not that there's more that isn't exposed. I'm not entirely sure why they did that, but it might be something as mundane as the fact that they were running low on IO pins on the microcontroller.

    In terms of touch detection - were you wearing the Bangle? I've found the touch detection can be a bit flakey if it's just sitting on a desk, but it's much better when the back of the watch is in contact with your hand.

  • Thanks @Gordon
    I don't have the device. I am working on a emulator.

  • I was talking more to @Sebastian who said it was unreliable at times.

    I think we're pretty sure the 'going back to home screen' issue you had was the setInterval

  • Thanks @Gordon.
    Yes thats right, setInterval was taking me back to the home screen.

  • Interesting, I didn't think there were actually only two zones hardware-wise.

    In fact the watch was sitting on the desk when I tried the wake-on-touch. I just tested it when wearing the watch, but what I think what happens is just that you need to press the display sufficiently long and firmly for it to react. If you just flick it with the tip of your finger briefly it won't trigger, and that happens more easily when the watch is not worn.

  • Just bumping this for bangle 2. I have some code using Bangle.on('swipe') to scroll left/right through objects in an array and want to replicate it with up/down. I've tried reading other app code and looking at the documentation but can't quite work it out. Should I use Bangle.on('drag') , Bangle.setUI('updown') or is there something else I've missed?

  • Use Bangle.setUI('updown')

    It emulates a BTN1 or BTN3 on a Bangle 1. Touch the top right or bottom right of the display to cycle through an array. See my Pastel App that uses this to control display of a status line.

  • This works on my Bangle 2:

    Bangle.on("swipe",function(direction){
      if (0==direction) console.log("Up or down swipe detected");
    });
    
  • Thanks both. I shall have a play later

  • Hi, did you find a good solution?

  • Swipe has a second undocumented parameter for up and down. Maybe it helps.

  • Ok. Does it fit in when doing a "Bangle.on('swipe', function(direction) { ... });" ?
    Do you know how it's used?

  • You can try the following code:

    Bangle.on("swipe", function(dirLeftRight, dirUpDown) {
      if (dirLeftRight == -1) {
        // left
        console.log("left");
      } else if (dirLeftRight == 1) {
        // right
        console.log("right");
      } else if (dirUpDown == -1) {
        // up
        console.log("Up");
      } else if (dirUpDown == 1) {
        // down
        console.log("Down");
      }
    });
    
  • That's perfect. Thanks!

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

Swipe up and Swipe down functionality?

Posted by Avatar for NewAtEspruino @NewAtEspruino

Actions