rgb animations perf

This commit is contained in:
Kyle Brown committed 2019-07-17 16:05:40 -07:00
1 parent c11984135a
commit b6af43ef90
2 files changed
+21 -20

No files matched your search

+5 -1
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()
+16 -19
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