forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at adding some documentation
- Loading branch information
Showing
7 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
*.swp | ||
profile.cov | ||
count.out | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,104 @@ | ||
package gobot | ||
// Copyright 2014 The Gobot Authors, HybridGroup. All rights reserved. | ||
|
||
/* | ||
Package gobot is the main point of entry in your Gobot application. A Gobot | ||
is typically composed of one or more robots that makes up a project. | ||
Commands are a way to expose your robots functionality with the external world. | ||
A Gobot can be configured to expose a restful HTTP interface using the api | ||
package. You can define custom commands on your Gobot and interact with your | ||
application as a web service. | ||
Basic Setup | ||
package main | ||
import ( | ||
"fmt" | ||
"time" | ||
"github.com/hybridgroup/gobot" | ||
) | ||
func main() { | ||
gbot := gobot.NewGobot() | ||
robot := gobot.NewRobot("Eve", func() { | ||
gobot.Every(500*time.Millisecond, func() { | ||
fmt.Println("Greeting Human") | ||
}) | ||
}) | ||
gbot.AddRobot(robot) | ||
gbot.Start() | ||
} | ||
Web Enabled? You bet! | ||
package main | ||
import ( | ||
"fmt" | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/api" | ||
) | ||
overall doc for my package | ||
func main() { | ||
gbot := gobot.NewGobot() | ||
// Starts the API server on default port 3000 | ||
api.NewAPI(gbot).Start() | ||
// Accessible via http://localhost:3000/api/commands/say_hello | ||
gbot.AddCommand("say_hello", func(params map[string]interface{}) interface{} { | ||
return "Master says hello!" | ||
}) | ||
hello := gbot.AddRobot(gobot.NewRobot("Eve")) | ||
// Accessible via http://localhost:3000/robots/Eve/commands/say_hello | ||
hello.AddCommand("say_hello", func(params map[string]interface{}) interface{} { | ||
return fmt.Sprintf("%v says hello!", hello.Name) | ||
}) | ||
gbot.Start() | ||
} | ||
Blinking teh LED (Hello Eve!) | ||
package main | ||
import ( | ||
"time" | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/platforms/firmata" | ||
"github.com/hybridgroup/gobot/platforms/gpio" | ||
) | ||
func main() { | ||
gbot := gobot.NewGobot() | ||
firmataAdaptor := firmata.NewFirmataAdaptor("arduino", "/dev/ttyACM0") | ||
led := gpio.NewLedDriver(firmataAdaptor, "led", "13") | ||
work := func() { | ||
gobot.Every(1*time.Second, func() { | ||
led.Toggle() | ||
}) | ||
} | ||
robot := gobot.NewRobot("Eve", | ||
[]gobot.Connection{firmataAdaptor}, | ||
[]gobot.Device{led}, | ||
work, | ||
) | ||
gbot.AddRobot(robot) | ||
gbot.Start() | ||
} | ||
*/ | ||
package gobot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters