PwmPin
- class PwmPin(pin: int)[source]
Bases:
objectOne servo output of the old HAT (OLD_VERSION): a hardware PWM pin driven through sysfs. The servo itself (angles, ramps, hold) is MotorOld, in chip.py.
- pin
The GPIO pin number used for the motor.
- Type:
int
- pinIdx
The index of the pin in the internal configuration lists.
- Type:
int
- pwmx
Mapping of pin indices to PWM channels.
- Type:
list[int]
- flag
State flag indicating if the PWM is enabled.
- Type:
bool
- chip
The path to the PWM chip.
- Type:
str
- __init__(pin: int) None[source]
Initializes the pin, with the PWM disabled.
- Parameters:
pin (int) – The GPIO pin number.
Methods
- enable(flag) None[source]
Enables or disables the PWM. Disabled, the servo gets no pulses and releases its holding torque.
- Parameters:
flag (bool) – True to enable, False to disable.
- set(on_time_ns) None[source]
Sets the duty cycle in nanoseconds, enabling the PWM if needed.
- Parameters:
on_time_ns (int) – The high time in nanoseconds.