mirror of
https://github.com/kidoman/embd
synced 2025-07-03 11:57:38 +02:00
make the process of registered available hosts less clunky
This commit is contained in:
parent
2504678ba9
commit
ef87ad7879
7 changed files with 66 additions and 69 deletions
|
@ -7,23 +7,20 @@ import (
|
|||
"github.com/kidoman/embd/i2c"
|
||||
)
|
||||
|
||||
type descriptor struct {
|
||||
rev int
|
||||
func init() {
|
||||
host.Describers[host.RPi] = describer
|
||||
}
|
||||
|
||||
func (d *descriptor) GPIO() gpio.GPIO {
|
||||
func describer(rev int) *host.Descriptor {
|
||||
var pins = rev1Pins
|
||||
if d.rev > 1 {
|
||||
pins = rev2Pins
|
||||
}
|
||||
|
||||
return lgpio.New(pins)
|
||||
}
|
||||
|
||||
func (d *descriptor) I2C() i2c.I2C {
|
||||
return li2c.New()
|
||||
}
|
||||
|
||||
func Descriptor(rev int) *descriptor {
|
||||
return &descriptor{rev}
|
||||
return &host.Descriptor{
|
||||
GPIO: func() gpio.GPIO {
|
||||
return lgpio.New(pins)
|
||||
},
|
||||
I2C: li2c.New,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue