// CNC Tragfächen Schneidegerät
// Interface für den PC/Linux
// Gekoppelt über Serielle Schnittstelle mit Arduino

import controlP5.*;

ControlP5 controlP5;

Textfield ProfLinks;
Textfield ProfRechts;
Textfield TLinks;
Textfield TRechts;
Textfield AWLinks;
Textfield AWRechts;
Textfield Pfeilung;
Textfield SegBreite;

void setup() {
  size(400,380);
  frameRate(25);
  controlP5 = new ControlP5(this);
  ProfLinks = controlP5.addTextfield("Profil Links",30,30,100,20);
  ProfRechts = controlP5.addTextfield("Profil Rechts",250,30,100,20);
  TLinks = controlP5.addTextfield("Tiefe Links",30,90,100,20);
  TRechts = controlP5.addTextfield("Tiefe Rechts",250,90,100,20);
  AWLinks = controlP5.addTextfield("Anstellwinkel Links",30,130,100,20);
  AWRechts = controlP5.addTextfield("Anstellwinkel Rechts",250,130,100,20);
  
  Pfeilung = controlP5.addTextfield("Pfeilungswinkel",140,220,100,20);
  SegBreite = controlP5.addTextfield("Segmentbreite",140,270,100,20);
  
  controlP5.addButton("Start",0,30,340,80,19).setId(9);
  controlP5.addButton("Cancel",255,150,340,80,19).setId(10);
  controlP5.addButton("Home",128,270,340,80,19).setId(11);
  
  
}

void draw() {
  background(100);
  fill(100);
  stroke(60);
  rect(10,10,160,180);
  rect(220,10,160,180);  
  rect(10,210,370,100);
}

public void controlEvent(ControlEvent theEvent) {
  println("got a control event from controller with id "+theEvent.controller().id());
  switch(theEvent.controller().id()) {
    case(9): // Start
    println("Start");
    println(ProfLinks.getText());
    break;
    case(10): // Cancel
    println("Cancel");
    println(Pfeilung.getText());
    break;
    case(11): // Home
    println("Home");
    println(SegBreite.getText());
    break;
  }
}
