lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Oliver,
this depends very much on the system of course. But from my experience
with such user hardware-interface programs I know that this is very
useful and beneficial for such hardware programming... . There will be
"normal" / "fast" / "slow" inputs, and the delay timing always will
depend on the input type... . The user typically should be free to
program this "as the user wants", and this should be done in some way
which is very easy for the user... .

If you program your "own switch module" and you have electronics
experience, then of course you can somehow circumvent this. But if you
have the ambition that somehow "any userr" can program such a system
"quite easily" (mainly without knowing anything about such bouncing
problems), then this is really very very beneficial to my experience.

On Wed, Feb 16, 2022 at 3:36 PM Oliver Kroth <oliver.kroth@nec-i.de> wrote:
>
> Hi Flyer31,
>
> you do not need to call a delay function to wait for an input to become
> stable. And definitely not one per input.
> You do not want to have to wait for 150ms for some action, trust me that
> is annoying.
> Actually debouncing works by detecting and reporting the changed value
> immediately, but ignore further changes for the debounce time.
> Usually switches don't bounce before they switch, the bounce after they
> travelled to their new position.
>
> I had successfully implemented a digital input module (sensing switches)
> that keep a last read state, last sent state, and a time stamp when the
> read value did change the last time.
> A changed value is sent immediately if the last change is longer in the
> past than the debounce time and read and sent value are different.
> Actually my code used only one byte for the millisecond time stamp
> (Arduino C++ code, but talks to a Lua script)
>
> Oliver