This commit is contained in:
Charles 2020-06-13 02:11:09 +02:00
parent 3272960531
commit c23c353a96
1 changed files with 8 additions and 27 deletions

View File

@ -29,17 +29,14 @@
#ifdef RGB_LED_PIN #ifdef RGB_LED_PIN
#include <NeoPixelBus.h> #include <NeoPixelBus.h>
#define colorSaturation 128 #define colorSaturation 128
// three element pixels, in different order and speeds // three element pixels, in different order and speeds
NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(1, RGB_LED_PIN); NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(1, RGB_LED_PIN);
RgbColor red(colorSaturation, 0, 0); RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0); RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation); RgbColor blue(0, 0, colorSaturation);
RgbColor white(colorSaturation); RgbColor white(colorSaturation);
RgbColor black(0); RgbColor black(0);
#endif #endif
TInfo tinfo; // Teleinfo object TInfo tinfo; // Teleinfo object
@ -48,11 +45,6 @@ TInfo tinfo; // Teleinfo object
unsigned long blinkLed = 0; unsigned long blinkLed = 0;
uint16_t blinkDelay= 0; uint16_t blinkDelay= 0;
// Uptime timer
boolean tick1sec=0;// one for interrupt, don't mess with
unsigned long uptime=0; // save value we can use in sketch even if we're interrupted
/* ====================================================================== /* ======================================================================
Function: ADPSCallback Function: ADPSCallback
Purpose : called by library when we detected a ADPS on any phased Purpose : called by library when we detected a ADPS on any phased
@ -76,7 +68,7 @@ void ADPSCallback(uint8_t phase)
#ifdef RGB_LED_PIN #ifdef RGB_LED_PIN
strip.SetPixelColor(0, red); strip.SetPixelColor(0, red);
// Keep it RED between all frame until it disapears // Keep it RED between all frame until it disapears
blinkDelay = 2500; // 2.5s blinkDelay = 2500; // 2.5s should be enough
strip.Show(); strip.Show();
blinkLed = millis(); blinkLed = millis();
#endif #endif
@ -94,18 +86,22 @@ void DataCallback(ValueList * me, uint8_t flags)
{ {
RgbColor col(0, 0, colorSaturation); RgbColor col(0, 0, colorSaturation);
// Nouvelle etiquette ?
if (flags & TINFO_FLAGS_ADDED) { if (flags & TINFO_FLAGS_ADDED) {
SerialMon.print(F("NEW -> ")); SerialMon.print(F("NEW -> "));
#ifdef RGB_LED_PIN #ifdef RGB_LED_PIN
strip.SetPixelColor(0, green); strip.SetPixelColor(0, green);
strip.Show();
blinkDelay = 10; // 10ms blinkDelay = 10; // 10ms
#endif #endif
} }
// Valeur de l'étiquette qui a changée ?
if (flags & TINFO_FLAGS_UPDATED) { if (flags & TINFO_FLAGS_UPDATED) {
SerialMon.print(F("MAJ -> ")); SerialMon.print(F("MAJ -> "));
#ifdef RGB_LED_PIN #ifdef RGB_LED_PIN
strip.SetPixelColor(0, blue); strip.SetPixelColor(0, blue);
strip.Show();
blinkDelay = 50; // 50ms blinkDelay = 50; // 50ms
#endif #endif
} }
@ -115,10 +111,7 @@ void DataCallback(ValueList * me, uint8_t flags)
SerialMon.print("="); SerialMon.print("=");
SerialMon.println(me->value); SerialMon.println(me->value);
#ifdef RGB_LED_PIN
strip.Show();
blinkLed = millis(); blinkLed = millis();
#endif
} }
@ -179,12 +172,6 @@ void loop()
static unsigned long previousMillis = 0; static unsigned long previousMillis = 0;
unsigned long currentMillis = millis(); unsigned long currentMillis = millis();
// Avons nous recu un ticker de seconde?
if (tick1sec) {
tick1sec = false;
uptime++;
}
// On a reçu un caractère ? // On a reçu un caractère ?
if ( Serial.available() ) { if ( Serial.available() ) {
// Le lire // Le lire
@ -194,9 +181,9 @@ void loop()
tinfo.process(c); tinfo.process(c);
// L'affcher dans la console // L'affcher dans la console
if (c!=TINFO_STX && c!=TINFO_ETX) { //if (c!=TINFO_STX && c!=TINFO_ETX) {
//SerialMon.print(c); //SerialMon.print(c);
} //}
} }
// Verifier si le clignotement LED doit s'arreter // Verifier si le clignotement LED doit s'arreter
@ -209,11 +196,5 @@ void loop()
blinkLed = 0; blinkLed = 0;
} }
if (currentMillis - previousMillis > 1000 ) {
// save the last time you blinked the LED
previousMillis = currentMillis;
tick1sec = true;
}
} }