-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename iot package to led and add port flag
- Loading branch information
Showing
10 changed files
with
76 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//+build !windows | ||
|
||
package led | ||
|
||
import "github.com/stianeikeland/go-rpio/v4" | ||
|
||
const ( | ||
defautPin = 23 | ||
) | ||
|
||
func EnableLed(port int) error { | ||
var pin rpio.Pin | ||
if port == 0 { | ||
pin = rpio.Pin(defautPin) | ||
} else { | ||
pin = rpio.Pin(port) | ||
} | ||
|
||
err := rpio.Open() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Switch on | ||
pin.Output() | ||
pin.High() | ||
|
||
return nil | ||
} | ||
|
||
func DisableLed(port int) error { | ||
var pin rpio.Pin | ||
if port == 0 { | ||
pin = rpio.Pin(defautPin) | ||
} else { | ||
pin = rpio.Pin(port) | ||
} | ||
|
||
// Switch off | ||
pin.Output() | ||
pin.Low() | ||
|
||
return rpio.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
//+build windows | ||
|
||
package iot | ||
package led | ||
|
||
func EnablePin() error { | ||
return nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters