There are 4 areas on my LED Ring and I made 4 buttons for choosing them. I want to be able to use these areas for different combinations.
So my aim is:
One click on the button: Selected area is active.
Double click on on the button: Selected area is deactive.
I know there is a function called mousePressed() but I couldn't implement it to my buttons with a double-click condition.
Here is the piece of my code of from processing:
Group AreaGroup = cp5.addGroup("AREAS")
.setPosition(290,50)
.setWidth(150)
.setHeight(30)
.setFont(font2)
.moveTo(SetupGroup);
background(0);
noStroke();
;
cp5.addButton("AREA_1") // The button
.setPosition(-15,10) // x and y relative to the group
.setSize(90, 50) // (width, height)
.setFont(font)
.moveTo(AreaGroup); // add it to the group
;
cp5.addButton("AREA_2") // The button
.setPosition(90,10) // x and y relative to the group
.setSize(90, 50) // (width, height)
.setFont(font)
.moveTo(AreaGroup); // add it to the group
;
cp5.addButton("AREA_3") // The button
.setPosition(-15,80) // x and y relative to the group
.setSize(90, 50) // (width, height)
.setFont(font)
.moveTo(AreaGroup); // add it to the group
;
cp5.addButton("AREA_4") // The button
.setPosition(90,80) // x and y relative to the group
.setSize(90, 50) // (width, height)
.setFont(font)
.moveTo(AreaGroup); // add it to the group
;
cp5.addButton("ALL") // The button
.setPosition(190,45) // x and y relative to the group
.setSize(90, 50) // (width, height)
.setFont(font)
.moveTo(AreaGroup); // add it to the group
;
void AREA_1(){
println("AREA_1");
if (port != null) port.write("a\n");
}
void AREA_2(){
println("AREA_2");
if (port != null) port.write("b\n");
}
void AREA_3(){
println("AREA_3");
if (port != null) port.write("c\n");
}
void AREA_4(){
println("AREA_4");
if (port != null) port.write("d\n");
}
void ALL(){
println("ALL");
if (port != null) port.write("t\n");
}
And here is the code pieces from Arduino
switch(state){
case 'p':
Serial.println(F("ex."));
break;
case 's':
Serial.println(F("Start"));
start = true;
break;
case '1':
Serial.println(F("Switching to ring #1"));
updateRing1 = true;
updateRing2 = false;
break;
case '2':
Serial.println(F("Switching to ring #2"));
updateRing1 = false;
updateRing2 = true;
break;
case 'a':
Serial.println(F("Area1"));
Area1 = true;
break;
case 'b':
Serial.println(F("Area2"));
Area2 = true;
break;
case 'c':
Serial.println(F("Area3"));
Area3 = true;
break;
case 'd':
Serial.println(F("Area4"));
Area4 = true;
break;
case 't':
Serial.println(F("All the leds are choosen"));
total = true;
Area1 = false;
Area2 = false;
Area3 = false;
Area4 = false;
break;