Skip to content

Digital outputs start high after initialization #7

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
diosdog opened this issue Mar 1, 2020 · 2 comments
Closed

Digital outputs start high after initialization #7

diosdog opened this issue Mar 1, 2020 · 2 comments

Comments

@diosdog
Copy link

diosdog commented Mar 1, 2020

According to the SX1509 datasheet, digital outputs default to high on initialization. This is the opposite of what's typically expected for Arduino outputs. With the current library setup, it appears impossible to avoid this, as performing a digitalWrite prior to setting a pin as an output changes the pullup/pulldown settings instead of the RegData register value. Ideally, there would be a way to specify the initial value prior to enabling an output. I see several possible solutions:

  1. Support an optional extra argument to pinMode to specify starting output level.
  2. Add a separate function to specify default output level, to be called prior to setting a pin as an output.
  3. Check the pullup/pulldown state to determine initial output state, allowing setting of initial output level by setting pullup/pulldown state prior to pin direction change.
  4. Change to default low on startup by always writing bit in RegData to low whenever about to set a pin as an output, to match Arduino behavior (however, this might cause unexpected behavior for previous scripts using the library)
@Bascy
Copy link
Contributor

Bascy commented Oct 14, 2021

I think this is already solved in commit a7c9317 using your #1 suggestion

@nseidle
Copy link
Member

nseidle commented Oct 14, 2021

Thanks @Bascy - I thought so. Please re-open if needed.

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

3 participants