Class SysFsAnalogInputDevice
- java.lang.Object
-
- com.diozero.internal.spi.AbstractDevice
-
- com.diozero.internal.spi.AbstractInputDevice<AnalogInputEvent>
-
- com.diozero.internal.provider.builtin.SysFsAnalogInputDevice
-
- All Implemented Interfaces:
DeviceInterface
,AnalogInputDeviceInterface
,InternalDeviceInterface
,AutoCloseable
public class SysFsAnalogInputDevice extends AbstractInputDevice<AnalogInputEvent> implements AnalogInputDeviceInterface
-
-
Constructor Summary
Constructors Constructor Description SysFsAnalogInputDevice(DefaultDeviceFactory deviceFactory, String key, int device, int adcNumber)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeDevice()
int
getAdcNumber()
float
getValue()
Read the analog value in the range 0..1 or -1..1 (if the ADC type is signed)-
Methods inherited from class com.diozero.internal.spi.AbstractInputDevice
accept, disableListener, enableListener, generatesEvents, removeListener, setListener
-
Methods inherited from class com.diozero.internal.spi.AbstractDevice
close, getDeviceFactory, getKey, isOpen
-
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.AnalogInputDeviceInterface
generatesEvents, getMode, removeListener, setListener
-
Methods inherited from interface com.diozero.api.DeviceInterface
close
-
Methods inherited from interface com.diozero.internal.spi.InternalDeviceInterface
getKey, isOpen
-
-
-
-
Constructor Detail
-
SysFsAnalogInputDevice
public SysFsAnalogInputDevice(DefaultDeviceFactory deviceFactory, String key, int device, int adcNumber)
-
-
Method Detail
-
getAdcNumber
public int getAdcNumber()
- Specified by:
getAdcNumber
in interfaceAnalogInputDeviceInterface
-
getValue
public float getValue() throws RuntimeIOException
Description copied from interface:AnalogInputDeviceInterface
Read the analog value in the range 0..1 or -1..1 (if the ADC type is signed)- Specified by:
getValue
in interfaceAnalogInputDeviceInterface
- Returns:
- the unscaled value (-1..1)
- Throws:
RuntimeIOException
- if an I/O error occurs
-
closeDevice
protected void closeDevice() throws RuntimeIOException
- Specified by:
closeDevice
in classAbstractDevice
- Throws:
RuntimeIOException
-
-