Pages: [1]   Go Down
Author Topic: Bug in AnalogButtons library  (Read 791 times)
0 Members and 1 Guest are viewing this topic.
Italy
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone, I think I have found a bug in AnalogButtons library, which I am using for a project since... 2 years ago!!!!  smiley-eek-blue

For anyone of you interested the bug is caused by:

Code:
void AnalogButtons::checkButtons()
{
  if (millis() + time > 70) // don't sample analog more than 70 ms
    {..

time is a class variable which is used to check if 70 ms (in this case) are over.
But of course we need the minus sign to check the current time (millis) against the previous saved time:
Code:
if (millis() - time > 70)

The IF in the original version is (almost) always true, this is way the library is actually working.

I cannon contact the author of the library, so I taught I could post this bug here.
Sorry if the forum is not the correct place...



Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13739
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Do you have a link to this (better the latest) analogButtons library?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Italy
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No.. the last version you can find is the buggy one... here..

http://playground.arduino.cc/Code/AnalogButtons

I cannot contact the author. Maybe I should fill in a bug report in github, but I don't have an account yet..

In my previous message you can find all the correct code, which should work as expected. I tested it on my actual project, which has been working for 2 years already.


Logged

Pages: [1]   Go Up
Jump to: