Skip to content

Commit

Permalink
dragonboard: fix example and documentation (hybridgroup#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2thomas authored Jul 7, 2023
1 parent 11e1598 commit beaefb7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 76 deletions.
4 changes: 2 additions & 2 deletions examples/dragonboard_button.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (

"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/chip"
"gobot.io/x/gobot/v2/platforms/dragonboard"
)

func main() {
dragonAdaptor := chip.NewAdaptor()
dragonAdaptor := dragonboard.NewAdaptor()
button := gpio.NewButtonDriver(dragonAdaptor, "GPIO_A")

work := func() {
Expand Down
37 changes: 1 addition & 36 deletions platforms/chip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,43 +40,8 @@ Reboot the device to make sure the init script loads the overlay on boot.

## How to Use

Please refer to one example for your platform, e.g. [chip_button.go](https://github.com/hybridgroup/gobot/blob/release/examples/chip_button.go).
The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.

```go
package main

import (
"fmt"

"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/chip"
)

func main() {
chipAdaptor := chip.NewAdaptor()
button := gpio.NewButtonDriver(chipAdaptor, "XIO-P0")

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

gobot.On(button.Event("release"), func(data interface{}) {
fmt.Println("button released")
})
}

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

robot.Start()
}
```

If you want to use the C.H.I.P. Pro, use the `NewProAdaptor()` function like this:

```go
Expand Down
42 changes: 4 additions & 38 deletions platforms/dragonboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,23 @@ transfer the final executable to your DragonBoard and run the program on the Dra

## How to Use

Please refer to one example for your platform, e.g. [dragonboard_button.go](https://github.com/hybridgroup/gobot/blob/release/examples/dragonboard_button.go).
The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself. See [here](https://www.96boards.org/db410c-getting-started/HardwareDocs/HWUserManual.md/).

```go
package main

import (
"fmt"

"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/drivers/gpio"
"gobot.io/x/gobot/v2/platforms/dragonboard"
)

func main() {
dragonAdaptor := dragonboard.NewAdaptor()
button := gpio.NewButtonDriver(dragonAdaptor, "GPIO_A")

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

gobot.On(button.Event("release"), func(data interface{}) {
fmt.Println("button released")
})
}

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

robot.Start()
}
```

## How to Connect

### Compiling

Compile your Gobot program on your workstation like this:

```sh
GOARCH=arm64 GOOS=linux go build examples/dragon_button.go
GOARCH=arm64 GOOS=linux go build examples/dragonboard_button.go
```

Once you have compiled your code, you can you can upload your program and execute it on the DragonBoard from your workstation
using the `scp` and `ssh` commands like this:

```sh
scp dragon_button [email protected]:
ssh -t [email protected] "./dragon_button"
scp dragonboard_button [email protected]:
ssh -t [email protected] "./dragonboard_button"
```

0 comments on commit beaefb7

Please sign in to comment.