SmartWaveAPI.configitems package
All 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, driver_id: int)
Bases:
object
A hardware driver for a communication protocol
- color: str = None
- 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(pin_name: str)
Remove the pin connection from the device.
- Parameters:
pin_name (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.gpio module
- class SmartWaveAPI.configitems.gpio.GPIO(device, pin: Pin, name: str = 'GPIO', level: Literal[0, 1] = 0, pullup: bool = False, output_type: PinOutputType = PinOutputType.Disable, input_level_callback: Callable[[Literal[0, 1]], None] | None = None)
Bases:
object
A hardware GPIO pin on the SmartWave device.
- color: str = '#435880'
- configure(name: str | None = None, level: Literal[0, 1] | None = None, pullup: bool | None = None, output_type: PinOutputType | None = None)
Configure the settings of this GPIO pin and write them to the connected device.
- Parameters:
name (str) – The name of the pin, displayed on the device
level (Literal[0, 1]) – The initial level of the pin
pullup (bool) – Whether to enable a pullup resistor on the pin
output_type (PinOutputType) – The output type of the pin
- delete()
Delete this GPIO pin and return all resources to the device.
- driverType: DriverType = 4
- property inputLevel: Literal[0, 1]
Get the current input level.
- Returns:
Current input level.
- Return type:
Literal[0, 1]
- property inputLevelCallback: Callable[[Literal[0, 1]], None] | None
Get the current registered input level callback.
The input level callback is a function that is called whenever the input level on the pin changes.
- Returns:
Current registered callback
- Return type:
Optional[Callable[[Literal[0, 1]], None]]
- property level: Literal[0, 1]
The output level of the pin.
- Returns:
The output level of the pin.
- Return type:
Literal[0, 1]
- property name: str
The name of the pin.
- Returns:
The name of the pin.
- Return type:
str
- property outputType: PinOutputType
The output type of the pin.
- Returns:
The output type of the pin
- Return type:
- property pullup: bool
Whether the pullup is enabled on the pin.
- Returns:
Whether the pullup is enabled on the pin.
- Return type:
bool
SmartWaveAPI.configitems.i2cconfig module
- class SmartWaveAPI.configitems.i2cconfig.I2CConfig(device, sda_pin: Pin | None = None, scl_pin: Pin | None = None, clock_speed: int | None = None, scl_display_name: str | None = None, sda_display_name: str | 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(device_id: int, length: int, blocking: bool = True, timeout: float | None = 1.0) None | I2CTransactionResult
Read bytes from an I2C device.
If the same read transaction already exists on the device, the reconfiguration of the device is skipped.
- Parameters:
device_id (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
timeout (Union[float, None]) – How long to wait for the response from the device in seconds. Ignored if blocking is set to False, default 1s, set to None to deactivate timeout.
- Returns:
If blocking == True, return the information on the transaction on the I2C bus. Else return None.
- Return type:
Union[None, I2CTransactionResult]
- Raises:
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
TimeoutError – If the timeout for reading back from the device is exceeded.
- readRegister(device_id: int, address: bytes, length: int, blocking: bool = True, timeout: float | None = 1.0) bytes | None
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:
device_id (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
timeout (Union[float, None]) – How long to wait for the response from the device in seconds. Ignored if blocking is set to False, default 1s, set to None to deactivate timeout.
- Return type:
Union[List[int], None]
- Returns:
If blocking == True, return the read bytes from the target device or throw an Error if the connection failed. If blocking == False, return None.
- Return type:
Union[bytes, None]
- Raises:
ConnectionError – If the transaction on the I2C bus was not acknowledged by the target device.
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
TimeoutError – If the timeout for reading back from the device is exceeded.
- scanAddresses(range_lower: int = 0, range_upper: int = 127, timeout: float | None = 5.0) List[int]
Scan a given range of addresses on the I2C Bus and return the list of connected device IDs.
- Parameters:
range_lower (int) – The address at which to start searching
range_upper (int) – The address at which to stop searching
timeout (Union[float, None]) – How long to wait for the response from the device in seconds. Default 5s, set to None to deactivate timeout.
- Returns:
A list of connected device IDs
- Return type:
List[int]
- Raises:
ValueError – If the range is not within [0x00, 0x7f] or range_lower is bigger than range_upper
Exception – If another callback for a readback operation is already registered
- property sclDisplayName: str
The name to display for the driver’s SCL pin
- property sdaDisplayName: str
The name to display for the driver’s SDA pin
- sendTransactions(transactions: List[I2CWrite | I2CRead], blocking: bool = True, timeout: float | None = 1.0) None | List[I2CTransactionResult]
Send a transaction over I2C with the connected device.
If the same transaction already exists on the device, the reconfiguration of the device is skipped.
- Parameters:
transactions (List[I2CTransaction]) – The transaction to perform on the bus
blocking (bool) – If true, wait for the response from the connected device
timeout (Union[float, None]) – How long to wait for the response from the device in seconds. Ignored if blocking is set to False, default 1s, set to None to deactivate timeout.
- Returns:
If blocking == true, return the information about the transaction on the I2C bus. Else return None.
- Return type:
Union[None, List[I2CTransactionResult]]
- Raises:
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
TimeoutError – If the timeout for reading back from the device is exceeded.
- 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(device_id: int, data: bytes, blocking: bool = True, timeout: float | None = 1.0) None | I2CTransactionResult
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:
device_id (int) – The I2C device ID to write to
data (bytes) – The bytes to write to the I2C bus
blocking (bool) – If true, wait for the response from the connected device
timeout (Union[float, None]) – How long to wait for the response from the device in seconds. Ignored if blocking is set to False, default 1s, set to None to deactivate timeout.
- Returns:
If blocking == true, return the information on the transaction on the I2C bus. Else return None.
- Return type:
Union[None, I2CTransactionResult]
- Raises:
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
TimeoutError – If the timeout for reading back from the device is exceeded.
- writeRegister(device_id: int, address: bytes, value: bytes, blocking: bool = True, timeout: float | None = 1.0) bool | None
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:
device_id (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
blocking (bool) – If true, wait for the response from the connected device
timeout (Union[True, None]) – How long to wait for the response from the device in seconds. Ignored if blocking is set to False, default 1s, set to None to deactivate timeout.
- Returns:
If blocking == true, return True if the transaction succeeded or throw an Error if not. If blocking == false, return None.
- Return type:
Union[True, None]
- Raises:
ConnectionError – If the transaction on the I2C bus was not acknowledged by the target device.
Exception – If the blocking mode is requested and another callback for a readback operation is already registered
TimeoutError – If the timeout for reading back from the device is exceeded.
SmartWaveAPI.configitems.i2cdriver module
- class SmartWaveAPI.configitems.i2cdriver.I2CDriver(device, driver_id: int, clock_speed: 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(clock_speed: int | None = None, scl_display_name: str | None = None, sda_display_name: str | None = None)
Configure the settings of this driver and write them to the connected device.
- Parameters:
clock_speed (int) – The transmission clock speed in Hz
scl_display_name (str) – The name to display for the SCL pin
sda_display_name (str) – The name to display for the SDA pin
- 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]
- property sclDisplayName: str
The name to display for the SCL pin
- property sdaDisplayName: str
The name to display for the SDA pin
- 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.
- property inputLevel: Literal[0, 1]
Get the current input level of the pin.
- Returns:
The current input level.
- Return type:
Literal[0, 1]
- writeToDevice()
Write the configuration parameters of this pin to the device.
SmartWaveAPI.configitems.spiconfig module
- class SmartWaveAPI.configitems.spiconfig.SPIConfig(device, sclk_pin: Pin | None = None, mosi_pin: Pin | None = None, miso_pin: Pin | None = None, cs_pin: Pin | None = None, clockspeed: int | None = None, bit_width: int | None = None, bit_numbering: Literal['MSB', 'LSB'] | None = None, cspol: Literal[0, 1] | None = None, cpol: Literal[0, 1] | None = None, cphase: Literal[0, 1] | None = None, sclk_display_name: str | None = None, mosi_display_name: str | None = None, miso_display_name: str | None = None, cs_display_name: str | None = None)
Bases:
Config
A collection of data, driver and pins used to send data via SPI using the SmartWave.
- property bitNumbering: Literal['MSB', 'LSB']
The bit numbering of the SPI transmissions; MSB-first or LSB-first
- property bitWidth: int
The bit width of the SPI transmissions
- property clockSpeed: int
The transmission clock speed in Hz.
- property cphase: Literal[0, 1]
The phase of the clock pin
- property cpol: Literal[0, 1]
The polarity of the clock pin
- property csDisplayName: str
The name to display for the driver’s CS pin.
- property cspol: Literal[0, 1]
The polarity of the chipselect pin
- property misoDisplayName: str
The name to display for the driver’s MISO pin.
- property mosiDisplayName: str
The name to display for the driver’s MOSI pin.
- property sclkDisplayName: str
The name to display for the driver’s SCLK pin.
- setData(data: List[int])
Set the data and send the configuration to the connected device.
Also checks if the data is new, and skips reconfiguring the device if not.
- Parameters:
data (List[int]) – The data to send
- write(data: List[int], blocking_read: bool = True, timeout: float | None = 1.0) None | List[int]
Write data over SPI with the connected device.
If the data is not new, the reconfiguration of the device is skipped.
- Parameters:
data (List[int]) – The data to write
blocking_read (bool) – If true, wait for the response from the connected device
timeout (float) – How long to wait for the response from the device in seconds. Ignored if blocking_read is set to False, default 1s, set to None to deactivate timeout.
- Returns:
If blockingRead == True, return the values that were read over SPI. Else return None.
- Return type:
Union[None, List[int]]
- Raises:
Exception – If the blocking read mode is requested and another callback for a readback operation is already registered.
TimeoutError – If the timeout for reading back from the device is exceeded.
SmartWaveAPI.configitems.spidriver module
- class SmartWaveAPI.configitems.spidriver.SPIDriver(device, id: int, clockSpeed: int = 25000000.0, bitWidth: int = 8, bitNumbering: Literal['MSB', 'LSB'] = 'MSB', cspol: Literal[0, 1] = 0, cpol: Literal[0, 1] = 0, cphase: Literal[0, 1] = 0)
Bases:
Driver
A hardware SPI driver on the SmartWave device
- property bitNumbering: Literal['MSB', 'LSB']
The bit numbering of the SPI transmissions; MSB-first or LSB-first
- property bitWidth: int
The bit width of the SPI transmissions
- property clockSpeed: int
The transmission clock speed in Hz.
- color: str = '#ab5848'
- configure(clockSpeed: int | None = None, bitWidth: int | None = None, bitNumbering: Literal['MSB', 'LSB'] | None = None, cspol: Literal[0, 1] | None = None, cpol: Literal[0, 1] | None = None, cphase: Literal[0, 1] | None = None, sclk_display_name: str | None = None, mosi_display_name: str | None = None, miso_display_name: str | None = None, cs_display_name: str | None = None)
Configure the settings of this driver and write them to the connected device.
- Parameters:
clockSpeed (int) – The transmission clock speed in Hz
bitWidth (int) – The bit width of the SPI transmissions
bitNumbering (Literal["MSB", "LSB"]) – Whether to transmit MSB-first or LSB-first
cspol (Literal[0, 1]) – The polarity of the chipselect pin
cpol (Literal[0, 1]) – The polarity of the clock pin
cphase (Literal[0, 1]) – The phase of the clock
sclk_display_name (str) – The name to display for the SCLK pin
mosi_display_name (str) – The name to display for the MOSI pin
miso_display_name (str) – The name to display for the MISO pin
cs_display_name (str) – The name to display for the CS pin
- Raises:
AttributeError – If clockSpeed is not available on the device
AttributeError – If bitWidth is not between 1 and 32
- property cphase: Literal[0, 1]
The phase of the clock pin
- property cpol: Literal[0, 1]
The polarity of the clock pin
- property csDisplayName: str
The name to display for the CS pin.
- property cspol: Literal[0, 1]
The polarity of the chipselect pin
- delete()
Unconfigure this driver along with its pins and return all resources to the device.
- driverType: DriverType = 0
- property misoDisplayName: str
The name to display for the MISO pin.
- property mosiDisplayName: str
The name to display for the MOSI pin.
- property sclkDisplayName: str
The name to display for the SCLK pin.
- 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.stimulus module
- class SmartWaveAPI.configitems.stimulus.Stimulus(device, stimulus_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.