SmartWaveAPI.configitems package
Module contents
All of the configuration items, such als pins, drivers, and stimuli, needed to configure a SmartWave device.
SmartWaveAPI.configitems.config module
- class SmartWaveAPI.configitems.config.Config(device, driver: Driver, stimulus: Stimulus)
Bases:
object
A collection of data, driver and pins used to send data via a protocol using the SmartWave.
- delete()
Delete this configuration and return all resources to the device.
- getRecorderId() int
Get the ID of the recorder associated with this Config object.
- Returns:
The recorder ID
- Return type:
int
- removeStimulusDriverConnection()
Remove the connection between the stimulus and the driver on the device.
- writeStimulusDriverConnectionToDevice()
Configure the connection between the stimulus and the driver on the device.
- writeToDevice()
Write the configurations of all relevant objects to the device.
SmartWaveAPI.configitems.driver module
- class SmartWaveAPI.configitems.driver.Driver(device, id: int)
Bases:
object
A hardware driver for a communication protocol
- color: str = None
- colorRGB565() int
Convert this driver’s color to an RGB565 value.
- Returns:
this driver’s color as an RGB565 value
- Return type:
int
- delete()
Delete this driver along with its pins and return all resources to the device.
- driverType: DriverType = None
- getId() int
Get the ID of this driver.
- Returns:
the ID of this driver
- Return type:
int
- removePinConnection(pinName: str)
Remove the pin connection from the device.
- Parameters:
pinName (str) – The name of the pin to remove
- writePinConnectionsToDevice()
Write the pin configuration (i.e. which pin does what) of this driver to the device.
- writePinsToDevice()
Write the configuration of each of this driver’s pins to the device.
- writeToDevice()
Write the configuration parameters of this driver to the device.
SmartWaveAPI.configitems.i2cconfig module
- class SmartWaveAPI.configitems.i2cconfig.I2CConfig(device, sdaPin: Pin | None = None, sclPin: Pin | None = None, clockSpeed: int | None = None)
Bases:
Config
A collection of data, driver and pins used to send data via I2C using the SmartWave.
- property clockSpeed: int
The driver’s transmission clock speed in Hz
- read(deviceId: int, length: int, blocking: bool = True) None | bytes
Read bytes from an I2C device.
If the same read transaction already exists on the device, the reconfiguration of the device is skipped.
- Parameters:
deviceId (int) – The I2C device ID to read from
length (int) – The number of bytes to read
blocking (bool) – If true, wait for the response from the connected device
- Returns:
If blocking == True, return the bytes that were read over I2C. Else return None.
- Return type:
Union[bytes, None]
- Raises:
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
- readRegister(deviceId: int, address: bytes, length: int, blocking: bool = True) None | bytes
Read bytes from an I2C device at a specified address.
If the same register transaction already exists on the device, the reconfiguration of the device is skipped.
- Parameters:
deviceId (int) – The I2C device ID to read from
address (bytes) – The address bytes where to read from on the I2C device
length (int) – The number of bytes to read
blocking (bool) – If true, wait for the response from the connected device
- Returns:
If blocking == True, return the bytes that were read over I2C. Else return None.
- Return type:
Union[List[int], None]
- Raises:
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
- setTransactions(transactions: List[I2CWrite | I2CRead])
Set the list of transactions and send the configuration to the connected device.
Also checks if the transactions were already the same, and skips reconfiguring the device if so.
- Parameters:
transactions (List[I2CTransaction]) – The list of transactions
- write(deviceId: int, data: bytes)
Write bytes over I2C with the connected device.
If the same write transaction already exists on the device, the reconfiguration of the device is skipped.
- Parameters:
deviceId (int) – The I2C device ID to write to
data (bytes) – The bytes to write to the I2C bus
- writeRegister(deviceId: int, address: bytes, value: bytes)
Write to a register on an I2C device.
If the same write transaction already exists on the device, the reconfiguration of the device is skipped.
- Parameters:
deviceId (int) – The I2C device ID to write to
address (bytes) – The address bytes of the target I2C register
value (bytes) – The value bytes of the target I2C register
SmartWaveAPI.configitems.i2cdriver module
- class SmartWaveAPI.configitems.i2cdriver.I2CDriver(device, id: int, clockSpeed: int = 400000.0)
Bases:
Driver
A hardware I2C driver on the SmartWave device
- property clockSpeed: int
The transmission clock speed in Hz
- color: str = '#a54be2'
- configure(clockSpeed: int | None = None)
Configure the settings of this driver and write them to the connected device.
- Parameters:
clockSpeed (int) – The transmission clock speed in Hz
- Raises:
AttributeError – If clockSpeed is not available on the device
- delete()
Unconfigure this driver along with its pins and return all resources to the device.
- driverType: DriverType = 1
- generateSamples(transactions: List[I2CWrite | I2CRead]) List[int]
Generate a stream of bytes for the SmartWave to interpret as I2C Transactions.
- Parameters:
transactions (I2CTransaction) – List of I2C transactions
- Returns:
List of samples for the SmartWave to interpret as I2C Transactions
- Return type:
List[int]
- writePinsToDevice()
Write the configuration of each of this driver’s pins to the device.
- writeToDevice()
Write the configuration parameters of this driver to the device.
SmartWaveAPI.configitems.pin module
- class SmartWaveAPI.configitems.pin.Pin(device, bank: Literal['A', 'B'], number: int)
Bases:
object
A hardware pin on the SmartWave device
- delete()
Unconfigure this pin and return its resources to the device.
- getBank() str
Get the bank this pin belongs to
- Returns:
The bank this pin belongs to
- Return type:
str
- getNumber() int
Get the number of this pin
- Returns:
The number of this pin
- Return type:
int
- id() int
Calculate the numerical ID of this pin.
- writeToDevice()
Write the configuration parameters of this pin to the device.
SmartWaveAPI.configitems.stimulus module
- class SmartWaveAPI.configitems.stimulus.Stimulus(device, id: int)
Bases:
object
A hardware stimulus on the SmartWave device
- delete()
- getId() int
Get the ID of this stimulus.
- Returns:
the ID of this stimulus
- Return type:
int
- stimulusType: int = 0
- writeToDevice()
Write the configuration parameters of this pin to the device.