mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-29 13:49:14 +08:00
Refactor beaglebone to use new adaptor interface
This commit is contained in:
parent
9a0f3b46f7
commit
149760e392
@ -14,7 +14,8 @@ import (
|
|||||||
"github.com/hybridgroup/gobot/sysfs"
|
"github.com/hybridgroup/gobot/sysfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ gobot.AdaptorInterface = (*BeagleboneAdaptor)(nil)
|
var _ gobot.Adaptor = (*BeagleboneAdaptor)(nil)
|
||||||
|
|
||||||
var slots = "/sys/devices/bone_capemgr.*"
|
var slots = "/sys/devices/bone_capemgr.*"
|
||||||
var ocp = "/sys/devices/ocp.*"
|
var ocp = "/sys/devices/ocp.*"
|
||||||
var usrLed = "/sys/devices/ocp.3/gpio-leds.8/leds/beaglebone:green:"
|
var usrLed = "/sys/devices/ocp.3/gpio-leds.8/leds/beaglebone:green:"
|
||||||
@ -114,7 +115,7 @@ var analogPins = map[string]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BeagleboneAdaptor struct {
|
type BeagleboneAdaptor struct {
|
||||||
gobot.Adaptor
|
name string
|
||||||
digitalPins []sysfs.DigitalPin
|
digitalPins []sysfs.DigitalPin
|
||||||
pwmPins map[string]*pwmPin
|
pwmPins map[string]*pwmPin
|
||||||
i2cDevice io.ReadWriteCloser
|
i2cDevice io.ReadWriteCloser
|
||||||
@ -126,10 +127,7 @@ type BeagleboneAdaptor struct {
|
|||||||
// NewBeagleboneAdaptor returns a new beaglebone adaptor with specified name
|
// NewBeagleboneAdaptor returns a new beaglebone adaptor with specified name
|
||||||
func NewBeagleboneAdaptor(name string) *BeagleboneAdaptor {
|
func NewBeagleboneAdaptor(name string) *BeagleboneAdaptor {
|
||||||
b := &BeagleboneAdaptor{
|
b := &BeagleboneAdaptor{
|
||||||
Adaptor: *gobot.NewAdaptor(
|
name: name,
|
||||||
name,
|
|
||||||
"BeagleboneAdaptor",
|
|
||||||
),
|
|
||||||
digitalPins: make([]sysfs.DigitalPin, 120),
|
digitalPins: make([]sysfs.DigitalPin, 120),
|
||||||
pwmPins: make(map[string]*pwmPin),
|
pwmPins: make(map[string]*pwmPin),
|
||||||
}
|
}
|
||||||
@ -141,6 +139,7 @@ func NewBeagleboneAdaptor(name string) *BeagleboneAdaptor {
|
|||||||
|
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
func (b *BeagleboneAdaptor) Name() string { return b.name }
|
||||||
|
|
||||||
// Connect returns true on a succesful connection to beaglebone board.
|
// Connect returns true on a succesful connection to beaglebone board.
|
||||||
// It initializes digital, pwm and analog pins
|
// It initializes digital, pwm and analog pins
|
||||||
|
@ -2,9 +2,10 @@ package beaglebone
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hybridgroup/gobot/sysfs"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hybridgroup/gobot/sysfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type pwmPin struct {
|
type pwmPin struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user