Reference
iclib.a1230 module
This module implements the A1230 driver.
- class iclib.a1230.A1230(outputa_gpio: GPIO, outputb_gpio: GPIO, frequency_monitor_sample_count: int = 5, frequency_monitor_poll_timeout: float = 1)
Bases:
objectA Python driver for Allegro MicroSystems A1230 Hall effect sensor with quadrature output
- property OUTPUTA: bool
Read OUTPUTA pin.
- Returns:
Pin value for OUTPUTA (E1).
- OUTPUTA_DIRECTION: ClassVar[str] = 'in'
The OUTPUTA GPIO direction.
- OUTPUTA_INVERTED: ClassVar[bool] = False
The OUTPUTA GPIO inverted status.
- property OUTPUTB: bool
Read OUTPUTB pin.
- Returns:
Pin value for OUTPUTB (E2).
- OUTPUTB_DIRECTION: ClassVar[str] = 'in'
The OUTPUTB GPIO direction.
- OUTPUTB_INVERTED: ClassVar[bool] = False
The OUTPUTB GPIO inverted status.
- frequency_monitor_poll_timeout: float = 1
The frequency monitor poll timeout.
- frequency_monitor_sample_count: int = 5
The frequency monitor sample count.
- property outputa_frequency: float
Get the OUTPUTA frequency.
- Returns:
The OUTPUTA frequency (in Hz).
- outputa_frequency_monitor: FrequencyMonitor
The OUTPUTA frequency monitor.
- outputa_gpio: GPIO
The OUTPUTA GPIO.
- property outputb_frequency: float
Get the OUTPUTB frequency.
- Returns:
The OUTPUTB frequency (in Hz).
- outputb_frequency_monitor: FrequencyMonitor
The OUTPUTB frequency monitor.
- outputb_gpio: GPIO
The OUTPUTB GPIO.
- stop() None
iclib.adc78h89 module
This module implements the ADC78H89 driver.
- class iclib.adc78h89.ADC78H89(spi: SPI, reference_voltage: float)
Bases:
objectThe class for Texas Instruments ADC78H89 7-Channel, 500 KSPS, 12-Bit A/D Converter.
- DEFAULT_INPUT_CHANNEL: ClassVar[InputChannel] = 0
The default input channel.
- DIVISOR: ClassVar[int] = 4096
The lsb width for ADC78H89.
- INPUT_CHANNEL_BITS_OFFSET: ClassVar[int] = 3
The input channel bits offset for control register bits.
- MAX_SPI_MAX_SPEED: ClassVar[float] = 8000000.0
The supported maximum spi maximum speed.
- MIN_SPI_MAX_SPEED: ClassVar[float] = 50000.0
The supported minimum spi maximum speed.
- SPI_BIT_ORDER: ClassVar[str] = 'msb'
The supported spi bit order.
- SPI_MODE: ClassVar[int] = 3
The supported spi mode.
- SPI_WORD_BIT_COUNT: ClassVar[int] = 8
The supported spi number of bits per word.
- reference_voltage: float
The reference voltage value (in volts).
- sample(*input_channels: InputChannel) list[float]
Sample the voltages of the input channels.
- Parameters:
input_channels – The input channels.
- Returns:
The sampled voltages.
- sample_all() dict[InputChannel, float]
Sample the voltages of all input channels.
- Returns:
The sampled voltages.
- spi: SPI
The SPI for the ADC device.
- class iclib.adc78h89.InputChannel(value)
Bases:
IntEnumThe enum class for input channels.
Refer to Table 3, ADC78H89 Datasheet, Page 13.
- property ADD0: bool
Get
ADD0of the input channel.- Returns:
ADD0.
- property ADD1: bool
Get
ADD1of the input channel.- Returns:
ADD1.
- property ADD2: bool
Get
ADD2of the input channel.- Returns:
ADD2.
- AIN1 = 0
The first (default) input channel.
- AIN2 = 1
The second input channel.
- AIN3 = 2
The third input channel.
- AIN4 = 3
The fourth input channel.
- AIN5 = 4
The fifth input channel.
- AIN6 = 5
The sixth input channel.
- AIN7 = 6
The seventh input channel.
- GROUND = 7
The ground input channel.
iclib.ina229 module
This module implements the INA229 driver.
- class iclib.ina229.CONFIGRegisterField(value)
Bases:
Enum- ADCRANGE = (range(4, 5), ReadOrWriteType.READ_OR_WRITE, 0)
- CONVDLY = (range(6, 14), ReadOrWriteType.READ_OR_WRITE, 0)
- RESERVED = (range(0, 4), ReadOrWriteType.READ, 0)
- RST = (range(15, 16), ReadOrWriteType.READ_OR_WRITE, 0)
- RSTACC = (range(14, 15), ReadOrWriteType.READ_OR_WRITE, 0)
- TEMPCOMP = (range(5, 6), ReadOrWriteType.READ_OR_WRITE, 0)
- property bit: int
- property field: str
- class iclib.ina229.INA229(alert_gpio: GPIO, spi: SPI, maximum_expected_current_: dataclasses.InitVar[float], shunt_resistance_: dataclasses.InitVar[float])
Bases:
objectA Python driver for Texas Instruments INA229 85-V, 20-Bit, Ultra-Precise Power/Energy/Charge Monitor With SPI Interface Expander with Serial Interface.
- MAX_SPI_MAX_SPEED: ClassVar[float] = 10000000.0
The supported maximum spi maximum speed.
- SPI_BIT_ORDER: ClassVar[str] = 'msb'
The supported spi bit order.
- SPI_MODE: ClassVar[int] = 1
The supported spi modes.
- SPI_WORD_BIT_COUNT: ClassVar[int] = 8
The supported spi number of bits per word.
- property adcrange: bool
- alert_gpio: GPIO
The alert GPIO.
- property bus_voltage: float
- property charge: float
- property current: float
- property current_lsb: float
- property energy: float
- property maximum_expected_current: float
- maximum_expected_current_: dataclasses.InitVar[float]
The maximum expected current.
- property maximum_expected_current_and_shunt_resistance: tuple[float, float]
- property power: float
- reset() None
- property shunt_calibration: int
- property shunt_resistance: float
- shunt_resistance_: dataclasses.InitVar[float]
The resistance value of the external shunt used to develop the differential voltage across the IN+ and IN- pins.
- property shunt_voltage: float
- spi: SPI
The SPI.
- property temperature: float
- class iclib.ina229.ReadOrWriteType(value)
Bases:
StrEnum- READ = 'R'
- READ_OR_WRITE = 'R/W'
- WRITE = 'W'
- class iclib.ina229.Register(value)
Bases:
Enum- ADC_CONFIG = (1, 'ADC Configuration', 16)
- BOVL = (14, 'Bus Overvoltage Threshold', 16)
- BUVL = (15, 'Bus Undervoltage Threshold', 16)
- CHARGE = (10, 'Charge Result', 40)
- CONFIG = (0, 'Configuration', 16)
- CURRENT = (7, 'Current Result', 24)
- DEVICE_ID = (63, 'Device ID', 16)
- DIAG_ALRT = (11, 'Diagnostic Flags and Alert', 16)
- DIETEMP = (6, 'Temperature Measurement', 16)
- ENERGY = (9, 'Energy Result', 40)
- MANUFACTURING_ID = (62, 'Manufacturer ID', 16)
- POWER = (8, 'Power Result', 24)
- PWR_LIMIT = (17, 'Power Over-Limit Threshold', 16)
- SHUNT_CAL = (2, 'Shunt Calibration', 16)
- SHUNT_TEMPCO = (3, 'Shunt Temperature Coefficient', 16)
- SOVL = (12, 'Shunt Overvoltage Threshold', 16)
- SUVL = (13, 'Shunt Undervoltage Threshold', 16)
- TEMP_LIMIT = (16, 'Temperature Over-Limit Threshold', 16)
- VBUS = (5, 'Bus Voltage Measurement', 24)
- VSHUNT = (4, 'Shunt Voltage Measurement', 24)
- property acronym: str
- property name: str
- class iclib.ina229.SPIFrame(register_: iclib.ina229.Register)
Bases:
ABC- READ_OR_WRITE_TYPE: ClassVar[ReadOrWriteType]
- property control_byte: int
- property data_byte_count: int
- abstract property data_bytes: list[int]
- parse_received_data_bytes(data_bytes: list[int]) int
- property read_or_write_bit: bool
- property transmitted_data_byte_count: int
- property transmitted_data_bytes: list[int]
- class iclib.ina229.SPIReadFrame(register_: iclib.ina229.Register)
Bases:
SPIFrame- READ_OR_WRITE_TYPE: ClassVar[ReadOrWriteType] = 'R'
- property data_bytes: list[int]
- class iclib.ina229.SPIWriteFrame(register_: iclib.ina229.Register, data: int)
Bases:
SPIFrame- READ_OR_WRITE_TYPE: ClassVar[ReadOrWriteType] = 'W'
- data: int
- property data_bytes: list[int]
iclib.mcp23s17 module
This module implements the MCP23S17 driver.
- class iclib.mcp23s17.MCP23S17(hardware_reset_gpio: GPIO, interrupt_output_a_gpio: GPIO, interrupt_output_b_gpio: GPIO, spi: SPI, hardware_address: int = 0)
Bases:
objectA Python driver for Microchip Technology MCP23S17 16-Bit I/O Expander with Serial Interface
- class Line(mcp23s17: 'MCP23S17', port: 'Port', bit: 'int', direction: 'str', inverted: 'bool' = False)
Bases:
object- bit: int
- direction: str
- inverted: bool = False
- read() bool
- write(value: bool) None
- MAX_SPI_MAX_SPEED: ClassVar[float] = 10000000.0
The supported maximum spi maximum speed.
- SPI_BIT_ORDER: ClassVar[str] = 'msb'
The supported spi bit order.
- SPI_MODES: ClassVar[tuple[int, int]] = (0, 3)
The supported spi modes.
- SPI_WORD_BIT_COUNT: ClassVar[int] = 8
The supported spi number of bits per word.
- hardware_address: int = 0
The hardware address.
- hardware_reset_gpio: GPIO
The hardware reset GPIO.
- interrupt_output_a_gpio: GPIO
The interrupt output for PORTA GPIO.
- interrupt_output_b_gpio: GPIO
The interrupt output for PORTB GPIO.
- read(register_address: int, data_byte_count: int) list[int]
- spi: SPI
The SPI.
- write(register_address: int, data_bytes: list[int]) list[int]
- class iclib.mcp23s17.Mode(value)
Bases:
IntEnumThe enum class for modes.
- EIGHT_BIT_MODE = 2
8-bit mode.
- SIXTEEN_BIT_MODE = 1
16-bit mode.
- class iclib.mcp23s17.Operation(hardware_address: 'int', register_address: 'int')
Bases:
ABC- READ_OR_WRITE_BIT: ClassVar[int]
- property control_byte: int
- abstract property data_byte_count: int
- abstract property data_bytes: list[int]
- hardware_address: int
- parse_received_data_bytes(data_bytes: list[int]) list[int]
- register_address: int
- property transmitted_data_byte_count: int
- property transmitted_data_bytes: list[int]
- class iclib.mcp23s17.Port(value)
Bases:
EnumThe enum class for ports.
- PORTA = 1
PORTA.
- PORTB = 2
PORTB.
- class iclib.mcp23s17.PortRegister(value)
Bases:
tuple[Port,Register],Enum- DEFVALA = (Port.PORTA, Register.DEFVAL)
- DEFVALB = (Port.PORTB, Register.DEFVAL)
- GPINTENA = (Port.PORTA, Register.GPINTEN)
- GPINTENB = (Port.PORTB, Register.GPINTEN)
- GPIOA = (Port.PORTA, Register.GPIO)
- GPIOB = (Port.PORTB, Register.GPIO)
- GPPUA = (Port.PORTA, Register.GPPU)
- GPPUB = (Port.PORTB, Register.GPPU)
- INTCAPA = (Port.PORTA, Register.INTCAP)
- INTCAPB = (Port.PORTB, Register.INTCAP)
- INTCONA = (Port.PORTA, Register.INTCON)
- INTCONB = (Port.PORTB, Register.INTCON)
- INTFA = (Port.PORTA, Register.INTF)
- INTFB = (Port.PORTB, Register.INTF)
- IOCONA = (Port.PORTA, Register.IOCON)
- IOCONB = (Port.PORTB, Register.IOCON)
- IODIRA = (Port.PORTA, Register.IODIR)
- IODIRB = (Port.PORTB, Register.IODIR)
- IPOLA = (Port.PORTA, Register.IPOL)
- IPOLB = (Port.PORTB, Register.IPOL)
- OLATA = (Port.PORTA, Register.OLAT)
- OLATB = (Port.PORTB, Register.OLAT)
- class iclib.mcp23s17.PortRegisterBit(value)
Bases:
tuple[Port,Register,int],Enum- DEFVALA_DEF0 = (Port.PORTA, Register.DEFVAL, 0)
- DEFVALA_DEF1 = (Port.PORTA, Register.DEFVAL, 1)
- DEFVALA_DEF2 = (Port.PORTA, Register.DEFVAL, 2)
- DEFVALA_DEF3 = (Port.PORTA, Register.DEFVAL, 3)
- DEFVALA_DEF4 = (Port.PORTA, Register.DEFVAL, 4)
- DEFVALA_DEF5 = (Port.PORTA, Register.DEFVAL, 5)
- DEFVALA_DEF6 = (Port.PORTA, Register.DEFVAL, 6)
- DEFVALA_DEF7 = (Port.PORTA, Register.DEFVAL, 7)
- DEFVALB_DEF0 = (Port.PORTB, Register.DEFVAL, 0)
- DEFVALB_DEF1 = (Port.PORTB, Register.DEFVAL, 1)
- DEFVALB_DEF2 = (Port.PORTB, Register.DEFVAL, 2)
- DEFVALB_DEF3 = (Port.PORTB, Register.DEFVAL, 3)
- DEFVALB_DEF4 = (Port.PORTB, Register.DEFVAL, 4)
- DEFVALB_DEF5 = (Port.PORTB, Register.DEFVAL, 5)
- DEFVALB_DEF6 = (Port.PORTB, Register.DEFVAL, 6)
- DEFVALB_DEF7 = (Port.PORTB, Register.DEFVAL, 7)
- GPINTENA_GPINT0 = (Port.PORTA, Register.GPINTEN, 0)
- GPINTENA_GPINT1 = (Port.PORTA, Register.GPINTEN, 1)
- GPINTENA_GPINT2 = (Port.PORTA, Register.GPINTEN, 2)
- GPINTENA_GPINT3 = (Port.PORTA, Register.GPINTEN, 3)
- GPINTENA_GPINT4 = (Port.PORTA, Register.GPINTEN, 4)
- GPINTENA_GPINT5 = (Port.PORTA, Register.GPINTEN, 5)
- GPINTENA_GPINT6 = (Port.PORTA, Register.GPINTEN, 6)
- GPINTENA_GPINT7 = (Port.PORTA, Register.GPINTEN, 7)
- GPINTENB_GPINT0 = (Port.PORTB, Register.GPINTEN, 0)
- GPINTENB_GPINT1 = (Port.PORTB, Register.GPINTEN, 1)
- GPINTENB_GPINT2 = (Port.PORTB, Register.GPINTEN, 2)
- GPINTENB_GPINT3 = (Port.PORTB, Register.GPINTEN, 3)
- GPINTENB_GPINT4 = (Port.PORTB, Register.GPINTEN, 4)
- GPINTENB_GPINT5 = (Port.PORTB, Register.GPINTEN, 5)
- GPINTENB_GPINT6 = (Port.PORTB, Register.GPINTEN, 6)
- GPINTENB_GPINT7 = (Port.PORTB, Register.GPINTEN, 7)
- GPIOA_GP0 = (Port.PORTA, Register.GPIO, 0)
- GPIOA_GP1 = (Port.PORTA, Register.GPIO, 1)
- GPIOA_GP2 = (Port.PORTA, Register.GPIO, 2)
- GPIOA_GP3 = (Port.PORTA, Register.GPIO, 3)
- GPIOA_GP4 = (Port.PORTA, Register.GPIO, 4)
- GPIOA_GP5 = (Port.PORTA, Register.GPIO, 5)
- GPIOA_GP6 = (Port.PORTA, Register.GPIO, 6)
- GPIOA_GP7 = (Port.PORTA, Register.GPIO, 7)
- GPIOB_GP0 = (Port.PORTB, Register.GPIO, 0)
- GPIOB_GP1 = (Port.PORTB, Register.GPIO, 1)
- GPIOB_GP2 = (Port.PORTB, Register.GPIO, 2)
- GPIOB_GP3 = (Port.PORTB, Register.GPIO, 3)
- GPIOB_GP4 = (Port.PORTB, Register.GPIO, 4)
- GPIOB_GP5 = (Port.PORTB, Register.GPIO, 5)
- GPIOB_GP6 = (Port.PORTB, Register.GPIO, 6)
- GPIOB_GP7 = (Port.PORTB, Register.GPIO, 7)
- GPPUA_PU0 = (Port.PORTA, Register.GPPU, 0)
- GPPUA_PU1 = (Port.PORTA, Register.GPPU, 1)
- GPPUA_PU2 = (Port.PORTA, Register.GPPU, 2)
- GPPUA_PU3 = (Port.PORTA, Register.GPPU, 3)
- GPPUA_PU4 = (Port.PORTA, Register.GPPU, 4)
- GPPUA_PU5 = (Port.PORTA, Register.GPPU, 5)
- GPPUA_PU6 = (Port.PORTA, Register.GPPU, 6)
- GPPUA_PU7 = (Port.PORTA, Register.GPPU, 7)
- GPPUB_PU0 = (Port.PORTB, Register.GPPU, 0)
- GPPUB_PU1 = (Port.PORTB, Register.GPPU, 1)
- GPPUB_PU2 = (Port.PORTB, Register.GPPU, 2)
- GPPUB_PU3 = (Port.PORTB, Register.GPPU, 3)
- GPPUB_PU4 = (Port.PORTB, Register.GPPU, 4)
- GPPUB_PU5 = (Port.PORTB, Register.GPPU, 5)
- GPPUB_PU6 = (Port.PORTB, Register.GPPU, 6)
- GPPUB_PU7 = (Port.PORTB, Register.GPPU, 7)
- INTCAPA_ICP0 = (Port.PORTA, Register.INTCAP, 0)
- INTCAPA_ICP1 = (Port.PORTA, Register.INTCAP, 1)
- INTCAPA_ICP2 = (Port.PORTA, Register.INTCAP, 2)
- INTCAPA_ICP3 = (Port.PORTA, Register.INTCAP, 3)
- INTCAPA_ICP4 = (Port.PORTA, Register.INTCAP, 4)
- INTCAPA_ICP5 = (Port.PORTA, Register.INTCAP, 5)
- INTCAPA_ICP6 = (Port.PORTA, Register.INTCAP, 6)
- INTCAPA_ICP7 = (Port.PORTA, Register.INTCAP, 7)
- INTCAPB_ICP0 = (Port.PORTB, Register.INTCAP, 0)
- INTCAPB_ICP1 = (Port.PORTB, Register.INTCAP, 1)
- INTCAPB_ICP2 = (Port.PORTB, Register.INTCAP, 2)
- INTCAPB_ICP3 = (Port.PORTB, Register.INTCAP, 3)
- INTCAPB_ICP4 = (Port.PORTB, Register.INTCAP, 4)
- INTCAPB_ICP5 = (Port.PORTB, Register.INTCAP, 5)
- INTCAPB_ICP6 = (Port.PORTB, Register.INTCAP, 6)
- INTCAPB_ICP7 = (Port.PORTB, Register.INTCAP, 7)
- INTCONA_IOC0 = (Port.PORTA, Register.INTCON, 0)
- INTCONA_IOC1 = (Port.PORTA, Register.INTCON, 1)
- INTCONA_IOC2 = (Port.PORTA, Register.INTCON, 2)
- INTCONA_IOC3 = (Port.PORTA, Register.INTCON, 3)
- INTCONA_IOC4 = (Port.PORTA, Register.INTCON, 4)
- INTCONA_IOC5 = (Port.PORTA, Register.INTCON, 5)
- INTCONA_IOC6 = (Port.PORTA, Register.INTCON, 6)
- INTCONA_IOC7 = (Port.PORTA, Register.INTCON, 7)
- INTCONB_IOC0 = (Port.PORTB, Register.INTCON, 0)
- INTCONB_IOC1 = (Port.PORTB, Register.INTCON, 1)
- INTCONB_IOC2 = (Port.PORTB, Register.INTCON, 2)
- INTCONB_IOC3 = (Port.PORTB, Register.INTCON, 3)
- INTCONB_IOC4 = (Port.PORTB, Register.INTCON, 4)
- INTCONB_IOC5 = (Port.PORTB, Register.INTCON, 5)
- INTCONB_IOC6 = (Port.PORTB, Register.INTCON, 6)
- INTCONB_IOC7 = (Port.PORTB, Register.INTCON, 7)
- INTFA_INT0 = (Port.PORTA, Register.INTF, 0)
- INTFA_INT1 = (Port.PORTA, Register.INTF, 1)
- INTFA_INT2 = (Port.PORTA, Register.INTF, 2)
- INTFA_INT3 = (Port.PORTA, Register.INTF, 3)
- INTFA_INT4 = (Port.PORTA, Register.INTF, 4)
- INTFA_INT5 = (Port.PORTA, Register.INTF, 5)
- INTFA_INT6 = (Port.PORTA, Register.INTF, 6)
- INTFA_INT7 = (Port.PORTA, Register.INTF, 7)
- INTFB_INT0 = (Port.PORTB, Register.INTF, 0)
- INTFB_INT1 = (Port.PORTB, Register.INTF, 1)
- INTFB_INT2 = (Port.PORTB, Register.INTF, 2)
- INTFB_INT3 = (Port.PORTB, Register.INTF, 3)
- INTFB_INT4 = (Port.PORTB, Register.INTF, 4)
- INTFB_INT5 = (Port.PORTB, Register.INTF, 5)
- INTFB_INT6 = (Port.PORTB, Register.INTF, 6)
- INTFB_INT7 = (Port.PORTB, Register.INTF, 7)
- IOCONA_BANK = (Port.PORTA, Register.IOCON, 7)
- IOCONA_DISSLW = (Port.PORTA, Register.IOCON, 4)
- IOCONA_HAEN = (Port.PORTA, Register.IOCON, 3)
- IOCONA_INTPOL = (Port.PORTA, Register.IOCON, 1)
- IOCONA_MIRROR = (Port.PORTA, Register.IOCON, 6)
- IOCONA_ODR = (Port.PORTA, Register.IOCON, 2)
- IOCONA_SEQOP = (Port.PORTA, Register.IOCON, 5)
- IOCONA_UNIMPLEMENTED = (Port.PORTA, Register.IOCON, 0)
- IOCONB_BANK = (Port.PORTB, Register.IOCON, 7)
- IOCONB_DISSLW = (Port.PORTB, Register.IOCON, 4)
- IOCONB_HAEN = (Port.PORTB, Register.IOCON, 3)
- IOCONB_INTPOL = (Port.PORTB, Register.IOCON, 1)
- IOCONB_MIRROR = (Port.PORTB, Register.IOCON, 6)
- IOCONB_ODR = (Port.PORTB, Register.IOCON, 2)
- IOCONB_SEQOP = (Port.PORTB, Register.IOCON, 5)
- IOCONB_UNIMPLEMENTED = (Port.PORTB, Register.IOCON, 0)
- IODIRA_IO0 = (Port.PORTA, Register.IODIR, 0)
- IODIRA_IO1 = (Port.PORTA, Register.IODIR, 1)
- IODIRA_IO2 = (Port.PORTA, Register.IODIR, 2)
- IODIRA_IO3 = (Port.PORTA, Register.IODIR, 3)
- IODIRA_IO4 = (Port.PORTA, Register.IODIR, 4)
- IODIRA_IO5 = (Port.PORTA, Register.IODIR, 5)
- IODIRA_IO6 = (Port.PORTA, Register.IODIR, 6)
- IODIRA_IO7 = (Port.PORTA, Register.IODIR, 7)
- IODIRB_IO0 = (Port.PORTB, Register.IODIR, 0)
- IODIRB_IO1 = (Port.PORTB, Register.IODIR, 1)
- IODIRB_IO2 = (Port.PORTB, Register.IODIR, 2)
- IODIRB_IO3 = (Port.PORTB, Register.IODIR, 3)
- IODIRB_IO4 = (Port.PORTB, Register.IODIR, 4)
- IODIRB_IO5 = (Port.PORTB, Register.IODIR, 5)
- IODIRB_IO6 = (Port.PORTB, Register.IODIR, 6)
- IODIRB_IO7 = (Port.PORTB, Register.IODIR, 7)
- IPOLA_IP0 = (Port.PORTA, Register.IPOL, 0)
- IPOLA_IP1 = (Port.PORTA, Register.IPOL, 1)
- IPOLA_IP2 = (Port.PORTA, Register.IPOL, 2)
- IPOLA_IP3 = (Port.PORTA, Register.IPOL, 3)
- IPOLA_IP4 = (Port.PORTA, Register.IPOL, 4)
- IPOLA_IP5 = (Port.PORTA, Register.IPOL, 5)
- IPOLA_IP6 = (Port.PORTA, Register.IPOL, 6)
- IPOLA_IP7 = (Port.PORTA, Register.IPOL, 7)
- IPOLB_IP0 = (Port.PORTB, Register.IPOL, 0)
- IPOLB_IP1 = (Port.PORTB, Register.IPOL, 1)
- IPOLB_IP2 = (Port.PORTB, Register.IPOL, 2)
- IPOLB_IP3 = (Port.PORTB, Register.IPOL, 3)
- IPOLB_IP4 = (Port.PORTB, Register.IPOL, 4)
- IPOLB_IP5 = (Port.PORTB, Register.IPOL, 5)
- IPOLB_IP6 = (Port.PORTB, Register.IPOL, 6)
- IPOLB_IP7 = (Port.PORTB, Register.IPOL, 7)
- OLATA_OL0 = (Port.PORTA, Register.OLAT, 0)
- OLATA_OL1 = (Port.PORTA, Register.OLAT, 1)
- OLATA_OL2 = (Port.PORTA, Register.OLAT, 2)
- OLATA_OL3 = (Port.PORTA, Register.OLAT, 3)
- OLATA_OL4 = (Port.PORTA, Register.OLAT, 4)
- OLATA_OL5 = (Port.PORTA, Register.OLAT, 5)
- OLATA_OL6 = (Port.PORTA, Register.OLAT, 6)
- OLATA_OL7 = (Port.PORTA, Register.OLAT, 7)
- OLATB_OL0 = (Port.PORTB, Register.OLAT, 0)
- OLATB_OL1 = (Port.PORTB, Register.OLAT, 1)
- OLATB_OL2 = (Port.PORTB, Register.OLAT, 2)
- OLATB_OL3 = (Port.PORTB, Register.OLAT, 3)
- OLATB_OL4 = (Port.PORTB, Register.OLAT, 4)
- OLATB_OL5 = (Port.PORTB, Register.OLAT, 5)
- OLATB_OL6 = (Port.PORTB, Register.OLAT, 6)
- OLATB_OL7 = (Port.PORTB, Register.OLAT, 7)
- class iclib.mcp23s17.Read(hardware_address: 'int', register_address: 'int', _data_byte_count: 'int')
Bases:
Operation- READ_OR_WRITE_BIT: ClassVar[int] = 1
- property data_byte_count: int
- property data_bytes: list[int]
- class iclib.mcp23s17.Register(value)
Bases:
IntEnum- DEFVAL = 3
- GPINTEN = 2
- GPIO = 9
- GPPU = 6
- INTCAP = 8
- INTCON = 4
- INTF = 7
- IOCON = 5
- IODIR = 0
- IPOL = 1
- OLAT = 10
- class iclib.mcp23s17.RegisterBit(value)
Bases:
tuple[Register,int],Enum- DEFVAL_DEF0 = (Register.DEFVAL, 0)
- DEFVAL_DEF1 = (Register.DEFVAL, 1)
- DEFVAL_DEF2 = (Register.DEFVAL, 2)
- DEFVAL_DEF3 = (Register.DEFVAL, 3)
- DEFVAL_DEF4 = (Register.DEFVAL, 4)
- DEFVAL_DEF5 = (Register.DEFVAL, 5)
- DEFVAL_DEF6 = (Register.DEFVAL, 6)
- DEFVAL_DEF7 = (Register.DEFVAL, 7)
- GPINTEN_GPINT0 = (Register.GPINTEN, 0)
- GPINTEN_GPINT1 = (Register.GPINTEN, 1)
- GPINTEN_GPINT2 = (Register.GPINTEN, 2)
- GPINTEN_GPINT3 = (Register.GPINTEN, 3)
- GPINTEN_GPINT4 = (Register.GPINTEN, 4)
- GPINTEN_GPINT5 = (Register.GPINTEN, 5)
- GPINTEN_GPINT6 = (Register.GPINTEN, 6)
- GPINTEN_GPINT7 = (Register.GPINTEN, 7)
- GPIO_GP0 = (Register.GPIO, 0)
- GPIO_GP1 = (Register.GPIO, 1)
- GPIO_GP2 = (Register.GPIO, 2)
- GPIO_GP3 = (Register.GPIO, 3)
- GPIO_GP4 = (Register.GPIO, 4)
- GPIO_GP5 = (Register.GPIO, 5)
- GPIO_GP6 = (Register.GPIO, 6)
- GPIO_GP7 = (Register.GPIO, 7)
- GPPU_PU0 = (Register.GPPU, 0)
- GPPU_PU1 = (Register.GPPU, 1)
- GPPU_PU2 = (Register.GPPU, 2)
- GPPU_PU3 = (Register.GPPU, 3)
- GPPU_PU4 = (Register.GPPU, 4)
- GPPU_PU5 = (Register.GPPU, 5)
- GPPU_PU6 = (Register.GPPU, 6)
- GPPU_PU7 = (Register.GPPU, 7)
- INTCAP_ICP0 = (Register.INTCAP, 0)
- INTCAP_ICP1 = (Register.INTCAP, 1)
- INTCAP_ICP2 = (Register.INTCAP, 2)
- INTCAP_ICP3 = (Register.INTCAP, 3)
- INTCAP_ICP4 = (Register.INTCAP, 4)
- INTCAP_ICP5 = (Register.INTCAP, 5)
- INTCAP_ICP6 = (Register.INTCAP, 6)
- INTCAP_ICP7 = (Register.INTCAP, 7)
- INTCON_IOC0 = (Register.INTCON, 0)
- INTCON_IOC1 = (Register.INTCON, 1)
- INTCON_IOC2 = (Register.INTCON, 2)
- INTCON_IOC3 = (Register.INTCON, 3)
- INTCON_IOC4 = (Register.INTCON, 4)
- INTCON_IOC5 = (Register.INTCON, 5)
- INTCON_IOC6 = (Register.INTCON, 6)
- INTCON_IOC7 = (Register.INTCON, 7)
- INTF_INT0 = (Register.INTF, 0)
- INTF_INT1 = (Register.INTF, 1)
- INTF_INT2 = (Register.INTF, 2)
- INTF_INT3 = (Register.INTF, 3)
- INTF_INT4 = (Register.INTF, 4)
- INTF_INT5 = (Register.INTF, 5)
- INTF_INT6 = (Register.INTF, 6)
- INTF_INT7 = (Register.INTF, 7)
- IOCON_BANK = (Register.IOCON, 7)
- IOCON_DISSLW = (Register.IOCON, 4)
- IOCON_HAEN = (Register.IOCON, 3)
- IOCON_INTPOL = (Register.IOCON, 1)
- IOCON_MIRROR = (Register.IOCON, 6)
- IOCON_ODR = (Register.IOCON, 2)
- IOCON_SEQOP = (Register.IOCON, 5)
- IOCON_UNIMPLEMENTED = (Register.IOCON, 0)
- IODIR_IO0 = (Register.IODIR, 0)
- IODIR_IO1 = (Register.IODIR, 1)
- IODIR_IO2 = (Register.IODIR, 2)
- IODIR_IO3 = (Register.IODIR, 3)
- IODIR_IO4 = (Register.IODIR, 4)
- IODIR_IO5 = (Register.IODIR, 5)
- IODIR_IO6 = (Register.IODIR, 6)
- IODIR_IO7 = (Register.IODIR, 7)
- IPOL_IP0 = (Register.IPOL, 0)
- IPOL_IP1 = (Register.IPOL, 1)
- IPOL_IP2 = (Register.IPOL, 2)
- IPOL_IP3 = (Register.IPOL, 3)
- IPOL_IP4 = (Register.IPOL, 4)
- IPOL_IP5 = (Register.IPOL, 5)
- IPOL_IP6 = (Register.IPOL, 6)
- IPOL_IP7 = (Register.IPOL, 7)
- OLAT_OL0 = (Register.OLAT, 0)
- OLAT_OL1 = (Register.OLAT, 1)
- OLAT_OL2 = (Register.OLAT, 2)
- OLAT_OL3 = (Register.OLAT, 3)
- OLAT_OL4 = (Register.OLAT, 4)
- OLAT_OL5 = (Register.OLAT, 5)
- OLAT_OL6 = (Register.OLAT, 6)
- OLAT_OL7 = (Register.OLAT, 7)
iclib.mcp4161 module
This module implements the MCP4161 driver.
- class iclib.mcp4161.Command(memory_address: int)
Bases:
ABCThe abstract base class class for commands.
- COMMAND_BITS: ClassVar[int]
The command bits.
- COMMAND_BITS_OFFSET: ClassVar[int] = 2
The command bits offset for the command byte.
- MEMORY_ADDRESS_OFFSET: ClassVar[int] = 4
The memory address offset for the command byte.
- memory_address: int
The memory address.
- abstractmethod parse_received_data_bytes(data_bytes: list[int]) int | None
Parse the received data bytes.
- Returns:
The received data bytes.
- abstract property transmitted_data_bytes: list[int]
Return the transmitted data bytes.
- Returns:
The transmitted data bytes.
- class iclib.mcp4161.Decrement(memory_address: int)
Bases:
EightBitCommandThe class for decrement commands.
- COMMAND_BITS: ClassVar[int] = 2
The command bits.
- parse_received_data_bytes(data_bytes: list[int]) None
Parse the received data bytes.
- Returns:
The received data bytes.
- class iclib.mcp4161.EightBitCommand(memory_address: int)
Bases:
Command,ABCThe abstract base class for 8-bit commands.
- property transmitted_data_bytes: list[int]
Return the transmitted data bytes.
- Returns:
The transmitted data bytes.
- class iclib.mcp4161.Increment(memory_address: int)
Bases:
EightBitCommandThe class for increment commands.
- COMMAND_BITS: ClassVar[int] = 1
The command bits.
- parse_received_data_bytes(data_bytes: list[int]) None
Parse the received data bytes.
- Returns:
The received data bytes.
- class iclib.mcp4161.MCP4161(spi: SPI)
Bases:
objectA Python driver for Microchip Technology MCP4161 7/8-Bit Single/Dual SPI Digital POT with Non-Volatile Memory
- MAX_SPI_MAX_SPEED: ClassVar[float] = 10000000.0
The supported maximum spi maximum speed.
- property NON_VOLATILE_WIPER_0: int
Read the NON_VOLATILE_WIPER_0 register.
- Returns:
The register value.
- SPI_BIT_ORDER: ClassVar[str] = 'msb'
The supported spi bit order.
- SPI_MODES: ClassVar[tuple[int, int]] = (0, 3)
The supported spi mode.
- SPI_WORD_BIT_COUNT: ClassVar[int] = 8
The supported spi number of bits per word.
- property STATUS_REGISTER: STATUSBit
Read the STATUS_REGISTER register.
- Returns:
The register value.
- STEP_RANGE: ClassVar[range] = range(0, 257)
The step range.
- property VOLATILE_TCON_REGISTER: TCONBit
Read the VOLATILE_TCON_REGISTER register.
- Returns:
The register value.
- property VOLATILE_WIPER_0: int
Read the VOLATILE_WIPER_0 register.
- Returns:
The register value.
- command(*commands: Command) list[int | None]
Apply the commands.
- Parameters:
commands – The commands.
- Returns:
The received data.
- decrement(memory_address: int) None
Decrement the data at the memory address.
- Parameters:
memory_address – The memory address.
- Returns:
None.
- increment(memory_address: int) None
Increment the data at the memory address.
- Parameters:
memory_address – The memory address.
- Returns:
None.
- read(memory_address: int) int
Read the data at the memory address.
- Parameters:
memory_address – The memory address.
- Returns:
The read data.
- set_non_volatile_wiper_step(step: int) None
Set the non-volatile wiper step.
- Parameters:
step – The step.
- Returns:
None.
- set_volatile_wiper_step(step: int) None
Set the volatile wiper step.
- Parameters:
step – The step.
- Returns:
None.
- spi: SPI
The SPI.
- write(memory_address: int, data: int) None
Write the data at the memory address.
- Parameters:
memory_address – The memory address.
data – The data.
- Returns:
None.
- class iclib.mcp4161.MemoryAddress(value)
Bases:
IntEnumThe enum class for memory addresses.
- NON_VOLATILE_WIPER_0 = 2
The non-volatile wiper 0.
- NON_VOLATILE_WIPER_1 = 3
The non-volatile wiper 1.
- STATUS_REGISTER = 5
The status register.
- VOLATILE_TCON_REGISTER = 4
The volatile TCON register.
- VOLATILE_WIPER_0 = 0
The volatile wiper 0.
- VOLATILE_WIPER_1 = 1
The volatile wiper 0.
- class iclib.mcp4161.Read(memory_address: int)
Bases:
SixteenBitCommandThe class for read commands.
- COMMAND_BITS: ClassVar[int] = 3
The command bits.
- READ_DATA_BIT_COUNT: ClassVar[int] = 9
The number of read data bits.
- parse_received_data_bytes(data_bytes: list[int]) int
Parse the received data bytes.
- Returns:
The received data bytes.
- property transmitted_data_bytes: list[int]
Return the transmitted data bytes.
- Returns:
The transmitted data bytes.
- class iclib.mcp4161.STATUSBit
Bases:
intThe class for STATUS bits.
- property EEWA
Get the EEWA bit.
- property SHDN
Get the SHDN bit.
- property WL0
Get the WL0 bit.
- property WL1
Get the WL1 bit.
- property WP
Get the WP bit.
- class iclib.mcp4161.SixteenBitCommand(memory_address: int)
Bases:
Command,ABCThe abstract base class for 8-bit commands.
- class iclib.mcp4161.TCONBit
Bases:
intThe class for TCON bits.
- property R0A
Get the R0A bit.
- property R0B
Get the R0B bit.
- property R0HW
Get the R0HW bit.
- property R0W
Get the R0W bit.
- property R1A
Get the R1A bit.
- property R1B
Get the R1B bit.
- property R1HW
Get the R1HW bit.
- property R1W
Get the R1W bit.
- class iclib.mcp4161.Write(memory_address: int, data: int)
Bases:
SixteenBitCommandThe class for write commands.
- COMMAND_BITS: ClassVar[int] = 0
The command bits.
- data: int
The data.
- parse_received_data_bytes(data_bytes: list[int]) None
Parse the received data bytes.
- Returns:
The received data bytes.
- property transmitted_data_bytes: list[int]
Return the transmitted data bytes.
- Returns:
The transmitted data bytes.
iclib.nhd_c12864a1z_fsw_fbw_htt module
- class iclib.nhd_c12864a1z_fsw_fbw_htt.NHDC12864A1ZFSWFBWHTT(spi: SPI, a0_pin: GPIO, reset_pin: GPIO)
Bases:
objectA Python driver for Newhaven Display Intl NHD-C12864A1Z-FSW-FBW-HTT COG (Chip-On-Glass) Liquid Crystal Display Module
- A0_PIN_DIRECTION: ClassVar[str] = 'out'
The direction of the a0 pin.
- A0_PIN_INVERTED: ClassVar[bool] = False
The inverted status of A0 pin.
- BASE_PAGE: ClassVar[int] = 176
The address of the first page (of 8).
- DISPLAY_OFF: ClassVar[int] = 174
The command to turn the display off.
- DISPLAY_ON: ClassVar[int] = 175
The command to turn the display on.
- DISPLAY_START_ADDRESS: ClassVar[int] = 64
The address of the display.
- HEIGHT: ClassVar[int] = 64
The number of pixels by height.
- MAX_SPI_MAX_SPEED: ClassVar[float] = 30000000.0
The supported maximum spi maximum speed.
- MIN_SPI_MAX_SPEED: ClassVar[float] = 50000.0
The supported minimum spi maximum speed.
- RESET_PIN_DIRECTION: ClassVar[str] = 'out'
The direction of the reset pin.
- RESET_PIN_INVERTED: ClassVar[bool] = True
The inverted status of reset pin.
- REVERT_NORMAL: ClassVar[int] = 164
The command to show the result on the display.
- SPI_BIT_ORDER: ClassVar[str] = 'msb'
The supported spi bit order.
- SPI_MODE: ClassVar[int] = 3
The supported spi modes.
- TURN_POINTS_ON: ClassVar[int] = 165
The command to confirm the writes on the display.
- WIDTH: ClassVar[int] = 128
The number of pixels by width.
- a0_pin: GPIO
The mode select pin for the display device.
- clear_pixel(x: int, y: int) None
Turn off pixel at
(x, y)in the framebuffer.This is does not immediately update the display.
- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
None.
- clear_pixel_immediate(x: int, y: int) None
Write to framebuffer and update display.
- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
None.
- clear_screen(display: bool = True) None
Clears the framebuffer and the display.
- Returns:
None.
- display() None
Writes what is in the local framebuffer to the display memory.
- Returns:
None.
- draw_fill_rect(x: int, y: int, width: int, height: int) None
Draw a filled rectangle.
- Parameters:
x – The
xcoordinate.y – The
ycoordinate.width – The width.
height – The height.
- Returns:
None
- draw_letter(letter: str, x: int, y: int) None
Draw the letter at position
(x, y).- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
None.
- draw_rect(x: int, y: int, width: int, height: int) None
Draw a hollow rectangle.
- Parameters:
x – The
xcoordinate.y – The
ycoordinate.width – The width.
height – The height.
- Returns:
None
- draw_word(word: str, x: int, y: int) None
Draws the word while wrapping if offscreen.
- Parameters:
word – The word.
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
None
- framebuffer_offset(x: int, y: int) int
Returns the flattened index in the framebuffer given an
xandycoordinate.- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
The framebuffer offset.
- page_offset(x: int, y: int) int
Returns the page
(1-8)given a coordinate on the display.- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
The page offset.
- pixel_in_bounds(x: int, y: int) bool
Checks if the x and y coordinate is within the bounds of the display resolution.
- reset() None
Resets everything in the display.
- Returns:
None.
- reset_pin: GPIO
The reset pin (active low) for the display device.
- set_font(filename: str) None
Set the font for drawing letters.
- Parameters:
filename – The
.ttffile to set.- Returns:
None.
- set_size(width: int, height: int) None
Set the size of the letters.
- Parameters:
width – The width.
height – The height.
- Returns:
None.
- spi: SPI
The SPI for the display device.
- write_pixel(x: int, y: int) None
Turn on pixel at
(x, y)in the framebuffer. This is does not immediately update the display.- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
None.
- write_pixel_immediate(x: int, y: int) None
Write to framebuffer and update display.
- Parameters:
x – The
xcoordinate.y – The
ycoordinate.
- Returns:
None.
iclib.rotary_encoder module
- class iclib.rotary_encoder.RotaryEncoder(a_gpio: periphery.gpio.GPIO, b_gpio: periphery.gpio.GPIO, callback: collections.abc.Callable[[iclib.rotary_encoder.RotaryEncoder.Direction], Any], timeout: float = 0.01)
Bases:
object- GPIO_DIRECTION: ClassVar[str] = 'in'
- a_gpio: GPIO
- b_gpio: GPIO
- property state: tuple[bool, bool]
- stop() None
- timeout: float = 0.01
iclib.sn74hcs137 module
This module implements the SN74HCS137 driver.
- class iclib.sn74hcs137.Address(value)
Bases:
IntEnumThe enum class for addresses.
- property A0: bool
Get
A0of the input channel.- Returns:
A0.
- property A1: bool
Get
A1of the input channel.- Returns:
A1.
- property A2: bool
Get
A2of the input channel.- Returns:
A2.
- Y0 = 0
Output 0.
- Y1 = 1
Output 1.
- Y2 = 2
Output 2.
- Y3 = 3
Output 3.
- Y4 = 4
Output 4.
- Y5 = 5
Output 5.
- Y6 = 6
Output 6.
- Y7 = 7
Output 7.
- class iclib.sn74hcs137.SN74HCS137(latch_enable_gpio: GPIO, strobe_input_0_gpio: GPIO, strobe_input_1_gpio: GPIO, address_select_0_gpio: GPIO, address_select_1_gpio: GPIO, address_select_2_gpio: GPIO)
Bases:
objectA Python driver for Texas instruments SN74HCS137 3- to 8-Line Decoder/Demultiplexer with Address Latches and SchmittTrigger Inputs
- ADDRESS_SELECT_0_GPIO_DIRECTION: ClassVar[str] = 'out'
The address select 0 GPIO direction.
- ADDRESS_SELECT_0_GPIO_INVERTED: ClassVar[bool] = False
The address select 0 GPIO inverted status.
- ADDRESS_SELECT_1_GPIO_DIRECTION: ClassVar[str] = 'out'
The address select 1 GPIO direction.
- ADDRESS_SELECT_1_GPIO_INVERTED: ClassVar[bool] = False
The address select 1 GPIO inverted status.
- ADDRESS_SELECT_2_GPIO_DIRECTION: ClassVar[str] = 'out'
The address select 2 GPIO direction.
- ADDRESS_SELECT_2_GPIO_INVERTED: ClassVar[bool] = False
The address select 2 GPIO inverted status.
- LATCH_ENABLE_GPIO_DIRECTION: ClassVar[str] = 'out'
The latch enable GPIO direction.
- LATCH_ENABLE_GPIO_INVERTED: ClassVar[bool] = True
The latch enable GPIO inverted status.
- STROBE_INPUT_0_GPIO_DIRECTION: ClassVar[str] = 'out'
The strobe input 0 GPIO direction.
- STROBE_INPUT_0_GPIO_INVERTED: ClassVar[bool] = False
The strobe input 0 GPIO inverted status.
- STROBE_INPUT_1_GPIO_DIRECTION: ClassVar[str] = 'out'
The strobe input 1 GPIO direction.
- STROBE_INPUT_1_GPIO_INVERTED: ClassVar[bool] = True
The strobe input 1 GPIO inverted status.
- address_select_0_gpio: GPIO
The address select 0 GPIO.
- address_select_1_gpio: GPIO
The address select 1 GPIO.
- address_select_2_gpio: GPIO
The address select 2 GPIO.
- deselect() None
Deselect.
- Returns:
None.
- disable_latch() None
Disable the latch.
- Returns:
None.
- enable_latch() None
Enable the latch.
The previous state is retained.
- Returns:
None.
- latch_enable_gpio: GPIO
The latch enable GPIO.
- strobe_input_0_gpio: GPIO
The strobe input 0 GPIO.
- strobe_input_1_gpio: GPIO
The strobe input 1 GPIO.
iclib.utilities module
This module implements various utilities.
- class iclib.utilities.ContinuousFrequencyMonitor(threshold: float, value_getter: Callable[[], float], window: float | None = 1, edge: Edge = Edge.BOTH, sample_count: int = 5)
Bases:
objectCalculate the frequency of an arbitrary analog signal.
Return the frequency and current reading.
- property frequency: float
Get the frequency.
- Returns:
The frequency (in hertz).
- property reading: float
Get the reading.
- Returns:
The reading.
- sample_count: int = 5
- stop() None
Stop the frequency monitor.
- Returns:
None.
- threshold: float
- value_getter: Callable[[], float]
- window: float | None = 1
- class iclib.utilities.FrequencyMonitor(gpio: GPIO, sample_count: int = 5, poll_timeout: float = 1)
Bases:
objectCalculate the frequency of how frequently a GPIO is triggered.
The GPIO can be configured to be triggered on any or both edges.
- GPIO_EDGE: ClassVar[str] = 'both'
The GPIO edge status.
- property frequency: float
Get the frequency.
- Returns:
The frequency (in hertz).
- gpio: GPIO
The GPIO to be monitored.
- poll_timeout: float = 1
The poll timeout.
- sample_count: int = 5
The number of samples in the sliding window.
- stop() None
Stop the frequency monitor.
- Returns:
None.
- class iclib.utilities.LockedI2C(i2c: ~periphery.i2c.I2C, _lock: ~_thread.allocate_lock = <factory>)
Bases:
objectI2C interface with mutually exclusive access.
- i2c: I2C
The I2C interface.
- transfer(address: int, messages: list[Message]) None
Transmit and receive data from I2C with mutually exclusive access.
- Parameters:
messages – List of I2C.Message messages.
- Returns:
None.
- class iclib.utilities.LockedSPI(spi: ~periphery.spi.SPI, _lock: ~_thread.allocate_lock = <factory>)
Bases:
objectSPI interface with mutually exclusive access.
- spi: SPI
The SPI interface.
- transfer(data: bytes | bytearray | list[int]) bytes | bytearray | list[int]
Transmit and receive data from SPI with mutually exclusive access.
- Parameters:
data – The transmitted data.
- Returns:
The received data.
- class iclib.utilities.ManualCSSPI(chip_select_gpio: GPIO, spi: SPI)
Bases:
objectSPI interface with manually driven GPIO as chip-select.
The manually driven chip-select must be active-low.
- CHIP_SELECT_GPIO_INVERTED: ClassVar[bool] = True
The chip-select inverted status (active-low).
- chip_select_gpio: GPIO
The chip-select GPIO.
- spi: SPI
The SPI interface.
- transfer(data: bytes | bytearray | list[int]) bytes | bytearray | list[int]
Transmit and receive data from SPI.
- Parameters:
data – The transmitted data.
- Returns:
The received data.
- iclib.utilities.bit_getter(index: int) Callable[[int], bool]
Return a callable that gets a bit at an index.
>>> zero = bit_getter(0) >>> one = bit_getter(1) >>> two = bit_getter(2) >>> three = bit_getter(3) >>> zero(0b1010) False >>> one(0b1010) True >>> two(0b1010) False >>> three(0b1010) True
- Parameters:
index – The bit index.
- Returns:
The bit getter.
- iclib.utilities.lsb_bits_to_byte(*bits: bool) int
Convert LSB bits to a byte.
>>> bin(lsb_bits_to_byte(True, True, False, False, True)) '0b10011'
- Parameters:
bits – The LSB bits.
- Returns:
The byte.
- iclib.utilities.msb_bits_to_byte(*bits: bool) int
Convert MSB bits to a byte.
>>> bin(msb_bits_to_byte(True, True, False, False, True)) '0b11001'
- Parameters:
bits – The MSB bits.
- Returns:
The byte.
- iclib.utilities.twos_complement(value: int, bit_count: int) int
If a value represents a negative number, perform two’s complement on it.
>>> bin(twos_complement(0b0101, 4)) '0b101' >>> bin(twos_complement(0b1101, 4)) '-0b11' >>> bin(twos_complement(0b00001011, 8)) '0b1011' >>> bin(twos_complement(0b10001011, 8)) '-0b1110101'
- Parameters:
value – The value.
bit_count – The number of bits in the value.
- Returns:
The negated value.