0.0.4 • Published 6 years ago

cosa-analog-pin-reader v0.0.4

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Cosa analog pin reader

This is a generic analog pin reader class for Cosa.

Inheriting from this class provides a read_voltage() interface returning a floating point reading in the range 0-5 V.

Sample usage: suppose values in 0.5-5.0 V range need to be read and scaled by 40.

class YourSensor: public wlp::AnalogPinReader { /* ... */ };

double YourSensor::read_value() {
    double reading0 = (read_voltage_raw() - 0.5) * 40;
    double reading1 = read_voltage_scaled(40) - 40*0.5;
    double reading2 = read_voltage_scaled(40, 0.5);  // Recommended usage
    assert(reading0 == reading1 && reading1 == reading2);
    return reading2;
}
0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago