From 2aea7685d2cc34437dba491a1d9d5dbf8b0a2a11 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Wed, 14 Jun 2017 00:14:52 +0200 Subject: [PATCH] curie: WIP on adding support for Intel Curie IMU Signed-off-by: deadprogram --- platforms/intel-iot/curie/README.md | 19 +++++++++ platforms/intel-iot/curie/doc.go | 7 ++++ platforms/intel-iot/curie/imu_driver.go | 43 ++++++++++++++++++++ platforms/intel-iot/curie/imu_driver_test.go | 21 ++++++++++ 4 files changed, 90 insertions(+) create mode 100644 platforms/intel-iot/curie/README.md create mode 100644 platforms/intel-iot/curie/doc.go create mode 100644 platforms/intel-iot/curie/imu_driver.go create mode 100644 platforms/intel-iot/curie/imu_driver_test.go diff --git a/platforms/intel-iot/curie/README.md b/platforms/intel-iot/curie/README.md new file mode 100644 index 00000000..f1a7c0a1 --- /dev/null +++ b/platforms/intel-iot/curie/README.md @@ -0,0 +1,19 @@ +# Curie + +The Intel Curie is a microcontroller for the Internet of Things. It is the platform used by the Intel Arduino/Genuino 101 and the Intel TinyTILE. + +For more info about the Curie platform go to: [http://www.intel.com/content/www/us/en/do-it-yourself/edison.html](http://www.intel.com/content/www/us/en/do-it-yourself/edison.html). + +## How to Install + +You would normally install Go and Gobot on your workstation. When you execute the program code, it will communicate with the connected microcontroller using the Firmata protocol. + +``` +go get -d -u gobot.io/x/gobot/... +``` + +## How To Use + +```go +// code here... +``` diff --git a/platforms/intel-iot/curie/doc.go b/platforms/intel-iot/curie/doc.go new file mode 100644 index 00000000..d66d15ad --- /dev/null +++ b/platforms/intel-iot/curie/doc.go @@ -0,0 +1,7 @@ +/* +Package curie contains the Gobot driver for the Intel Curie IMU. + +For further information refer to intel-iot README: +https://github.com/hybridgroup/gobot/blob/master/platforms/intel-iot/curie/README.md +*/ +package curie // import "gobot.io/x/gobot/platforms/intel-iot/curie" diff --git a/platforms/intel-iot/curie/imu_driver.go b/platforms/intel-iot/curie/imu_driver.go new file mode 100644 index 00000000..973eb773 --- /dev/null +++ b/platforms/intel-iot/curie/imu_driver.go @@ -0,0 +1,43 @@ +package curie + +import ( + "gobot.io/x/gobot" + "gobot.io/x/gobot/platforms/firmata" +) + +// IMUDriver represents the IMU that is built-in to the Curie +type IMUDriver struct { + name string + connection *firmata.Adaptor + gobot.Eventer +} + +// NewIMUDriver returns a new IMUDriver +func NewIMUDriver(a *firmata.Adaptor) *IMUDriver { + imu := &IMUDriver{ + name: gobot.DefaultName("CurieIMU"), + connection: a, + Eventer: gobot.NewEventer(), + } + + return imu +} + +// Start starts up the IMUDriver +func (imu *IMUDriver) Start() (err error) { + return +} + +// Halt stops the IMUDriver +func (imu *IMUDriver) Halt() (err error) { + return +} + +// Name returns the IMUDriver's name +func (imu *IMUDriver) Name() string { return imu.name } + +// SetName sets the IMUDriver'ss name +func (imu *IMUDriver) SetName(n string) { imu.name = n } + +// Connection returns the IMUDriver's Connection +func (imu *IMUDriver) Connection() gobot.Connection { return imu.connection } diff --git a/platforms/intel-iot/curie/imu_driver_test.go b/platforms/intel-iot/curie/imu_driver_test.go new file mode 100644 index 00000000..42b5999d --- /dev/null +++ b/platforms/intel-iot/curie/imu_driver_test.go @@ -0,0 +1,21 @@ +package curie + +import ( + "testing" + + "gobot.io/x/gobot" + "gobot.io/x/gobot/gobottest" + + "gobot.io/x/gobot/platforms/firmata" +) + +var _ gobot.Driver = (*IMUDriver)(nil) + +func initTestIMUDriver() *IMUDriver { + return NewIMUDriver(firmata.NewAdaptor("/dev/null")) +} + +func TestIMUDriverHalt(t *testing.T) { + d := initTestIMUDriver() + gobottest.Assert(t, d.Halt(), nil) +}