|
upm
1.5.0
Sensor/Actuator repository for libmraa (v1.8.0)
|
API for the Light Sensor. More...
The light sensor detects the intensity of the ambient light. As the light intensity of the environment increases, the resistance of the sensor decreases. This means the raw value from the analog pin is larger in bright light and smaller in the dark. A very approximate lux value can also be returned.
Public Member Functions | |
| Light (unsigned int pin) | |
| ~Light () | |
| float | raw_value () |
| int | value () |
| void | setAref (float aref) |
| void | setScale (float scale) |
| void | setOffset (float offset) |
| float | getAref () |
| float | getScale () |
| float | getOffset () |
| float | getNormalized () |
| float | getRawVolts () |
| std::string | name () |
Protected Attributes | |
| light_context | m_light |
| Light | ( | unsigned int | pin | ) |
analog light sensor constructor
| pin | Analog pin to use |
| std::runtime_error | on initialization error |
| float raw_value | ( | ) |
Gets the raw value from the AIO pin
| std::runtime_error | on error |

| int value | ( | ) |
Gets an approximate light value in lux from the sensor
| std::runtime_error | on error |


| void setAref | ( | float | aref | ) |
Set ADC reference voltage
| aref | ADC reference voltage |

| void setScale | ( | float | scale | ) |
Set sensor scale. This scale is applied to the return value: counts = counts * scale
| scale | count scale value used |

| void setOffset | ( | float | offset | ) |
Set sensor offset. This offset is applied to the return value: value = value + offset
| offset | count offset value used |

| float getAref | ( | ) |
Get sensor aref
| dev | sensor context pointer |

| float getScale | ( | ) |
Get sensor scale
| dev | sensor context pointer |

| float getOffset | ( | ) |
Get sensor offset
| dev | sensor context pointer |

| float getNormalized | ( | ) |
Read normalized value for sensor
| dev | sensor context pointer |
| *value | Normalized value (0.0 -> 1.0) |
| std::runtime_error | on error |

| float getRawVolts | ( | ) |
Read raw voltage from the sensor
| dev | sensor context pointer |
| *value | Raw sensor voltage |
| std::runtime_error | on error |


1.8.11