Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing dependency on Bounce library saves 190 bytes. #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lazyatom
Copy link
Contributor

I've copied the implementation of a software debouncer from the
Arduino website1. Using Arduino 1.0.1, before this commit the
sketch size is 29,906 bytes, and after it is 29,716 bytes.

However, the main benefit of this commit is that no non-standard
libraries are required to compile the sketch.

I've copied the implementation of a software debouncer from the
Arduino website[1]. Using Arduino 1.0.1, before this commit the
sketch size is 29,906 bytes, and after it is 29,716 bytes.

However, the main benefit of this commit is that no non-standard
libraries are required to compile the sketch.

[1]: http://arduino.cc/playground/Learning/SoftwareDebounce
@lazyatom
Copy link
Contributor Author

If we merge this, we should also update the instructions on the wiki (which mention, I believe, installing the Bounce library).

@chrisroos
Copy link
Contributor

Do we need to worry about debouncing at all? From my very limited understanding of debouncing I'm not sure it really applies to our situation. If we have a download waiting and see a button press then we'll start printing. If there are multiple other button presses almost immediately after the initial one then they'll essentially be ignored by our sketch, won't they?

@chrisroos
Copy link
Contributor

I just did a very scientific experiment* where I removed the debouncing code (i.e. I used digitalRead(buttonPin) to check for a button press) and sent a test print to my Printer. It downloaded successfully and I left the printer sat there with its green LED showing me that something was waiting (this was to see if we ever get false positives). Having satisfied myself that we weren't going to see any false positives, I pressed the button which sent the file to print. So, how would you feel about removing it entirely?

  • No science was involved

@lazyatom
Copy link
Contributor Author

lazyatom commented Aug 2, 2012

Without wanting to question your scientific veracity*, I think I've seen false positives in the past - particularly if you somehow manage to ground a part of the board by touching it. Can you repeat your experiment and handle the board a bit while the green LED is lit?

Also, how many bytes does removing the debouncing save?

  • if you weren't wearing a white coat, it ain't science.

@chrisroos
Copy link
Contributor

It takes us down to 28,348 bytes (29,602 with debug). I just left the Printer with a pending print (green LED) for 30 minutes, during which time I would occasionally pick it up and generally rub my grubby hands all over it. It didn't print until I pressed the button. This was with the soldered shield. I'm now going to try with the breadboard set-up.

@chrisroos
Copy link
Contributor

And now I've had it sitting on the green light for 30 minutes with the breadboard. Again I've had my grubby mitts all over it and still nothing. As soon as I press the button it prints...

@lazyatom
Copy link
Contributor Author

lazyatom commented Aug 2, 2012

After a bit more discussion and a bit more "science", we've come to the conclusion that debouncing is more about avoiding multiple button presses rather than preventing phantom button presses. Because subsequent button presses are ignored while the printer is printing, we don't really need to manage multiple presses, and therefore we can lose the debouncing code.

@lazyatom lazyatom force-pushed the master branch 2 times, most recently from b7c06fb to fc8edb8 Compare January 24, 2018 15:00
Base automatically changed from master to main January 15, 2021 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants