public class MCP3004GpioProvider extends MCP3x0xGpioProvider implements AdcGpioProvider
This GPIO provider implements the MCP3004 SPI GPIO expansion board as native Pi4J GPIO pins. It is a 10-bit ADC providing 4 input channels. More information about the board can be found here: - http://ww1.microchip.com/downloads/en/DeviceDoc/21295d.pdf
The MCP3004 is connected via SPI connection to the Raspberry Pi and provides 4 GPIO pins that can be used for analog input pins. The values returned are in the range 0-1023 (10 bit value). Note: This implementation currently only supports single-ended inputs.
Modifier and Type | Field and Description |
---|---|
static String |
DESCRIPTION |
static int |
INPUT_COUNT |
static String |
NAME |
static int |
RESOLUTION |
MAX_VALUE, MIN_VALUE
allPins, conversionDelay, monitor, monitorInterval, threshold
cache, DEFAULT_CACHE_SIZE, isshutdown, listeners
DEFAULT_MONITOR_INTERVAL, DEFAULT_THRESHOLD, INVALID_VALUE, MIN_MONITOR_INTERVAL
Constructor and Description |
---|
MCP3004GpioProvider(SpiChannel channel)
Create new instance of this MCP3004 provider with background monitoring and pin notification events enabled.
|
MCP3004GpioProvider(SpiChannel channel,
int speed)
Create new instance of this MCP3004 provider with background monitoring and pin notification events enabled.
|
MCP3004GpioProvider(SpiChannel channel,
int speed,
SpiMode mode)
Create new instance of this MCP3004 provider with background monitoring and pin notification events enabled.
|
MCP3004GpioProvider(SpiChannel channel,
int speed,
SpiMode mode,
boolean enableBackgroundMonitoring)
Create new instance of this MCP3004 provider.
|
MCP3004GpioProvider(SpiChannel channel,
SpiMode mode)
Create new instance of this MCP3004 provider with background monitoring and pin notification events enabled.
|
Modifier and Type | Method and Description |
---|---|
String |
getName() |
getImmediateValue, getMaxSupportedValue, getMinSupportedValue
getEventThreshold, getEventThreshold, getImmediateValue, getMonitorEnabled, getMonitorInterval, getPercentValue, getPercentValue, getValue, setEventThreshold, setEventThreshold, setMonitorEnabled, setMonitorInterval, shutdown
addListener, dispatchPinAnalogValueChangeEvent, dispatchPinDigitalStateChangeEvent, export, export, getMode, getPinCache, getPullResistance, getPwm, getState, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, unexport
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEventThreshold, getEventThreshold, getImmediateValue, getImmediateValue, getMaxSupportedValue, getMinSupportedValue, getMonitorEnabled, getMonitorInterval, getPercentValue, getPercentValue, setEventThreshold, setEventThreshold, setMonitorEnabled, setMonitorInterval
addListener, export, export, getMode, getPullResistance, getPwm, getState, getValue, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, shutdown, unexport
public static final String NAME
public static final String DESCRIPTION
public static final int INPUT_COUNT
public static final int RESOLUTION
public MCP3004GpioProvider(SpiChannel channel) throws IOException
channel
- spi channel the MCP3004 is connected toIOException
- if an error occurs during initialization of the SpiDevicepublic MCP3004GpioProvider(SpiChannel channel, int speed) throws IOException
channel
- spi channel the MCP3004 is connected tospeed
- spi speed to communicate with MCP3004IOException
- if an error occurs during initialization of the SpiDevicepublic MCP3004GpioProvider(SpiChannel channel, SpiMode mode) throws IOException
channel
- spi channel the MCP3004 is connected tomode
- spi mode to communicate with MCP3004IOException
- if an error occurs during initialization of the SpiDevicepublic MCP3004GpioProvider(SpiChannel channel, int speed, SpiMode mode) throws IOException
channel
- spi channel the MCP3004 is connected tospeed
- spi speed to communicate with MCP3004mode
- spi mode to communicate with MCP3004IOException
- if an error occurs during initialization of the SpiDevicepublic MCP3004GpioProvider(SpiChannel channel, int speed, SpiMode mode, boolean enableBackgroundMonitoring) throws IOException
channel
- spi channel the MCP3004 is connected tospeed
- spi speed to communicate with MCP3004mode
- spi mode to communicate with MCP3004enableBackgroundMonitoring
- if enabled, then a background thread will be created to constantly acquire the ADC input values and
publish pin change listeners if the value change is beyond the configured threshold.IOException
- if an error occurs during initialization of the SpiDevicepublic String getName()
getName
in interface GpioProvider
getName
in class GpioProviderBase
Copyright © 2012–2016 Pi4J. All rights reserved.