Updated the examples to show how to setup the sparkfun edison

This commit is contained in:
devfubar 2016-10-22 15:13:45 +01:00
parent 54d9b16141
commit bf4b74cb57
4 changed files with 148 additions and 8 deletions

View File

@ -12,6 +12,10 @@ func main() {
e := edison.NewAdaptor() e := edison.NewAdaptor()
led := gpio.NewLedDriver(e, "13") led := gpio.NewLedDriver(e, "13")
// Uncomment the line below if you are using a Sparkfun
// Edison board with the GPIO block
// e.SetBoard("sparkfun")
work := func() { work := func() {
gobot.Every(1*time.Second, func() { gobot.Every(1*time.Second, func() {
led.Toggle() led.Toggle()

View File

@ -62,6 +62,10 @@ func main() {
e := edison.NewAdaptor() e := edison.NewAdaptor()
led := gpio.NewLedDriver(e, "13") led := gpio.NewLedDriver(e, "13")
// Uncomment the line below if you are using a Sparkfun
// Edison board with the GPIO block
// e.SetBoard("sparkfun")
work := func() { work := func() {
gobot.Every(1*time.Second, func() { gobot.Every(1*time.Second, func() {
led.Toggle() led.Toggle()

View File

@ -93,14 +93,26 @@ func (e *Adaptor) SetBoard(n string) { e.board = n }
func (e *Adaptor) Connect() (errs []error) { func (e *Adaptor) Connect() (errs []error) {
e.digitalPins = make(map[int]sysfs.DigitalPin) e.digitalPins = make(map[int]sysfs.DigitalPin)
e.pwmPins = make(map[int]*pwmPin) e.pwmPins = make(map[int]*pwmPin)
if e.board != "arduino" {
switch e.Board() {
case "sparkfun":
e.pinmap = sparkfunPinMap
if err := e.sparkfunSetup(); err != nil {
errs = append(errs, err)
}
case "arduino":
e.pinmap = arduinoPinMap
if err := e.arduinoSetup(); err != nil {
errs = append(errs, err)
}
case "miniboard":
e.pinmap = miniboardPinMap e.pinmap = miniboardPinMap
if err := e.miniboardSetup(); err != nil { if err := e.miniboardSetup(); err != nil {
return []error{err} errs = append(errs, err)
} }
} default:
if err := e.arduinoSetup(); err != nil { err := errors.New("Unknown board type: " + e.Board())
return []error{err} errs = append(errs, err)
} }
return return
} }
@ -244,6 +256,10 @@ func (e *Adaptor) arduinoI2CSetup() (err error) {
return return
} }
func (e *Adaptor) sparkfunSetup() (err error) {
return
}
// miniboardSetup does needed setup for Edison minibpard and other compatible boards // miniboardSetup does needed setup for Edison minibpard and other compatible boards
func (e *Adaptor) miniboardSetup() (err error) { func (e *Adaptor) miniboardSetup() (err error) {
return return

View File

@ -0,0 +1,116 @@
package edison
var sparkfunPinMap = map[string]sysfsPin{
"12": sysfsPin{
pin: 12,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"13": sysfsPin{
pin: 13,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"14": sysfsPin{
pin: 14,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"15": sysfsPin{
pin: 15,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"44": sysfsPin{
pin: 44,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"45": sysfsPin{
pin: 45,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"46": sysfsPin{
pin: 46,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"47": sysfsPin{
pin: 47,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"48": sysfsPin{
pin: 48,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"49": sysfsPin{
pin: 49,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"128": sysfsPin{
pin: 128,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"129": sysfsPin{
pin: 129,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"130": sysfsPin{
pin: 130,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"131": sysfsPin{
pin: 131,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"182": sysfsPin{
pin: 182,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
"183": sysfsPin{
pin: 183,
resistor: -1,
levelShifter: -1,
pwmPin: -1,
mux: []mux{},
},
}