mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
grove: initial groveLight support
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
parent
11ac453218
commit
5e14ddb540
@ -88,3 +88,30 @@ float GroveTemp::raw_value()
|
|||||||
{
|
{
|
||||||
return (float) maa_aio_read_u16(m_aio);
|
return (float) maa_aio_read_u16(m_aio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//// GroveLight ////
|
||||||
|
|
||||||
|
GroveLight::GroveLight(unsigned int pin)
|
||||||
|
{
|
||||||
|
maa_init();
|
||||||
|
m_aio = maa_aio_init(pin);
|
||||||
|
m_name = "Light Sensor";
|
||||||
|
}
|
||||||
|
|
||||||
|
GroveLight::~GroveLight()
|
||||||
|
{
|
||||||
|
maa_aio_close(m_aio);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GroveLight::value ()
|
||||||
|
{
|
||||||
|
// rough conversion to Lux
|
||||||
|
int a = maa_aio_read_u16(m_aio);
|
||||||
|
a = 10000/(((1023-a)*10/a)*15)^(4/3);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GroveLight::raw_value()
|
||||||
|
{
|
||||||
|
return (float) maa_aio_read_u16(m_aio);
|
||||||
|
}
|
||||||
|
@ -61,4 +61,14 @@ class GroveTemp: public Grove {
|
|||||||
maa_aio_context* m_aio;
|
maa_aio_context* m_aio;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GroveLight: public Grove {
|
||||||
|
public:
|
||||||
|
GroveLight(unsigned int pin);
|
||||||
|
~GroveLight();
|
||||||
|
float raw_value();
|
||||||
|
int value();
|
||||||
|
private:
|
||||||
|
maa_aio_context* m_aio;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user