1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00

particle: update examples to take key params via command line

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-01-04 15:15:38 +01:00
parent 85127c5f49
commit 8e10ea30d7
7 changed files with 64 additions and 7 deletions

View File

@ -1,6 +1,14 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_api.go mydevice myaccesstoken
*/
package main package main
import ( import (
"os"
"time" "time"
"gobot.io/x/gobot" "gobot.io/x/gobot"
@ -13,7 +21,7 @@ func main() {
master := gobot.NewMaster() master := gobot.NewMaster()
api.NewAPI(master).Start() api.NewAPI(master).Start()
core := particle.NewAdaptor("device_id", "access_token") core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "D7") led := gpio.NewLedDriver(core, "D7")
work := func() { work := func() {

View File

@ -1,6 +1,14 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_blink.go mydevice myaccesstoken
*/
package main package main
import ( import (
"os"
"time" "time"
"gobot.io/x/gobot" "gobot.io/x/gobot"
@ -9,7 +17,7 @@ import (
) )
func main() { func main() {
core := particle.NewAdaptor("device_id", "access_token") core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "D7") led := gpio.NewLedDriver(core, "D7")
work := func() { work := func() {

View File

@ -1,13 +1,22 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_button.go mydevice myaccesstoken
*/
package main package main
import ( import (
"os"
"gobot.io/x/gobot" "gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio" "gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/particle" "gobot.io/x/gobot/platforms/particle"
) )
func main() { func main() {
core := particle.NewAdaptor("device_id", "access_token") core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "D7") led := gpio.NewLedDriver(core, "D7")
button := gpio.NewButtonDriver(core, "D5") button := gpio.NewButtonDriver(core, "D5")

View File

@ -1,14 +1,22 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_events.go mydevice myaccesstoken
*/
package main package main
import ( import (
"fmt" "fmt"
"os"
"gobot.io/x/gobot" "gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/particle" "gobot.io/x/gobot/platforms/particle"
) )
func main() { func main() {
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN") core := particle.NewAdaptor(os.Args[1], os.Args[2])
work := func() { work := func() {
if stream, err := core.EventStream("all", ""); err != nil { if stream, err := core.EventStream("all", ""); err != nil {

View File

@ -1,14 +1,22 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_function.go mydevice myaccesstoken
*/
package main package main
import ( import (
"fmt" "fmt"
"os"
"gobot.io/x/gobot" "gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/particle" "gobot.io/x/gobot/platforms/particle"
) )
func main() { func main() {
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN") core := particle.NewAdaptor(os.Args[1], os.Args[2])
work := func() { work := func() {
if result, err := core.Function("brew", "202,230"); err != nil { if result, err := core.Function("brew", "202,230"); err != nil {

View File

@ -1,6 +1,14 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_led_brightness.go mydevice myaccesstoken
*/
package main package main
import ( import (
"os"
"time" "time"
"gobot.io/x/gobot" "gobot.io/x/gobot"
@ -9,7 +17,7 @@ import (
) )
func main() { func main() {
core := particle.NewAdaptor("device_id", "access_token") core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "A1") led := gpio.NewLedDriver(core, "A1")
work := func() { work := func() {

View File

@ -1,7 +1,15 @@
/*
To run this example, pass the device ID as first param,
and the access token as the second param:
go run examples/particle_variable.go mydevice myaccesstoken
*/
package main package main
import ( import (
"fmt" "fmt"
"os"
"time" "time"
"gobot.io/x/gobot" "gobot.io/x/gobot"
@ -9,7 +17,7 @@ import (
) )
func main() { func main() {
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN") core := particle.NewAdaptor(os.Args[1], os.Args[2])
work := func() { work := func() {
gobot.Every(1*time.Second, func() { gobot.Every(1*time.Second, func() {