rlogiacco / AnalogButtons

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

Use Analog namespace. Remove unnecessary pin-mode argument. #1

Closed jtwalters closed 8 years ago

jtwalters commented 9 years ago

For analogRead, you don't have to specify a pin mode.

Not tested (yet). But, I wanted to get your feedback.

Since there's another Button arduino library, the namespace will allow both to be used in the same sketch.

rlogiacco commented 9 years ago

I'm not sure the pinMode is not necessary, can you provide a reference to documentation?

Regarding the namespace, while I do like the approach, I believe not many Arduino users are used to namespaces: why would the namespace usage improve on using both libraries together?

jtwalters commented 9 years ago

Here's a related thread that explains why pinMode is unnecessary for analogRead.

The namespace helps because I'm using another library (named Button) that has a class named Button with a different interface. It confuses the compiler and I'm unable to use both Button classes at once, since neither libraries are namespaced.

rlogiacco commented 8 years ago

Almost a year later, apologies... I suggest you add the namespace in your copy, I prefer this not to be the only namespaced library around.

With regards to the pinMode setting, it's correct in terms of being unnecessary, but it is executed only once and allows to chose between INPUT and INPUT_PULLUP, so I believe the overhead is ok compared to making the library user think about what they are doing.