Skip to content

ServoKit: Add an interface to set min_pulse and max_pulse #52

@T-Mosher

Description

@T-Mosher

The interface for objects created with ServoKit include settings for the i2c address, reference clock speed, and pulse frequency. What's missing in order to fully calibrate a servo is the ability to set the min_pulse and max_pulse parameters.

class ServoKit:
    def __init__(
        self,
        *,
        channels: int,
        i2c: Optional[I2C] = None,
        address: int = 0x40,
        reference_clock_speed: int = 25000000,
        frequency: int = 50
    ) -> None:
        if channels not in [8, 16]:
            raise ValueError("servo_channels must be 8 or 16!")
        self._items = [None] * channels
        self._channels = channels
        if i2c is None:
            i2c = board.I2C()
        self._pca = PCA9685(
            i2c, address=address, reference_clock_speed=reference_clock_speed
        )
        self._pca.frequency = frequency

        self._servo = _Servo(self)
        self._continuous_servo = _ContinuousServo(self)

It may be possible to get to the min_pulse and max_pulse parameters by referencing down into the Servo and adafruit_motor classes, but this isn't simple or obvious in the way it could be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions