Added initial interfaces and some sensors implementing them

This commit is contained in:
Mihai Stefanescu
2018-06-12 18:46:49 +03:00
committed by Serban Waltter
parent 85608a9f61
commit e7820f2831
102 changed files with 1183 additions and 182 deletions

View File

@ -57,6 +57,17 @@ int Light::value()
return (int)roundf(value);
}
float Light::getLuminance()
{
float value;
if (light_get_lux(m_light, &value))
throw std::runtime_error(std::string(__FUNCTION__) +
": light_get_normalized() failed.");
return value;
}
float Light::raw_value()
{
// This is a hack. Deprecated. Should be removed ASAP.

View File

@ -28,6 +28,7 @@
#pragma once
#include <string>
#include <interfaces/iLight.hpp>
#include "light.h"
@ -58,7 +59,7 @@ namespace upm {
* @image html light.jpg
* @snippet light.cxx Interesting
*/
class Light {
class Light : virtual public iLight {
public:
/**
* Analog light sensor constructor
@ -91,6 +92,14 @@ namespace upm {
*/
int value();
/**
* Gets an approximate light value in lux from the sensor
*
* @return Approximate light reading in lux
* @throws std::runtime_error on error
*/
virtual float getLuminance();
/**
* Set ADC reference voltage
*