Compare commits

...

5 Commits

Author SHA1 Message Date
Alex
22326398a5 Modification de l'adresse IP du brocker MQTT 2023-10-19 21:15:24 +02:00
Alex
78f085915d Changement du remplissage pour éviter les flash 2022-06-14 23:35:27 +02:00
Alex
0af54b04b8 Optimisation de l'allumage 2022-06-12 18:02:59 +02:00
Alex
15fd42805e Affichage du nombre de workers 2022-06-10 23:11:06 +02:00
Alex
600e110e21 Modification image 2022-05-29 18:22:31 +02:00
6 changed files with 33 additions and 52 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@@ -12,7 +12,7 @@
platform = espressif8266 platform = espressif8266
board = nodemcuv2 board = nodemcuv2
monitor_speed = 115200 monitor_speed = 115200
upload_port = COM11 upload_port = COM13
framework = arduino framework = arduino
lib_deps = lib_deps =
adafruit/Adafruit NeoPixel@^1.10.4 adafruit/Adafruit NeoPixel@^1.10.4

View File

@@ -15,7 +15,7 @@
#include <Arduino.h> #include <Arduino.h>
//#define ModeDebug //#define ModeDebug
const String firmwareActualVersion = "1.0.0"; const String firmwareActualVersion = "1.1.1";
#ifdef ModeDebug #ifdef ModeDebug
#define DEBUG(message) \ #define DEBUG(message) \
@@ -49,7 +49,6 @@ int LED_COUNT = 66;
// LEDS // LEDS
boolean g_BOO_AnimationSeconde = true;
#include "my_leds.h" #include "my_leds.h"
@@ -104,8 +103,6 @@ void setup() {
strip.show(); // Turn OFF all pixels ASAP strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(255); strip.setBrightness(255);
LED_Animation(5); LED_Animation(5);
g_BOO_AnimationSeconde = true;
DEBUG("************************** Tout est initialise"); DEBUG("************************** Tout est initialise");
} }
@@ -120,10 +117,6 @@ void setup() {
unsigned long lastRecu = 0; unsigned long lastRecu = 0;
int numled = 0; int numled = 0;
void loop() { void loop() {
// On écoute le serveur OTA
// OTA_doUpdate();
// Test si la connection Wifi existe toujours ................................... // Test si la connection Wifi existe toujours ...................................
if (WiFi.status() != WL_CONNECTED) { if (WiFi.status() != WL_CONNECTED) {
// Si on est déconnecté on tente de se reconnecter automatiquement avec les anciens settings. // Si on est déconnecté on tente de se reconnecter automatiquement avec les anciens settings.
@@ -145,28 +138,6 @@ void loop() {
// Animation des LEDS toutes les secondes .........................................
if (millis() - lastRecu > 1000 ) {
lastRecu = millis();
// Allumage d'une led
if ( g_BOO_AnimationSeconde ) {
if ( numled >= LED_COUNT /2 ) {
LED_AllumeBaton( numled -1, 0,0,0 ); // Noir
LED_AllumeBaton( numled -2, 0,0,0 ); // Noir
numled = 0;
}
LED_AllumeBaton( numled, 255,0,100 ); // Rouge
LED_AllumeBaton( numled -1, 50,0,70 ); // Noir
LED_AllumeBaton( numled -2, 0,0,0 ); // Noir
numled++;
}
}
// Traitement des Messages MQTT ................................................... // Traitement des Messages MQTT ...................................................
// Tout est fait dans MQTT_callback() // Tout est fait dans MQTT_callback()
} }

View File

@@ -1,6 +1,6 @@
// MQTT client // MQTT client
#include <PubSubClient.h> #include <PubSubClient.h>
#define MQTT_broker "192.168.0.11" #define MQTT_broker "192.168.100.11"
#define MQTT_port 1883 #define MQTT_port 1883
#define MQTT_user "" #define MQTT_user ""
#define MQTT_password "" #define MQTT_password ""
@@ -14,6 +14,7 @@ char topic_lumiere_color[8 + 6 + DEVICEID_SIZE];
char topic_lumiere_bright[8 + 11 + DEVICEID_SIZE]; char topic_lumiere_bright[8 + 11 + DEVICEID_SIZE];
char topic_lumiere_anim[8 + 10 + DEVICEID_SIZE]; char topic_lumiere_anim[8 + 10 + DEVICEID_SIZE];
char topic_lumiere_rempli[8 + 7 + DEVICEID_SIZE]; char topic_lumiere_rempli[8 + 7 + DEVICEID_SIZE];
char topic_lumiere_allume_barres[8 + 7 + 7 + DEVICEID_SIZE];
@@ -87,16 +88,12 @@ void MQTT_callback(char* topic, byte* payload, unsigned int length) {
if ( String( message ) == "ON") { if ( String( message ) == "ON") {
DEBUG("Allumage les leds"); DEBUG("Allumage les leds");
c.B = 255;
LED_changeCouleur( c, 10 );
} else if ( String( message ) == "OFF") { } else if ( String( message ) == "OFF") {
DEBUG("Extinction des leds"); DEBUG("Extinction des leds");
LED_changeCouleurInverse( c, 1 ); LED_changeCouleurInverse( c, 1 );
} }
g_BOO_AnimationSeconde = false;
// ..................................................................................... // .....................................................................................
} else if ( strcmp( topic, topic_lumiere_color) == 0) { } else if ( strcmp( topic, topic_lumiere_color) == 0) {
@@ -140,6 +137,19 @@ void MQTT_callback(char* topic, byte* payload, unsigned int length) {
DEBUG("Detection du topics :" + String( topic_lumiere_rempli )); DEBUG("Detection du topics :" + String( topic_lumiere_rempli ));
DEBUG("Lancement du remplissage à :" + String( message )); DEBUG("Lancement du remplissage à :" + String( message ));
LED_Remplissage(String( message ).toInt()); LED_Remplissage(String( message ).toInt());
// .....................................................................................
} else if ( strcmp( topic, topic_lumiere_allume_barres) ==0 ) {
DEBUG("Detection du topics :" + String( topic_lumiere_allume_barres ));
DEBUG("Lancement du remplissage des " + String( message ) + " barres");
Couleur color;
color.R = 255;
color.V = 255;
color.B = 255;
for(int i = 0; i < String( message ).toInt(); i++){
LED_AllumeBaton(i, color );
}
} }
} }
@@ -169,4 +179,5 @@ void MQTT_setup(){
sprintf( topic_lumiere_bright, "lumiere/brightness/%s", DeviceID); sprintf( topic_lumiere_bright, "lumiere/brightness/%s", DeviceID);
sprintf( topic_lumiere_anim, "lumiere/animation/%s", DeviceID); sprintf( topic_lumiere_anim, "lumiere/animation/%s", DeviceID);
sprintf( topic_lumiere_rempli, "lumiere/allume/%s", DeviceID); sprintf( topic_lumiere_rempli, "lumiere/allume/%s", DeviceID);
sprintf( topic_lumiere_allume_barres, "lumiere/allume/%s/barres", DeviceID);
} }

View File

@@ -33,6 +33,9 @@ void LED_AllumeBaton(unsigned int num, Couleur color){
// ALLUMAGE LEDS DESCENDENTE // ALLUMAGE LEDS DESCENDENTE
strip.setPixelColor(LED_COUNT-1 - num, strip.Color( color.R, color.V, color.B )); strip.setPixelColor(LED_COUNT-1 - num, strip.Color( color.R, color.V, color.B ));
// MISE À JOUR DU LED STRIP
strip.show();
} }
void LED_AllumeBaton(unsigned int num, unsigned int R, unsigned int V, unsigned int B){ void LED_AllumeBaton(unsigned int num, unsigned int R, unsigned int V, unsigned int B){
// ALLUMAGE LEDS MONTANTE // ALLUMAGE LEDS MONTANTE
@@ -266,16 +269,10 @@ void theaterChaseRainbow(uint8_t wait) {
*/ */
void LED_Remplissage(unsigned int value){ void LED_Remplissage(unsigned int value){
// ON PASSE TOUTES LES LEDS EN NOIR
for (int i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, strip.Color(0,0,0)); // Noir
}
strip.show();
// ALLUMAGE DES LEDS // ALLUMAGE DES LEDS
Couleur color; Couleur color;
for (int i = 0; i <= (int) ((LED_COUNT/2) * value / 100); i++) { int max = (int) ((LED_COUNT/2) * value / 100);
for (int i = 0; i <= max; i++) {
// DEFINITION DE LA COULEUR // DEFINITION DE LA COULEUR
int value = 255 - i * 255/(LED_COUNT/2); int value = 255 - i * 255/(LED_COUNT/2);
color.R = 255 - value; color.R = 255 - value;
@@ -285,10 +282,16 @@ void LED_Remplissage(unsigned int value){
// ALLUMAGE DU BATON DE LEDS // ALLUMAGE DU BATON DE LEDS
LED_AllumeBaton(i, color ); LED_AllumeBaton(i, color );
// MISE À JOUR DU LED STRIP
strip.show();
} }
// ON PASSE TOUTES LES LEDS EN NOIR
color.R = 0;
color.V = 0;
color.B = 0;
for (int i = max +1; i < LED_COUNT / 2 ; i++) {
LED_AllumeBaton(i, color );
}
strip.show();
} }
@@ -299,7 +302,6 @@ void LED_Remplissage(unsigned int value){
// [1..9] // [1..9]
// //
void LED_Animation(int num) { void LED_Animation(int num) {
g_BOO_AnimationSeconde = false;
DEBUG(num); DEBUG(num);
switch ( num ) { switch ( num ) {
case 0: case 0:
@@ -320,9 +322,6 @@ void LED_Animation(int num) {
case 5: case 5:
rainbowCycle(10); rainbowCycle(10);
break; break;
case 6:
g_BOO_AnimationSeconde = true;
break;
default: default:
DEBUG("Animation inconnue ->" + String(num) ); DEBUG("Animation inconnue ->" + String(num) );
break; break;