ESP32 Native version of Blinky, featureful controller code for WS2811/WS2812/NeoPixels
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.

62 lines
1.0KB

  1. #include <map>
  2. #include "presets.hpp"
  3. namespace Gradients {
  4. #define GRADIENT(name, len, ...) \
  5. constexpr Gradient name = { \
  6. .n_colors = len, \
  7. .colors = __VA_ARGS__, \
  8. }
  9. GRADIENT(rainbow, 6, {
  10. Colors::red,
  11. Colors::orange,
  12. Colors::yellow,
  13. Colors::green,
  14. Colors::blue,
  15. Colors::purple,
  16. });
  17. GRADIENT(peacock, 4, {
  18. Colors::teal,
  19. Colors::black,
  20. Colors::purple,
  21. Colors::blue,
  22. });
  23. } // Gradients
  24. namespace Patterns {
  25. #define PATTERN(x) \
  26. static const Pattern x = { \
  27. .cycle_length = 20, \
  28. .cycle_time_ms = 10000, \
  29. .reverse = false, \
  30. .march = false, \
  31. .gradient = Gradients::x, \
  32. }
  33. PATTERN(rainbow);
  34. PATTERN(peacock);
  35. } // Patterns
  36. #define PRESET(x) {#x, &Patterns::x}
  37. static const std::map <std::string, const Pattern*> presets = {
  38. PRESET(rainbow),
  39. PRESET(peacock),
  40. };
  41. const Pattern* Presets::find(const std::string &name) {
  42. auto e = presets.find(name);
  43. return e == presets.end() ? NULL : e->second;
  44. }