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" #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() void setup()
{ {
Serial.begin(SERIAL_SPEED); Serial.begin(SERIAL_SPEED);
@ -39,26 +23,33 @@ void setup()
testConnectMQTT(); testConnectMQTT();
// LED // 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); LEDS.addLeds<LED_CHIPSET,LED_PIN, LED_COLOR_ORDER>(leds, LED_NUM).setCorrection(TypicalSMD5050);
ledBlackAll(); ledBlackAll();
FastLED.setBrightness(brightness); FastLED.setBrightness(brightness);
//////////////////////////////// ColorPalette ///////////////////////////////
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
//////////////////////////////// ColorPalette ///////////////////////////////
Serial.println("Ready"); Serial.println("Ready");
/* MQTT /* MQTT
* Il est important de faire un loop avant toute chose, * Il est important de faire un loop avant toute chose,
* afin de récupérer les valeurs provenant du broker mqtt * afin de récupérer les valeurs provenant du broker mqtt
* et pas démarrer avec de vieilles infos. * 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++) { for (short int i = 0; i < 10; i++) {
delay(200); delay(200);
client.loop(); client.loop();
} }
//////////////////////////////// ColorPalette ///////////////////////////////
currentPalette = RainbowColors_p;
currentBlending = LINEARBLEND;
//////////////////////////////// ColorPalette ///////////////////////////////
Serial.println("End of setup"); Serial.println("End of setup");
} }

View File

@ -4,6 +4,7 @@
#define LED_NUM 300 #define LED_NUM 300
#define LED_PIN 5 // = D1 #define LED_PIN 5 // = D1
#define LED_CHIPSET WS2812B #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_COLOR_ORDER GRB
#define LED_BRIGHTNESS_DEFAULT 96 #define LED_BRIGHTNESS_DEFAULT 96
#define LED_SPEED_DEFAULT 120 #define LED_SPEED_DEFAULT 120
@ -16,10 +17,19 @@
#define LED_EFFECT_FULLRED "full" #define LED_EFFECT_FULLRED "full"
#define LED_EFFECT_ERROR "error" #define LED_EFFECT_ERROR "error"
int brightness;
int color;
int speed;
CRGB leds[LED_NUM];
String ledEffect;
boolean ledState;
// WIFI // WIFI
#define WIFI_SSID "XXX" #define WIFI_SSID "XXX"
#define WIFI_PASSWORD "XXX" #define WIFI_PASSWORD "XXX"
WiFiClient espClient;
// MQTT // MQTT
#define MQTT_SERVER "XXX" #define MQTT_SERVER "XXX"
#define MQTT_PORT 1883 #define MQTT_PORT 1883
@ -37,6 +47,10 @@
#define MQTT_LED_COLOR_COMMAND "strip1/color/switch" #define MQTT_LED_COLOR_COMMAND "strip1/color/switch"
#define MQTT_LED_COLOR_STATE "strip1/color/status" #define MQTT_LED_COLOR_STATE "strip1/color/status"
char message_buff[100];
PubSubClient client(espClient);
void setupWifi(); void setupWifi();
void testConnectMQTT(); void testConnectMQTT();
void callbackMQTT(char* topic, byte* payload, unsigned int length); void callbackMQTT(char* topic, byte* payload, unsigned int length);