Open Alfiszcze opened 6 years ago
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);
}
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 ... :(
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;
}
}
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
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 isartnet.read();
which added tovoid rainbow
still listen incoming packets and let me control the node. Is there any similar method to do with your library ??