-
Notifications
You must be signed in to change notification settings - Fork 0
/
led.go
39 lines (32 loc) · 837 Bytes
/
led.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package gobone
import (
"fmt"
)
type LED struct {
Sys sysfs_led
Value string //"0" or "1"
}
//LED Globals
var (
Usr0 = LED{Sys: sysfs_led{SysfsLOC: "/beaglebone:green:usr0", Name: "usr0"}}
Usr1 = LED{Sys: sysfs_led{SysfsLOC: "/beaglebone:green:usr1", Name: "usr1"}}
Usr2 = LED{Sys: sysfs_led{SysfsLOC: "/beaglebone:green:usr2", Name: "usr2"}}
Usr3 = LED{Sys: sysfs_led{SysfsLOC: "/beaglebone:green:usr3", Name: "usr3"}}
)
//GetLEDSysfs - returns complete abs path to gpio dir
//
func (l *LED) GetLEDSysfs() string {
return ledBase + l.Sys.SysfsLOC
}
//LedOff - turns LED off
//
func (l *LED) LedOff() {
fmt.Printf("LED %s off\n", l)
WriteAndClose(l.GetLEDSysfs()+"/brightness", "0")
}
//LedOn - turns LED on
//
func (l *LED) LedOn() {
fmt.Printf("LED %s on\n", l)
WriteAndClose(l.GetLEDSysfs()+"/brightness", "1")
}