Package com.diozero.devices
Class McpAdc
- java.lang.Object
-
- com.diozero.internal.spi.AbstractDeviceFactory
-
- com.diozero.devices.McpAdc
-
- All Implemented Interfaces:
DeviceInterface
,AnalogInputDeviceFactoryInterface
,DeviceFactoryInterface
,AutoCloseable
public class McpAdc extends AbstractDeviceFactory implements AnalogInputDeviceFactoryInterface, DeviceInterface
-
-
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 inherited from class com.diozero.internal.spi.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this device factory including all devices that have been provisioned by it.AnalogInputDeviceInterface
createAnalogInputDevice(String key, PinInfo pinInfo)
BoardPinInfo
getBoardPinInfo()
Get information about pins that can be provisioned by this device factory.String
getName()
Get the name of this device factoryfloat
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.spi.AbstractDeviceFactory
createI2CKey, createPinKey, createPwmPinKey, createSerialKey, createServoPinKey, createSpiKey, deviceClosed, deviceOpened, getDevice, isClosed, isDeviceOpened, reopen
-
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.spi.AnalogInputDeviceFactoryInterface
provisionAnalogInputDevice
-
Methods inherited from interface com.diozero.internal.spi.DeviceFactoryInterface
createI2CKey, createPinKey, createPwmPinKey, createSerialKey, createServoPinKey, createSpiKey, deviceClosed, deviceOpened, getDevice, isClosed, isDeviceOpened, reopen, start
-
-
-
-
Constructor Detail
-
McpAdc
public McpAdc(McpAdc.Type type, int chipSelect, float vRef) throws RuntimeIOException
- Throws:
RuntimeIOException
-
McpAdc
public McpAdc(McpAdc.Type type, int controller, int chipSelect, float vRef) throws RuntimeIOException
- Throws:
RuntimeIOException
-
-
Method Detail
-
getVRef
public float getVRef()
- Specified by:
getVRef
in interfaceAnalogInputDeviceFactoryInterface
-
close
public void close() throws RuntimeIOException
Description copied from interface:DeviceFactoryInterface
Close this device factory including all devices that have been provisioned by it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceFactoryInterface
- Specified by:
close
in interfaceDeviceInterface
- Overrides:
close
in classAbstractDeviceFactory
- Throws:
RuntimeIOException
-
getValue
public float getValue(int adcPin) throws RuntimeIOException
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(String key, PinInfo pinInfo) throws RuntimeIOException
- Specified by:
createAnalogInputDevice
in interfaceAnalogInputDeviceFactoryInterface
- Throws:
RuntimeIOException
-
getName
public String getName()
Description copied from interface:DeviceFactoryInterface
Get the name of this device factory- Specified by:
getName
in interfaceDeviceFactoryInterface
- Returns:
- the name of this device factory
-
getBoardPinInfo
public BoardPinInfo getBoardPinInfo()
Description copied from interface:DeviceFactoryInterface
Get information about pins that can be provisioned by this device factory.- Specified by:
getBoardPinInfo
in interfaceDeviceFactoryInterface
- Returns:
- board pin info instance for this device factory
-
-