Skip to content

PwmControl.setPwm() #1890

@AlecHub

Description

@AlecHub

The SDK doesn't seem to provide an api, say PwmControl.setPwm(), to be able to specify an exact pwm pusle width.

The following technique seems to work though:

    boolean setPwm(Servo servo, double usPwm)
    {
        if (usPwm >= 500.0 && usPwm <= 2500.00) {
            if (PwmControl.class.isInstance(servo)) {
                PwmControl pwm = (PwmControl) servo;
                PwmControl.PwmRange range = pwm.getPwmRange();
                pwm.setPwmRange(new PwmControl.PwmRange(usPwm, usPwm, range.usFrame));
                servo.setPosition(1.0);
                return true;
            }
        }
        return false;
    }

Would this technique be reliable?

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