Motor

class Motor(channel: int, values: list[int], pwm, worker: _ChipWorker)[source]

Bases: object

__init__(channel: int, values: list[int], pwm, worker: _ChipWorker) → None[source]

Methods

servo_pulse(ms: float) → int[source]
move(angle: int, total_ms: int = 0, hold: bool | None = None, settle_ms: int = MOTOR_SETTLE_MS) → None[source]

Ramps the servo to angle, spreading total_ms over the steps.

The travel is split into MOTOR_STEP_DEGREES-degree steps; each step waits total_ms / number_of_steps, so the whole move takes about total_ms. The first move after boot goes straight to the target (the real position is unknown) and just syncs current_angle; every later move ramps smoothly.

hold decides whether the servo keeps holding torque once it arrives. None (the default) uses this motor’s own setting; True keeps it powered, so it resists a load but hums and heats up; False cuts the PWM after settle_ms, which is quiet and cool but lets anything push it out of position. settle_ms only matters for hold=False: cutting power right after the order to move would not give the servo time to physically get there, so that wait is added first (raise it for a heavier door).

Returns immediately – the move itself runs on this chip’s worker thread, one command at a time.

disable() → None[source]

Stops PWM signal to release holding torque.

open(hold: bool | None = None, settle_ms: int = MOTOR_SETTLE_MS) → None[source]

Moves the motor to the open position (see move). Returns immediately.

close(hold: bool | None = None, settle_ms: int = MOTOR_SETTLE_MS) → None[source]

Moves the motor to the close position (see move). Returns immediately.