In an other post, I came to talk about debouncing switches. I wrote that there are so many debouncing libraries available here in the playground, that it would be useless to write your own debouncer in a sketch and that it would be easier to use a library instead.
But I am retired, and I got time on my hand.
I looked carefully at all the debouncing solutions that were offered. My first observation is that .cpp and .h files are poorely commented. Deciphering what the code meant took me the better part of the weekend. My second observation was that some of them would statisticaly be on the unsafe side, some of them were too heavy in system resources.
One that cought my attention (the last one on the list), was offered by Paul Murray. It simulates an RC circuit and a Schmidt Trigger. It is efficient, fast and lightweight. He goes to great lenght in explaining how he does the magic with simple words. Great job here.
Then I spent my monday (remember, I am retired) searching the net for debouncing. All the solutions presented on those sites were implemented in one way or the other by one of the libraries found on the Playground.
Then I fell on this little gem. It was offered by the Ganssle Group. The autor (Jack Ganssle) pulled up his sleeves, gathered many switches and fired up an oscilloscope. The report that he made of his findings can be found here.
When you see the various ways a switch can lie to you, you see bouncing in a fresh and frightening light.
Later in the article, he tackles both hardware and software ways of mastering the beast. That is where I found the algorithm.
It is fast, lightweight and can tackle all, but the nasty "O" switch (read the article). It can also counteract EMI. Not bad.
So I decided to make it a library and make it available here. You will also find a complete tutorial there.
I was tempted to ask for some feedback on my work, but experience has shown me that (after introducing more than a couple libraries), even in the "Exhibition / Gallery" forum, you get little feedbak if any unless "Light Saber" figures in the subject.
Anyway. To all of you that might consider giving my debouncer a try, I wish you to live long and prosper.