opsoro.hardware

This module defines the interface for communicating with the shield.

class opsoro.hardware._Hardware[source]

Bases: object

__init__()[source]

Hardware class, used to communicate with the shield.

led_off()[source]

Turns status LED off.

led_on()[source]

Turns status LED on.

ping()[source]

Returns True if OPSOROHAT rev3 is connected.

Returns:True if shield is connected
Return type:bool
reset()[source]

Resets the ATmega328, MPR121 and PCA9685.

opsoro.hardware.analog

class opsoro.hardware.analog.Analog[source]

Bases: object

read_all_channels()[source]

Reads all analog channels and returns them as a list.

Returns:analog values
Return type:list
read_channel(channel)[source]

Reads the value of a single analog channel.

Parameters:channel (int) – analog channel to read
Returns:analog value of the channel
Return type:var

opsoro.hardware.capacitive

class opsoro.hardware.capacitive.Capacitive[source]

Bases: object

get_baseline_data()[source]

Get list of electrode baseline data. Result is 10 bits, but the 2 least significant bits are set to 0.

Returns:electrode baseline data (10 bits).
Return type:list
get_filtered_data()[source]

Get list of electrode filtered data (10 bits per electrode).

Returns:electrode filtered data (10 bits per electrode).
Return type:list
get_touched()[source]

Returns the values of the touch registers, each bit corresponds to one electrode.

Returns:values of the touch registers,
Return type:list
init(electrodes, gpios=0, autoconfig=True)[source]

Initialize the MPR121 capacitive touch sensor.

Parameters:
  • electrodes (int) – amount of electrodes
  • gpios (int) – amount of gpios
  • autoconfig (bool) –
read_gpio()[source]

Returns the status of all GPIO channels, each bit corresponds to one gpio channel.

Returns:status of all GPIO channels.
Return type:list
set_gpio_pinmode(gpio, pinmode)[source]

Sets a GPIO channel’s pin mode.

Parameters:
  • gpio (int) – gpio channel
  • pinmode (int) – pinmode to set
set_threshold(electrode, touch, release)[source]

Set an electrode’s touch and release threshold.

Parameters:
  • electrode (int) – index of electrode
  • touch (int) – threshold value for touch detection
  • release (int) – threshold value for release detection
write_gpio(gpio, data)[source]

Set GPIO channel value.

Parameters:
  • gpio (int) – gpio channel
  • data (int) – data to write to gpio channel.

opsoro.hardware.dummy_spidev

class opsoro.hardware.dummy_spidev.SpiDev[source]

Bases: object

__init__()[source]
open(*args)[source]
xfer2(*args)[source]

opsoro.hardware.i2c

class opsoro.hardware.i2c.I2C[source]

Bases: object

detect(addr)[source]

Returns True if an I2C device is found at a particular address.

Parameters:addr (int) – address of the I2C device.
Returns:I2C device detected
Return type:bool
read16(addr, reg)[source]

Read 2 bytes from an I2C device.

Parameters:
  • addr (int) – address of the I2C device.
  • reg (int) – register address in the I2C device
Returns:

2 Bytes

Return type:

var

read8(addr, reg)[source]

Read a Byte from an I2C device.

Parameters:
  • addr (int) – address of the I2C device.
  • reg (int) – register address in the I2C device
Returns:

what is the function returning?

Return type:

var

write16(addr, reg, data)[source]

Write 2 bytes to an I2C device.

Parameters:
  • addr (int) – address of the I2C device.
  • reg (int) – register address in the I2C device
  • data (var) – Bytes to send
write8(addr, reg, data)[source]

Write a Byte to an I2C device.

Parameters:
  • addr (int) – address of the I2C device.
  • reg (int) – register address in the I2C device
  • data (var) – Byte to send

opsoro.hardware.neopixel

class opsoro.hardware.neopixel.Neopixel[source]

Bases: object

disable()[source]

Turns off the NeoPixel MOSFET, disabling the NeoPixels. Data is lost when pixels are disabled.

enable()[source]

Turns on the NeoPixel MOSFET, enabling the NeoPixels. Data is lost when pixels are disabled, so call show() again afterwards.

init(num_leds)[source]

Initialize the NeoPixel library.

Parameters:num_leds (int) – number of neopixel leds.
set_all(r, g, b)[source]

Set the color of the entire strip.

Parameters:
  • r (int) – red color value (0-255)
  • g (int) – green color value (0-255)
  • b (int) – blue color value (0-255)
set_all_hsv(h, s, v)[source]

Set the HSV color of the entire strip.

Parameters:
  • h (int) – hue color value (0-255)
  • s (int) – saturation color value (0-255)
  • v (int) – value color value (0-255)
set_brightness(brightness)[source]

Set the NeoPixel’s global brightness, 0-255.

Parameters:brightness (int) – brightness to set (0-255)
set_pixel(pixel, r, g, b)[source]

Set the color of a single pixel.

Parameters:
  • pixel (int) – pixel index
  • r (int) – red color value (0-255)
  • g (int) – green color value (0-255)
  • b (int) – blue color value (0-255)
set_pixel_hsv(pixel, h, s, v)[source]

Set the HSV color of a single pixel.

Parameters:
  • pixel (int) – pixel index
  • h (int) – hue color value (0-255)
  • s (int) – saturation color value (0-255)
  • v (int) – value color value (0-255)
set_range(start, end, r, g, b)[source]

Set the color of a range of pixels.

Parameters:
  • start (int) – start index of led range
  • end (int) – end index of led range
  • r (int) – red color value (0-255)
  • g (int) – green color value (0-255)
  • b (int) – blue color value (0-255)
set_range_hsv(start, end, h, s, v)[source]

Set the HSV color of a range of pixels.

Parameters:
  • start (int) – start index of led range
  • end (int) – end index of led range
  • h (int) – hue color value (0-255)
  • s (int) – saturation color value (0-255)
  • v (int) – value color value (0-255)
show()[source]

Sends the pixel data from the ATmega328 to the NeoPixels.

opsoro.hardware.servo

class opsoro.hardware.servo.Servo[source]

Bases: object

disable()[source]

Turns off the servo power MOSFET, disabling all servos.

enable()[source]

Turns on the servo power MOSFET, enabling all servos.

init()[source]

Set up the PCA9685 for driving servos.

neutral()[source]

Set all servos to 1500us.

set(channel, pos)[source]

Set the position of one servo. Pos in us, 500 to 2500

Parameters:
  • channel (int) – channel of the servo
  • pos (int) – position of the servo (500 to 2500)
set_all(pos_list)[source]

Set position of all 16 servos using a list.

Parameters:pos_list (list) – list of servo positions
set_all_us(us)[source]

Set all servos to a certain position (us)

Parameters:us (int) – position in us

opsoro.hardware.spi

This module defines the interface for communicating with SPI.

class opsoro.hardware.spi._SPI[source]

Bases: object

__init__()[source]

SPI class, used to communicate with the shield.

command(cmd, params=None, returned=0, delay=0)[source]
Send a command over the SPI bus to the ATmega328. Optionally reads the result buffer and returns those Bytes.
Parameters:
  • cmd (string) – spi command
  • params (strin) – parameters for the command
  • returned (int) – size of result reading
  • delay (int) – delay between sending the command and reading the result
Returns:

result buffer (Bytes)

Return type:

list

opsoro.hardware.usb_serial

opsoro.hardware.usb_serial

alias of opsoro.hardware.usb_serial