Bandeau de LEDs contrôlable (puissance, couleur, effet) au travers de Home Assistant
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.

185 lines
6.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #define SERIAL_SPEED 115200
  2. // OTA
  3. #define OTA_PASSWORD "n87z21Tx5%P%EX&*"
  4. // DebugRemote
  5. RemoteDebug Debug;
  6. // LED
  7. #define LED_NUM 300
  8. #define LED_PIN 5 // = D5
  9. #define LED_CHIPSET WS2812B
  10. #define LED_COLOR_ORDER GRB
  11. #define LED_BRIGHTNESS_DEFAULT 96
  12. #define LED_SPEED_DEFAULT 120
  13. #define LED_COLOR_DEFAULT CRGB::Red
  14. #define LED_EFFECT_CYLON "cylon"
  15. #define LED_EFFECT_COLORPATTERN "colorp"
  16. #define LED_EFFECT_COLORTEMP "colort"
  17. #define LED_EFFECT_FIRE "fire"
  18. #define LED_EFFECT_BREATHING "breathing"
  19. #define LED_EFFECT_ERROR "error"
  20. // WIFI
  21. #define WIFI_SSID "XXX"
  22. #define WIFI_PASSWORD "XXX"
  23. // MQTT
  24. #define MQTT_SERVER "XXX"
  25. #define MQTT_PORT 1883
  26. #define MQTT_USER "XXX"
  27. #define MQTT_PASS "XXX"
  28. #define MQTT_LED_COMMAND "strip1/switch"
  29. #define MQTT_LED_STATE "strip1/status"
  30. #define MQTT_LED_EFFECT_COMMAND "strip1/effect/switch"
  31. #define MQTT_LED_EFFECT_STATE "strip1/effect/status"
  32. #define MQTT_LED_BRIGHTNESS_COMMAND "strip1/brightness/switch"
  33. #define MQTT_LED_BRIGHTNESS_STATE "strip1/brightness/status"
  34. #define MQTT_LED_SPEED_COMMAND "strip1/speed/switch"
  35. #define MQTT_LED_SPEED_STATE "strip1/speed/status"
  36. #define MQTT_LED_COLOR_COMMAND "strip1/color/switch"
  37. #define MQTT_LED_COLOR_STATE "strip1/color/status"
  38. void setupOTA();
  39. void setupWifi();
  40. void testConnectMQTT();
  41. void callbackMQTT(char* topic, byte* payload, unsigned int length);
  42. void mqttSendState();
  43. void mqttSendEffectState();
  44. void mqttSendBrightnessState();
  45. void mqttSendSpeedState();
  46. void mqttSendColorState();
  47. void ledBlackAll();
  48. void ledCylon();
  49. void ledError();
  50. void ledBreathing();
  51. ///////////////////////////////// ColorPalette
  52. // This example shows several ways to set up and use 'palettes' of colors
  53. // with FastLED.
  54. //
  55. // These compact palettes provide an easy way to re-colorize your
  56. // animation on the fly, quickly, easily, and with low overhead.
  57. //
  58. // USING palettes is MUCH simpler in practice than in theory, so first just
  59. // run this sketch, and watch the pretty lights as you then read through
  60. // the code. Although this sketch has eight (or more) different color schemes,
  61. // the entire sketch compiles down to about 6.5K on AVR.
  62. //
  63. // FastLED provides a few pre-configured color palettes, and makes it
  64. // extremely easy to make up your own color schemes with palettes.
  65. //
  66. // Some notes on the more abstract 'theory and practice' of
  67. // FastLED compact palettes are at the bottom of this file.
  68. CRGBPalette16 currentPalette;
  69. TBlendType currentBlending;
  70. extern CRGBPalette16 myRedWhiteBluePalette;
  71. extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
  72. // This example shows how to set up a static color palette
  73. // which is stored in PROGMEM (flash), which is almost always more
  74. // plentiful than RAM. A static PROGMEM palette like this
  75. // takes up 64 bytes of flash.
  76. const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
  77. {
  78. CRGB::Red,
  79. CRGB::Gray, // 'white' is too bright compared to red and blue
  80. CRGB::Blue,
  81. CRGB::Black,
  82. CRGB::Red,
  83. CRGB::Gray,
  84. CRGB::Blue,
  85. CRGB::Black,
  86. CRGB::Red,
  87. CRGB::Red,
  88. CRGB::Gray,
  89. CRGB::Gray,
  90. CRGB::Blue,
  91. CRGB::Blue,
  92. CRGB::Black,
  93. CRGB::Black
  94. };
  95. void ledColorPattern();
  96. void FillLEDsFromPaletteColors(uint8_t colorIndex);
  97. void ChangePalettePeriodically();
  98. void SetupTotallyRandomPalette();
  99. void SetupBlackAndWhiteStripedPalette();
  100. void SetupPurpleAndGreenPalette();
  101. //////////////////////////////////////////////// ColorTemperature
  102. // THIS EXAMPLE demonstrates the second, "color temperature" control.
  103. // It shows a simple rainbow animation first with one temperature profile,
  104. // and a few seconds later, with a different temperature profile.
  105. //
  106. // The first pixel of the strip will show the color temperature.
  107. //
  108. // HELPFUL HINTS for "seeing" the effect in this demo:
  109. // * Don't look directly at the LED pixels. Shine the LEDs aganst
  110. // a white wall, table, or piece of paper, and look at the reflected light.
  111. //
  112. // * If you watch it for a bit, and then walk away, and then come back
  113. // to it, you'll probably be able to "see" whether it's currently using
  114. // the 'redder' or the 'bluer' temperature profile, even not counting
  115. // the lowest 'indicator' pixel.
  116. //
  117. //
  118. // FastLED provides these pre-conigured incandescent color profiles:
  119. // Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc,
  120. // HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky,
  121. // FastLED provides these pre-configured gaseous-light color profiles:
  122. // WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent,
  123. // FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent,
  124. // MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium,
  125. // FastLED also provides an "Uncorrected temperature" profile
  126. // UncorrectedTemperature;
  127. #define TEMPERATURE_1 Tungsten100W
  128. #define TEMPERATURE_2 OvercastSky
  129. // How many seconds to show each temperature before switching
  130. #define DISPLAYTIME 20
  131. // How many seconds to show black between switches
  132. #define BLACKTIME 3
  133. void colorTemp();
  134. ///////////////////////////////////////////////Fire202
  135. bool gReverseDirection = false;
  136. // This basic one-dimensional 'fire' simulation works roughly as follows:
  137. // There's a underlying array of 'heat' cells, that model the temperature
  138. // at each point along the line. Every cycle through the simulation,
  139. // four steps are performed:
  140. // 1) All cells cool down a little bit, losing heat to the air
  141. // 2) The heat from each cell drifts 'up' and diffuses a little
  142. // 3) Sometimes randomly new 'sparks' of heat are added at the bottom
  143. // 4) The heat from each cell is rendered as a color into the leds array
  144. // The heat-to-color mapping uses a black-body radiation approximation.
  145. //
  146. // Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
  147. //
  148. // This simulation scales it self a bit depending on NUM_LEDS; it should look
  149. // "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
  150. //
  151. // I recommend running this simulation at anywhere from 30-100 frames per second,
  152. // meaning an interframe delay of about 10-35 milliseconds.
  153. //
  154. // Looks best on a high-density LED setup (60+ pixels/meter).
  155. //
  156. //
  157. // There are two main parameters you can play with to control the look and
  158. // feel of your fire: COOLING (used in step 1 above), and SPARKING (used
  159. // in step 3 above).
  160. //
  161. // COOLING: How much does the air cool as it rises?
  162. // Less cooling = taller flames. More cooling = shorter flames.
  163. // Default 50, suggested range 20-100
  164. #define COOLING 55
  165. // SPARKING: What chance (out of 255) is there that a new spark will be lit?
  166. // Higher chance = more roaring fire. Lower chance = more flickery fire.
  167. // Default 120, suggested range 50-200.
  168. #define SPARKING 120
  169. void fire();