BS1: BUTTON: when used for debounce, does it return while the button is still a
I am using BUTTON with the delay set to 255. Does BUTTON return before the input signal goes inactive or does it not return until the input signal goes inactive. I am trying to debounce a 100 ms signal from another device, and wish to know how to handle the return. If the signal is still active, I must pause for some amount of time to let it go inactive before continuing the loop and risking double counting the signal. If BUTTON doesn't return until the signal goes inactive then I don't need to worry about pausing, but I note that I still must account for the time spent waiting, and have missed the beginning of the event.
Comments
The PBASIC Help File offers the following insight into the BUTTON command:
"BUTTON is designed for use inside a program loop. Each time through the loop, BUTTON checks the state of the specified pin. When it first matches DownState, BUTTON begins the Delay countdown for auto-repeat. Then, in accordance with TargetState, it either branches to address (TargetState = 1) or doesn't (TargetState = 0)."
and
"BUTTON does not stop program execution. In order for its delay and auto repeat functions to work properly, BUTTON must be executed from within a program loop."
Thus there is no pre-planned or inherent delay within BUTTON itself, except for the ordinary execution time (including token fetch time), otherwise there would be no necessity for the BUTTON command to be a part of a program loop.
I _may_ be able to offer just a bit more information, later today, or tomorrow. If so, I will add another reply to this thread. I hope that gives you the information you were seeking.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I had read the help, and I am experienced with imbedded systems and with software development, BUT new to the BS-series.
I am puzzled by the wording for the BUTTON. If I interpret the Help correctly, then the first time that the BUTTON sees the signal go active, it will branch accordingly. Thereafter, it will continue to be evaluated each time through the loop, and - in my case, which is debounce only, no repeats - will NOT branch the next times though the loop even though the signal is still active. BUTTON would then reset itself when the signal goes inactive. This would be great for me as I am looking at an electronic signal, and don't expect it to bounce. If all this is true, then I am fat, because then I can keep the loop timers running as planned.
Gratefully,
~Rich