Package com.diozero.devices
Class PCA9685
java.lang.Object
com.diozero.internal.provider.AbstractDeviceFactory
com.diozero.devices.PCA9685
- All Implemented Interfaces:
DeviceFactoryInterface
,PwmOutputDeviceFactoryInterface
,java.io.Closeable
,java.lang.AutoCloseable
public class PCA9685 extends AbstractDeviceFactory implements PwmOutputDeviceFactoryInterface
PCA9685 I2C-bus controlled 16-channel 12-bit PWM controller as used in the popular Adafruit PWM add-on board
Datasheet: http://www.nxp.com/documents/data_sheet/PCA9685.pdf
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PCA9685.PCA9685BoardPinInfo
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ADDRESS
Fields inherited from class com.diozero.internal.provider.AbstractDeviceFactory
closed, deviceStates
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description void
close()
void
closeChannel(int channel)
PwmOutputDeviceInterface
createPwmOutputDevice(java.lang.String key, PinInfo pinInfo, int pwmFrequency, float initialValue)
BoardPinInfo
getBoardPinInfo()
int
getBoardPwmFrequency()
java.lang.String
getName()
float
getValue(int channel)
void
setBoardPwmFrequency(int pwmFrequency)
void
setServoPulseWidthMs(int channel, double pulseWidthMs)
Set the pulse duration (micro-seconds) E.g.void
setValue(int channel, float value)
Set PWM output on a specific channel, value must be 0..1Methods inherited from class com.diozero.internal.provider.AbstractDeviceFactory
createI2CKey, createPinKey, createSpiKey, deviceClosed, deviceOpened, getDevice, getDevice, isClosed, isDeviceOpened
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.diozero.internal.provider.DeviceFactoryInterface
createI2CKey, createPinKey, createSpiKey, deviceClosed, deviceOpened, getDevice, getDevice, isClosed, isDeviceOpened
Methods inherited from interface com.diozero.internal.provider.PwmOutputDeviceFactoryInterface
provisionPwmOutputDevice
-
Field Details
-
DEFAULT_ADDRESS
public static final int DEFAULT_ADDRESS- See Also:
- Constant Field Values
-
-
Constructor Details
-
PCA9685
- Throws:
RuntimeIOException
-
PCA9685
- Throws:
RuntimeIOException
-
PCA9685
- Throws:
RuntimeIOException
-
-
Method Details
-
setServoPulseWidthMs
Set the pulse duration (micro-seconds) E.g. For TowerPro SG90 servo pulse width range = 500-2400 us TowerPro SG5010 servo pulse width range = 1ms-2ms- Parameters:
channel
- PWM channelpulseWidthMs
- The desired pulse width in milli-seconds- Throws:
RuntimeIOException
- if an I/O error occurs
-
getName
public java.lang.String getName()- Specified by:
getName
in interfaceDeviceFactoryInterface
-
close
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceDeviceFactoryInterface
- Overrides:
close
in classAbstractDeviceFactory
- Throws:
RuntimeIOException
-
closeChannel
- Throws:
RuntimeIOException
-
createPwmOutputDevice
public PwmOutputDeviceInterface createPwmOutputDevice(java.lang.String key, PinInfo pinInfo, int pwmFrequency, float initialValue) throws RuntimeIOException- Specified by:
createPwmOutputDevice
in interfacePwmOutputDeviceFactoryInterface
- Throws:
RuntimeIOException
-
getValue
- Throws:
RuntimeIOException
-
setValue
Set PWM output on a specific channel, value must be 0..1- Parameters:
channel
- PWM channelvalue
- Must be 0..1- Throws:
RuntimeIOException
- if an I/O error occurs
-
getBoardPwmFrequency
public int getBoardPwmFrequency()- Specified by:
getBoardPwmFrequency
in interfacePwmOutputDeviceFactoryInterface
-
setBoardPwmFrequency
public void setBoardPwmFrequency(int pwmFrequency)- Specified by:
setBoardPwmFrequency
in interfacePwmOutputDeviceFactoryInterface
-
getBoardPinInfo
- Specified by:
getBoardPinInfo
in interfaceDeviceFactoryInterface
-