Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hallard committed Jun 13, 2020
1 parent 3272960 commit c23c353
Showing 1 changed file with 8 additions and 27 deletions.
35 changes: 8 additions & 27 deletions examples/ESP8266_DataChanged/ESP8266_DataChanged.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@

#ifdef RGB_LED_PIN
#include <NeoPixelBus.h>

#define colorSaturation 128
// three element pixels, in different order and speeds
NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(1, RGB_LED_PIN);

RgbColor red(colorSaturation, 0, 0);
RgbColor green(0, colorSaturation, 0);
RgbColor blue(0, 0, colorSaturation);
RgbColor white(colorSaturation);
RgbColor black(0);

#endif

TInfo tinfo; // Teleinfo object
Expand All @@ -48,11 +45,6 @@ TInfo tinfo; // Teleinfo object
unsigned long blinkLed = 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
Purpose : called by library when we detected a ADPS on any phased
Expand All @@ -76,7 +68,7 @@ void ADPSCallback(uint8_t phase)
#ifdef RGB_LED_PIN
strip.SetPixelColor(0, red);
// Keep it RED between all frame until it disapears
blinkDelay = 2500; // 2.5s
blinkDelay = 2500; // 2.5s should be enough
strip.Show();
blinkLed = millis();
#endif
Expand All @@ -94,18 +86,22 @@ void DataCallback(ValueList * me, uint8_t flags)
{
RgbColor col(0, 0, colorSaturation);

// Nouvelle etiquette ?
if (flags & TINFO_FLAGS_ADDED) {
SerialMon.print(F("NEW -> "));
#ifdef RGB_LED_PIN
strip.SetPixelColor(0, green);
strip.Show();
blinkDelay = 10; // 10ms
#endif
#endif
}

// Valeur de l'étiquette qui a changée ?
if (flags & TINFO_FLAGS_UPDATED) {
SerialMon.print(F("MAJ -> "));
#ifdef RGB_LED_PIN
strip.SetPixelColor(0, blue);
strip.Show();
blinkDelay = 50; // 50ms
#endif
}
Expand All @@ -115,10 +111,7 @@ void DataCallback(ValueList * me, uint8_t flags)
SerialMon.print("=");
SerialMon.println(me->value);

#ifdef RGB_LED_PIN
strip.Show();
blinkLed = millis();
#endif

}

Expand Down Expand Up @@ -179,12 +172,6 @@ void loop()
static unsigned long previousMillis = 0;
unsigned long currentMillis = millis();

// Avons nous recu un ticker de seconde?
if (tick1sec) {
tick1sec = false;
uptime++;
}

// On a reçu un caractère ?
if ( Serial.available() ) {
// Le lire
Expand All @@ -194,9 +181,9 @@ void loop()
tinfo.process(c);

// L'affcher dans la console
if (c!=TINFO_STX && c!=TINFO_ETX) {
//if (c!=TINFO_STX && c!=TINFO_ETX) {
//SerialMon.print(c);
}
//}
}

// Verifier si le clignotement LED doit s'arreter
Expand All @@ -209,11 +196,5 @@ void loop()

blinkLed = 0;
}

if (currentMillis - previousMillis > 1000 ) {
// save the last time you blinked the LED
previousMillis = currentMillis;
tick1sec = true;
}
}

0 comments on commit c23c353

Please sign in to comment.