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

Input pull-up doesn't work on expanders #1833

Open
scottgonzalez opened this issue Oct 5, 2023 · 1 comment
Open

Input pull-up doesn't work on expanders #1833

scottgonzalez opened this issue Oct 5, 2023 · 1 comment

Comments

@scottgonzalez
Copy link
Contributor

I'm using an MCP23017, which supports pull-up resistors on all pins. When initializing a button with isPullup: true, the pull-up resistor is not activated on the pin.

@scottgonzalez
Copy link
Contributor Author

I found a way to get this working. Here's more context and some follow-up questions:

I expected the following code to work:

    const expander = new five.Expander({
      controller: "MCP23017",
      address: 0x21,
    });
    const virtual = new five.Board.Virtual(expander);

    const button = new five.Button({
      board: virtual,
      isPullup: true,
      pin: 5,
    });

However, this only configures the pin to be an input pin, without the internal pull-up resistor enabled. Looking through the code, I saw that the MCP23017 code does have support for controlling the pull-up registers and I was able to get the button to work with the following code:

    const expander = new five.Expander({
      controller: "MCP23017",
      address: 0x21,
    });
    const virtual = new five.Board.Virtual(expander);

    // ADDED COMMAND
    expander.pullUp(5, virtual.io.HIGH)

    const button = new five.Button({
      board: virtual,
      isPullup: true,
      pin: 5,
    });

So I have two questions:

  1. Is the expectation that the first block of code should have worked?
  2. If the button API alone is not expected to work, is my current approach correct or am I reaching too far into the internals?

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