Open mahdibbb opened 6 years ago
Here is a short example. It compiles but i have not tested it on hardware!
Get the time of your last received Art-Net frame. The millis()
-function seams good for that. After that, wait a short time, let's say 5000ms, and than start the animation. I choose a simple state-machine. You can do it in a simple loop, but your program will not be able to response to new artnet data. With the state-machine you can put small steps of the effect at a time and in between new artnet data can be processed as they come in.
I would not add more delay than 500ms per step. If you need more time, add more steps ;-)
As a base the ArtnetWifiNeoPixel - example.
...
unsigned long lastRx = 0;
int autoEffectStep = 0;
...
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
...
lastRx = millis();
}
void setup()
{
...
lastRx = millis();
}
void loop()
{
...
if (lastRx + 5000 < millis()) {
switch (autoEffectStep) {
case 0:
for (int i = 0 ; i < numLeds ; i++) {
leds.setPixelColor(i, 127, 0, 0);
}
leds.show();
delay(500);
break;
case 1:
for (int i = 0 ; i < numLeds ; i++) {
leds.setPixelColor(i, 0, 127, 0);
}
leds.show();
delay(500);
break;
case 2:
for (int i = 0 ; i < numLeds ; i++) {
leds.setPixelColor(i, 0, 0, 127);
}
leds.show();
delay(500);
break;
case 3:
autoEffectStep = -1;
break;
}
autoEffectStep++;
}
}
There is alway the option to do it more sophisticated!
Thanks alot for your help. I really appreciate it. But unfortunately the last part was some how vague. Would you please restate it in a more simple way. Please help me so that I can display a special animation whenever frames are received, and again if the frames are received, they will process them. Thanks a million
Have you tried my example? Is it technically working?
Is there a mistake in you question?
special animation whenever frames are received if the frames are received, they will process them
You would like to do the animation if frames are NOT received. Right?
What does "special animation" mean to you? I guess simple Red -> Green -> Blue is it not.
Hi, how can I do a specific task, such as displaying an auto-effect, when the data does not arrive to the ESP07? Thank you