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.

38 lines
810 B

  1. #if GARLAND_SUPPORT
  2. #include "../anim.h"
  3. #include "../color.h"
  4. #include "../palette.h"
  5. //------------------------------------------------------------------------------
  6. class AnimRun : public Anim {
  7. public:
  8. AnimRun() : Anim("Run") {
  9. }
  10. void SetupImpl() override {
  11. pos = 0;
  12. inc = 1 + (rngb() >> 5);
  13. if (secureRandom(10) > 5) {
  14. inc = -inc;
  15. }
  16. }
  17. void Run() override {
  18. int p = pos;
  19. for (int i = 0; i < numLeds; ++i) {
  20. Color c = palette->getCachedPalColor((byte)p);
  21. leds[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. pos = pos + 1;
  30. }
  31. };
  32. #endif // GARLAND_SUPPORT