8000 Added support for pull down control buttons by stzoran1 · Pull Request #701 · HomeSpan/HomeSpan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added support for pull down control buttons #701

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

Closed
wants to merge 1 commit into from

Conversation

stzoran1
Copy link

See #645

@stzoran1
Copy link
Author

If you like this new feature I can update docs before merge. Please let me know.

@HomeSpan
Copy link
Owner

Thanks, but I think it would be more generic to simply add a second optional argument to setControlButton to allow the user to specify the Trigger Type, which could be one of the built-ins, or a complete custom function:

setControlPin(uint8_t pin, triggerType_t triggerType=TRIGGER_ON_LOW){controlButton=new PushButton(pin, triggerType_t);}

I can add this to the next release (in progress at release-1.8.1-dev)

@stzoran1
Copy link
Author

I completely agree @HomeSpan

@HomeSpan
Copy link
Owner

Completed.

homeSpan.setControlPin() now accepts a second optional argument specifying the trigger type using the same logic as SpanButton. Choices are:

SpanButton::TRIGGER_ON_LOW --- for control pin connected to ground through a pushbutton (the default)
SpanButton::TRIGGER_ON_HIGH --- for control pin connected to VCC through a pushbutton
SpanButton::TRIGGER_ON_TOUCH --- for a control pin connected to a touch sensor (not really recommended for this use)

or you can provide your own trigger function of form boolean f(int pin) For example, using a lambda function:

pinMode(21,OUTPUT);
homeSpan.setControlPin(21, [](int pin)->boolean{ return(digitalRead(pin)); } );

is equivalent to:

homeSpan.setControlPin(21, SpanButton::TRIGGER_ON_HIGH);

Note as per above, if you specify your own trigger function, you need to explicitly configure the pin (or whatever device you are using for the control pin).

Code is updated in 1.8.1-dev branch and will be part of next production release (with documentation updated accordingly).

Thanks again for the suggestion.

@HomeSpan HomeSpan closed this Jan 13, 2024
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
0