Skip to content

Removing dependency on Bounce library saves 190 bytes. #34

Open
wants to merge 1 commit into from

2 participants

@lazyatom

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.

@lazyatom lazyatom Removing dependency on Bounce library saves 190 bytes.
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
1c0aa09
@lazyatom

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

@chrisroos

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

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
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

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

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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.