add new
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user