algorithmic modeling for Rhino
Hi world,
now i'm tring to connect Emotiv headset with grasshopper. Specificly, when i blink my eyes, parameter A will immediately turn to 1 from 0 then turn back to 0 automatically. I want to write a script that when A turn to 1 the first time, B is turn and the second time B is false.
Tags:
Hi Mark,
interesting headset ;-)
Check this pseudocode to get the basic idea of a "Toggle" that runs in a second thread:
using System.Threading;
public bool B = false;
private Thread thread;
private void Main()
{
thread = new Thread(new ThreadStart(WorkThreadFunction));
thread.Start();
}
public void WorkThreadFunction()
{
try
{
while(emotiv.isReading)
{
if(emotiv.A)
B = !B;
}
}
catch (Exception ex) { // log errors }
}
Of course this is just one way to do it. Do you want to make a plugin or do you just want to use a script component?
Cheers,
FF
Note that you cannot call any interface code from a non-UI thread, nor the ExpireSolution() methods. You have to invoke on the main thread and you may even have to schedule a solution to prevent you from updating your state in the middle of a solution.
--
David Rutten
david@mcneel.com
Tirol, Austria
I see,
this needs a far more simple approach...maybe it's dump but what's about this? First you push the button on reset...0 will be stored in the memory of the RhinoDocument. and on every push of the second button / in your case when A turns 1, the stored value will toggle.
Look at the definition attached....The definition will show red at the very first opening...push each button and it will work.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by