Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2. Crhistian David Lucumi
  3. Sistemas Embebidos
  4. Laboratorio 9
  5.  
  6. */
  7.  
  8. import processing.serial.*;
  9. import controlP5.*;
  10.  
  11. ControlP5 cp5;
  12. Textarea myTextarea;
  13. String textValue = "";
  14. Serial serie;
  15. void setup() {
  16.   size(700,400);
  17.  
  18.   PFont font = createFont("arial",20);
  19.  
  20.   cp5 = new ControlP5(this);
  21.  
  22.   cp5.addTextfield("input")
  23.      .setPosition(20,100)
  24.      .setSize(200,40)
  25.      .setFont(font)
  26.      .setFocus(true)
  27.      .setColor(color(255,0,0))
  28.      ;
  29.                  
  30.  
  31.        
  32.   cp5.addBang("clear")
  33.      .setPosition(240,170)
  34.      .setSize(80,40)
  35.      .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
  36.      ;    
  37.     myTextarea = cp5.addTextarea("txt")
  38.                   .setPosition(20,70)
  39.                   .setSize(200,20)
  40.                   .setFont(createFont("arial",12))
  41.                   .setLineHeight(14)
  42.                   .setColor(color(128))
  43.                   .setColorBackground(color(255,100))
  44.                   .setColorForeground(color(255,100));
  45.                   ;
  46.                  
  47.     myTextarea.setText("Solo Letras de la A-Z y Numeros Positivos"
  48.                     );
  49.  
  50.      serie = new Serial(this, Serial.list()[0], 9600);
  51.   textFont(font);
  52. }
  53.  
  54. void draw() {
  55.   background(0);
  56.   fill(255);
  57.   text(cp5.get(Textfield.class,"input").getText(), 360,130);
  58.   text(textValue, 360,180);
  59. }
  60.  
  61. public void clear() {
  62.   cp5.get(Textfield.class,"input").clear();
  63. }
  64.  
  65. void controlEvent(ControlEvent theEvent) {
  66.   if(theEvent.isAssignableFrom(Textfield.class)) {
  67.     serie.write( ""+theEvent.getStringValue()  );
  68.     }
  69. }