rgb animations perf

This commit is contained in:
Kyle Brown 2019-07-13 18:07:37 -07:00
parent c11984135a
commit b6af43ef90
2 changed files with 21 additions and 20 deletions

View File

@ -289,6 +289,7 @@ class Firmware:
if self.rgb_pixel_pin:
self.pixels = rgb.RGB(self.rgb_config, self.rgb_pixel_pin)
self.rgb_config = None # No longer needed
self.pixels.loopcounter = 0
else:
self.pixels = None
@ -351,7 +352,10 @@ class Firmware:
self._send_hid()
if self.pixels and self.pixels.enabled and self.pixels.animation_mode:
self.pixels = self.pixels.animate()
self.pixels.loopcounter +=1
if self.pixels.loopcounter >= 7:
self.pixels = self.pixels.animate()
self.pixels.loopcounter = 0
if self.led and self.led.enabled and self.led.animation_mode:
self.led = self.led.animate()

View File

@ -432,33 +432,30 @@ class RGB:
return self
def effect_breathing_rainbow(self):
if self._animation_step():
self.increase_hue(self.animation_speed)
self.increase_hue(self.animation_speed)
self.effect_breathing()
return self
def effect_rainbow(self):
if self._animation_step():
self.increase_hue(self.animation_speed)
self.set_hsv_fill(self.hue, self.sat, self.val)
self.increase_hue(self.animation_speed)
self.set_hsv_fill(self.hue, self.sat, self.val)
return self
def effect_swirl(self):
if self._animation_step():
self.increase_hue(self.animation_speed)
self.disable_auto_write = True # Turn off instantly showing
for i in range(0, self.num_pixels):
self.set_hsv(
(self.hue - (i * self.num_pixels)) % 360,
self.sat,
self.val,
i)
self.increase_hue(self.animation_speed * 2)
self.disable_auto_write = True # Turn off instantly showing
for i in range(0, self.num_pixels):
self.set_hsv(
(self.hue - (i * self.num_pixels)) % 360,
self.sat,
self.val,
i)
# Show final results
self.disable_auto_write = False # Resume showing changes
self.show()
# Show final results
self.disable_auto_write = False # Resume showing changes
self.show()
return self
def effect_knight(self):
@ -476,9 +473,9 @@ class RGB:
self.reverse_animation = not self.reverse_animation
if self.reverse_animation:
self.pos -= self.animation_speed / 5
self.pos -= self.animation_speed / 2
else:
self.pos += self.animation_speed / 5
self.pos += self.animation_speed / 2
# Show final results
self.disable_auto_write = False # Resume showing changes