Skip to content

Commit

Permalink
Merge pull request hybridgroup#316 from hybridgroup/feature/new-adapt…
Browse files Browse the repository at this point in the history
…or-driver-signatures

Simplify new adaptor/new driver function signatures
  • Loading branch information
deadprogram authored Oct 10, 2016
2 parents 5442e0b + 7d272e1 commit 532200e
Show file tree
Hide file tree
Showing 291 changed files with 2,018 additions and 1,835 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: go
sudo: true
go:
- 1.2
- 1.3
- 1.4
- 1.5
- 1.6
Expand All @@ -11,25 +9,25 @@ go:
matrix:
allow_failures:
- go: tip
- go: 1.2
- go: 1.3
- go: 1.4
- go: 1.5
before_install:
- sudo add-apt-repository -y ppa:kubuntu-ppa/backports
- sudo add-apt-repository -y ppa:zoogie/sdl2-snapshots
- sudo apt-get update
- sudo apt-get install --force-yes libcv-dev libcvaux-dev libhighgui-dev libopencv-dev libsdl2-dev libsdl2-image-dev libsdl2 libusb-dev xvfb unzip libgtk2.0-0
- mkdir -p gnatsd
- cd gnatsd
- "wget https://github.com/nats-io/gnatsd/releases/download/v0.8.1/gnatsd-v0.8.1-linux-amd64.zip"
- unzip -j gnatsd-v0.8.1-linux-amd64.zip
- "wget https://github.com/nats-io/gnatsd/releases/download/v0.9.4/gnatsd-v0.9.4-linux-amd64.zip"
- unzip -j gnatsd-v0.9.4-linux-amd64.zip
- ./gnatsd -p 4222 &
- ./gnatsd -p 4223 --user test --pass testwd &
- cd $HOME/gopath/src/github.com/hybridgroup/gobot
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
install:
- go get -d -v ./...
- make deps
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PACKAGES := gobot gobot/api gobot/platforms/firmata/client gobot/platforms/intel-iot/edison gobot/sysfs $(shell ls ./platforms | sed -e 's/^/gobot\/platforms\//')
PACKAGES := gobot gobot/api gobot/drivers/gpio gobot/drivers/i2c gobot/platforms/firmata/client gobot/platforms/intel-iot/edison gobot/platforms/intel-iot/joule gobot/sysfs $(shell ls ./platforms | sed -e 's/^/gobot\/platforms\//')
.PHONY: test cover robeaux examples

test:
Expand Down Expand Up @@ -38,3 +38,15 @@ examples:
for example in $(EXAMPLES) ; do \
go build -o /tmp/$$example examples/$$example ; \
done ; \

deps:
go get -d -v github.com/bmizerany/pat
go get -d -v github.com/hybridgroup/go-ardrone/client
go get -d -v github.com/currantlabs/gatt
go get -d -v github.com/tarm/serial
go get -d -v github.com/veandco/go-sdl2/sdl
go get -d -v golang.org/x/net/websocket
go get -d -v github.com/eclipse/paho.mqtt.golang
go get -d -v github.com/nats-io/nats
go get -d -v github.com/lazywei/go-opencv
go get -d -v github.com/donovanhide/eventsource
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import (

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/firmata"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/drivers/gpio"
)

func main() {
gbot := gobot.NewGobot()

firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "led", "13")
firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
led := gpio.NewLedDriver(firmataAdaptor, "13")

work := func() {
gobot.Every(1*time.Second, func() {
Expand Down Expand Up @@ -72,8 +72,8 @@ import (
func main() {
gbot := gobot.NewGobot()

adaptor := sphero.NewSpheroAdaptor("sphero", "/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor, "sphero")
adaptor := sphero.NewAdaptor("/dev/rfcomm0")
driver := sphero.NewSpheroDriver(adaptor)

work := func() {
gobot.Every(3*time.Second, func() {
Expand Down Expand Up @@ -101,16 +101,16 @@ You can use the entire Gobot framework as shown in the examples above ("Classic"
package main

import (
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/drivers/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
"time"
)

func main() {
e := edison.NewEdisonAdaptor("edison")
e := edison.NewAdaptor()
e.Connect()

led := gpio.NewLedDriver(e, "led", "13")
led := gpio.NewLedDriver(e, "13")
led.Start()

for {
Expand All @@ -132,23 +132,25 @@ Gobot has a extensible system for connecting to hardware devices. The following
- [C.H.I.P](http://www.nextthing.co/pages/chip) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/chip)
- [Digispark](http://digistump.com/products/1) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/digispark)
- [Intel Edison](http://www.intel.com/content/www/us/en/do-it-yourself/edison.html) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/intel-iot/edison)
- [Intel Joule](http://intel.com/joule/getstarted) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/intel-iot/joule)
- [Joystick](http://en.wikipedia.org/wiki/Joystick) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/joystick)
- [Keyboard](https://en.wikipedia.org/wiki/Computer_keyboard) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/keyboard)
- [Leap Motion](https://www.leapmotion.com/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/leapmotion)
- [MavLink](http://qgroundcontrol.org/mavlink/start) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/mavlink)
- [MegaPi](http://www.makeblock.com/megapi) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/megapi)
- [MQTT](http://mqtt.org/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/mqtt)
- [Neurosky](http://neurosky.com/products-markets/eeg-biosensors/hardware/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/neurosky)
- [NATS](http://nats.io/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/nats)
- [Neurosky](http://neurosky.com/products-markets/eeg-biosensors/hardware/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/neurosky)
- [OpenCV](http://opencv.org/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/opencv)
- [Particle](https://www.particle.io/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/particle)
- [Pebble](https://www.getpebble.com/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/pebble)
- [Raspberry Pi](http://www.raspberrypi.org/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/raspi)
- [Spark](https://www.spark.io/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/spark)
- [Sphero](http://www.gosphero.com/) <=> [Package](https://github.com/hybridgroup/gobot/tree/master/platforms/sphero)

Support for many devices that use General Purpose Input/Output (GPIO) have
a shared set of drivers provided using the `gobot/platforms/gpio` package:
a shared set of drivers provided using the `gobot/drivers/gpio` package:

- [GPIO](https://en.wikipedia.org/wiki/General_Purpose_Input/Output) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/platforms/gpio)
- [GPIO](https://en.wikipedia.org/wiki/General_Purpose_Input/Output) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/drivers/gpio)
- Analog Sensor
- Button
- Buzzer
Expand All @@ -171,9 +173,9 @@ a shared set of drivers provided using the `gobot/platforms/gpio` package:
- Servo

Support for devices that use Inter-Integrated Circuit (I2C) have a shared set of
drivers provided using the `gobot/platforms/i2c` package:
drivers provided using the `gobot/drivers/i2c` package:

- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/platforms/i2c)
- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) <=> [Drivers](https://github.com/hybridgroup/gobot/tree/master/drivers/i2c)
- BlinkM
- Grove Digital Accelerometer
- Grove RGB LCD
Expand Down Expand Up @@ -210,6 +212,12 @@ You can also specify the api host and port, and turn on authentication:

You may access the [robeaux](https://github.com/hybridgroup/robeaux) React.js interface with Gobot by navigating to `http://localhost:3000/index.html`.

## CLI

Gobot uses the Gort [http://gort.io](http://gort.io) Command Line Interface (CLI) so you can access important features right from the command line. We call it "RobotOps", aka "DevOps For Robotics". You can scan, connect, update device firmware, and more!

Gobot also has its own CLI to generate new platforms, adaptors, and drivers. You can check it out at [https://github.com/hybridgroup/gobot/cli](https://github.com/hybridgroup/gobot/cli).

## Documentation
We're busy adding documentation to our web site at http://gobot.io/ please check there as we continue to work on Gobot

Expand Down
2 changes: 2 additions & 0 deletions adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package gobot
type Adaptor interface {
// Name returns the label for the Adaptor
Name() string
// SetName sets the label for the Adaptor
SetName(n string)
// Connect initiates the Adaptor
Connect() []error
// Finalize terminates the Adaptor
Expand Down
2 changes: 2 additions & 0 deletions api/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type testDriver struct {
func (t *testDriver) Start() (errs []error) { return }
func (t *testDriver) Halt() (errs []error) { return }
func (t *testDriver) Name() string { return t.name }
func (t *testDriver) SetName(n string) { t.name = n }
func (t *testDriver) Pin() string { return t.pin }
func (t *testDriver) Connection() gobot.Connection { return t.connection }

Expand Down Expand Up @@ -69,6 +70,7 @@ var testAdaptorFinalize = func() (errs []error) { return }
func (t *testAdaptor) Finalize() (errs []error) { return testAdaptorFinalize() }
func (t *testAdaptor) Connect() (errs []error) { return testAdaptorConnect() }
func (t *testAdaptor) Name() string { return t.name }
func (t *testAdaptor) SetName(n string) { t.name = n }
func (t *testAdaptor) Port() string { return t.port }

func newTestAdaptor(name string, port string) *testAdaptor {
Expand Down
41 changes: 41 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Gobot CLI

Gobot has its own CLI to generate new platforms, adaptors, and drivers.

## Building the CLI

```
go build -o /path/to/dest/gobot .
```

## Running the CLI

```
/path/to/dest/gobot help
```

Should display help for the Gobot CLI:

```
CLI tool for generating new Gobot projects.
NAME:
gobot - Command Line Utility for generating new Gobot adaptors, drivers, and platforms
USAGE:
gobot [global options] command [command options] [arguments...]
VERSION:
0.12.1
COMMANDS:
generate Generate new Gobot adaptors, drivers, and platforms
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
```

## License
Copyright (c) 2013-2016 The Hybrid Group. Licensed under the Apache 2.0 license.
6 changes: 3 additions & 3 deletions gobot/doc.go → cli/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
CLI tool for generating new Gobot projects.
NAME:
gobot - Command Line Utility for Gobot
gobot - Command Line Utility for generating new Gobot adaptors, drivers, and platforms
USAGE:
gobot [global options] command [command options] [arguments...]
VERSION:
0.1
0.12.1
COMMANDS:
generate Generate new Gobot skeleton project
generate Generate new Gobot adaptors, drivers, and platforms
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
Expand Down
Loading

0 comments on commit 532200e

Please sign in to comment.