adafruit_blinka - Runtime utility objects for re-implementation of CircuitPython API

  • Author(s): cefn
class adafruit_blinka.ContextManaged

An object that automatically deinitializes hardware with a context manager.

deinit()

Free any hardware used by the object.

class adafruit_blinka.Enum

Object supporting CircuitPython-style of static symbols as seen with Direction.OUTPUT, Pull.UP

classmethod iteritems()

Inspects attributes of the class for instances of the class and returns as key,value pairs mirroring dict#iteritems

class adafruit_blinka.Lockable

An object that must be locked to prevent collisions on a microcontroller resource.

try_lock()

Attempt to grab the lock. Return True on success, False if the lock is already taken.

unlock()

Release the lock so others may use the resource.

adafruit_blinka.patch_system()

Patch modules that may be different due to the platform.

Allows useful indirection to test Pin naming logic by switching platform in testing or provide bootstrapping logic for board identification where auto-detection is not feasible (e.g. multiple ESP8266 boards architecturally identical). Once runtime environment is established, can choose various routes to make available and re-export common modules and operations, depending on platform support

analogio - Analog input and output control

See analogio in CircuitPython for more details. Not supported by all boards.

  • Author(s): Carter Nelson, Melissa LeBlanc-Williams

bitbangio - Bitbanged bus protocols

See bitbangio in CircuitPython for more details.

  • Author(s): cefn
class bitbangio.I2C(scl, sda, frequency=400000)

Bitbang/Software I2C implementation

deinit()

Deinitialization

init(scl, sda, frequency)

Initialization

readfrom_into(address, buffer, start=0, end=None)

Read from a device at specified address into a buffer

scan()

Scan for attached devices

writeto(address, buffer, start=0, end=None, stop=True)

Write to a device at specified address from a buffer

class bitbangio.SPI(clock, MOSI=None, MISO=None)

Bitbang/Software SPI implementation

configure(baudrate=100000, polarity=0, phase=0, bits=8)

Update the configuration

readinto(buf)

Read from the SPI device into a buffer

write(buf)

Write to the SPI device

write_readinto(buffer_out, buffer_in)

Write to the SPI device and read from the SPI device into a buffer

board - Define ids for available pins

See board in CircuitPython for more details.

  • Author(s): cefn

busio - Bus protocol support like I2C and SPI

See busio in CircuitPython for more details.

  • Author(s): cefn
class busio.I2C(scl, sda, frequency=100000)

Busio I2C Class for CircuitPython Compatibility. Used for both MicroPython and Linux.

deinit()

Deinitialization

init(scl, sda, frequency)

Initialization

readfrom_into(address, buffer, *, start=0, end=None)

Read from a device at specified address into a buffer

scan()

Scan for attached devices

writeto(address, buffer, *, start=0, end=None, stop=True)

Write to a device at specified address from a buffer

writeto_then_readfrom(address, buffer_out, buffer_in, *, out_start=0, out_end=None, in_start=0, in_end=None, stop=False)

“Write to a device at specified address from a buffer then read from a device at specified address into a buffer

class busio.OneWire(pin)

Stub class for OneWire, which is currently not implemented

deinit()

Deinitialize the OneWire bus and release any hardware resources for reuse.

read_bit()

Read in a bit

reset()

Reset the OneWire bus and read presence

write_bit(value)

Write out a bit based on value.

class busio.SPI(clock, MOSI=None, MISO=None)

Busio SPI Class for CircuitPython Compatibility. Used for both MicroPython and Linux.

configure(baudrate=100000, polarity=0, phase=0, bits=8)

Update the configuration

deinit()

Deinitialization

frequency

Return the baud rate if implemented

readinto(buf, start=0, end=None, write_value=0)

Read from the SPI device into a buffer

write(buf, start=0, end=None)

Write to the SPI device

write_readinto(buffer_out, buffer_in, out_start=0, out_end=None, in_start=0, in_end=None)

Write to the SPI device and read from the SPI device into a buffer

class busio.UART(tx, rx, baudrate=9600, bits=8, parity=None, stop=1, timeout=1000, receiver_buffer_size=64, flow=None)

Busio UART Class for CircuitPython Compatibility. Used for MicroPython and a few other non-Linux boards.

class Parity

Parity Enumeration

deinit()

Deinitialization

read(nbytes=None)

Read from the UART

readinto(buf, nbytes=None)

Read from the UART into a buffer

readline()

Read a line of characters up to a newline charater from the UART

write(buf)

Write to the UART from a buffer

digitalio - Digital input and output control (GPIO)

See digitalio in CircuitPython for more details.

  • Author(s): cefn
class digitalio.DigitalInOut(pin)

DigitalInOut CircuitPython compatibility implementation

deinit()

Deinitialize the Digital Pin

direction

Get or Set the Digital Pin Direction

drive_mode

The Digital Pin Drive Mode

pull

The pin pull direction

switch_to_input(pull=None)

Switch the Digital Pin Mode to Input

switch_to_output(value=False, drive_mode=digitalio.DriveMode.PUSH_PULL)

Switch the Digital Pin Mode to Output

value

The Digital Pin Value

class digitalio.Direction

Direction Enumeration

class digitalio.DriveMode

Drive Mode Enumeration

class digitalio.Pull

PullUp/PullDown Enumeration

keypad - Support for scanning keys and key matrices

See keypad in CircuitPython for more details.

  • Author(s): Melissa LeBlanc-Williams
class keypad.Event(key_number=0, pressed=True)

A key transition event.

key_number

The key number.

pressed

True if the event represents a key down (pressed) transition. The opposite of released.

released

True if the event represents a key up (released) transition. The opposite of pressed.

class keypad.KeyMatrix(row_pins, column_pins, columns_to_anodes=True, interval=0.02, max_events=64)

Manage a 2D matrix of keys with row and column pins.

deinit()

Stop scanning and release the pins.

key_count

The number of keys that are being scanned. (read-only)

reset()

Reset the internal state of the scanner to assume that all keys are now released. Any key that is already pressed at the time of this call will therefore immediately cause a new key-pressed event to occur.

class keypad.Keys(pins, *, value_when_pressed, pull=True, interval=0.02, max_events=64)

Manage a set of independent keys.

deinit()

Stop scanning and release the pins.

key_count

The number of keys that are being scanned. (read-only)

reset()

Reset the internal state of the scanner to assume that all keys are now released. Any key that is already pressed at the time of this call will therefore immediately cause a new key-pressed event to occur.

class keypad.ShiftRegisterKeys(*, clock, data, latch, value_to_latch=True, key_count, value_when_pressed, interval=0.02, max_events=64)

Manage a set of keys attached to an incoming shift register.

deinit()

Stop scanning and release the pins.

events

The EventQueue associated with this Keys object. (read-only)

key_count

The number of keys that are being scanned. (read-only)

reset()

Reset the internal state of the scanner to assume that all keys are now released. Any key that is already pressed at the time of this call will therefore immediately cause a new key-pressed event to occur.

microcontroller - Pin references and cpu functionality

  • Author(s): Melissa LeBlanc-Williams
class microcontroller.Pin(pin_id)

Identifies an IO pin on the microcontroller.

They are fixed by the hardware so they cannot be constructed on demand. Instead, use board or microcontroller.pin to reference the desired pin.

microcontroller.delay_us(delay)

Sleep for delay usecs.

micropython - MicroPython Specific Decorator Functions

  • Author(s): cefn
micropython.asm_thumb(f)

User is attempting to use an inline assembler

micropython.const(x)

Emulate making a constant

micropython.native(f)

Emulate making a native

micropython.viper(f)

User is attempting to use a viper code emitter

neopixel_write - NeoPixel precision timed writing support

See neopixel_write in CircuitPython for more details. Currently supported on Raspberry Pi only.

  • Author(s): ladyada
neopixel_write.neopixel_write(gpio, buf)

Write buf out on the given DigitalInOut.

pulseio - Pulse Width Modulation input and output control

See pulseio in CircuitPython for more details. Not supported by all boards.

  • Author(s): Melissa LeBlanc-Williams

pwmio - Support for PWM based protocols

See pwmio in CircuitPython for more details. Not supported by all boards.

  • Author(s): Melissa LeBlanc-Williams

rainbowio - Provides the colorwheel() function

See rainbowio in CircuitPython for more details. Not supported by all boards.

  • Author(s): Kattni Rembor
rainbowio.colorwheel(color_value)

A colorwheel. 0 and 255 are red, 85 is green, and 170 is blue, with the values between being the rest of the rainbow.

Parameters:color_value (int) – 0-255 of color value to return
Returns:tuple of RGB values