Devices¶
Device templates and registry for common components.
devices ¶
Device templates and registry for pinviz.
DeviceRegistry ¶
Central registry for device templates.
Source code in src/pinviz/devices/registry.py
create ¶
Create a device instance from a template.
| PARAMETER | DESCRIPTION |
|---|---|
type_id
|
Device type identifier
TYPE:
|
**kwargs
|
Parameters to pass to the factory function
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Device
|
Device instance |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If device type is not registered |
Source code in src/pinviz/devices/registry.py
get ¶
get_categories ¶
list_all ¶
list_by_category ¶
register ¶
register(
type_id: str,
name: str,
description: str,
category: str,
factory: Callable[..., Device],
parameters: dict[str, Any] | None = None,
url: str | None = None,
) -> None
Register a device template.
| PARAMETER | DESCRIPTION |
|---|---|
type_id
|
Unique identifier for the device type (used in YAML configs)
TYPE:
|
name
|
Human-readable device name
TYPE:
|
description
|
Brief description of the device
TYPE:
|
category
|
Device category (sensors, displays, leds, io, etc.)
TYPE:
|
factory
|
Factory function that creates the device
TYPE:
|
parameters
|
Optional dict describing factory parameters
TYPE:
|
url
|
Optional URL to device documentation or datasheet
TYPE:
|
Source code in src/pinviz/devices/registry.py
DeviceTemplate
dataclass
¶
DeviceTemplate(
type_id: str,
name: str,
description: str,
category: str,
factory: Callable[..., Device],
parameters: dict[str, Any] | None = None,
url: str | None = None,
)
Metadata for a device template.
bh1750_light_sensor ¶
BH1750 I2C ambient light sensor.
Pinout (top to bottom): - VCC: 3.3V power - GND: Ground - SCL: I2C clock - SDA: I2C data - ADDR: I2C address select (optional)
Source code in src/pinviz/devices/sensors.py
button_switch ¶
Push button or switch.
| PARAMETER | DESCRIPTION |
|---|---|
pull_up
|
True for pull-up configuration, False for pull-down
TYPE:
|
Pinout: - SIG: Signal to GPIO - GND or VCC: Ground (pull-up) or VCC (pull-down)
Source code in src/pinviz/devices/io.py
ds18b20_temp_sensor ¶
DS18B20 waterproof digital temperature sensor (1-Wire protocol).
Pinout (typical wire colors): - VCC: 3.3V power (red wire) - GND: Ground (black wire) - DATA: 1-Wire data line (yellow/white wire)
Note: Requires a 4.7kΩ pull-up resistor between DATA and VCC. Use inline resistor components in connections to add the pull-up resistor.
The DATA pin connects to any available GPIO pin on the Raspberry Pi. Enable 1-Wire in raspi-config and load the w1-gpio kernel module.
Source code in src/pinviz/devices/sensors.py
generic_i2c_device ¶
Generic I2C device template.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Device display name
TYPE:
|
has_int_pin
|
Whether device has an interrupt pin
TYPE:
|
Pinout: - VCC: 3.3V power - GND: Ground - SCL: I2C clock - SDA: I2C data - INT: Interrupt (optional)
Source code in src/pinviz/devices/generic.py
generic_spi_device ¶
Generic SPI device template.
Pinout: - VCC: 3.3V power - GND: Ground - SCLK: SPI clock - MOSI: Master Out Slave In - MISO: Master In Slave Out - CS: Chip Select
Source code in src/pinviz/devices/generic.py
get_registry ¶
ir_led_ring ¶
IR LED ring module with control pin.
Pinout: - VCC: 5V power - GND: Ground - CTRL: Control signal (GPIO)
| PARAMETER | DESCRIPTION |
|---|---|
num_leds
|
Number of LEDs in the ring (for display purposes)
TYPE:
|
Source code in src/pinviz/devices/leds.py
simple_led ¶
Simple LED module.
Pinout: - +: Anode (positive terminal, connects to GPIO) - -: Cathode (negative terminal, connects to GND)
Note: Use inline resistor components in connections to add current-limiting resistors. Typical values: 220Ω-330Ω for 3.3V, 470Ω-1kΩ for 5V.
| PARAMETER | DESCRIPTION |
|---|---|
color_name
|
LED color for display
TYPE:
|