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

Many updates including new held() and retrigger() #15

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

AlbertPhan
Copy link

Updated Constructors to do all the pin() and interval() setups. All the
setup can now be done in one step when instantiating the object. Added
held() and retrigger(). See examples. Updated other examples to use the
new constructor.

Updated Constructors to do all the pin() and interval() setups. All the
setup can now be done in one step when instantiating the object. Added
held() and retrigger(). See examples. Updated other examples to use the
new constructor.
@AlbertPhan AlbertPhan changed the title Many updates including held() and retrigger() Many updates including new held() and retrigger() Mar 27, 2015
@thomasfredericks
Copy link
Owner

All the setup can now be done in one step when instantiating the object.

The thing is you want to setup the pin before attaching it. That is why it was moved to the separate attach() function.

Added held() and retrigger().

retrigger() is a common request and held() is an interesting addition. Instead of having a separate variable, maybe the held time could be passed in the function? Like held(500) ?

@AlbertPhan
Copy link
Author

Oh I see what you mean with the attach(). I'll move it out of the constructor and do some more updates.

@AlbertPhan
Copy link
Author

I can move the attach() function to run at the first time update() is called so we could still have it all in one constructor and after the pin is setup. I'm not sure I can add the held(500) easily since all the code for that function is in update() and requires a separate variable. I did have to add many more variables to the program to get the functionality of held and retrigger but I feel it was worth the extra bytes. I'll take a look again and see if I can reduce the extra variables in any way.

attach() is now called the first time update() is run so the pin setup
is before attach(). I also removed previous_millis_retrigger to save 4
bytes. Also updated retrigger.ino example with a few more comments.
Function wasn't properly returning a false when held() was low.
This caused people to use retrigger() to have it constantly return a 1
when using active low buttons.
@exabrial
Copy link

exabrial commented Nov 3, 2017

Whats the status on this? Looks very handy!

@NelsonVides
Copy link

Should be on a different object, this would increase the size of the object, which is not good on a limited Arduino Uno with already too many objects going around. Might be implemented in a children class for example, that way if we don't need this extra functionality we can just instantiate the parent and keep a smaller object.

@AlbertPhan
Copy link
Author

AlbertPhan commented Jan 3, 2018 via email

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.

4 participants