diff --git a/src/grove/grove.cxx b/src/grove/grove.cxx index fd4ffbae..fc79760f 100644 --- a/src/grove/grove.cxx +++ b/src/grove/grove.cxx @@ -1,6 +1,7 @@ /* * Author: Brendan Le Foll * Contributions: Mihai Tudor Panu + * Contributions: Sarah Knepper * 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()