pyduinoincludes
is a SNAPpy library that is designed to make development for the Synapse Pyduino board easier. It
allows references to the nifty Pyduino IO names (like D3, AD0, or SCL) instead of the underlying SNAPpy GPIO numbers.
It also provides a bit-banged SPI implementation that can be used for shields that utilize the SPI pins.
Download and extract the latest release zip file to Portal's snappyImages
directory.
By default, this is located at ...\Documents\Portal\snappyImages
on Windows.
The easiest way to install pyduinoincludes
for use with SNAPbuild is using
pip:
pip install git+https://github.com/synapse-wireless/pyduino-includes.git@master
Alternatively you can download the source, extract it, and install it:
python setup.py install
In order to use the nice IO names, simply import pyduinoincludes
in your SNAPpy script like this:
from pyduinoincludes import *
def drive_d4_pin_high():
setPinDir(D4, True)
writePin(D4, True)
Pins can be referenced as follows:
Pin Type | Pyduino IO Name |
---|---|
Digital | D0 - D13 |
Analog | A0 - A5 |
i2c | SDA, SCL |
LED pin | LED_PIN |
5V sense | SENSE_5V |
Setting up the SPI pins is very simple, too:
from pyduinoincludes.spi import *
def my_spi_function():
spi_init() # Sets up the bit-banged SPI
spi_write("\x12\x34\x56") # Write data to the SPI bus
spi_read(4) # Read four bytes from the SPI bus
This library is available under Apache License version 2.0. See LICENSE.md for more information.
We love pull requests! For information on contributing to this project, please check out CONTRIBUTING.md.