mirror of
https://github.com/kidoman/embd
synced 2025-07-04 20:37:46 +02:00
gpio library for rpi
This commit is contained in:
parent
283e8eb140
commit
b7096cfe6c
6 changed files with 480 additions and 0 deletions
24
gpio/pinmap.go
Normal file
24
gpio/pinmap.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package gpio
|
||||
|
||||
type pinMap []*pinDesc
|
||||
|
||||
func (m pinMap) lookup(k interface{}) (*pinDesc, bool) {
|
||||
switch key := k.(type) {
|
||||
case int:
|
||||
for i := range m {
|
||||
if m[i].n == key {
|
||||
return m[i], true
|
||||
}
|
||||
}
|
||||
case string:
|
||||
for i := range m {
|
||||
for j := range m[i].ids {
|
||||
if m[i].ids[j] == key {
|
||||
return m[i], true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue