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

Add support for "fake" MCP2221 #807

Merged
merged 15 commits into from Apr 5, 2024
Merged

Conversation

brentru
Copy link
Member

@brentru brentru commented Apr 2, 2024

This pull request adds Blinka support for a "fake" MCP2221 device. This means that no device is attached and the environment will mock the CircuitPython hardware API layer.

To test, set the following environment variables in either your shell or a CPython script:

os.environ["BLINKA_FORCEBOARD"] = "MICROCHIP_MCP2221"
os.environ["BLINKA_ FORCECHIP"] = "MCP2221"

Implemented and tested on CPython:

  • Digital Input
    • Returns a True/False value, toggles between them on each call
  • Analog Input
    • Returns an arbitrary 16-bit value
  • I2C
    • Scan (returns reasonable values, otherwise can feed the scan() function it a list of arguments as a test stimuli)
    • Support for "Fake BME280" driver
      • This driver mocks the functionality of the Adafruit_CircuitPython_BME280, allowing you to test your code without attaching physical hardware. Instead of using random data, weather data is instead pulled from the OpenWeatherMaps API and returned as if it were coming from the BME280 sensor properties.

Copy link
Contributor

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

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

There are a bunch of code blocks where it leaves the slimmest possibility of it not functioning as intended. Other than that, it looks good.

src/board.py Outdated Show resolved Hide resolved
src/busio.py Outdated Show resolved Hide resolved
src/digitalio.py Outdated Show resolved Hide resolved
src/microcontroller/__init__.py Outdated Show resolved Hide resolved
src/microcontroller/pin.py Outdated Show resolved Hide resolved
src/analogio.py Outdated Show resolved Hide resolved
Copy link
Contributor

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you.

@makermelissa makermelissa merged commit 2e47afc into adafruit:main Apr 5, 2024
1 check passed
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.

None yet

2 participants