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
import (
"os"
"time"
"gobot.io/x/gobot"
@ -13,7 +21,7 @@ func main() {
master := gobot.NewMaster()
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")
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
import (
"os"
"time"
"gobot.io/x/gobot"
@ -9,7 +17,7 @@ import (
)
func main() {
core := particle.NewAdaptor("device_id", "access_token")
core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "D7")
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
import (
"os"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/particle"
)
func main() {
core := particle.NewAdaptor("device_id", "access_token")
core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "D7")
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
import (
"fmt"
"os"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/particle"
)
func main() {
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN")
core := particle.NewAdaptor(os.Args[1], os.Args[2])
work := func() {
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
import (
"fmt"
"os"
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/particle"
)
func main() {
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN")
core := particle.NewAdaptor(os.Args[1], os.Args[2])
work := func() {
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
import (
"os"
"time"
"gobot.io/x/gobot"
@ -9,7 +17,7 @@ import (
)
func main() {
core := particle.NewAdaptor("device_id", "access_token")
core := particle.NewAdaptor(os.Args[1], os.Args[2])
led := gpio.NewLedDriver(core, "A1")
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
import (
"fmt"
"os"
"time"
"gobot.io/x/gobot"
@ -9,7 +17,7 @@ import (
)
func main() {
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN")
core := particle.NewAdaptor(os.Args[1], os.Args[2])
work := func() {
gobot.Every(1*time.Second, func() {