Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Last active January 16, 2022 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stonehippo/e6a4882682a140419b8005068233fcdf to your computer and use it in GitHub Desktop.
Save stonehippo/e6a4882682a140419b8005068233fcdf to your computer and use it in GitHub Desktop.
Zsh aliases for managing access with the Adafruit MCP2221A breakout

Zsh aliases for Adafruit MCP2221A breakout

The AdafruitMCP2221A breakout is a handy little board for adding peripherals to a computer via USB. It provides UART, similar to a standard USB to serial interface, and adds GPIO, ADC, DAC, and I2C. This means you can use your computer to directly read sensors or control devices directly, without using a microcontroller.

Adafruit has added support for the MCP2221A to the CPython port of CircuitPython (Blinka). This means that you get a nice Python interface to work with all sorts of fun stuff.

The aliases in this gist reflect some settings that are needed in my MacOS setup to work with the MCP2221A breakout. I am using the now-default zsh, supplemented by the excellent Oh My Zsh, so I put this file in OMZ's custom location, $ZSH_CUSTOM.

For more information on the breakout, and getting it set up with Windows, MacOS, and Linux, check out the Adafruit MCP2221A guide.

Aliases

Alias Command Notes
mcp start MCP2221A session Fire up the Python under the Blinka virtualenv with MCP2221A support turned on
blinka start Blinka session Fire up the Python under the Blinka virtualenv
blinka_enable enable Blinka virtualenv I installed Aadfruit Blinka in it's own Python virtualenv, which I manage with pyenv
blinka_disable disable Blinka virtualenv
mcp_on check MCP2221A status For CircuitPython to work with the MCP2221A, an environment variable must be set. Return the current state
mcp_enable enable MCP2221A support
mcp_enable disable MCP2221A support
alias blinka_enable="pyenv activate blinka"
alias blinka_disable="pyenv deactivate"
alias blinka="blinka_enable && python && blinka_disable"
# Support for MCP2221A breakout
alias mcp_on="echo $BLINKA_MCP2221"
alias mcp_enable="export BLINKA_MCP2221=\"1\""
alias mcp_disable="export BLINKA_MCP2221=\"0\""
alias mcp="mcp_enable && blinka && mcp_disable"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment