From d5605838ddb8ee91ec81ab00386c965a5d4c0737 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Thu, 9 Jul 2015 11:48:46 -0700 Subject: [PATCH] Scale analog values to 1024 --- platforms/intel-iot/edison/edison_adaptor.go | 5 ++++- platforms/intel-iot/edison/edison_adaptor_test.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/platforms/intel-iot/edison/edison_adaptor.go b/platforms/intel-iot/edison/edison_adaptor.go index 29b2f98a0..be12770b3 100644 --- a/platforms/intel-iot/edison/edison_adaptor.go +++ b/platforms/intel-iot/edison/edison_adaptor.go @@ -440,7 +440,10 @@ func (e *EdisonAdaptor) AnalogRead(pin string) (val int, err error) { if err != nil { return } - return strconv.Atoi(string(buf[0 : len(buf)-1])) + + val, err = strconv.Atoi(string(buf[0 : len(buf)-1])) + + return val / 4, err } // I2cStart initializes i2c device for addresss diff --git a/platforms/intel-iot/edison/edison_adaptor_test.go b/platforms/intel-iot/edison/edison_adaptor_test.go index ef48c4b65..5f33ac540 100644 --- a/platforms/intel-iot/edison/edison_adaptor_test.go +++ b/platforms/intel-iot/edison/edison_adaptor_test.go @@ -179,5 +179,5 @@ func TestEdisonAdaptorAnalog(t *testing.T) { fs.Files["/sys/bus/iio/devices/iio:device1/in_voltage0_raw"].Contents = "1000\n" i, _ := a.AnalogRead("0") - gobot.Assert(t, i, 1000) + gobot.Assert(t, i, 250) }