Pfth Forth: How does create a push-button debounce in Forth words?
LoopyByteloose
Posts: 12,537
Hello all,
I am rather clueless about how to begin. It seems some debounce code will do multiple i/o pins at the same time; and other code may be 'blocking' or 'no blocking'. I am not clear what blocking means or if that is good or bad.
I suppose a general solution that applies to all versions of Forth on the Propeller would be welcome.
I am rather clueless about how to begin. It seems some debounce code will do multiple i/o pins at the same time; and other code may be 'blocking' or 'no blocking'. I am not clear what blocking means or if that is good or bad.
I suppose a general solution that applies to all versions of Forth on the Propeller would be welcome.
Comments
"
"Blocking" and "non-blocking" describe individual operations, or individual function calls (or system calls). A blocking operation is basically one that can take a long time. In particular, if you made a function that read data, and waited for data to arrive before returning, it would be a blocking operation, because it could take arbitrarily long before the data arrived, and the CPU would be idle. A non-blocking operation, on the other hand, would be one designed to return immediately, with some return value indicating that it does not have data at this time.
"
Better than I could have said it. You create the words for the debounce routine and choose whether they perform in a blocking or non-blocking fashion.
So I suppose a de-bouncing that blocks would not take any action until the end of the de-bouncing delay. I can live with such a delay in this current project.
I also suppose that what ever I do, the actual debouncing code is likely to require a PASM solution defined as a Forth word with some means to attach it do the i/o designated on the data stack.
I am a bit unclear how to actually insert it into active code that is polling the state of an i/o input in an infinite loop. I just guess I'd have to accept that the loop would run slower.