|
|
@ -1,17 +1,20 @@ |
|
|
#include <Arduino.h>
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
#include "mqttfastledmenu.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO : essayer, devrait limiter le flikering
|
|
|
|
|
|
//#define FASTLED_ALLOW_INTERRUPTS 0
|
|
|
|
|
|
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
|
|
|
#include <FastLED.h>
|
|
|
#include <FastLED.h>
|
|
|
#include <ESP8266WiFi.h>
|
|
|
#include <ESP8266WiFi.h>
|
|
|
#include <PubSubClient.h>
|
|
|
#include <PubSubClient.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "mqttfastledmenu.h"
|
|
|
|
|
|
|
|
|
// LED
|
|
|
// LED
|
|
|
int brightness = LED_BRIGHTNESS_DEFAULT; |
|
|
int brightness = LED_BRIGHTNESS_DEFAULT; |
|
|
int color = LED_COLOR_DEFAULT; |
|
|
int color = LED_COLOR_DEFAULT; |
|
|
int speed = LED_SPEED_DEFAULT; |
|
|
int speed = LED_SPEED_DEFAULT; |
|
|
CRGB leds[LED_NUM]; |
|
|
CRGB leds[LED_NUM]; |
|
|
String ledEffect = LED_EFFECT_CYLON; |
|
|
|
|
|
|
|
|
String ledEffect = LED_EFFECT_ERROR; |
|
|
boolean ledState = false; |
|
|
boolean ledState = false; |
|
|
|
|
|
|
|
|
// WIFI
|
|
|
// WIFI
|
|
|
@ -21,6 +24,7 @@ WiFiClient espClient; |
|
|
char message_buff[100]; |
|
|
char message_buff[100]; |
|
|
PubSubClient client(espClient); |
|
|
PubSubClient client(espClient); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup() |
|
|
void setup() |
|
|
{ |
|
|
{ |
|
|
Serial.begin(SERIAL_SPEED); |
|
|
Serial.begin(SERIAL_SPEED); |
|
|
@ -33,8 +37,6 @@ void setup() |
|
|
client.setServer(MQTT_SERVER, MQTT_PORT); |
|
|
client.setServer(MQTT_SERVER, MQTT_PORT); |
|
|
client.setCallback(callbackMQTT); |
|
|
client.setCallback(callbackMQTT); |
|
|
testConnectMQTT(); |
|
|
testConnectMQTT(); |
|
|
// TODO : ne marche pas comme je le désire :
|
|
|
|
|
|
// au boot il prends les params par défaut, j'aimerais ceux de home assistant
|
|
|
|
|
|
|
|
|
|
|
|
// LED
|
|
|
// LED
|
|
|
LEDS.addLeds<LED_CHIPSET,LED_PIN, LED_COLOR_ORDER>(leds, LED_NUM).setCorrection(TypicalSMD5050); |
|
|
LEDS.addLeds<LED_CHIPSET,LED_PIN, LED_COLOR_ORDER>(leds, LED_NUM).setCorrection(TypicalSMD5050); |
|
|
@ -43,16 +45,21 @@ void setup() |
|
|
Serial.println("Ready"); |
|
|
Serial.println("Ready"); |
|
|
|
|
|
|
|
|
/* MQTT
|
|
|
/* MQTT
|
|
|
* Il est important de faire un loop avant toute chose, |
|
|
|
|
|
* afin de récupérer les valeurs provenant du broker mqtt |
|
|
|
|
|
* et pas démarrer avec de vieilles infos. |
|
|
|
|
|
*/ |
|
|
|
|
|
for (short int i = 0; i < 10; i++) { |
|
|
|
|
|
delay(200); |
|
|
|
|
|
client.loop(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
* Il est important de faire un loop avant toute chose, |
|
|
|
|
|
* afin de récupérer les valeurs provenant du broker mqtt |
|
|
|
|
|
* et pas démarrer avec de vieilles infos. |
|
|
|
|
|
*/ |
|
|
|
|
|
for (short int i = 0; i < 10; i++) { |
|
|
|
|
|
delay(200); |
|
|
|
|
|
client.loop(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Serial.println("End of setup"); |
|
|
|
|
|
|
|
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
|
|
|
|
|
currentPalette = RainbowColors_p; |
|
|
|
|
|
currentBlending = LINEARBLEND; |
|
|
|
|
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
Serial.println("End of setup"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// WIFI
|
|
|
// WIFI
|
|
|
@ -122,7 +129,6 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length) |
|
|
// Si on ne repasse pas tout à noir, cela peut faire des effets surprenants
|
|
|
// Si on ne repasse pas tout à noir, cela peut faire des effets surprenants
|
|
|
ledBlackAll(); |
|
|
ledBlackAll(); |
|
|
ledEffect = msgString; |
|
|
ledEffect = msgString; |
|
|
// TODO : a vraiment tester
|
|
|
|
|
|
client.publish(MQTT_LED_EFFECT_STATE, message_buff, true); |
|
|
client.publish(MQTT_LED_EFFECT_STATE, message_buff, true); |
|
|
} else if (stopic == MQTT_LED_BRIGHTNESS_COMMAND) { |
|
|
} else if (stopic == MQTT_LED_BRIGHTNESS_COMMAND) { |
|
|
brightness = msgString.toInt(); |
|
|
brightness = msgString.toInt(); |
|
|
@ -143,61 +149,287 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// LED
|
|
|
// LED
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Coupe tout le strip de led. |
|
|
|
|
|
*/ |
|
|
void ledBlackAll() |
|
|
void ledBlackAll() |
|
|
{ |
|
|
{ |
|
|
FastLED.clear(); |
|
|
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
|
FastLED.clear(); |
|
|
|
|
|
FastLED.show(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Effet Cylon : défilement d'une simple led sur le strip aller/retour. |
|
|
|
|
|
* Pour faire plus sympas on ajoute une lueur autour, avec une lumière atténué. |
|
|
|
|
|
*/ |
|
|
void ledCylon() |
|
|
void ledCylon() |
|
|
{ |
|
|
{ |
|
|
// Effet cylon : on allume une led, on attends, on eteinds, on passe à la suivante
|
|
|
|
|
|
for(int i = 0; i < LED_NUM; i++) { |
|
|
|
|
|
client.loop(); |
|
|
|
|
|
if (ledEffect != LED_EFFECT_CYLON) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for(int i = 0; i < LED_NUM; i++) { |
|
|
|
|
|
client.loop(); |
|
|
|
|
|
|
|
|
leds[i] = color; |
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
leds[i] = CRGB::Black; |
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
|
|
|
if (ledEffect != LED_EFFECT_CYLON) { |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for(int i = LED_NUM - 1; i > 0; i--) { |
|
|
|
|
|
client.loop(); |
|
|
|
|
|
if (ledEffect != LED_EFFECT_CYLON) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ((i - 3) >= 0) { |
|
|
|
|
|
leds[i - 3] = CRGB::Black; |
|
|
|
|
|
} |
|
|
|
|
|
if ((i - 2) >= 0) { |
|
|
|
|
|
/*
|
|
|
|
|
|
* Se lit 128/256 d'intensité lumineuse actuelle |
|
|
|
|
|
* https://github.com/FastLED/FastLED/wiki/Pixel-reference#dimming-and-brightening-colors
|
|
|
|
|
|
*/ |
|
|
|
|
|
leds[i - 2].fadeLightBy(240); |
|
|
|
|
|
} |
|
|
|
|
|
if ((i - 1) >= 0) { |
|
|
|
|
|
leds[i - 1].fadeLightBy(200); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
leds[i] = color; |
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
leds[i] = CRGB::Black; |
|
|
|
|
|
FastLED.show(); |
|
|
|
|
|
|
|
|
leds[i] = color; |
|
|
|
|
|
|
|
|
|
|
|
if ((i + 1) <= LED_NUM) { |
|
|
|
|
|
leds[i + 1] = color; |
|
|
|
|
|
// Je suis volontairement un peu moins puissant sur l'avant
|
|
|
|
|
|
// pour donner un effet de trainée sur l'arrière
|
|
|
|
|
|
leds[i + 1].fadeLightBy(220); |
|
|
|
|
|
} |
|
|
|
|
|
if ((i + 2) <= LED_NUM) { |
|
|
|
|
|
leds[i + 2] = color; |
|
|
|
|
|
leds[i + 2].fadeLightBy(240); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// led[0] et led[255] sont gérées par la loop précédante
|
|
|
|
|
|
for(int i = LED_NUM - 1; i > 0; i--) { |
|
|
|
|
|
client.loop(); |
|
|
|
|
|
|
|
|
|
|
|
if (ledEffect != LED_EFFECT_CYLON) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((i - 2) >= 0) { |
|
|
|
|
|
leds[i - 2] = color; |
|
|
|
|
|
leds[i - 2].fadeLightBy(240); |
|
|
|
|
|
} |
|
|
|
|
|
if ((i - 1) >= 0) { |
|
|
|
|
|
leds[i - 1] = color; |
|
|
|
|
|
leds[i - 1].fadeLightBy(220); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
leds[i] = color; |
|
|
|
|
|
|
|
|
|
|
|
if ((i + 1) <= LED_NUM) { |
|
|
|
|
|
leds[i + 1].fadeLightBy(200); |
|
|
|
|
|
} |
|
|
|
|
|
if ((i + 2) <= LED_NUM) { |
|
|
|
|
|
leds[i + 2].fadeLightBy(240); |
|
|
} |
|
|
} |
|
|
|
|
|
if ((i + 3) <= LED_NUM) { |
|
|
|
|
|
leds[i + 3] = CRGB::Black; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Utilise pour indiquer une erreur sur la reception de l'effet. |
|
|
|
|
|
*/ |
|
|
void ledError() |
|
|
void ledError() |
|
|
{ |
|
|
{ |
|
|
for(int i = 0; i < LED_NUM; i++) { |
|
|
|
|
|
if ((i % 2) == 0) { |
|
|
|
|
|
leds[i] = CRGB::Black; |
|
|
|
|
|
} else { |
|
|
|
|
|
leds[i] = color; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (int i = 0; i < LED_NUM; i++) { |
|
|
|
|
|
if ((i % 2) == 0) { |
|
|
|
|
|
leds[i] = CRGB::Black; |
|
|
|
|
|
} else { |
|
|
|
|
|
leds[i] = CRGB::Red; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Affiche une couleur de manière uniforme sur le strip. |
|
|
|
|
|
* Pour éviter un éclairage basique, on applique un breath qui permet |
|
|
|
|
|
* de faire respirer la couleur (brightness). |
|
|
|
|
|
*/ |
|
|
void ledFullColor() |
|
|
void ledFullColor() |
|
|
{ |
|
|
{ |
|
|
fill_solid(leds, LED_NUM, color); |
|
|
|
|
|
int breath = (exp(sin(millis() / 2000.0 * PI)) - 0.36787944) * 108.4; |
|
|
|
|
|
FastLED.setBrightness(breath); |
|
|
|
|
|
FastLED.delay(100 / speed); |
|
|
|
|
|
|
|
|
fill_solid(leds, LED_NUM, color); |
|
|
|
|
|
// TODO : il fadrait pas faire 0 -> 255 mais plutot 20 (ou plus) -> brightness
|
|
|
|
|
|
// Source : http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
|
|
|
|
|
|
// Augmenter 2000 augmente la fréquence (c'est en fait sin((temps / 1000) * Pi/2)
|
|
|
|
|
|
// 0.36787944 ?? censé correspondre au minimum
|
|
|
|
|
|
// 108.4 ?? censé correspondre au maximum
|
|
|
|
|
|
int breath = (exp(sin(millis() / 2000.0 * PI)) - 0.3678794) * 108.4; |
|
|
|
|
|
Serial.print(breath); |
|
|
|
|
|
Serial.println(" / 255"); |
|
|
|
|
|
FastLED.setBrightness(breath); |
|
|
|
|
|
FastLED.delay(100 / speed); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///////////////////// FastLED-3.1.5/examples/ColorPalette /////////////////////
|
|
|
|
|
|
void ledColorPattern() |
|
|
|
|
|
{ |
|
|
|
|
|
ChangePalettePeriodically(); |
|
|
|
|
|
|
|
|
|
|
|
static uint8_t startIndex = 0; |
|
|
|
|
|
startIndex = startIndex + 1; /* motion speed */ |
|
|
|
|
|
|
|
|
|
|
|
FillLEDsFromPaletteColors(startIndex); |
|
|
|
|
|
|
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FillLEDsFromPaletteColors(uint8_t colorIndex) |
|
|
|
|
|
{ |
|
|
|
|
|
uint8_t brightness = 255; |
|
|
|
|
|
|
|
|
|
|
|
for( int i = 0; i < LED_NUM; i++) { |
|
|
|
|
|
leds[i] = ColorFromPalette( |
|
|
|
|
|
currentPalette, |
|
|
|
|
|
colorIndex, |
|
|
|
|
|
brightness, |
|
|
|
|
|
currentBlending |
|
|
|
|
|
); |
|
|
|
|
|
colorIndex += 3; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// There are several different palettes of colors demonstrated here.
|
|
|
|
|
|
//
|
|
|
|
|
|
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
|
|
|
|
|
|
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
|
|
|
|
|
|
//
|
|
|
|
|
|
// Additionally, you can manually define your own color palettes, or you can write
|
|
|
|
|
|
// code that creates color palettes on the fly. All are shown here.
|
|
|
|
|
|
void ChangePalettePeriodically() |
|
|
|
|
|
{ |
|
|
|
|
|
uint8_t secondHand = (millis() / 1000) % 60; |
|
|
|
|
|
static uint8_t lastSecond = 99; |
|
|
|
|
|
|
|
|
|
|
|
if( lastSecond != secondHand) { |
|
|
|
|
|
lastSecond = secondHand; |
|
|
|
|
|
if (secondHand == 0) { currentPalette = RainbowColors_p; currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 10) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; } |
|
|
|
|
|
if (secondHand == 15) { currentPalette = RainbowStripeColors_p; currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 20) { SetupPurpleAndGreenPalette(); currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 25) { SetupTotallyRandomPalette(); currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 30) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; } |
|
|
|
|
|
if (secondHand == 35) { SetupBlackAndWhiteStripedPalette(); currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 40) { currentPalette = CloudColors_p; currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 45) { currentPalette = PartyColors_p; currentBlending = LINEARBLEND; } |
|
|
|
|
|
if (secondHand == 50) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; } |
|
|
|
|
|
if (secondHand == 55) { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// This function fills the palette with totally random colors.
|
|
|
|
|
|
void SetupTotallyRandomPalette() |
|
|
|
|
|
{ |
|
|
|
|
|
for (int i = 0; i < 16; i++) { |
|
|
|
|
|
currentPalette[i] = CHSV(random8(), 255, random8()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// This function sets up a palette of black and white stripes,
|
|
|
|
|
|
// using code. Since the palette is effectively an array of
|
|
|
|
|
|
// sixteen CRGB colors, the various fill_* functions can be used
|
|
|
|
|
|
// to set them up.
|
|
|
|
|
|
void SetupBlackAndWhiteStripedPalette() |
|
|
|
|
|
{ |
|
|
|
|
|
// 'black out' all 16 palette entries...
|
|
|
|
|
|
fill_solid(currentPalette, 16, CRGB::Black); |
|
|
|
|
|
// and set every fourth one to white.
|
|
|
|
|
|
currentPalette[0] = CRGB::White; |
|
|
|
|
|
currentPalette[4] = CRGB::White; |
|
|
|
|
|
currentPalette[8] = CRGB::White; |
|
|
|
|
|
currentPalette[12] = CRGB::White; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// This function sets up a palette of purple and green stripes.
|
|
|
|
|
|
void SetupPurpleAndGreenPalette() |
|
|
|
|
|
{ |
|
|
|
|
|
CRGB purple = CHSV(HUE_PURPLE, 255, 255); |
|
|
|
|
|
CRGB green = CHSV(HUE_GREEN, 255, 255); |
|
|
|
|
|
CRGB black = CRGB::Black; |
|
|
|
|
|
|
|
|
|
|
|
currentPalette = CRGBPalette16( |
|
|
|
|
|
green, green, black, black, |
|
|
|
|
|
purple, purple, black, black, |
|
|
|
|
|
green, green, black, black, |
|
|
|
|
|
purple, purple, black, black |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
///////////////////// FastLED-3.1.5/examples/ColorPalette /////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////// FastLED-3.1.5/examples/ColorTemperature ///////////////////
|
|
|
|
|
|
void colorTemp() |
|
|
|
|
|
{ |
|
|
|
|
|
// draw a generic, no-name rainbow
|
|
|
|
|
|
static uint8_t starthue = 0; |
|
|
|
|
|
fill_rainbow(leds + 5, LED_NUM - 5, --starthue, 20); |
|
|
|
|
|
|
|
|
|
|
|
// Choose which 'color temperature' profile to enable.
|
|
|
|
|
|
uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2); |
|
|
|
|
|
if (secs < DISPLAYTIME) { |
|
|
|
|
|
FastLED.setTemperature(TEMPERATURE_1 ); // first temperature
|
|
|
|
|
|
leds[0] = TEMPERATURE_1; // show indicator pixel
|
|
|
|
|
|
} else { |
|
|
|
|
|
FastLED.setTemperature(TEMPERATURE_2 ); // second temperature
|
|
|
|
|
|
leds[0] = TEMPERATURE_2; // show indicator pixel
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Black out the LEDs for a few secnds between color changes
|
|
|
|
|
|
// to let the eyes and brains adjust
|
|
|
|
|
|
if((secs % DISPLAYTIME) < BLACKTIME) { |
|
|
|
|
|
memset8(leds, 0, LED_NUM * sizeof(CRGB)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FastLED.show(); |
|
|
|
|
|
FastLED.delay(8); |
|
|
|
|
|
} |
|
|
|
|
|
/////////////////// FastLED-3.1.5/examples/ColorTemperature ///////////////////
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////// FastLED-3.1.5/examples/Fire202 ///////////////////////
|
|
|
|
|
|
void fire() |
|
|
|
|
|
{ |
|
|
|
|
|
// Array of temperature readings at each simulation cell
|
|
|
|
|
|
static byte heat[LED_NUM]; |
|
|
|
|
|
|
|
|
|
|
|
// Step 1. Cool down every cell a little
|
|
|
|
|
|
for (int i = 0; i < LED_NUM; i++) { |
|
|
|
|
|
heat[i] = qsub8(heat[i], random8(0, ((COOLING * 10) / LED_NUM) + 2)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Step 2. Heat from each cell drifts 'up' and diffuses a little
|
|
|
|
|
|
for (int k= LED_NUM - 1; k >= 2; k--) { |
|
|
|
|
|
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
|
|
|
|
|
|
if (random8() < SPARKING ) { |
|
|
|
|
|
int y = random8(7); |
|
|
|
|
|
heat[y] = qadd8(heat[y], random8(160,255)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Step 4. Map from heat cells to LED colors
|
|
|
|
|
|
for (int j = 0; j < LED_NUM; j++) { |
|
|
|
|
|
CRGB color = HeatColor( heat[j]); |
|
|
|
|
|
int pixelnumber; |
|
|
|
|
|
if (gReverseDirection) { |
|
|
|
|
|
pixelnumber = (LED_NUM - 1) - j; |
|
|
|
|
|
} else { |
|
|
|
|
|
pixelnumber = j; |
|
|
|
|
|
} |
|
|
|
|
|
leds[pixelnumber] = color; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FastLED.delay(1000 / speed); |
|
|
} |
|
|
} |
|
|
|
|
|
//////////////////////// FastLED-3.1.5/examples/Fire202 ///////////////////////
|
|
|
|
|
|
|
|
|
void loop() { |
|
|
void loop() { |
|
|
// MQTT
|
|
|
// MQTT
|
|
|
@ -212,6 +444,12 @@ void loop() { |
|
|
ledCylon(); |
|
|
ledCylon(); |
|
|
} else if (ledEffect == LED_EFFECT_FULLRED) { |
|
|
} else if (ledEffect == LED_EFFECT_FULLRED) { |
|
|
ledFullColor(); |
|
|
ledFullColor(); |
|
|
|
|
|
} else if (ledEffect == LED_EFFECT_COLORPATTERN) { |
|
|
|
|
|
ledColorPattern(); |
|
|
|
|
|
} else if (ledEffect == LED_EFFECT_COLORTEMP) { |
|
|
|
|
|
colorTemp(); |
|
|
|
|
|
} else if (ledEffect == LED_EFFECT_FIRE) { |
|
|
|
|
|
fire(); |
|
|
} else { |
|
|
} else { |
|
|
ledError(); |
|
|
ledError(); |
|
|
} |
|
|
} |
|
|
|