We are about to switch to a new forum software. Until then we have removed the registration on this forum.
When i move my slider the values of it move with it and are "spammed" along side it, im confused as ive dont this before and this didn't happen!
thehobbit.
import processing.serial.*;
import controlP5.*;
ControlP5 cp5;
int pan = 100;
int tilt = 100;
Serial port;
void setup()
{
noStroke();
background(0);
size(640, 640);
port = new Serial(this, Serial.list()[0],9600);
cp5 = new ControlP5(this);
cp5.addSlider("pan")
.setPosition(60,500)
.setSize(10,100)
.setRange(0,179)
.setValue(90)
;
//,0,179,90,60,500,10,100);
cp5.addSlider("tilt")
//,0,179,90,60,500,100,10);
.setPosition(60,500)
.setSize(100,10)
.setRange(0,179)
.setValue(90)
;
}
void draw()
{
port.write("a"+pan);
port.write("b"+tilt);
}
Answers
Define "spammed". What is the displayed behavior? What is the expected behavior?
You are writing your values 60 times per second in your draw loop.
Hi,
Thanks for the reply.
It only happens with the pan slider. The value of the slider is displayed adjacent to the position of the slider outside the slider box. As i move the slider the value of it moves with it and is left printed there e.g. if i move the slider up and down many times im left with a white line or "blur" that runs parallel to the slider.
the expected behavior is that the pan slider value is displayed inside the slider box like the tilt and it not create this "blur" when i move the slider.
How do you know that it is writing values at 60 times per sec?
Thanks again.
thehobbit.
Ive changed it to be horizontal now and that works. Although this is still miffing me off!
Ah, now it is clear what you mean.
The problem is you are not clearing the background, so the drawing (also of the gui value) is aggregate. So the solution is simple, add the following line to your draw() loop: background(0);
The default framerate of Processing's draw() loop is 60 frames per second (although this is not always the accurate and actual framerate of course).
Wow thanks !