Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Effect #14

Open
mahdibbb opened this issue May 24, 2018 · 3 comments
Open

Auto Effect #14

mahdibbb opened this issue May 24, 2018 · 3 comments

Comments

@mahdibbb
Copy link

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

@rstephan
Copy link
Owner

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!

@mahdibbb
Copy link
Author

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

@rstephan
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants