From 57865e58681e0d73540bf9c21022bc5011d18334 Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Fri, 10 Mar 2017 13:59:30 +0100 Subject: [PATCH] oubli de definition dans le .h d'exemple --- arduino/mqttfastledmenu/mqttfastledmenu.cpp | 10 +- .../mqttfastledmenu/mqttfastledmenu.example.h | 134 +++++++++++++++++- 2 files changed, 130 insertions(+), 14 deletions(-) diff --git a/arduino/mqttfastledmenu/mqttfastledmenu.cpp b/arduino/mqttfastledmenu/mqttfastledmenu.cpp index f061c1f..4b7124f 100644 --- a/arduino/mqttfastledmenu/mqttfastledmenu.cpp +++ b/arduino/mqttfastledmenu/mqttfastledmenu.cpp @@ -8,7 +8,6 @@ #include #include "mqttfastledmenu.h" -#include "ledeffect.c" // LED int brightness = LED_BRIGHTNESS_DEFAULT; @@ -25,13 +24,6 @@ WiFiClient espClient; char message_buff[100]; PubSubClient client(espClient); - -//////////////////////////////// ColorPalette -CRGBPalette16 currentPalette; -TBlendType currentBlending; - -extern CRGBPalette16 myRedWhiteBluePalette; -extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM; /////////////////////////////////////////////// void setup() @@ -273,7 +265,7 @@ void ledColorPattern() FastLED.delay(1000 / speed); } -void FillLEDsFromPaletteColors( uint8_t colorIndex) +void FillLEDsFromPaletteColors(uint8_t colorIndex) { uint8_t brightness = 255; diff --git a/arduino/mqttfastledmenu/mqttfastledmenu.example.h b/arduino/mqttfastledmenu/mqttfastledmenu.example.h index 3653ce5..2ee2ea4 100644 --- a/arduino/mqttfastledmenu/mqttfastledmenu.example.h +++ b/arduino/mqttfastledmenu/mqttfastledmenu.example.h @@ -10,6 +10,9 @@ #define LED_COLOR_DEFAULT CRGB::Red #define LED_EFFECT_CYLON "cylon" +#define LED_EFFECT_COLORPATTERN "colorp" +#define LED_EFFECT_COLORTEMP "colort" +#define LED_EFFECT_FIRE "fire" #define LED_EFFECT_FULLRED "full" #define LED_EFFECT_ERROR "error" @@ -34,11 +37,6 @@ #define MQTT_LED_COLOR_COMMAND "strip1/color/switch" #define MQTT_LED_COLOR_STATE "strip1/color/status" -// FastLED -// TODO : essayer, devrait limiter le flikering -//#define FASTLED_ALLOW_INTERRUPTS 0 -#define FASTLED_ESP8266_NODEMCU_PIN_ORDER - void setupWifi(); void testConnectMQTT(); void callbackMQTT(char* topic, byte* payload, unsigned int length); @@ -46,3 +44,129 @@ void ledBlackAll(); void ledCylon(); void ledError(); void ledFullColor(); +///////////////////////////////// ColorPalette +// This example shows several ways to set up and use 'palettes' of colors +// with FastLED. +// +// These compact palettes provide an easy way to re-colorize your +// animation on the fly, quickly, easily, and with low overhead. +// +// USING palettes is MUCH simpler in practice than in theory, so first just +// run this sketch, and watch the pretty lights as you then read through +// the code. Although this sketch has eight (or more) different color schemes, +// the entire sketch compiles down to about 6.5K on AVR. +// +// FastLED provides a few pre-configured color palettes, and makes it +// extremely easy to make up your own color schemes with palettes. +// +// Some notes on the more abstract 'theory and practice' of +// FastLED compact palettes are at the bottom of this file. +CRGBPalette16 currentPalette; +TBlendType currentBlending; + +extern CRGBPalette16 myRedWhiteBluePalette; +extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM; + +// This example shows how to set up a static color palette +// which is stored in PROGMEM (flash), which is almost always more +// plentiful than RAM. A static PROGMEM palette like this +// takes up 64 bytes of flash. +const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM = +{ + CRGB::Red, + CRGB::Gray, // 'white' is too bright compared to red and blue + CRGB::Blue, + CRGB::Black, + + CRGB::Red, + CRGB::Gray, + CRGB::Blue, + CRGB::Black, + + CRGB::Red, + CRGB::Red, + CRGB::Gray, + CRGB::Gray, + CRGB::Blue, + CRGB::Blue, + CRGB::Black, + CRGB::Black +}; + +void ledColorPattern(); +void FillLEDsFromPaletteColors(uint8_t colorIndex); +void ChangePalettePeriodically(); +void SetupTotallyRandomPalette(); +void SetupBlackAndWhiteStripedPalette(); +void SetupPurpleAndGreenPalette(); +//////////////////////////////////////////////// ColorTemperature +// THIS EXAMPLE demonstrates the second, "color temperature" control. +// It shows a simple rainbow animation first with one temperature profile, +// and a few seconds later, with a different temperature profile. +// +// The first pixel of the strip will show the color temperature. +// +// HELPFUL HINTS for "seeing" the effect in this demo: +// * Don't look directly at the LED pixels. Shine the LEDs aganst +// a white wall, table, or piece of paper, and look at the reflected light. +// +// * If you watch it for a bit, and then walk away, and then come back +// to it, you'll probably be able to "see" whether it's currently using +// the 'redder' or the 'bluer' temperature profile, even not counting +// the lowest 'indicator' pixel. +// +// +// FastLED provides these pre-conigured incandescent color profiles: +// Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc, +// HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky, +// FastLED provides these pre-configured gaseous-light color profiles: +// WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent, +// FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent, +// MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium, +// FastLED also provides an "Uncorrected temperature" profile +// UncorrectedTemperature; + +#define TEMPERATURE_1 Tungsten100W +#define TEMPERATURE_2 OvercastSky +// How many seconds to show each temperature before switching +#define DISPLAYTIME 20 +// How many seconds to show black between switches +#define BLACKTIME 3 +void colorTemp(); +///////////////////////////////////////////////Fire202 +bool gReverseDirection = false; +// This basic one-dimensional 'fire' simulation works roughly as follows: +// There's a underlying array of 'heat' cells, that model the temperature +// at each point along the line. Every cycle through the simulation, +// four steps are performed: +// 1) All cells cool down a little bit, losing heat to the air +// 2) The heat from each cell drifts 'up' and diffuses a little +// 3) Sometimes randomly new 'sparks' of heat are added at the bottom +// 4) The heat from each cell is rendered as a color into the leds array +// The heat-to-color mapping uses a black-body radiation approximation. +// +// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot). +// +// This simulation scales it self a bit depending on NUM_LEDS; it should look +// "OK" on anywhere from 20 to 100 LEDs without too much tweaking. +// +// I recommend running this simulation at anywhere from 30-100 frames per second, +// meaning an interframe delay of about 10-35 milliseconds. +// +// Looks best on a high-density LED setup (60+ pixels/meter). +// +// +// There are two main parameters you can play with to control the look and +// feel of your fire: COOLING (used in step 1 above), and SPARKING (used +// in step 3 above). +// +// COOLING: How much does the air cool as it rises? +// Less cooling = taller flames. More cooling = shorter flames. +// Default 50, suggested range 20-100 +#define COOLING 55 + +// SPARKING: What chance (out of 255) is there that a new spark will be lit? +// Higher chance = more roaring fire. Lower chance = more flickery fire. +// Default 120, suggested range 50-200. +#define SPARKING 120 +void fire();