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

How to get rid of #define PIN_INPUT? #143

Open
mister-Monk opened this issue Jun 27, 2024 · 1 comment
Open

How to get rid of #define PIN_INPUT? #143

mister-Monk opened this issue Jun 27, 2024 · 1 comment

Comments

@mister-Monk
Copy link

I want to use the GPIO number obtained from SPIFFS in OneButton.
Something like this:

#include <OneButton.h>
#include <FS.h>

void setup()
{
File _file = SPIFFS.open
...
BUTTON_pin = r_c.toInt();
...
OneButton button1(BUTTON_pin, true, true);
}

Is this possible? How?

@mister-Monk
Copy link
Author

mister-Monk commented Jun 27, 2024

This is what I did:

Added a copy OneButton::OneButton to the library

void initOB(const int pin, const boolean activeLow = true, const bool pullupActive = true);

void OneButton::initOB(const int pin, const boolean activeLow, const bool pullupActive)
{
// OneButton();
_pin = pin;

if (activeLow) {
// the button connects the input pin to GND when pressed.
_buttonPressed = LOW;
...

Further

#include <OneButton.h>
#include <FS.h>

OneButton button1;

void setup()
{
File _file = SPIFFS.open
...
BUTTON_pin = r_c.toInt();
...
button1.initOB(BUTTON_pin, true, true);
}

It works. But I'm not sure if this is the right way.

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

No branches or pull requests

1 participant