Fork of the espurna firmware for `mhsw` switches
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.

54 lines
1.2 KiB

  1. #if GARLAND_SUPPORT
  2. #include <list>
  3. #include "../anim.h"
  4. #include "../color.h"
  5. #include "../palette.h"
  6. //------------------------------------------------------------------------------
  7. class AnimAssemble : public Anim {
  8. public:
  9. AnimAssemble() : Anim("Assemble") {
  10. cycleFactor = 2;
  11. }
  12. void SetupImpl() override {
  13. inc = 1 + (rngb() >> 5);
  14. if (secureRandom(10) > 5) {
  15. inc = -inc;
  16. }
  17. int p = 0;
  18. for (int i = 0; i < numLeds; i++) {
  19. leds[i] = 0;
  20. Color c = palette->getCachedPalColor((byte)p);
  21. ledstmp[i] = c;
  22. p = p + inc;
  23. if (p >= 256) {
  24. p = p - 256;
  25. } else if (p < 0) {
  26. p = p + 256;
  27. }
  28. }
  29. initSeq();
  30. shuffleSeq();
  31. pos = 0;
  32. }
  33. void Run() override {
  34. if (pos < numLeds) {
  35. byte cur_point = seq[pos];
  36. leds[cur_point] = ledstmp[cur_point];
  37. ++pos;
  38. } else {
  39. int del_pos = pos - numLeds;
  40. byte cur_point = seq[del_pos];
  41. leds[cur_point] = 0;
  42. if (++pos >= numLeds * 2)
  43. pos = 0;
  44. }
  45. }
  46. };
  47. #endif // GARLAND_SUPPORT