mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
added documentation
This commit is contained in:
parent
3f88b67361
commit
a35692aabb
6 changed files with 57 additions and 0 deletions
12
led.go
12
led.go
|
@ -1,5 +1,8 @@
|
|||
// LED support.
|
||||
|
||||
package embd
|
||||
|
||||
// The LED interface is used to control a led on the prototyping board.
|
||||
type LED interface {
|
||||
On() error
|
||||
Off() error
|
||||
|
@ -9,6 +12,8 @@ type LED interface {
|
|||
Close() error
|
||||
}
|
||||
|
||||
// LEDDriver interface interacts with the host descriptors to allow us
|
||||
// control of the LEDs.
|
||||
type LEDDriver interface {
|
||||
LED(key interface{}) (LED, error)
|
||||
|
||||
|
@ -17,6 +22,7 @@ type LEDDriver interface {
|
|||
|
||||
var ledDriverInstance LEDDriver
|
||||
|
||||
// InitLED initializes the LED driver.
|
||||
func InitLED() error {
|
||||
desc, err := DescribeHost()
|
||||
if err != nil {
|
||||
|
@ -32,14 +38,18 @@ func InitLED() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// CloseLED gracefully closes the LED driver.
|
||||
func CloseLED() error {
|
||||
return ledDriverInstance.Close()
|
||||
}
|
||||
|
||||
// NewLED returns a LED interface which allows control over the LED
|
||||
// represented by key.
|
||||
func NewLED(key interface{}) (LED, error) {
|
||||
return ledDriverInstance.LED(key)
|
||||
}
|
||||
|
||||
// LEDOn switches the corresponding LED on.
|
||||
func LEDOn(key interface{}) error {
|
||||
led, err := NewLED(key)
|
||||
if err != nil {
|
||||
|
@ -49,6 +59,7 @@ func LEDOn(key interface{}) error {
|
|||
return led.On()
|
||||
}
|
||||
|
||||
// LEDOff switches the corresponding LED off.
|
||||
func LEDOff(key interface{}) error {
|
||||
led, err := NewLED(key)
|
||||
if err != nil {
|
||||
|
@ -58,6 +69,7 @@ func LEDOff(key interface{}) error {
|
|||
return led.Off()
|
||||
}
|
||||
|
||||
// LEDToggle toggles the corresponding LED.
|
||||
func LEDToggle(key interface{}) error {
|
||||
led, err := NewLED(key)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue