[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can C code recognize, whether Lua inside some loop/block? (for/while/repeat/if)
- From: Oliver Kroth <oliver.kroth@...>
- Date: Wed, 16 Feb 2022 15:35:38 +0100
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