Bangle.js 2 touch int pin

Posted on
  • Hello, I just gt my bangle.js 2, thanks a lot.

    I am trying to play with the touch controller, I read at your info on hackaday on the smaq3, that the interups is D36,b ut it does not work for me, this reports nothing on touch.

    lala=setWatch(function(s){
    print("lala");
    },D36,{repeat:true, edge:0});

    this is my info, any idea as to what I may be missing?

    VERSION: "2v11",
    GIT_COMMIT: "531080858",
    BOARD: "BANGLEJS2",

    ps. also, I get this message when tryin to run a watch on pin D39:
    WARNING: No free GPIOTE for watch
    I have seen that before on fanoush's builds for the rock/magic when over 4 watches are running.

  • It's probably because you're using the standard Bangle.js firmware?

    As soon as the IRQ pin changes, the firmware itself jumps in and processes the IRQ before the JS can get there. That may even be the reason you can't get the watch working.

    I think you're not going to get anywhere with this unless you make your own build that completely disables Bangle.js's touch functionality - which is probably not what you want!

  • this makes sense, thank you for answering, I will use the included functionality :)

  • in the case someone else want to have control of the touch like I do, a solution is to run software i2c on top. This way the bangle's integrated events can be used instead of the interrupt pin, works very nice.

  • run software i2c on top

    I like the I2C bus, please provide a piece of code that shows how this can be done.

  • something like that works fine for getting raw data on touch/swipe

    var i2c=new I2C(); i2c.setup({scl:D34, sda:D33, bitrate:100000});
    TC= function(){
    i2c.writeTo(0x15,0);
    print(i2c.readFrom(0x15,7));
    };
    Bangle.on('touch', TC);
    Bangle.on('swipe', TC);

  • a solution is to run software i2c on top. This way the bangle's integrated events can be used instead of the interrupt pin, works very nice.

    Interesting that it works. Bangle firmware already use (software) i2c on top of same touch i2c pins, in fact many of them seen here

    So you have yet another new I2C() that you setup() to have same pins as one of those bangle internal ones.That may still be OK but I wonder what happens when the touch irq comes in the middle of your i2c code call and bangle native irq handler runs some read over same pins via its own I2C object.

  • I wonder what happens when the touch irq comes in the middle of your i2c code call and bangle native irq handler runs some read over same pins via its own I2C object.

    an

    Uncaught Error: I2C Error: Arbitration (start)

    is thrown, but it still works, been testing for a day now. :)

  • Yes, I guess if both are using software then the pin states are kept the same - you'll just get the occasional clash if the touch IRQ jumps in at the wrong time.

    I guess in a way a neat longer-term solution would be to add touchRd/touchWr functions like we have for the other sensors on the watch.

  • I guess in a way a neat longer-term solution would be to add touchRd/touchWr functions like we have for the other sensors on the watch.

    that would be nice, or maybe info on swipe event for up/dn and x,y.

    One last question that is a bit irrelevant, is there an easy way to bypass/set longer timeout on the side button's long press action?
    It restarts the watch on long press, is there a way to customize that?

  • or maybe info on swipe event for up/dn and x,y.

    we have that already??

    It restarts the watch on long press, is there a way to customize that?

    Sadly no, I believe the bootloader needs a software update for that. It's built in at a very low level to try and make the Bangle.js extremely hard to brick :)

  • It restarts the watch on long press, is there a way to customize that?

    Maybe yes in a hackish way. This is about watchdog interval and stopping kicking it when it is held. So if you will kick watchdog yourself while button is held then you can extend it as you wish.

  • we have that already??

    I was looking at swipe event, it only has left/right. and then there is drag event with yz but not the action id, but it is not a problem really, I used the drag event with the i2c.writeTo(0x15,0xFA,17);
    so now I get no Arbitration error, it actually works very nice.

    On the reset issue, I think we are not talking about the same one.
    There is one that resets the watch on a 10sec hold, handles the dfu mode, this is very nice.

    but there is another one as well, it fires at 1.5-2 sec in, and it issues an E.reboot() and the screen displays "loading".
    I have noticed that it is only started after I call the Bangle.getOptions() or set an option, or set a event. If I do not, I can bypass it, so I guess I could work around it.

    I also tried calling E.kickWatchdog() , it doesn't seem to work, I guess it is not the watchdog, because I get a message from E.kill event, and the manual says this should not work on a watchdog timer reset.

  • On the reset issue, I think we are not talking about the same one.

    Yes, you initially described it as "It restarts the watch on long press, is there a way to customize that?" so I was thinking you mean the watchdog reset that restarts whole watch. Not the one that exits the app.

  • but there is another one as well, it fires at 1.5-2 sec in, and it issues an E.reboot() and the screen displays "loading".

    Yes, that one should be adjustable with a firmware tweak.

    I was looking at swipe event, it only has left/right.

    You can see how stuff is handled in touchHandlerInternal: https://github.com/espruino/Espruino/blo­b/master/libs/banglejs/jswrap_bangle.c#L­1475

    I believe everything is forwarded as events

  • Thank you both. :)

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

Bangle.js 2 touch int pin

Posted by Avatar for enaon @enaon

Actions