ControlP5 timing
in
Contributed Library Questions
•
8 months ago
Hi All,
I ran into a problem with ControlP5.
In this sketch i've placed a Start button and a Status toggle
Purpose:
Press the start button, the status toggle should be activated, wait 3 seconds and then get deactivated.
When i comment-out line 14+15, the activation of the status reacts right after pressing the start button, as expected.
But when i un-comment 14+15, the activation seems to happen after the delay of 3 sec.
Why doesn't it work like it should?
How can i get this to work?
Thnx
I ran into a problem with ControlP5.
In this sketch i've placed a Start button and a Status toggle
Purpose:
Press the start button, the status toggle should be activated, wait 3 seconds and then get deactivated.
When i comment-out line 14+15, the activation of the status reacts right after pressing the start button, as expected.
But when i un-comment 14+15, the activation seems to happen after the delay of 3 sec.
Why doesn't it work like it should?
How can i get this to work?
Thnx
- import controlP5.*;
- ControlP5 cp5;
- void setup() {
- size(400,400);
- cp5 = new ControlP5(this);
- cp5.addBang("Start");
- cp5.addToggle("Status");
- }
- public void controlEvent(ControlEvent theEvent) {
- if (theEvent.isController()) {
- print("control event from : " + theEvent.getController().getName());
- if ( theEvent.getController().getName() == "Start") {
- cp5.getController("Status").setValue(1);
- delay(3000);
- cp5.getController("Status").setValue(0);
- }
- }
- }
- void draw() {
- background(0);
- }
1