fusion_hat.adc module
Fusion Hat on-board analog to digital converter
Example
Import ADC
>>> from fusion_hat.adc import ADC
Init ADC channel 0
>>> a0 = ADC(0)
Read ADC channel 0 value
>>> a0.read()
2048
Read ADC channel 0 voltage
>>> a0.read_voltage()
1.65
- class fusion_hat.adc.ADC(channel: [<class 'int'>, <class 'str'>], *args, **kwargs)[source]
Bases:
_BaseADC class
- Parameters:
channel (int or str) – channel number or Str start with A
*args – pass to
fusion_hat._base._base**kwargs – pass to
fusion_hat._base._base
- Raises:
ValueError – channel must be channel number or Str start with A
- DEVICE_NAME = 'fusion-hat'
- IIO_DEVICE_PATH_PREFIX = '/sys/bus/iio/devices/iio:device'
- read_voltage() float[source]
read voltage value in V
- Returns:
voltage value in V
- Return type:
float
- property channel: str
get channel
- Returns:
channel number
- Return type:
str
- property voltage: int
get voltage
- Returns:
voltage value in mV
- Return type:
int
- property raw: int
get raw value
- Returns:
raw value
- Return type:
int