• Sample output from KeypadMDS_Inline.js code (with AC control application in mind that toggles power and fan and 'ups' and 'down' temperature):

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v80 Copyright 2015 G.Williams
    >echo(0);
    =undefined
    949377234.41604518890
    scan si: 0 - di: 0 - s: 0
    949377234.41604518890: Button # 0 pressed: pwr toggle
    4.81315994262
    scan si: 0 - di: 0 - s: 0
    scan si: 0 - di: 1 - s: 0
    949377241.43724060058: Button # 2 pressed: temp down
    -1.82220757007
    2.95375728607
    scan si: 0 - di: 0 - s: 0
    scan si: 0 - di: 1 - s: 0
    scan si: 0 - di: 2 - s: 0
    949377246.60013008117: Button # 4 pressed: fan toggle
    6.82493495941
    scan si: 0 - di: 0 - s: 0
    scan si: 0 - di: 1 - s: 0
    949377255.63546943664: Button # 2 pressed: temp down
    78.17845439910
    scan si: 1 - di: 0 - s: 0
    scan si: 1 - di: 1 - s: 0
    949377336.02310276031: Button # 3 pressed: temp up
    -1.92238414287
    2.93543815612
    scan si: 1 - di: 0 - s: 0
    949377341.16769027709: Button # 1 pressed: N/C
    0.59415245056
    scan si: 1 - di: 0 - s: 0
    scan si: 1 - di: 1 - s: 0
    scan si: 1 - di: 2 - s: 0
    949377343.96973037719: Button # 5 pressed: N/C
    > 
    

    Noteworthy are lines with the negative numbers: Events in espruino are queued.... and with a lousy switch - I just used I wire to touch a Espruino Pico castellation pad which produced a lot of queud events... interestingly not on the touch, but on the 'move away' which then on scan did not show any buttons pressed. Therefore, .np - earliest / Next allowed Press time is set - with current time plus set debounce time - and checked to filter and ignore these events. It helos avoid faulty callbacks for now, but I'm not settled on it it yet. There must be a better approach... I hope.

    Verified module usage with this code:

    var dbg = true;
    var log = function() { console.log(arguments.join("")); };
    
    // var keypad = keypadModule.connect( // for inline use
    var keypad = require("KeypadMDS").connect( // for module use
        [B13,B14,B15], [B1,B10], function(btn,tme){ // 0,1,2,3...
          if (dbg) log("" + tme + ": Button # ",btn," pressed: "
              , [ "pwr toggle","N/C"
                , "temp down" ,"temp up"
                , "fan toggle","N/C"
                ][btn] );
      });
    

    Producing this output:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v80 Copyright 2015 G.Williams
    >echo(0);
    =undefined
    949385591.92534446716: Button # 3 pressed: temp up
    949385600.08324909210: Button # 5 pressed: N/C
    949385630.64551258087: Button # 0 pressed: pwr toggle
    949385633.89211368560: Button # 2 pressed: temp down
    949385641.41957569122: Button # 0 pressed: pwr toggle
    949385645.01201820373: Button # 4 pressed: fan toggle
    > 
    
About

Avatar for allObjects @allObjects started