We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Actually have to two issues. The first is pretty much described in the question. I created a button that writes text to the screen using text("" + q[3]*rad2deg, 280, 360) in the button function as follows:
public void controlEvent(ControlEvent theEvent) {
//println(theEvent.getController().getName());
}
public void Button1() {
println("a button event from colorB: ");
fill(255,0,0);
textSize(12);
text("" + q[0]*rad2deg, 170, 360);
text("" + q[1]*rad2deg, 170, 380);
text("" + q[2]*rad2deg, 170, 400);
text("" + q[3]*rad2deg, 280, 360);
text("" + q[4]*rad2deg, 280, 380);
text("" + q[5]*rad2deg, 280, 40);
}
On release of the button the values flashes on the screen and then disappears. Not sure how to fix this issue. I did a web search but nothing. I am using processing 3 with the latest library. I have attached a screen shot of the GUI for reference. The offending fields are t0 through t6. Ultimate intent to have these update as the calculations for robot arm position is calculated. Also tried to this with a ControlP5 textfield and textarea but they don't update until after the last iteration is completed and only shows the last iteration.
Heres the actual link: https://drive.google.com/file/d/0BwzZjH9KYYMDcXBHWkdrdU1yZEk/view?usp=sharing
v/R Mike
Answers
DISCLAIMER: I dunno ControlP5 so my help here is very limited. 8-X
println(Thread.currentThread());
inside your Button1() callback function for debugging.Thread[Animation Thread,5,main]
, you can't use any Processing API dealing w/ canvas there. Including your fill(), textSize() & text()! :-\"boolean
variable in order to flag the action.Hi GoToLoop.
Thanks for getting back to me so fast. Did as you suggested but No Joy. The print returned exactly Thread[Animation Thread,5,main]. Thanks for suggestion - just learned something new.
Mike
line 6 gets only called once
so no use to use text() here (because draw runs 60 times per second and clears the screen)
so after line 6 set a boolean showText = true;
now in draw() check if(showText) and if so do the text() you have in line 6 now
gotoloop wrote that but too brief for you
Yea, I hinted about the
boolean
variable.And although it's not about the "Animation Thread" anymore now, there's still the fact that background() erases everything as @Chrisir mentioned! :-\"
Hey All,
@GoToLoop, from your post i did not try the boolean because I assumed the problem laid elsewhere and not in printing text to the screen from the function. However, with that said I moved the text commands to the draw function with the boolean as you and @Chrisir suggested and of course it worked. I also tried one other thing based on @GoToLoop's identification of what happens with Background(). I moved the backgrond(230) to setup and left the text in the button function. It worked as well. However, the text now looks like garbage - tried smooth(8) but did not work. Any ideas on this one.
thanks for your help.
If you don't have any background() executed after setup(), things gonna be drawn over & over.
Even those always drawn at the same place can still get some blur result due to accumulation of color blending and anti-aliasing.
You are a wealth of info, I mean it, for understanding the issue. Got this one solved but now I another issue with ControlP5. If you checked the image you will see a Run Script button. Basically this runs a series of commands to execute a Inverser Kinematic calculation and moves the arm then for now just displays the angles on the screen. Tried to write to the screen with the text() but it does not pdate until after the last move. Will post this as a separate issue.
thanks again.
Hello,
you wrote:
It is true:
draw()
updates / outputs the screen only once at the end ofdraw()
.This is not a bug though but intentionally.
println()
works throughout duringdraw()
whiletext()
works only at its end.A workaround:
You wrote:
if you had the commands in an
ArrayList
named "commands" you could go through it. Now with a for-loop indraw()
you won't see your text till the very end.But when you use the fact that
draw()
in-build runs automatically 60 times per second you could use a var "index" or so for the ArrayList and in draw sayindex++;
to slow down just say
frameRate(12);
or so.Best, Chrisir ;-)
Will give it try at some point to see if it works. The arraylist is good since at somepoint i am planning on using G-Codes to move the arm. Just seems like a lot of effort to get values displayed.
Thanks for the help, CyberMerln