This commit is contained in:
Jay
2020-04-17 16:41:48 +08:00
parent d7f1b47860
commit 31150c8280
12 changed files with 487 additions and 2 deletions
+16
View File
@@ -23,6 +23,7 @@ func Init(gpio, count, brightness int) (*LED, error) {
err := ws2811.Init(gpio, count, brightness)
if err != nil {
led = nil
return nil, err
}
@@ -36,15 +37,30 @@ func Init(gpio, count, brightness int) (*LED, error) {
return led, nil
}
func IsInit() bool {
if led == nil {
return false
}
return led.IsInit
}
func Close() {
ws2811.Clear()
ws2811.Fini()
led.IsInit = false
}
func ClearAll() {
ws2811.Clear()
}
func Len() int {
if led == nil {
return 0
}
return led.Count
}
func WriteColor(pos int, color uint32) error {
if pos < 0 || pos > led.Count {
return errors.New("position out of range")