public class PCF8591 extends AbstractDeviceFactory implements AnalogInputDeviceFactoryInterface, AnalogOutputDeviceFactoryInterface, Closeable
Note the raspoid driver states there is a known bug when reading digital values from PCF8591 if analog output disabled ! (independent of this framework).
Modifier and Type | Class and Description |
---|---|
static class |
PCF8591.InputMode |
deviceStates
Constructor and Description |
---|
PCF8591() |
PCF8591(int controller,
int address,
PCF8591.InputMode inputMode,
boolean outputEnabled) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getName() |
int |
getNumPins() |
float |
getValue(int adcPin)
Read the analog value in the range 0..1
|
GpioAnalogInputDeviceInterface |
provisionAnalogInputPin(int pinNumber) |
GpioAnalogOutputDeviceInterface |
provisionAnalogOutputPin(int pinNumber) |
void |
setOutputEnabledFlag(boolean outputEnabled) |
void |
setValue(int dacPin,
float value)
Set the analog output value.
|
deviceClosed, deviceOpened, getDevice, isDeviceOpened, shutdown
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deviceClosed, deviceOpened, isDeviceOpened, shutdown
public PCF8591()
public PCF8591(int controller, int address, PCF8591.InputMode inputMode, boolean outputEnabled)
public void close() throws RuntimeIOException
close
in interface Closeable
close
in interface AutoCloseable
RuntimeIOException
public String getName()
getName
in interface DeviceFactoryInterface
public GpioAnalogInputDeviceInterface provisionAnalogInputPin(int pinNumber) throws RuntimeIOException
provisionAnalogInputPin
in interface AnalogInputDeviceFactoryInterface
RuntimeIOException
public GpioAnalogOutputDeviceInterface provisionAnalogOutputPin(int pinNumber) throws RuntimeIOException
provisionAnalogOutputPin
in interface AnalogOutputDeviceFactoryInterface
RuntimeIOException
public float getValue(int adcPin) throws RuntimeIOException
adcPin
- Pin on the MCP deviceRuntimeIOException
- if an I/O error occurspublic void setValue(int dacPin, float value) throws RuntimeIOException
dacPin
- The analog output channel.value
- Analogue output value (0..1).RuntimeIOException
- if an I/O error occurspublic int getNumPins()
public void setOutputEnabledFlag(boolean outputEnabled)
Copyright © 2016 mattjlewis. All rights reserved.