Package com.diozero.internal
Class PwmServoDevice
- java.lang.Object
-
- com.diozero.internal.spi.AbstractDevice
-
- com.diozero.internal.PwmServoDevice
-
- All Implemented Interfaces:
DeviceInterface
,GpioDeviceInterface
,InternalDeviceInterface
,InternalServoDeviceInterface
,AutoCloseable
public class PwmServoDevice extends AbstractDevice implements InternalServoDeviceInterface
-
-
Constructor Summary
Constructors Constructor Description PwmServoDevice(String key, DeviceFactoryInterface deviceFactory, InternalPwmOutputDeviceInterface pwmOutputDevice, int minPulseWidthUs, int maxPulseWidthUs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeDevice()
int
getGpio()
int
getPulseWidthUs()
Get the current Servo pulse width in microseconds.int
getServoFrequency()
Get the Servo frequency in Hzint
getServoNum()
Get the device Servo device numbervoid
setPulseWidthUs(int pulseWidthUs)
Set the Servo output pulse width in microseconds.void
setServoFrequency(int frequencyHz)
Set the Servo frequency, most servos operate at 50Hz.-
Methods inherited from class com.diozero.internal.spi.AbstractDevice
close, getDeviceFactory, getKey, isChild, isOpen, setChild
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.diozero.api.DeviceInterface
close
-
Methods inherited from interface com.diozero.internal.spi.InternalDeviceInterface
getKey, isChild, isOpen, setChild
-
Methods inherited from interface com.diozero.internal.spi.InternalServoDeviceInterface
getMode
-
-
-
-
Constructor Detail
-
PwmServoDevice
public PwmServoDevice(String key, DeviceFactoryInterface deviceFactory, InternalPwmOutputDeviceInterface pwmOutputDevice, int minPulseWidthUs, int maxPulseWidthUs)
-
-
Method Detail
-
getGpio
public int getGpio()
- Specified by:
getGpio
in interfaceGpioDeviceInterface
-
getServoNum
public int getServoNum()
Description copied from interface:InternalServoDeviceInterface
Get the device Servo device number- Specified by:
getServoNum
in interfaceInternalServoDeviceInterface
- Returns:
- Device native Servo device number
-
getPulseWidthUs
public int getPulseWidthUs() throws RuntimeIOException
Description copied from interface:InternalServoDeviceInterface
Get the current Servo pulse width in microseconds.- Specified by:
getPulseWidthUs
in interfaceInternalServoDeviceInterface
- Returns:
- Servo pulse width value in microseconds
- Throws:
RuntimeIOException
- if an I/O error occurs
-
setPulseWidthUs
public void setPulseWidthUs(int pulseWidthUs) throws RuntimeIOException
Description copied from interface:InternalServoDeviceInterface
Set the Servo output pulse width in microseconds.- Specified by:
setPulseWidthUs
in interfaceInternalServoDeviceInterface
- Parameters:
pulseWidthUs
- New pulse width value in microseconds, range minPulseWidth to maxPulseWidth- Throws:
RuntimeIOException
- if an I/O error occurs
-
getServoFrequency
public int getServoFrequency()
Description copied from interface:InternalServoDeviceInterface
Get the Servo frequency in Hz- Specified by:
getServoFrequency
in interfaceInternalServoDeviceInterface
- Returns:
- frequency in Hz
-
setServoFrequency
public void setServoFrequency(int frequencyHz) throws RuntimeIOException
Description copied from interface:InternalServoDeviceInterface
Set the Servo frequency, most servos operate at 50Hz.- Specified by:
setServoFrequency
in interfaceInternalServoDeviceInterface
- Parameters:
frequencyHz
- frequency in Hz- Throws:
RuntimeIOException
- if an I/O error occurs
-
closeDevice
protected void closeDevice() throws RuntimeIOException
- Specified by:
closeDevice
in classAbstractDevice
- Throws:
RuntimeIOException
-
-