From 732847196d62633cf5c07b7d42bf380ccec186c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Agsj=C3=B6?= Date: Tue, 28 Feb 2017 00:54:21 +0100 Subject: [PATCH] Fixed a bug where drv2605 keeps triggering after shutdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Erik Agsjö --- drivers/i2c/drv2605l_driver.go | 4 ++-- drivers/i2c/drv2605l_driver_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/drv2605l_driver.go b/drivers/i2c/drv2605l_driver.go index 5c099bbb..4f2f2f85 100644 --- a/drivers/i2c/drv2605l_driver.go +++ b/drivers/i2c/drv2605l_driver.go @@ -183,7 +183,7 @@ func (d *DRV2605LDriver) SetMode(newMode DRV2605Mode) (err error) { } // clear mode bits (lower three bits) - mode &= 0xf1 + mode &= 0xf8 // set new mode bits mode |= uint8(newMode) @@ -264,7 +264,7 @@ func (d *DRV2605LDriver) Halt() (err error) { } // enter standby - return d.connection.WriteByteData(drv2605RegMode, 1) + return d.SetStandbyMode(true) } return } diff --git a/drivers/i2c/drv2605l_driver_test.go b/drivers/i2c/drv2605l_driver_test.go index a659f143..62ef734c 100644 --- a/drivers/i2c/drv2605l_driver_test.go +++ b/drivers/i2c/drv2605l_driver_test.go @@ -42,7 +42,7 @@ func TestDRV2605LDriverHalt(t *testing.T) { gobottest.Assert(t, d.Start(), nil) adaptor.written = []byte{} gobottest.Assert(t, d.Halt(), nil) - gobottest.Assert(t, adaptor.written, []byte{drv2605RegGo, 0, drv2605RegMode, 1}) + gobottest.Assert(t, adaptor.written, []byte{drv2605RegGo, 0, drv2605RegMode, 42 | drv2605Standby}) } func TestDRV2605LDriverGetPause(t *testing.T) {