public class I2CExpander extends Sensor
Constructor and Description |
---|
I2CExpander()
Creates a sensor instance connected to sensor port 1.
|
I2CExpander(SensorPort port)
Creates a sensor instance connected to the given port.
|
I2CExpander(SensorPort port,
int deviceType,
int slaveAddress8bit)
Creates a sensor instance connected to the given port and selects
device type and I2C address of attached device.
|
I2CExpander(SensorPort port,
int deviceType,
int inputMode,
int slaveAddress8bit)
Creates a sensor instance connected to the given port and selects
devivce type, input mode and I2C address of attached device.
|
Modifier and Type | Method and Description |
---|---|
int[] |
readAnalog()
Reads all analog inputs at same time (8 bit ADC).
|
int |
readAnalog(int channel)
Reads one analog input channel (8 bit ADC).
|
int |
readAnalogInt()
Reads all analog inputs at same time (8 bit ADC).
|
void |
setAnalogInputMode(int inputMode)
Sets the input mode for the PCF8591 device.
|
void |
setup(int deviceType,
int slaveAddress8bit)
Selects device type and I2C address of attached device.
|
void |
writeAnalog(int out)
Sets the output voltage of the 8-bit DAC.
|
int |
writeDigital(int out)
Writes one byte data to the output and reads back the result.
|
public I2CExpander(SensorPort port)
port
- the port where the sensor is plugged-inpublic I2CExpander()
public I2CExpander(SensorPort port, int deviceType, int inputMode, int slaveAddress8bit)
port
- the port where the sensor is plugged-indeviceType
- expander typeinputMode
- expander input mode (for PCF8591)slaveAddress8bit
- the 8 bit I2C address of the devicepublic I2CExpander(SensorPort port, int deviceType, int slaveAddress8bit)
port
- the port where the sensor is plugged-indeviceType
- expander typeslaveAddress8bit
- the 8 bit I2C address of the devicepublic void setup(int deviceType, int slaveAddress8bit)
deviceType
- expander type; supported devices. 0: PCF8574, 1: PCF8574A, 2: PCF8591slaveAddress8bit
- the 8 bit I2C address of the devicepublic int writeDigital(int out)
out
- Digital out: 0 for digital out - LO state, 1 for digital out - HI state.
Digital in: 1 must be written to the port pin and the external electronics pulls
the pin to LO or HI.public void writeAnalog(int out)
out
- 0..255 converted to 0..VCCpublic void setAnalogInputMode(int inputMode)
inputMode
- the input mode (0, 1, 2, 3)public int[] readAnalog()
public int readAnalogInt()
public int readAnalog(int channel)