Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dragonboard: fix example and documentation #977

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 root@192.168.1.xx:
ssh -t root@192.168.1.xx "./dragon_button"
scp dragonboard_button root@192.168.1.xx:
ssh -t root@192.168.1.xx "./dragonboard_button"
```