Closed deadprogram closed 7 years ago
This subject is dear to my heart b/c it was the impetus behind my first submission to the project. I think it's important to provide a clear narrative in the docs helping people understand that the robot abstraction is powerful and useful, but that Gobot also shines as a way to just directly interact with things.
B/c of the adapter interface, I think that the docs can probably just choose one SBC as an example (RPi, BeagleBone, Edison). I vote for Beagle since we've already got an example of using the lib this way in our examples dir.
BTW, I am working on making the following syntax work as you would expect:
package main
import (
"fmt"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
"time"
)
func main() {
e := edison.NewEdisonAdaptor("edison")
led := gpio.NewLedDriver(e, "led", "13")
button := gpio.NewButtonDriver(e, "button", "4")
e.Connect()
led.Start()
button.Start()
for {
select {
case event := <-button.Events:
fmt.Println("Event:", event.Name, event.Data)
if event.Name == "pushed" {
led.Toggle()
}
}
}
}
It does not work quite yet, but that is a temporary condition.
Progress! This actually works in my branch:
package main
import (
"fmt"
"github.com/hybridgroup/gobot/platforms/gpio"
"github.com/hybridgroup/gobot/platforms/intel-iot/edison"
)
func main() {
e := edison.NewEdisonAdaptor("edison")
led := gpio.NewLedDriver(e, "led", "13")
button := gpio.NewButtonDriver(e, "button", "5")
e.Connect()
led.Start()
button.Start()
led.Off()
buttonEvents := button.Subscribe()
for {
select {
case event := <-buttonEvents:
fmt.Println("Event:", event.Name, event.Data)
if event.Name == "push" {
led.Toggle()
}
}
}
}
Nice!
On Aug 30, 2016, at 6:19 AM, Ron Evans notifications@github.com wrote:
Progress! This actually works in my branch:
package main
import ( "fmt" "github.com/hybridgroup/gobot/platforms/gpio" "github.com/hybridgroup/gobot/platforms/intel-iot/edison" )
func main() { e := edison.NewEdisonAdaptor("edison") led := gpio.NewLedDriver(e, "led", "13") button := gpio.NewButtonDriver(e, "button", "5")
e.Connect() led.Start() button.Start() led.Off() buttonEvents := button.Subscribe() for { select { case event := <-buttonEvents: fmt.Println("Event:", event.Name, event.Data) if event.Name == "push" { led.Toggle() } } }
} — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
is there anything I can do to help w/ this or you got it? Do we need further additions/explanations in the docs?
Hi @trevrosen please check out https://github.com/hybridgroup/gobot/pull/306 and give feedback!
Also, I have entered an issue for a proposed change related to new driver and new adaptor function signatures. Please check it out at https://github.com/hybridgroup/gobot/issues/307
This was released as part of Gobot 1.0 so closing.
We need to add some docs that show how to use Gobot as a library, without using the entire framework, as discussed over in https://github.com/hybridgroup/gobot/issues/302