Config Loader¶
YAML and JSON configuration file parsing.
config_loader ¶
Load diagram configurations from YAML/JSON files.
ConfigLoader ¶
Load and parse diagram configurations from files.
Supports loading diagrams from YAML and JSON configuration files. Handles predefined device types from the device registry and custom device definitions with automatic wire color assignment.
Examples:
>>> loader = ConfigLoader()
>>> diagram = loader.load_from_file("config.yaml")
>>> print(diagram.title)
My GPIO Diagram
load_from_dict ¶
Load a diagram from a configuration dictionary.
Expected structure: { "title": "My Diagram", "board": "raspberry_pi_5" or {"name": "...", ...}, "devices": [ {"type": "bh1750", "name": "Light Sensor"}, {"name": "Custom Device", "pins": [...], ...} ], "connections": [ {"board_pin": 1, "device": "Light Sensor", "device_pin": "VCC"}, ... ] }
| PARAMETER | DESCRIPTION |
|---|---|
config
|
Configuration dictionary
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Diagram
|
Diagram object |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If configuration fails schema validation |
Source code in src/pinviz/config_loader.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
load_from_file ¶
Load a diagram from a YAML or JSON configuration file.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
Path to configuration file (.yaml, .yml, or .json)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Diagram
|
Diagram object |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If file format is not supported or config is invalid |
Source code in src/pinviz/config_loader.py
PinAssigner ¶
Manages automatic pin assignment for role-based connections.
Distributes connections across multiple available pins of the same role to avoid multiple wires on a single pin (better for soldering/connections).
Example
assigner = PinAssigner(board)
First GND connection gets pin 14¶
pin1 = assigner.assign_pin("GND")
Second GND connection gets pin 19 (next available GND)¶
pin2 = assigner.assign_pin("GND")
Initialize pin assigner with a board.
| PARAMETER | DESCRIPTION |
|---|---|
board
|
Board object with pins to assign
TYPE:
|
Source code in src/pinviz/config_loader.py
assign_pin ¶
Assign next available pin of the specified role.
Uses round-robin distribution to spread connections across multiple pins of the same role.
| PARAMETER | DESCRIPTION |
|---|---|
role
|
Pin role (e.g., "GND", "3V3") as string or PinRole enum
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Physical pin number |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no pins of the specified role are available |