rlogiacco / AnalogButtons

Arduino library to wire multiple buttons to one single analog pin
GNU Lesser General Public License v3.0
54 stars 13 forks source link

Master #3

Closed crisap94 closed 8 years ago

crisap94 commented 8 years ago

Some Improvements, checkit.

rlogiacco commented 8 years ago

What you are asking to pull is a fundamental change in the library where instead of using software debounce you suggest to use hardware debounce. I don't want to break existing code but I'm willing to accept a pull request if, instead of replacing what's already there, you add a switch via a pre-processor macro.

Please do not delete files, especially those you might not know what are meant for, like the .cir file, which is a spice simulation.

crisap94 commented 8 years ago

Hi Roberto, ahmmm i added some capacitors to the schematic for better debounce, but , via software is debounced too. because i have add an attribute Clicked, that means that is clicked just one time even if you keep pressed the button hole day.

Check that part of the code, i guess this is a better version.

And let me know what do i need to change for a correct pull.

Best Regards

2016-02-29 12:47 GMT-05:00 Roberto Lo Giacco notifications@github.com:

Closed #3 https://github.com/rlogiacco/AnalogButtons/pull/3.

— Reply to this email directly or view it on GitHub https://github.com/rlogiacco/AnalogButtons/pull/3#event-571506570.

rlogiacco commented 8 years ago

That's not debouncing... you are relying on the capacitor for the debouncing. Remove the RC circuit and you'll see spurious clicks coming in. On top of that, by removing the 50Hz limitation you are unnecessarily overloading the ADC with conversion requests it might not be able to fulfill... If an improvement can be made is to use a time based debouncing rather than a count based one, but completely removing it it's not going to work without your RC circuit.

So you have two options:

  1. you create your own fork of the library and publish it under another name (to avoid collisions)
  2. maintain the user interface and add a pre processor switch: people can decide if they want to use software debouncing (default) or hardware debouncing, and you can deactivate the debouncing depending on that

I will accept a pull request which doesn't unnecessarily break the API and doesn't remove functionalities while still adding some value.

I see value in your contribution, but it is breaking the API and the hardware configuration.