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

Feather ESP32-S2: turn on I2C power after reset #5779

Merged

Conversation

dhalbert
Copy link
Collaborator

This is the pretty much the same as #5776, but is a PR against 7.1.x instead of main. I read the code and could not understand why it didn't work, and after trying it myself, I was unable to repoduce the D7 in use message.

@ladyada, could you test, in your own way? I was using this, with the DigitalInOut commented out and not.

import time
import board
import digitalio
import adafruit_bme280.basic

# Test with and without this.
# power = digitalio.DigitalInOut(board.I2C_POWER_INVERTED)
# power.switch_to_output(False)

i2c = board.I2C()  # uses board.SCL and board.SDA
bme280 = adafruit_bme280.basic.Adafruit_BME280_I2C(i2c)

while True:
    print("\nTemperature: %0.1f C" % bme280.temperature)
    print("Humidity: %0.1f %%" % bme280.relative_humidity)
    print("Pressure: %0.1f hPa" % bme280.pressure)
    print("Altitude = %0.2f meters" % bme280.altitude)
    time.sleep(2)

@dhalbert dhalbert requested a review from ladyada December 24, 2021 16:52
@dhalbert dhalbert mentioned this pull request Dec 24, 2021
@jepler
Copy link
Member

jepler commented Dec 24, 2021

I'm not sure about this change. Specifically, I think it may behave differently when merged to main, where we've taken

and specifically fae6d47 where we now ensure that a "never reset" pin continues is marked as "in use" after reset_all_pins().

This was needed to resolve a problem where the state of a displayio backlight pin was lost over soft resets.

@jepler jepler closed this Dec 24, 2021
@jepler jepler reopened this Dec 24, 2021
@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 24, 2021

That must be why it didn't work when I tested with an artifact from #5776.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Dec 24, 2021

@ladyada and I talked about turning on the power-enable in reset_board() instead of board_init(). reset_board() gets called each time the VM shuts down. That would cause any setting of the pin not to be sticky from boot.py to code.py, but that could be OK.

But #5674 makes the backlight pin unavailable for setting manually, I think. Is that OK?

@dhalbert
Copy link
Collaborator Author

and specifically fae6d47 where we now ensure that a "never reset" pin continues is marked as "in use" after reset_all_pins().

This is true only on espressif. As another example, something similar is done for CPB, so we might want to be consistent across ports.

I think never_reset is being overloaded with responsibilities. Maybe we need to separate "never reset" and "never allocate".

Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that did it! works great

@ladyada
Copy link
Member

ladyada commented Dec 24, 2021

can u cherrypick into 7.1?

@dhalbert
Copy link
Collaborator Author

can u cherrypick into 7.1?

This is already against 7.1.x, so it will go into 7.1.0-rc.1. We'll merge it into main as well.

@dhalbert dhalbert merged commit ab9cef7 into adafruit:7.1.x Dec 24, 2021
@dhalbert dhalbert deleted the feather-esp32-s2-turn-on-i2c-power-by-default branch December 24, 2021 23:21
@ladyada
Copy link
Member

ladyada commented Dec 24, 2021

ok rad thanks! this should help with customer confusions

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.

3 participants