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

Added virtual functions to allow easy adaption to other button-types … (e.g touch or IO extender) #50

Merged
merged 4 commits into from
Jan 11, 2019

Conversation

euphi
Copy link
Collaborator

@euphi euphi commented Nov 27, 2017

To be able to use Atm_button for buttons that are not directly connected to a GPIO I created virtual methods

	  virtual void initButton();
	  virtual bool isPressed();
	  virtual bool isReleased();

initButton() is called from begin() to initialize the button (e.g. set INPUT_PULLUP) the other methods are called from event() to check if they trigger the related event.

The default implementation still has the same behaviour as before, but this allows to derive an own class and overwrite these methods, so you can read other PINs, e.g a touch controller (like MPR121) or IO expander (PCF8575).

See https://github.com/euphi/ESP-Touch/blob/Display_WS2812/src/AtmTouchButton.cpp & https://github.com/euphi/ESP-Touch/blob/Display_WS2812/src/AtmTouchButton.h
for example usage with MPR121 I2C touch controller.

euphi added a commit to euphi/ESP-Touch that referenced this pull request Nov 27, 2017
See tinkerspy/Automaton#50

If this PR is merged and deployed (updated on platformio) it is possible
to go back to original automaton.
@euphi
Copy link
Collaborator Author

euphi commented Dec 9, 2017

I also added similar functionality to Atm_LED

@euphi euphi mentioned this pull request Jan 10, 2019
@tinkerspy tinkerspy merged commit 1cdfaa1 into tinkerspy:master Jan 11, 2019
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