Skip to content

Making the initialization of MCP23017 class optional? #23

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
postal opened this issue Mar 3, 2020 · 13 comments
Closed

Making the initialization of MCP23017 class optional? #23

postal opened this issue Mar 3, 2020 · 13 comments

Comments

@postal
Copy link

postal commented Mar 3, 2020

# Reset to all inputs with no pull-ups and no inverted polarity.

I have connected an MCP23017 to my Raspberry Pi. During reboot the MCP23017 is used to configure the inputs, outputs and pullup resistors. If I use the library afterwards, the configuration is reset when the class is initialized.

Is there a way to bypass the initialization?

@kattni kattni added the enhancement New feature or request label May 4, 2020
@evaherrada
Copy link
Collaborator

Maybe try something like what's discussed here:
https://stackoverflow.com/questions/38010391/share-python-objects-between-two-or-more-py-files

@tannewt
Copy link
Member

tannewt commented Jun 26, 2020

I'd suggest we add a reset=True kwarg that can be used to disable the reset on startup. This will be needed when CircuitPython can deep sleep and therefore the code.py runs from scratch each time.

@evaherrada
Copy link
Collaborator

@tannewt Ok, I'll take a look at doing that

@evaherrada
Copy link
Collaborator

hi @postal Can you share the code you're using? I'd like to be able to test this with that exact code so I can be sure what you're trying to do will work.

@postal
Copy link
Author

postal commented Jul 3, 2020

hi @dherrada, this is the script which is executed by cronjob after a restarting the Pi, to setup the mcp23017.

`#!/bin/bash
echo "setup all gpio on bank A to output (0x00)"
sudo i2cset -y 1 0x20 0x00 0x00
sudo i2cget -y 1 0x20 0x00

echo "setup all gpio on bank B to input (0xff)"
sudo i2cset -y 1 0x20 0x01 0xff
sudo i2cget -y 1 0x20 0x01

echo "setup pullup resistors on bank B (0xff)"
sudo i2cset -y 1 0x20 0x0D 0xff
sudo i2cget -y 1 0x20 0x0D
`

All these settings are reset when the library is initialized.

@evaherrada
Copy link
Collaborator

@postal Great. Thanks. I'll load this on my pi and try to add the reset keyword

@JuliaHorvath
Copy link

@dherrada Hey, I am having the same problem. Did you find any solution yet? :)

@evaherrada
Copy link
Collaborator

@JuliaHorvath Hey. I don't think I ever ended up getting to it. Is there a way to set those settings after the library has been initialized? If there is, that would probably be a pretty simple workaround.

@tannewt Is this still something you think I should do? If so, I can add to my list

@tannewt
Copy link
Member

tannewt commented Jan 14, 2021

@dherrada Yup! We should still do it. We actually have sleep support now so this will be even more useful.

@ladyada
Copy link
Member

ladyada commented Jan 15, 2021

@JuliaHorvath @postal can ya try the PR ?

@jposada202020 jposada202020 added needs retest and removed enhancement New feature or request labels May 12, 2021
@jposada202020
Copy link
Contributor

@JuliaHorvath @postal Let me know if you tried the PR. I think we are good to close this issue. Thanks.

@JuliaHorvath
Copy link

yes, it is working now! Thanks!

@jposada202020
Copy link
Contributor

@JuliaHorvath Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants