Package com.diozero.devices
Class PiconZero.PiconZeroServoDevice
- java.lang.Object
-
- com.diozero.internal.spi.AbstractDevice
-
- com.diozero.devices.PiconZero.PiconZeroServoDevice
-
- All Implemented Interfaces:
DeviceInterface
,GpioDeviceInterface
,InternalDeviceInterface
,InternalServoDeviceInterface
,AutoCloseable
- Enclosing class:
- PiconZero
public static class PiconZero.PiconZeroServoDevice extends AbstractDevice implements InternalServoDeviceInterface
-
-
Constructor Summary
Constructors Constructor Description PiconZeroServoDevice(PiconZero piconZero, String key, int gpio, int channel, int minPulseWidthUs, int maxPulseWidthUs, int initialPulseWidthUs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeDevice()
int
getChannel()
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
-
-
-
-
Method Detail
-
getGpio
public int getGpio()
- Specified by:
getGpio
in interfaceGpioDeviceInterface
-
getChannel
public int getChannel()
-
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
-
closeDevice
protected void closeDevice() throws RuntimeIOException
- Specified by:
closeDevice
in classAbstractDevice
- Throws:
RuntimeIOException
-
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
-
-