|
|
|
@ -9,22 +9,6 @@ |
|
|
|
|
|
|
|
#include "mqttfastledmenu.h"
|
|
|
|
|
|
|
|
// LED
|
|
|
|
int brightness = LED_BRIGHTNESS_DEFAULT; |
|
|
|
int color = LED_COLOR_DEFAULT; |
|
|
|
int speed = LED_SPEED_DEFAULT; |
|
|
|
CRGB leds[LED_NUM]; |
|
|
|
String ledEffect = LED_EFFECT_ERROR; |
|
|
|
boolean ledState = false; |
|
|
|
|
|
|
|
// WIFI
|
|
|
|
WiFiClient espClient; |
|
|
|
|
|
|
|
// MQTT
|
|
|
|
char message_buff[100]; |
|
|
|
PubSubClient client(espClient); |
|
|
|
|
|
|
|
|
|
|
|
void setup() |
|
|
|
{ |
|
|
|
Serial.begin(SERIAL_SPEED); |
|
|
|
@ -39,26 +23,33 @@ void setup() |
|
|
|
testConnectMQTT(); |
|
|
|
|
|
|
|
// LED
|
|
|
|
brightness = LED_BRIGHTNESS_DEFAULT; |
|
|
|
color = LED_COLOR_DEFAULT; |
|
|
|
speed = LED_SPEED_DEFAULT; |
|
|
|
ledEffect = LED_EFFECT_ERROR; |
|
|
|
ledState = false; |
|
|
|
|
|
|
|
LEDS.addLeds<LED_CHIPSET,LED_PIN, LED_COLOR_ORDER>(leds, LED_NUM).setCorrection(TypicalSMD5050); |
|
|
|
ledBlackAll(); |
|
|
|
FastLED.setBrightness(brightness); |
|
|
|
|
|
|
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
|
|
|
currentPalette = RainbowColors_p; |
|
|
|
currentBlending = LINEARBLEND; |
|
|
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
|
|
|
Serial.println("Ready"); |
|
|
|
|
|
|
|
/* 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. |
|
|
|
* Il faut un certains nombres de tentative pour tout récuperer. |
|
|
|
*/ |
|
|
|
for (short int i = 0; i < 10; i++) { |
|
|
|
delay(200); |
|
|
|
client.loop(); |
|
|
|
} |
|
|
|
|
|
|
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
|
|
|
currentPalette = RainbowColors_p; |
|
|
|
currentBlending = LINEARBLEND; |
|
|
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
|
|
|
|
|
|
|
Serial.println("End of setup"); |
|
|
|
} |
|
|
|
|
|
|
|
|