@@ -86,7 +86,7 @@ func (led *LEDArray) Display(delay int) error {
86
86
"delay" , delay ,
87
87
"brightness" , led .Brightness ,
88
88
)
89
- err := led .setBrightness ()
89
+ err := led .SetBrightness ()
90
90
if err != nil {
91
91
return err
92
92
}
@@ -107,7 +107,7 @@ func (led *LEDArray) Display(delay int) error {
107
107
// setBrightness turns the LED array to a brightness value
108
108
// and sets the led.brightness value accordingly
109
109
// if it goes out of bounds, it will be set to min or max
110
- func (led * LEDArray ) setBrightness () error {
110
+ func (led * LEDArray ) SetBrightness () error {
111
111
led .checkBrightness ()
112
112
led .Logger .Debugw ("setting brightness" , "value" , led .Brightness )
113
113
led .WS .SetBrightness (0 , led .Brightness )
@@ -142,16 +142,13 @@ func (led *LEDArray) checkBrightness() {
142
142
// Check the bounds
143
143
led .Logger .Debugw ("comparing value to min/max" , "value" , led .Brightness , "min" , led .MinBrightness , "max" , led .MaxBrightness )
144
144
if led .Brightness < led .MinBrightness {
145
- led .Logger .Debugw ("brightness below min, setting to min" , "value" , led .Brightness , "min" , led .MinBrightness )
146
145
led .Brightness = led .MinBrightness
147
146
return
148
147
}
149
148
if led .Brightness > led .MaxBrightness {
150
- led .Logger .Debugw ("brightness above max, setting to max" , "value" , led .Brightness , "max" , led .MaxBrightness )
151
149
led .Brightness = led .MaxBrightness
152
150
return
153
151
}
154
- led .Logger .Debugw ("value is not out of min/max bounds" , "value" , led .Brightness )
155
152
}
156
153
157
154
// Fade goes to a new brightness in the duration specified
@@ -166,9 +163,8 @@ func (led *LEDArray) Fade(target int) error {
166
163
}
167
164
168
165
for _ , step := range ramp {
169
- led .Logger .Debugw ("processing fade step" , "step" , step )
170
166
led .Brightness = step
171
- err := led .setBrightness ()
167
+ err := led .SetBrightness ()
172
168
if err != nil {
173
169
return err
174
170
}
@@ -218,9 +214,9 @@ func (led *LEDArray) Demo(count int, delay int, gradientLength int) {
218
214
func (led * LEDArray ) FadeToggleOnOff () {
219
215
var err error
220
216
if led .Brightness == led .MinBrightness {
221
- err = led .Fade ( led . MaxBrightness )
217
+ err = led .SetMaxBrightness ( )
222
218
} else {
223
- err = led .Fade ( led . MinBrightness )
219
+ err = led .SetMinBrightness ( )
224
220
}
225
221
if err != nil {
226
222
led .Logger .Errorw ("could not change brightness from button press" , "error" , err )
0 commit comments