| Author |
Message |
agkbill
Joined: Feb 15, 2007 Posts: 11 Location: Uppsala Sweden
|
Posted: Sun Dec 19, 2010 1:29 pm Post subject:
[SOLVED] Advancing time and with sporked shreds. |
 |
|
I have a code that look like this:
| Code: | fun void flash()
{
while( true )
{
1 => f_led;
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_flash[i][j] == 1 )
{
xmit.startMsg("/sleep/led", "iii");
i => xmit.addInt;
j => xmit.addInt;
f_led => xmit.addInt;
}
}
}
1000::ms => now;
0 => f_led;
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_flash[i][j] == 1 )
{
xmit.startMsg("/sleep/led", "iii");
i => xmit.addInt;
j => xmit.addInt;
f_led => xmit.addInt;
}
}
}
1000::ms => now;
<<<"¤¤¤¤">>>;
<<<"x-flash" , x>>>;
<<<"y-flash" , y>>>;
<<<"f_led-flash" , f_led>>>;
}
}
spork~ flash();
[ [0, 0, 0], [0, 2, 0], [0, 0, 0] ] @=> int p_led_s[][];
while( true )
{
//zero matrix
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
0 => p_led_flash[i][j];
0 => p_led_on[i][j];
0 => p_led_off[i][j];
}
}
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_s[i][j] == 2 )
{
// add into flash led matrix
1 => p_led_flash[i][j];
}
if( p_led_s[i][j] == 1)
{
// add into normal led matrix
1 => p_led_on[i][j];
}
if( p_led_s[i][j] == 0 )
{
1 => p_led_off[i][j];
}
}
}
c
<<<" ------------------------------------------------- NEXT ---------------">>>;
} |
But what causing me problem is the time deley I put in, for example and
It is when I have it in both places, main code and the sporked part. If I delete from one of the places the code run but with it in both places everything halts.
I guess I missed something in how => now; is working.
I need the time delay in the sporked part because I making a led to flash in that way.
I also need it in main part to control progress there.
Any ide on how to deal with this?
All input most appreciated.
Best regards,
/Christer Last edited by agkbill on Mon Dec 20, 2010 1:18 pm; edited 1 time in total |
|
|
Back to top
|
|
 |
vrachnasormora

Joined: Mar 22, 2007 Posts: 42 Location: Preveza,Greece
|
Posted: Sun Dec 19, 2010 5:52 pm Post subject:
|
 |
|
Hi Christer,
your code works fine for me.I can't find anything weird into it.I tried to reconstruct your code with the missing variables and added the "2000::ms => now" part at the end of the main loop ( I guess you replaced it with the "c" character in the code you posted ) and it just runs.This is it:
| Code: | int f_led;
[ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] @=> int p_led_flash[][];
[ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] @=> int p_led_on[][];
[ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] @=> int p_led_off[][];
OscSend xmit;
xmit.setHost( "localhost", 6449 );
fun void flash()
{
while( true )
{
1 => f_led;
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_flash[i][j] == 1 )
{
xmit.startMsg("/sleep/led", "iii");
i => xmit.addInt;
j => xmit.addInt;
f_led => xmit.addInt;
}
}
}
1000::ms => now;
0 => f_led;
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_flash[i][j] == 1 )
{
xmit.startMsg("/sleep/led", "iii");
i => xmit.addInt;
j => xmit.addInt;
f_led => xmit.addInt;
}
}
}
1000::ms => now;
//<<<"¤¤¤¤">>>;
//<<<"x-flash" , x>>>;
//<<<"y-flash" , y>>>;
//<<<"f_led-flash" , f_led>>>;
}
}
spork~ flash();
[ [0, 0, 0], [0, 2, 0], [0, 0, 0] ] @=> int p_led_s[][];
while( true )
{
//zero matrix
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
0 => p_led_flash[i][j];
0 => p_led_on[i][j];
0 => p_led_off[i][j];
}
}
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_s[i][j] == 2 )
{
// add into flash led matrix
1 => p_led_flash[i][j];
}
if( p_led_s[i][j] == 1)
{
// add into normal led matrix
1 => p_led_on[i][j];
}
if( p_led_s[i][j] == 0 )
{
1 => p_led_off[i][j];
}
}
}
2000::ms => now;
<<<" ------------------------------------------------- NEXT ---------------">>>;
} |
Maybe you should search elsewhere for the source of your problem.
Hope it helps
Cheers,
Andreas |
|
|
Back to top
|
|
 |
agkbill
Joined: Feb 15, 2007 Posts: 11 Location: Uppsala Sweden
|
Posted: Mon Dec 20, 2010 5:53 am Post subject:
|
 |
|
Thank you vrachnasormora,
Ok, the problem is not that I have several
instructions in both main code and spork~ processes.
I am glad to sort that out. Now I just have to keep on looking for what cause the unwanted behavior.
All the best!
/Christer |
|
|
Back to top
|
|
 |
Antimon

Joined: Jan 18, 2005 Posts: 3371 Location: Sweden
Audio files: 211
G2 patch files: 92
|
Posted: Mon Dec 20, 2010 6:54 am Post subject:
|
 |
|
I don't know if you tested with a monome, vrachnasormora, but anyway I tried your version, and I got the second row second column led flashing on my monome.
I had to change the port to 8080 to match my old default setting in monomeserial, and ChucK doesn't give any error even though you transmit to a port where no one is listening. Have you double-checked that the ports match, Christer?
/Stefan _________________ Antimon's Window
@soundcloud @Flattr @myspace A blog home - you can't explain music |
|
|
Back to top
|
|
 |
vrachnasormora

Joined: Mar 22, 2007 Posts: 42 Location: Preveza,Greece
|
Posted: Mon Dec 20, 2010 11:58 am Post subject:
|
 |
|
| Quote: | | I don't know if you tested with a monome |
No, Stefan, I don't have a monome.I just completed the code Christer sent with the variables and their values missing in order to check how it runs.The choice of the port number was random.
Andreas |
|
|
Back to top
|
|
 |
agkbill
Joined: Feb 15, 2007 Posts: 11 Location: Uppsala Sweden
|
Posted: Mon Dec 20, 2010 1:12 pm Post subject:
|
 |
|
Thanks for the comments,
I have managed to find the problem. It was not in the chucK code but rather in the way monome handle OSC I would believe.
I noticed that when I added the code: | Code: | fun void on()
{
while( write_out == 1 )
{
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_on[i][j] == 1 )
{
xmit.startMsg("/sleep/led", "iii");
i => xmit.addInt;
j => xmit.addInt;
1 => xmit.addInt;
<<<"¤¤on¤¤">>>;
}
}
}
}
}
spork~ on(); |
That is the function to layout the layer of no flash led on the monome, it all freeze up.
It seems to be when to much data is sent to the monome, it get to much and it stop to respond.
| Code: | fun void on()
{
while( write_out == 1 )
{
for( 0 => int i; i < 3; i++ )
{
for( 0 => int j; j < 3; j++ )
{
if( p_led_on[i][j] == 1 )
{
xmit.startMsg("/sleep/led", "iii");
i => xmit.addInt;
j => xmit.addInt;
1 => xmit.addInt;
<<<"¤¤on¤¤">>>;
}
}
}
step_time => now;
}
}
spork~ on(); |
So I put the time for each step in the main loop and put it in a "dur" that I called step_time and then used that one to delay the loop until next step. In that way I only send data each step and not all the time.
it looks like it working.
Thank you for all input!
All the best!
/Christer |
|
|
Back to top
|
|
 |
|