Additional Drivers¶
|
Supports MCP23017 instance on specified I2C bus and optionally at the specified I2C address. |
|
Driver for the LSM9DS1 accelerometer, magnetometer, gyroscope. |
MCP23017 I/O Expander Driver¶
Python module for the MCP23017 I2C I/O extender.
Based on https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx.git
-
class
pipuck.mcp23017.
DigitalInOut
(pin_number, mcp230xx)¶ Digital input/output of the MCP230xx. The interface is exactly the same as the digitalio.DigitalInOut class (however the MCP230xx does not support pull-down resistors and an exception will be thrown attempting to set one).
Specify the pin number of the MCP230xx (0…7 for MCP23008, or 0…15 for MCP23017) and MCP23008 instance.
-
property
direction
¶ The direction of the pin, either True for an input or False for an output.
-
property
pull
¶ Enable or disable internal pull-up resistors for this pin. A value of _MCP23017_PULL_UP will enable a pull-up resistor, and None will disable it. Pull-down resistors are NOT supported!
-
switch_to_input
(pull=None)¶ Switch the pin state to a digital input with the provided starting pull-up resistor state (optional, no pull-up by default). Note that pull-down resistors are NOT supported!
-
switch_to_output
(value=False)¶ Switch the pin state to a digital output with the provided starting value (True/False for high or low, default is False/low).
-
property
value
¶ The value of the pin, either True for high or False for low. Note you must configure as an output or input appropriately before reading and writing this value.
-
property
-
class
pipuck.mcp23017.
MCP23017
(i2c_bus, address=32)¶ Supports MCP23017 instance on specified I2C bus and optionally at the specified I2C address.
-
clear_inta
()¶ Clears port A interrupts.
-
clear_intb
()¶ Clears port B interrupts.
-
clear_ints
()¶ Clears interrupts by reading INTCAP.
-
property
default_value
¶ The raw DEFVAL interrupt control register. The default comparison value is configured in the DEFVAL register. If enabled (via GPINTEN and INTCON) to compare against the DEFVAL register, an opposite value on the associated pin will cause an interrupt to occur.
-
get_pin
(pin)¶ Convenience function to create an instance of the DigitalInOut class pointing at the specified pin of this MCP23017 device.
-
property
gpio
¶ The raw GPIO output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.
-
property
gpioa
¶ The raw GPIO A output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.
-
property
gpiob
¶ The raw GPIO B output register. Each bit represents the output value of the associated pin (0 = low, 1 = high), assuming that pin has been configured as an output previously.
-
property
gppu
¶ The raw GPPU pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!
-
property
gppua
¶ The raw GPPU A pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!
-
property
gppub
¶ The raw GPPU B pull-up register. Each bit represents if a pull-up is enabled on the specified pin (1 = pull-up enabled, 0 = pull-up disabled). Note pull-down resistors are NOT supported!
-
property
int_flag
¶ Returns a list with the pin numbers that caused an interrupt port A —-> pins 0-7 port B —-> pins 8-15
-
property
int_flaga
¶ Returns a list of pin numbers that caused an interrupt in port A pins: 0-7
-
property
int_flagb
¶ Returns a list of pin numbers that caused an interrupt in port B pins: 8-15
-
property
interrupt_configuration
¶ The raw INTCON interrupt control register. The INTCON register controls how the associated pin value is compared for the interrupt-on-change feature. If a bit is set, the corresponding I/O pin is compared against the associated bit in the DEFVAL register. If a bit value is clear, the corresponding I/O pin is compared against the previous value.
-
property
interrupt_enable
¶ The raw GPINTEN interrupt control register. The GPINTEN register controls the interrupt-on-change feature for each pin. If a bit is set, the corresponding pin is enabled for interrupt-on-change. The DEFVAL and INTCON registers must also be configured if any pins are enabled for interrupt-on-change.
-
property
io_control
¶ The raw IOCON configuration register. Bit 1 controls interrupt polarity (1 = active-high, 0 = active-low). Bit 2 is whether irq pin is open drain (1 = open drain, 0 = push-pull). Bit 3 is unused. Bit 4 is whether SDA slew rate is enabled (1 = yes). Bit 5 is if I2C address pointer auto-increments (1 = no). Bit 6 is whether interrupt pins are internally connected (1 = yes). Bit 7 is whether registers are all in one bank (1 = no).
-
property
iodir
¶ The raw IODIR direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.
-
property
iodira
¶ The raw IODIR A direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.
-
property
iodirb
¶ The raw IODIR B direction register. Each bit represents direction of a pin, either 1 for an input or 0 for an output mode.
-
LSM9DS1 IMU Driver¶
Sensor driver for the LSM9DS1 IMU.
Based on https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS1 with patches to use SMBus and to fix some minor inconsistencies compared to the datasheet.
-
class
pipuck.lsm9ds1.
LSM9DS1
(i2c_bus, mag_address=30, xg_address=107)¶ Driver for the LSM9DS1 accelerometer, magnetometer, gyroscope.
Initialise the LSM9DS1.
-
property
accel_range
¶ Accelerometer range.
- Must be a value of:
ACCELRANGE_2G
ACCELRANGE_4G
ACCELRANGE_8G
ACCELRANGE_16G
-
property
acceleration
¶ Accelerometer X, Y, Z axis values as a 3-tuple of m/s^2 values.
-
close
()¶ Close the I2C bus.
-
property
gyro
¶ Gyroscope X, Y, Z axis values as a 3-tuple of degrees/second values.
-
property
gyro_scale
¶ Gyroscope scale.
- Must be a value of:
GYROSCALE_245DPS
GYROSCALE_500DPS
GYROSCALE_2000DPS
-
property
mag_gain
¶ Magnetometer gain.
- Must be a value of:
MAGGAIN_4GAUSS
MAGGAIN_8GAUSS
MAGGAIN_12GAUSS
MAGGAIN_16GAUSS
-
property
magnetic
¶ Magnetometer X, Y, Z axis values as a 3-tuple of gauss values.
-
read_accel_raw
()¶ Read raw accelerometer sensor and return it as a 3-tuple of X, Y, Z values that are 16-bit unsigned values.
If you want the acceleration in nice units you probably want to use the accelerometer property!
-
read_gyro_raw
()¶ Read raw gyroscope sensor values and return as a 3-tuple of X, Y, Z values that are 16-bit unsigned values.
If you want the gyroscope in nice units you probably want to use the gyroscope property!
-
read_mag_raw
()¶ Read raw magnetometer sensor and return as a 3-tuple of X, Y, Z values that are 16-bit unsigned values.
If you want the magnetometer in nice units you probably want to use the magnetometer property!
-
read_temp_raw
()¶ Read the raw temperature sensor value and return it as a 12-bit signed value.
If you want the temperature in nice units you probably want to use the temperature property!
-
property
temperature
¶ Temperature of the sensor in degrees Celsius.
-
property
VL53L1X ToF Sensor Driver¶
-
VL53L1X.
VL53L1X
¶
See https://github.com/pimoroni/vl53l1x-python/tree/multiple-i2c-bus-support.