grove.cxx: change lux formula used in GroveLight

Signed-off-by: Sarah Knepper <sarah.knepper@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Sarah Knepper 2014-12-04 10:35:51 +00:00 committed by Brendan Le Foll
parent 8504830c52
commit 6fa68db79f

View File

@ -1,6 +1,7 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributions: Mihai Tudor Panu <mihai.t.panu@intel.com>
* Contributions: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
@ -106,10 +107,10 @@ GroveLight::~GroveLight()
int GroveLight::value ()
{
// rough conversion to Lux
int a = mraa_aio_read(m_aio);
a = 10000/(((1023-a)*10/a)*15)^(4/3);
return a;
// rough conversion to lux, using formula from Grove Starter Kit booklet
float a = (float) mraa_aio_read(m_aio);
a = 10000.0/pow(((1023.0-a)*10.0/a)*15.0,4.0/3.0);
return (int) round(a);
}
float GroveLight::raw_value()