Add CalibratedDevice and Potentiometer classes
The CalibratedDevice Class
Most of the devices supported by libDevCom deal with writing a digital value to output an analogue signal or reading a digital value that corresponds to an analogue signal. The DeviceCalibration
class takes care of the analogue to digital (and vice versa) conversion in a flexible manner. However any device that wishes to use it must apply the calibration itself. This results in a lot of duplicated code, especially when multi-channel devices are involved. The new CalibratedDevice
class tried to generalize this. Any device that want to benefit from it should inherit from it and implement the read/writeCount
methods.
Reading/Writing
Controlling a calibrated device is reading or writing (or both) digital values, independent of device type. The base CalibratedDevice
class implements the read
/write
functions that deal with the calibration and call the abstract digital readCount
/writeCount
functions.
The default implementation of the digital read/write functions throws a NotSupportedException
exception. The supported operations need to be implemented in the device subclass.
The write function returns the real value set. This is needed as not all analogue values can be represented using the discrete representations of a device.
Multi-Channel Devices
For multi-channel ADC's, a per-channel calibration can be applied using the setCalibration(ch,...)
function. If no per-channel calibration is set for a specific channel, then the global calibration (set via constructor or setCalibration(...)
) is used.
The calibration of a channel should be retrieved via the findCalibration
function. This handles the case of per-channel settings as described above.
The Potentiometer Class
Abstract interface for a digital potentiometer. It uses the CalibratedDevice
class to convert desired output resistances to corresponding digital values. The read and write functions correspond to setting the wiper-to-B resistance.
Also adds the AD5245
class, which implements the AD5245 256-Position I2C-Compatible Digital Potentiometer.
Other Changes
- libDevCom exception classes now correctly inherit publicly from
ComException
. - Add an offset option to
LinearCalibration
. By default it is set to 0. It can be used to add offsets, like the wiper resistance in a potentiometer.