(WIP) RGB controller on Arduino w/ sync to main PC system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aura.cpp 817B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "aura.h"
  2. #include "color.h"
  3. // ==== The Aura Rainbow Effect ====
  4. void AuraEffect::reset() {
  5. auraCounter = 0;
  6. paletteCounter = 0;
  7. auraWidth = NUM_LEDS;
  8. }
  9. void AuraEffect::stepColor() {
  10. curColor = *getPaletteColor(paletteCounter);
  11. nextColor = *nextPaletteColor(&paletteCounter);
  12. }
  13. void AuraEffect::postInit() {
  14. this->stepColor();
  15. }
  16. void AuraEffect::onUpdate() {
  17. // Shift all LEDs left by 1 px
  18. for (int i = 0; i < NUM_LEDS - 1; i++) {
  19. leds[i] = CRGB(leds[i + 1].r, leds[i + 1].g, leds[i + 1].b);
  20. }
  21. // Calculate the color for the last LED
  22. int last = NUM_LEDS - 1;
  23. leds[last] = blendColor(curColor, nextColor, auraCounter, auraWidth);
  24. if (auraCounter == (auraWidth - 1)) {
  25. this->stepColor();
  26. }
  27. // Increment the counter
  28. auraCounter = (auraCounter + 1) % auraWidth;
  29. }