File tree 2 files changed +19
-9
lines changed
adafruit_led_animation/animation
2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ def bar_colors():
96
96
bar_no += 1
97
97
98
98
colorgen = bar_colors ()
99
- self .pixel_object [:] = [next (colorgen ) for _ in self .pixel_object ]
99
+ self .pixel_object [:] = [next (colorgen ) for _ in range ( len ( self .pixel_object )) ]
100
100
101
101
if self .draw_count % len (self .pixel_object ) == 0 :
102
102
self .cycle_complete = True
Original file line number Diff line number Diff line change @@ -120,14 +120,24 @@ def draw(self):
120
120
colors = self ._comet_colors
121
121
if self .reverse :
122
122
colors = reversed (colors )
123
- for pixel_no , color in enumerate (colors ):
124
- draw_at = self ._tail_start + pixel_no
125
- if draw_at < 0 or draw_at >= self ._num_pixels :
126
- if not self ._ring :
127
- continue
128
- draw_at = draw_at % self ._num_pixels
129
-
130
- self .pixel_object [draw_at ] = color
123
+
124
+ pixels = self .pixel_object
125
+ start = self ._tail_start
126
+ npixels = len (pixels )
127
+ if self ._ring :
128
+ start %= npixels
129
+ for color in colors :
130
+ pixels [start ] = color
131
+ start += 1
132
+ if start == npixels :
133
+ start = 0
134
+ else :
135
+ for color in colors :
136
+ if start >= npixels :
137
+ break
138
+ if start >= 0 :
139
+ pixels [start ] = color
140
+ start += 1
131
141
132
142
self ._tail_start += self ._direction
133
143
You can’t perform that action at this time.
0 commit comments