Going forward. Testing lp5 controls of Sojamo. myTextarea.setText ("."); // pressed push button, we clean text area.
The question is if there is not a command to clean lines every time a new data comes in.
Thanks KLL.
import static java.nio.charset.StandardCharsets.*;
import processing.serial.*;
Serial port;
byte bloque_datos[];
static byte TOTAL_BYTES=32;
/**
* ControlP5 Println
*
*
* a console like textarea which captures the output from the System.out stream
*
* by Andreas Schlegel, 2012
* www.sojamo.de/libraries/controlp5
*
*/
import controlP5.*;
ControlP5 cp5;//create cp5 object
PFont font;
Textarea myTextarea;
int c = 0;
Println console;
void setup(){
size(360, 500);
cp5 = new ControlP5(this);
cp5.enableShortcuts();
frameRate(50);
myTextarea = cp5.addTextarea("txt")
.setPosition(30, 10)
.setSize(300, 100)
.setFont(createFont("", 30))
.setLineHeight(14)
.setColor(color(0, 255))
.setColorBackground(color(5, 255,136))
.setColorForeground(color(5, 237, 242));
console = cp5.addConsole(myTextarea);//
frameRate(10);
port=new Serial(this,"COM7",9600);
bloque_datos=new byte[TOTAL_BYTES];
//lets add button to empty window
cp5 = new ControlP5(this);
font = createFont("calibre light bold", 20);
//cp5.addButton("columns_1_rows_1") //position of button
cp5.addButton("A")
.setPosition(30, 170) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font)
;
//cp5.addButton("columns_1_rows_2") //position of button
cp5.addButton("B")
.setPosition(30, 240) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_1rows_3") //"position of button
cp5.addButton("C")
.setPosition(30,310) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_1_rows_4") //"position of button
cp5.addButton("D")
.setPosition(30, 380) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_2_rows_1") //"position of button
cp5.addButton("E")
.setPosition(110, 170) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_2_rows_2") //"position of button
cp5.addButton("F")
.setPosition(110, 240) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_2_rows_3") //"position of button
cp5.addButton("G")
.setPosition(110, 310) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_2_rows_4") //"position of button
cp5.addButton("H")
.setPosition(110, 380) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_3_rows_1") //"position of button
cp5.addButton("I")
.setPosition(190, 170) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_3_rows_2") //"position of button
cp5.addButton("J")
.setPosition(190, 240) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_3_rows_2") //"position of button
cp5.addButton("K")
.setPosition(190, 310) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_3_rows_2") //"position of button
cp5.addButton("L")
.setPosition(190, 380) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_4_rows_1") //"position of button
cp5.addButton("M")
.setPosition(270, 170) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_4_rows_2") //"position of button
cp5.addButton("N")
.setPosition(270, 240) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_4_rows_3") //"position of button
cp5.addButton("O")
.setPosition(270, 310) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_4_rows_4") //"position of button
cp5.addButton("P")
.setPosition(270, 380) //x and y coordinates of upper left corner of button
.setSize(60, 60) //(width, height)
.setFont(font);
//cp5.addButton("columns_4_rows_4") //"position of button
cp5.addButton("c")
.setPosition(10, 120) //x and y coordinates of upper left corner of button
.setSize(30, 30) //(width, height)
.setFont(font);
}
void draw(){
background(128);
noStroke();
text("clean text area", 60, 140);textSize(16); // ("text", x coordinate, y coordinate)
{
if(port.available()>0)
{
bloque_datos=port.readBytes(TOTAL_BYTES);
if(bloque_datos!=null)
{
print(new String(bloque_datos,UTF_8));
}
}
}
}
void A(){
port.write('A');
}
void B(){
port.write('B');
}
void C(){
port.write('C');
}
void D(){
port.write('D');
}
void E(){
port.write('E');
}
void F(){
port.write('F');
}
void G(){
port.write('G');
}
void H(){
port.write('H');
}
void I(){
port.write('I');
}
void J(){
port.write('J');
}
void K(){
port.write('K');
}
void L(){
port.write('L');
}
void M(){
port.write('M');
}
void N(){
port.write('N');
}
void O(){
port.write('O');
}
void P(){
port.write('P');
}
void c(){
myTextarea.setText("."); // pressed push button, we clean text area
}
void keyPressed() {
if(key=='r') {
myTextarea.setText("."); // PC keyboard "C" key, pressed, clean text area
}}