Arduino library with debounced controls

Are you building a cockpit, planning to build one or just dreaming, this is your cockpit builder meeting point

Moderators: russ, Ralph

Post Reply
Message
Author
User avatar
WillemijnL
Posts: 107
Joined: Sat Jan 30, 2016 1:14 pm

Arduino library with debounced controls

#1 Post by WillemijnL »

I have published an Arduino library with debounced controls. At the moment the library contains a button class and a rotary encoder class. And also a general debouncer class used by the other classes. There are more solutions available on the internet but this library will contain a complete set and is rock solid. The classes all work the same way and the error rate is extreme low, especially with the rotary encoder, which makes every control a high class control. The rotary encoder has also error detection and correction. The library is usefull in combination with the Air Manager message port. Plan is to add also a (multi)switch class with "unlimited" positions. For now multiple buttons can be used to support a (multi)switch. The button will be extended with long press and double press in the future.

The library supports a technical and a natural way. For the technical way methods like "fell" and "rose" are available. For the natural way you can use methods like "press" and "release". The rotary encoder not only supports direction but also a counter the same time. It's up to you what you prefer and what is best for you to use. The library supports built-in pulldown resistors if available on the MCU and has good and clear support for external pullup/pulldown resistors.

Library:
https://github.com/openfsb/openFSB_Debo ... ls_Arduino
Documentation:
https://docs-debounced-controls-arduino.openfsb.org

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Arduino library with debounced controls

#2 Post by Sling »

Thanks but can I ask what the purpose is for this when we already have pretty much this builtin to the standard AM Arduino. I get that it’s a way of adding buttons, switches and encoders for message port but generally you would only use message port if you were interfacing some piece of hardware not natively supported by the standard Arduino.

User avatar
WillemijnL
Posts: 107
Joined: Sat Jan 30, 2016 1:14 pm

Re: Arduino library with debounced controls

#3 Post by WillemijnL »

You are right. Standard AM Arduino supports it all. But when you want to create a hardware instrument with a display not supported bij AM in combination with push buttons and a rotary encoder, then you have to to use the message port and a library like this one.

User avatar
Sling
Posts: 5237
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Arduino library with debounced controls

#4 Post by Sling »

Agreed. It’s perhaps useful for creating your own controls using message port as I acknowledged in my first post but it is surely simpler and quicker to use another board flashed with the standard AM image. A little Nano for instance is really cheap and the AM script would be easier to write, albeit using another USB. It has some uses for more advanced users I think.

Thanks again for sharing.

Tony

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Arduino library with debounced controls

#5 Post by jph »

WillemijnL wrote: Mon Jan 13, 2020 6:10 am You are right. Standard AM Arduino supports it all. But when you want to create a hardware instrument with a display not supported bij AM in combination with push buttons and a rotary encoder, then you have to to use the message port and a library like this one.
Thanks for sharing. You are absolutely correct. and, an additional 'nano' flashed with standard AM would do absolutely nothing for you if you wanted to use - for example - the TM1638 which I think is a lovely unit.
My own code is interrupt driven for reading/de-bouncing for the encoders etc so your library is of no use to me personally, but it is good to share and someone will find it useful.
There is also the case of using the DUE or other devices not supported by AM. The DUE is a lovely board - a real star ! all those lovely 12 bit ADC's and full USB hid support :) :) - AND a hardware usb / serial port at the same time. you can run it as a USB game controller / hid device at the same time as having a usb serial connection to AM.
Using Message-port you can call the device anything you want - call the DUE a nano if you want, it doesn't matter to AM providing the message port code runs. ;)
Every little helps as they say
:)
Joe
Joe. CISSP, MSc.

JackZ
Posts: 2262
Joined: Mon Feb 22, 2016 1:02 pm

Re: Arduino library with debounced controls

#6 Post by JackZ »

That seems promising, was facing the very same problem of having to deal with two separate Arduino for using two OLED Displays using Message Port, along encoders and buttons using another Arduino.

Thé possibility to have an all in one is interesting, will test it for sure.

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply