public class MCP3208GpioProvider extends MCP3x0xGpioProvider implements AdcGpioProvider
This GPIO provider implements the MCP3208 SPI GPIO expansion board as native Pi4J GPIO pins. It is a 12-bit ADC providing 8 input channels.
The MCP3008 is connected via SPI connection to the Raspberry Pi and provides 8 GPIO pins that can be used for analog input pins. The values returned are in the range 0-4095 (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 |
---|
MCP3208GpioProvider(SpiChannel channel)
Create new instance of this MCP3208 provider with background monitoring and pin notification events enabled.
|
MCP3208GpioProvider(SpiChannel channel,
int speed)
Create new instance of this MCP3208 provider with background monitoring and pin notification events enabled.
|
MCP3208GpioProvider(SpiChannel channel,
int speed,
SpiMode mode)
Create new instance of this MCP3208 provider with background monitoring and pin notification events enabled.
|
MCP3208GpioProvider(SpiChannel channel,
int speed,
SpiMode mode,
boolean enableBackgroundMonitoring)
Create new instance of this MCP3208 provider.
|
MCP3208GpioProvider(SpiChannel channel,
SpiMode mode)
Create new instance of this MCP3208 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 MCP3208GpioProvider(SpiChannel channel) throws IOException
channel
- spi channel the MCP3208 is connected toIOException
- if an error occurs during initialization of the SpiDevicepublic MCP3208GpioProvider(SpiChannel channel, int speed) throws IOException
channel
- spi channel the MCP3208 is connected tospeed
- spi speed to communicate with MCP3208IOException
- if an error occurs during initialization of the SpiDevicepublic MCP3208GpioProvider(SpiChannel channel, SpiMode mode) throws IOException
channel
- spi channel the MCP3208 is connected tomode
- spi mode to communicate with MCP3208IOException
- if an error occurs during initialization of the SpiDevicepublic MCP3208GpioProvider(SpiChannel channel, int speed, SpiMode mode) throws IOException
channel
- spi channel the MCP3208 is connected tospeed
- spi speed to communicate with MCP3208mode
- spi mode to communicate with MCP3208IOException
- if an error occurs during initialization of the SpiDevicepublic MCP3208GpioProvider(SpiChannel channel, int speed, SpiMode mode, boolean enableBackgroundMonitoring) throws IOException
channel
- spi channel the MCP3208 is connected tospeed
- spi speed to communicate with MCP3208mode
- spi mode to communicate with MCP3208enableBackgroundMonitoring
- 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.