From 6fa68db79f0e2e549bb1239c4464956dd27d8f9b Mon Sep 17 00:00:00 2001 From: Sarah Knepper Date: Thu, 4 Dec 2014 10:35:51 +0000 Subject: [PATCH] grove.cxx: change lux formula used in GroveLight Signed-off-by: Sarah Knepper Signed-off-by: Brendan Le Foll --- src/grove/grove.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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()