Look at your data more closely - you're getting spurious callbacks while it's false... But when the signal goes high (which consistently happens every 20ms, just like it should for a 50hz signal), it is consistently followed by a record with the signal going low about 1ms (ie, 0.9 and a margin of error) later.
Why not record the state of the last call, and discard any call that has the same state as the last one?
(Edit: Oops - meant to just make that a normal post, not "in reply to...")
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.
I've noticed this kind of behavior as well.
Look at your data more closely - you're getting spurious callbacks while it's false... But when the signal goes high (which consistently happens every 20ms, just like it should for a 50hz signal), it is consistently followed by a record with the signal going low about 1ms (ie, 0.9 and a margin of error) later.
Why not record the state of the last call, and discard any call that has the same state as the last one?
(Edit: Oops - meant to just make that a normal post, not "in reply to...")