I have been tring to understand the Button behaviour and wonder if i am right:
This is my class:
// Buttton Class
class Button extends IoExpander
{
// IO Pin assignments
pinButton = 0;
state = 0;
constructor(port, address, pinButton)
{
server.log(format("constructor"));
base.constructor(port, address);
// enable pin as active
setPin(pinButton, 0);
// set button IRQ
setPullUp(pinButton, 1);
setIrqMask(pinButton, 1);
setIrqEdges(pinButton, 1, 1); // Set for rising and falling
}
// Read button
function readState()
{
state = getPin(pinButton);
//server.log(format("debug %d", state));
return state;
}
}
Then i initialize and read the button every sec.
If i press the button for more than a sec, i get chaotic behaviour. Like several 1 and 0s from the read.
How should i get process the button read output?
thanks
Patrick