API Reference¶
This section provides detailed documentation for all PinViz modules and classes.
Core Modules¶
Model¶
Core data structures and types:
Board,Device,HeaderPin,DevicePin- Component definitionsConnection,Diagram- Diagram structurePinRole,WireStyle,WireColor- Enums and constantsComponent,ComponentType- Inline component support
Boards¶
Predefined board templates:
raspberry_pi_5()- Raspberry Pi 5 board factory- Board pin configuration and layout
Devices¶
Device templates and registry:
bh1750_light_sensor()- BH1750 I2C light sensorir_led_ring()- IR LED ring modulesimple_led(),button_switch()- Basic componentsgeneric_i2c_device(),generic_spi_device()- Generic templatesDeviceRegistry- Device template management
Config Loader¶
YAML/JSON configuration parsing:
ConfigLoader- Parse configuration files into diagram objectsload_diagram()- Convenience function
Layout¶
Diagram layout engine:
LayoutEngine- Position devices and route wiresLayoutConfig- Layout configuration optionsRoutedWire- Wire routing information
Rendering¶
SVG rendering:
SVGRenderer- Convert diagrams to SVG filesRenderConfig- Rendering configuration options
CLI¶
Command-line interface:
main()- CLI entry point- Command implementations
Quick Links¶
Usage Examples¶
Creating a Simple Diagram¶
from pinviz import boards, devices, Connection, Diagram, SVGRenderer
board = boards.raspberry_pi_5()
led = devices.simple_led("Red LED", color="#FF0000")
connections = [
Connection(11, "Red LED", "+", color="#FF0000"),
Connection(9, "Red LED", "-", color="#000000"),
]
diagram = Diagram(
title="Simple LED",
board=board,
devices=[led],
connections=connections
)
renderer = SVGRenderer()
renderer.render(diagram, "led.svg")
Custom Device¶
from pinviz import Device, DevicePin, PinRole
custom_device = Device(
name="Custom Sensor",
width=80.0,
height=50.0,
color="#4A90E2",
pins=[
DevicePin("VCC", PinRole.V3_3, position=(5.0, 10.0)),
DevicePin("GND", PinRole.GND, position=(5.0, 20.0)),
DevicePin("DATA", PinRole.GPIO, position=(5.0, 30.0)),
]
)