-
Notifications
You must be signed in to change notification settings - Fork 73
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
base: main
Are you sure you want to change the base?
Conversation
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
If we merge this, we should also update the instructions on the wiki (which mention, I believe, installing the Bounce library). |
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? |
I just did a very scientific experiment* where I removed the debouncing code (i.e. I used
|
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?
|
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. |
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... |
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. |
b7c06fb
to
fc8edb8
Compare
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.