Private
Public Access
2
0

aio.c: added normalized read returning a float in a 0.0-1.0 range

Closes #32.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Alex Tereschenko
2015-02-01 20:54:13 +01:00
committed by Brendan Le Foll
parent dbc64fbe86
commit cd6701d604
3 changed files with 30 additions and 0 deletions

View File

@@ -67,6 +67,14 @@ mraa_aio_context mraa_aio_init(unsigned int pin);
*/
unsigned int mraa_aio_read(mraa_aio_context dev);
/**
* Read the input voltage and return it as a normalized float (0.0f-1.0f).
*
* @param dev The AIO context
* @returns The current input voltage as a normalized float (0.0f-1.0f)
*/
float mraa_aio_read_float(mraa_aio_context dev);
/**
* Close the analog input context, this will free the memory for the context
*

View File

@@ -65,6 +65,14 @@ class Aio {
int read() {
return mraa_aio_read(m_aio);
}
/**
* Read a value from the AIO pin and return it as a normalized float.
*
* @returns The current input voltage as a normalized float (0.0f-1.0f)
*/
float readFloat() {
return mraa_aio_read_float(m_aio);
}
/**
* Set the bit value which mraa will shift the raw reading
* from the ADC to. I.e. 10bits