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] );
});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Sample output from KeypadMDS_Inline.js code (with AC control application in mind that toggles power and fan and 'ups' and 'down' temperature):
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:
Producing this output: