fixed formating issue identified by black and pylint
This commit is contained in:
parent
5f56db76aa
commit
c3b868b880
2 changed files with 13 additions and 13 deletions
|
|
@ -90,14 +90,11 @@ class Sparkle(Animation):
|
|||
def _random_in_mask(self):
|
||||
if len(self._mask) == 0:
|
||||
return random.randint(0, (len(self.pixel_object) - 1))
|
||||
else:
|
||||
return self._mask[random.randint(0, (len(self._mask)-1))]
|
||||
else:
|
||||
return self._mask[random.randint(0, (len(self._mask) - 1))]
|
||||
|
||||
def draw(self):
|
||||
self._pixels = [
|
||||
self._random_in_mask()
|
||||
for _ in range(self._num_sparkles)
|
||||
]
|
||||
self._pixels = [self._random_in_mask() for _ in range(self._num_sparkles)]
|
||||
for pixel in self._pixels:
|
||||
self.pixel_object[pixel] = self._sparkle_color
|
||||
|
||||
|
|
@ -105,5 +102,5 @@ class Sparkle(Animation):
|
|||
self.show()
|
||||
for pixel in self._pixels:
|
||||
self.pixel_object[pixel % self._num_pixels] = self._half_color
|
||||
if (pixel+1) % self._num_pixels in self._mask: self.pixel_object[(pixel + 1) % self._num_pixels] = self._dim_color
|
||||
|
||||
if (pixel + 1) % self._num_pixels in self._mask:
|
||||
self.pixel_object[(pixel + 1) % self._num_pixels] = self._dim_color
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@ import neopixel
|
|||
|
||||
from adafruit_led_animation.animation.sparkle import Sparkle
|
||||
from adafruit_led_animation.sequence import AnimationSequence
|
||||
from adafruit_led_animation.color import AMBER, JADE, AQUA, PINK
|
||||
from adafruit_led_animation.color import JADE, AQUA, PINK
|
||||
|
||||
# Update to match the pin connected to your NeoPixels
|
||||
# Update to match the pin connected to your NeoPixels
|
||||
pixel_pin = board.A1
|
||||
# Update to match the number of NeoPixels you have connected
|
||||
pixel_num = 64
|
||||
# fmt: off
|
||||
heart_mask = [ 1, 2, 5, 6,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23,
|
||||
|
|
@ -32,6 +33,7 @@ unheart_mask = [0, 3, 4, 7,
|
|||
40, 41, 46, 47,
|
||||
48, 49, 50, 53, 54, 55,
|
||||
56, 57, 58, 59, 60, 61, 62, 63]
|
||||
# fmt: on
|
||||
|
||||
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.9, auto_write=False)
|
||||
|
||||
|
|
@ -39,8 +41,9 @@ animations = AnimationSequence(
|
|||
Sparkle(pixels, speed=0.05, color=JADE, num_sparkles=1, mask=unheart_mask),
|
||||
Sparkle(pixels, speed=0.05, color=AQUA, num_sparkles=1),
|
||||
Sparkle(pixels, speed=0.05, color=PINK, num_sparkles=1, mask=heart_mask),
|
||||
advance_interval=5, auto_clear=False,
|
||||
advance_interval=5,
|
||||
auto_clear=False,
|
||||
)
|
||||
|
||||
|
||||
while True:
|
||||
animations.animate()
|
||||
animations.animate()
|
||||
|
|
|
|||
Loading…
Reference in a new issue