ESP32 Native version of Blinky, featureful controller code for WS2811/WS2812/NeoPixels
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

63 rindas
1.0KB

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