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

Triggering via some channel data #16

Open
Alfiszcze opened this issue Dec 27, 2017 · 4 comments
Open

Triggering via some channel data #16

Alfiszcze opened this issue Dec 27, 2017 · 4 comments

Comments

@Alfiszcze
Copy link

Hi ...

I'm trying to trigger some actions via setting in script something like that
if (e131.universe == 14) { if (e131.data[1] > 1 && e131.data[1] < 10) { rainbow(e131.data[9]); }
But when this action start runnig I lost control and cannot get back to previous state.
In artnetwifi script there is artnet.read(); which added to void rainbow still listen incoming packets and let me control the node. Is there any similar method to do with your library ??

@juleskers
Copy link

The problem is that the default implementation of rainbow() is a very long-running function. It does its own internal for-loop, with lots of delay()s in it and doesn't return control to the outer loop{} until it has finished an entire animation, which takes several seconds.

The "solution" is to rewrite "rainbow" itself to work in smaller steps. Instead of "blocking" and doing its own internal rainbow-loop, it should be rewritten to always only update a single step on each calling, so that you can call it from the main-loop, where you do:

(Pseudocode)

bool rainbow_should_be_running = false;

loop {
 # listen to network
 foo();

 if (network_says_rainbow_should_start) {
   rainbow_should_be_running = true;
  }
 if (rainbow_should_be_running) {
    # update rainbow TO NEXT FRAME
  }
  delay(1);
}

@Alfiszcze
Copy link
Author

Ok .. so if I rewrite effects it can be done in this soft .... to make some effects only by triggerring some addreses ?? ... like Mtong do that ?? His effects are very cool .. but his soft hangs very...very often ... :(

@juleskers
Copy link

I have no idea who "Mtong" is, but:
Yes, this can be done, but you'll have to design your own effects, and redesign most of this software.
This software is designed so that the dmx sender (e.g. laptop) sends the exact pixel "image", and the "dumb" receiver only shows it.
The effects run on the laptop, not the microcontroller.
What you describe is a "smart" receiver, that calculates its own images.

I do it like this:

current_frame = 0;

loop {
  #todo: read dmx packet

  #todo: extract single channel for which animation
  current_animation = 7;

  switch (current_animation) {
     .... # other animations
     case 7: show_rainbow_frame(current_frame); break;
    .... #more other animations
  }
  current_frame++;
  if (current_frame > animation_end) {
     current_frame = 0;
  }
}

@Alfiszcze
Copy link
Author

Here is what Mtong is :)
https://github.com/mtongnz/ESP8266_ArtNetNode_v2

Will try do it your way...hope it can be done by me :)
Thanks for advice :D

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