Class ServoDevice

    • Constructor Detail

      • ServoDevice

        public ServoDevice​(ServoDeviceFactoryInterface deviceFactory,
                           PinInfo pinInfo,
                           int frequency,
                           ServoTrim trim,
                           int initialPulseWidthUs,
                           boolean inverted)
                    throws RuntimeIOException
        Parameters:
        deviceFactory - Device factory to use to provision this device.
        pinInfo - GPIO to which the output device is connected.
        frequency - Servo frequency (Hz).
        trim - Servo min / mid / max pulse widths and angle mapping
        initialPulseWidthUs - Initial servo pulse width in microseconds
        inverted - If the output is inverted, i.e. min is output as max and vice versa
        Throws:
        RuntimeIOException - If an I/O error occurred.
    • Method Detail

      • close

        public void close()
        Description copied from interface: DeviceInterface
        Close this device
      • getPulseWidthUs

        public int getPulseWidthUs()
                            throws RuntimeIOException
        Get the current servo pulse width in microseconds.
        Returns:
        Current output pulse width value.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • setPulseWidthUs

        public void setPulseWidthUs​(int pulseWidthUs)
                             throws RuntimeIOException
        Set the servo pulse width value in microseconds.
        Parameters:
        pulseWidthUs - New pulse width value in microseconds.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • getServoFrequency

        public int getServoFrequency()
      • isOn

        public boolean isOn()
                     throws RuntimeIOException
        Get the device on / off status.
        Returns:
        Returns true if the device currently has a value > 0.
        Throws:
        RuntimeIOException - If an I/O error occurred.
      • getAngle

        public float getAngle()
        Get the current servo angle where 90 degrees is the middle position
        Returns:
        Servo angle (90 degrees is middle)
      • setAngle

        public void setAngle​(float angle)
        Turn the servo to the specified angle where 90 is the middle position
        Parameters:
        angle - Servo angle (90 degrees is middle)
      • min

        public void min()
      • mid

        public void mid()
      • max

        public void max()