Package com.diozero.devices
Class McpAdc
java.lang.Object
com.diozero.internal.provider.AbstractDeviceFactory
com.diozero.devices.McpAdc
- All Implemented Interfaces:
AnalogInputDeviceFactoryInterface
,DeviceFactoryInterface
,java.io.Closeable
,java.lang.AutoCloseable
public class McpAdc extends AbstractDeviceFactory implements AnalogInputDeviceFactoryInterface
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
McpAdc.McpAdcBoardPinInfo
static class
McpAdc.Type
The MCP3204/3208 devices offer the choice of using the analog input channels configured as single-ended inputs or pseudo-differential pairs. -
Field Summary
Fields Modifier and Type Field Description static McpAdc.Type
MCP3001
static McpAdc.Type
MCP3002
static McpAdc.Type
MCP3004
static McpAdc.Type
MCP3008
static McpAdc.Type
MCP3201
static McpAdc.Type
MCP3202
static McpAdc.Type
MCP3204
static McpAdc.Type
MCP3208
static McpAdc.Type
MCP3301
static McpAdc.Type
MCP3302
static McpAdc.Type
MCP3304
Fields inherited from class com.diozero.internal.provider.AbstractDeviceFactory
closed, deviceStates
-
Constructor Summary
Constructors Constructor Description McpAdc(McpAdc.Type type, int chipSelect, float vRef)
McpAdc(McpAdc.Type type, int controller, int chipSelect, float vRef)
-
Method Summary
Modifier and Type Method Description void
close()
AnalogInputDeviceInterface
createAnalogInputDevice(java.lang.String key, PinInfo pinInfo)
BoardPinInfo
getBoardPinInfo()
java.lang.String
getName()
float
getValue(int adcPin)
Read the analog value in the range 0..1 or -1..1 (if the ADC type is signed)float
getVRef()
Methods 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.AnalogInputDeviceFactoryInterface
provisionAnalogInputDevice
Methods inherited from interface com.diozero.internal.provider.DeviceFactoryInterface
createI2CKey, createPinKey, createSpiKey, deviceClosed, deviceOpened, getDevice, getDevice, isClosed, isDeviceOpened
-
Field Details
-
Constructor Details
-
McpAdc
- Throws:
RuntimeIOException
-
McpAdc
public McpAdc(McpAdc.Type type, int controller, int chipSelect, float vRef) throws RuntimeIOException- Throws:
RuntimeIOException
-
-
Method Details
-
getVRef
public float getVRef()- Specified by:
getVRef
in interfaceAnalogInputDeviceFactoryInterface
-
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
-
getValue
Read the analog value in the range 0..1 or -1..1 (if the ADC type is signed)- Parameters:
adcPin
- Pin on the MCP device- Returns:
- the unscaled value (-1..1)
- Throws:
RuntimeIOException
- if an I/O error occurs
-
createAnalogInputDevice
public AnalogInputDeviceInterface createAnalogInputDevice(java.lang.String key, PinInfo pinInfo) throws RuntimeIOException- Specified by:
createAnalogInputDevice
in interfaceAnalogInputDeviceFactoryInterface
- Throws:
RuntimeIOException
-
getName
public java.lang.String getName()- Specified by:
getName
in interfaceDeviceFactoryInterface
-
getBoardPinInfo
- Specified by:
getBoardPinInfo
in interfaceDeviceFactoryInterface
-