setWatch "false" trigger ?

Posted on
  • Hello Gordon

    On the EspruinoWifi. Two buttons connected:
    3.3v -> A1
    3.3v -> A4

    Code:

    pinMode(A1, "input_pulldown");
    var a1=setWatch(function(e) {
        console.log('A1');
        console.log(e);
    },A1, { repeat: true, edge: 'both', debounce: 200 } );
    
    pinMode(A4, "input_pulldown");
    var a1=setWatch(function(e) {
        console.log('A4');
        console.log(e);
    },A4, { repeat: true, edge: 'both', debounce: 200 } );
    

    When i push the button on A4 or A1 i also get a callback on the other watch.

    Output, pressed button connected on A4:

    A1
    { "state": false, "lastTime": 946685544.60812091827, "time": 946685548.80402851104 }
    A4
    { "state": true, "lastTime": 946685544.78433227539, "time": 946685548.80407905578 }
    

    I expected only receive a setWatch callback from A4.

    Thanks

    Sacha

  • I used 1V95

  • Corrected code. I used the same var for both setWatches.
    Same output.

    pinMode(A1, "input_pulldown");
    var a1=setWatch(function(e) {
        console.log('A1');
        console.log(e);
    },A1, { repeat: true, edge: 'both', debounce: 200 } );
    
    pinMode(A4, "input_pulldown");
    var a4=setWatch(function(e) {
        console.log('A4');
        console.log(e);
    },A4, { repeat: true, edge: 'both', debounce: 200 } );
    
  • Still triggers both Watches.

  • That's odd - does it happen repeatedy, or just that first time?

    Also, are the buttons pulling up to 3.3v, or a higher voltage? The pins should be 5v tolerant but I've noticed that if the pins are over-volted, it can actually start to cause other pins to read a voltage as well.

  • It happen each time. Very easy setup.

    Connected the PIN 3.3v to the butten or switch and then to A1 (Btn1) and A4 (Btn2).
    I think it happens on other pins too.

    Sacha

  • It triggers "false" on the other pin. This is the right value. But i do not wan't this information, because that is the current unchanged state.

    There is a workaround. I will remember the states and ignore the same value.

    Sacha

  • It's strange. I just wired this up on a board here and it works great - with absolute latest and 1v95 firmware...

  • Ups. Hmmm. Have several EspruinoWifi's will check it again with a differnt one.
    Will also reflash the 1v95.

  • Flashed 1V96, same result. Even on another EspruinoWifi.
    I'm a bit confused.

    Sacha

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

setWatch "false" trigger ?

Posted by Avatar for user85862 @user85862

Actions