mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 01:41:12 +03:00
Added initial interfaces and some sensors implementing them
This commit is contained in:

committed by
Serban Waltter

parent
85608a9f61
commit
e7820f2831
@ -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.
|
||||
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user