SDK docs menu

class

Part

One part of the board, by its schematic reference designator.

from hardlabs_sdk import Part

Get one with board.U3 or Board.part, or list them with Board.parts. print(part) shows what it is and the controls and readings it has.

Attributes

refstr
Its reference designator: "U3".
partstr | None
Its part number or name in the parts list: "MCP9808".
whatstr | None
What it is: "Temperature sensor".
wherestr | None
Its bus and address, when it is on one: "i2c0 0x18".
statusstr | None
How far it is simulated: simulated, partial, folded, not_simulated or not_fitted.
notestr | None
What the simulation leaves out, when the model says.
controlstuple[Control, ...]
Its controls, named U3.<control>.
reading_namestuple[str, ...]
Its readings' names, U3.<reading>.
busstr | None
Its bus, as the board names it: "i2c0", "spi0".
addressint | None
Its address on an I2C bus: 0x6B.
csstr | None
An SPI part's chip select.
behindstr | None
The part its bus runs through, such as an I2C switch.
mcu_pinstuple[dict, ...]
The processor pins it reaches, each {"pin": "P2.05", "net": "IMU_INT"}.
connected_refstuple[str, ...]
The parts it is wired to, the processor first.
is_mcubool
Whether it is the processor.

Part.connectedmethod

Returns the parts it is wired to.

part.connected() -> list[Part]

That is the processor (over a bus or a pin), an I2C switch it sits behind, and the parts on its signal nets. On the processor, it is every part the processor reaches.

Usage

for part in board.mcu.connected():
    print(part.ref, part.bus, part.address, part.mcu_pins)

Returns

list[Part] — The parts, the processor first.

Part.domethod

Works one of its controls. The same as Board.do("U3.<control>", ...).

part.do(control, value=None, **values) -> str

Usage

board.U3.do("set-ambient-temperature", 30)

Arguments

controlstr
The control's name, with or without the U3. prefix.
valueAnydefault None
True/False for a toggle, a number for a number or slider.
**valuesfloat
The named values for a form, vector or generator.

Returns

str — The control's output, if it has any.

Part.readmethod

Returns one of its readings' value. The same as Board.read("U3.<reading>").

part.read(name) -> Any

Usage

assert not board.U3.read("alert-pin")

Arguments

namestr
The reading's name, with or without the U3. prefix.

Returns

Any — A number, True/False, a name, or None.

Part.readingsmethod

Returns every reading it has now.

part.readings() -> dict[str, Reading]

Returns

dict[str, Reading] — Its readings, keyed U3.<reading>.

Part.memoryproperty

Its contents, when it is a memory chip: board.U7.memory is board.memory("U7").

part.memory -> Memory

Raises

  • KeyError — The part isn't one of the board's memory chips.