Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Jul 10, 2015
2 parents e7beae5 + 36777f6 commit 19c3622
Show file tree
Hide file tree
Showing 39 changed files with 1,660 additions and 107 deletions.
38 changes: 38 additions & 0 deletions examples/edison_grove_accelerometer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"fmt"
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/i2c"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("edison")
accel := i2c.NewGroveAccelerometerDriver(board, "accel")

work := func() {
gobot.Every(500*time.Millisecond, func() {
if x, y, z, err := accel.XYZ(); err == nil {
fmt.Println(x, y, z)
fmt.Println(accel.Acceleration(x, y, z))
} else {
fmt.Println(err)
}
})
}

robot := gobot.NewRobot("accelBot",
[]gobot.Connection{board},
[]gobot.Device{accel},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
32 changes: 32 additions & 0 deletions examples/edison_grove_blink.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

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

work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}

robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
37 changes: 37 additions & 0 deletions examples/edison_grove_button.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"fmt"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

e := edison.NewEdisonAdaptor("edison")
button := gpio.NewGroveButtonDriver(e, "button", "2")

work := func() {
gobot.On(button.Event(gpio.Push), func(data interface{}) {
fmt.Println("On!")
})

gobot.On(button.Event(gpio.Release), func(data interface{}) {
fmt.Println("Off!")
})

}

robot := gobot.NewRobot("bot",
[]gobot.Connection{e},
[]gobot.Device{button},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
55 changes: 55 additions & 0 deletions examples/edison_grove_buzzer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package main

import (
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("edison")
buzzer := gpio.NewBuzzerDriver(board, "buzzer", "3")

work := func() {
type note struct {
tone float64
duration float64
}

song := []note{
{gpio.C4, gpio.Quarter},
{gpio.C4, gpio.Quarter},
{gpio.G4, gpio.Quarter},
{gpio.G4, gpio.Quarter},
{gpio.A4, gpio.Quarter},
{gpio.A4, gpio.Quarter},
{gpio.G4, gpio.Half},
{gpio.F4, gpio.Quarter},
{gpio.F4, gpio.Quarter},
{gpio.E4, gpio.Quarter},
{gpio.E4, gpio.Quarter},
{gpio.D4, gpio.Quarter},
{gpio.D4, gpio.Quarter},
{gpio.C4, gpio.Half},
}

for _, val := range song {
buzzer.Tone(val.tone, val.duration)
<-time.After(10 * time.Millisecond)
}
}

robot := gobot.NewRobot("bot",
[]gobot.Connection{board},
[]gobot.Device{buzzer},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
43 changes: 43 additions & 0 deletions examples/edison_grove_lcd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/i2c"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("edison")
screen := i2c.NewGroveLcdDriver(board, "screen")

work := func() {
screen.Write("hello")

screen.SetRGB(255, 0, 0)

gobot.After(5*time.Second, func() {
screen.Clear()
screen.Home()
screen.SetRGB(0, 255, 0)
screen.Write("goodbye")
})

screen.Home()
<-time.After(1 * time.Second)
screen.SetRGB(0, 0, 255)
}

robot := gobot.NewRobot("screenBot",
[]gobot.Connection{board},
[]gobot.Device{screen},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
32 changes: 32 additions & 0 deletions examples/edison_grove_led.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"time"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

e := edison.NewEdisonAdaptor("edison")
led := gpio.NewGroveLedDriver(e, "led", "4")

work := func() {
gobot.Every(1*time.Second, func() {
led.Toggle()
})
}

robot := gobot.NewRobot("blinkBot",
[]gobot.Connection{e},
[]gobot.Device{led},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
32 changes: 32 additions & 0 deletions examples/edison_grove_light_sensor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("board")
sensor := gpio.NewGroveLightSensorDriver(board, "sensor", "0")

work := func() {
gobot.On(sensor.Event("data"), func(data interface{}) {
fmt.Println("sensor", data)
})
}

robot := gobot.NewRobot("sensorBot",
[]gobot.Connection{board},
[]gobot.Device{sensor},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
32 changes: 32 additions & 0 deletions examples/edison_grove_piezo_vibration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("edison")
sensor := gpio.NewGrovePiezoVibrationSensorDriver(board, "sensor", "0")

work := func() {
gobot.On(sensor.Event(gpio.Vibration), func(data interface{}) {
fmt.Println("got one!")
})
}

robot := gobot.NewRobot("bot",
[]gobot.Connection{board},
[]gobot.Device{sensor},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
32 changes: 32 additions & 0 deletions examples/edison_grove_rotary_sensor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("board")
sensor := gpio.NewGroveRotaryDriver(board, "sensor", "0")

work := func() {
gobot.On(sensor.Event("data"), func(data interface{}) {
fmt.Println("sensor", data)
})
}

robot := gobot.NewRobot("sensorBot",
[]gobot.Connection{board},
[]gobot.Device{sensor},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
32 changes: 32 additions & 0 deletions examples/edison_grove_sound_sensor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"

"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)

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

board := edison.NewEdisonAdaptor("board")
sensor := gpio.NewGroveSoundSensorDriver(board, "sensor", "0")

work := func() {
gobot.On(sensor.Event("data"), func(data interface{}) {
fmt.Println("sensor", data)
})
}

robot := gobot.NewRobot("sensorBot",
[]gobot.Connection{board},
[]gobot.Device{sensor},
work,
)

gbot.AddRobot(robot)

gbot.Start()
}
Loading

0 comments on commit 19c3622

Please sign in to comment.