on bouge les vars dans le .h

This commit is contained in:
Julien Cabillot 2017-04-20 15:13:51 +02:00 committed by Cabillot Julien
parent 498f5ca80c
commit d0833e7b08
2 changed files with 26 additions and 21 deletions

View File

@ -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");
}

View File

@ -4,6 +4,7 @@
#define LED_NUM 300
#define LED_PIN 5 // = D1
#define LED_CHIPSET WS2812B
// TODO: https://github.com/bruhautomation/ESP-MQTT-JSON-Digital-LEDs/blob/master/ESP_MQTT_Digital_LEDs/ESP_MQTT_Digital_LEDs.ino#L175 essayer BGR
#define LED_COLOR_ORDER GRB
#define LED_BRIGHTNESS_DEFAULT 96
#define LED_SPEED_DEFAULT 120
@ -16,10 +17,19 @@
#define LED_EFFECT_FULLRED "full"
#define LED_EFFECT_ERROR "error"
int brightness;
int color;
int speed;
CRGB leds[LED_NUM];
String ledEffect;
boolean ledState;
// WIFI
#define WIFI_SSID "XXX"
#define WIFI_PASSWORD "XXX"
WiFiClient espClient;
// MQTT
#define MQTT_SERVER "XXX"
#define MQTT_PORT 1883
@ -37,6 +47,10 @@
#define MQTT_LED_COLOR_COMMAND "strip1/color/switch"
#define MQTT_LED_COLOR_STATE "strip1/color/status"
char message_buff[100];
PubSubClient client(espClient);
void setupWifi();
void testConnectMQTT();
void callbackMQTT(char* topic, byte* payload, unsigned int length);