Source code for herosdevices.hardware.generic.adc
"""Generic ADC drivers."""
from heros import RemoteHERO
from herosdevices.interfaces import atomiq
[docs]
class ADCChannel(atomiq.ADCChannel):
"""A generic ADC channel that can be connected to a multi channel ADC that implements the atomiq ADC interface.
Args:
adc_device: Object or HERO of the ADC this channel belongs to
channel: channel number
"""
def __init__(
self,
adc_device: atomiq.DAC | RemoteHERO,
channel: str,
samples: int = 1,
) -> None:
self.adc_device = adc_device
self.channel = channel
self.samples = samples
[docs]
def measure(self, samples: int | None = None, cached: bool = False, channel: str = "") -> float: # noqa: ARG002
"""Measure voltage at the current channel.
Args:
samples: Number of samples to average.
cached: not used
channel: not used
"""
samples = self.samples if samples is None else samples
return self.adc_device.measure(samples=samples, channel=self.channel)
def _observable_data(self) -> tuple[float, str]:
return (self.measure(), "V")