import processing.serial.*; import controlP5.*; import java.util.Date; Serial port; Textfield recived; Textfield recived1; Textfield recived2; Textfield recived3; Textfield recived4; Textfield recived5; String val; String data; String DateTab; String Dat; int data2=0; String time; Button vyvod; PrintWriter output; Table table2; int i=0; ControlP5 cp5; ControlP5 ax; PFont font; PFont font2; String[] args = {"YourSketchNameHere"}; SecondApplet sa; PImage fon; PImage fon2; PImage titlebaricon; // void setup() { titlebaricon = loadImage("data/myicon.png"); surface.setIcon(titlebaricon); surface.setTitle(" "); // ))) printArray(Serial.list()); port = new Serial(this, "/dev/ttyUSB0", 9600); // com ( Ubuntu, Windows //com port) cp5 = new ControlP5(this); font = createFont("Arial", 20); // fon = loadImage("data/phil.bmp"); // fon2 = loadImage("data/fon2.bmp"); /* void settings()*/ PImage img; img = loadImage("data/image1.bmp"); // - "data" image(img, 0, 0); tint(0, 255, 0, 126); // - 50% image(img, 50, 0); PImage img2; img2 = loadImage("data/image2.bmp"); image(img2, 0, 0); image(img2, 50, 0); // // tint() . PImage img3; // . img3 = loadImage("data/image3.bmp"); image(img3, 0, 0); image(img3, 50, 0); PImage img4; img4 = loadImage("data/image4.bmp"); image(img4, 0, 0); image(img4, 50, 0); PImage img5; img5 = loadImage("data/imagezapros.bmp"); image(img5, 0, 0); image(img5, 50, 0); PImage img6; img6 = loadImage("data/temper.bmp"); image(img6, 0, 0); image(img6, 50, 0); cp5.addButton("Relay_1") .setSize (100, 50) .setPosition(50, 50) .setFont(font) .setImage(img) .setLabel(" 1"); cp5.addButton("Relay_2") .setSize (100, 50) .setPosition(250, 50) .setFont(font) .setImage(img2) .setLabel(" 2"); cp5.addButton("Relay_ON") .setSize (300, 50) .setPosition(50, 120) .setFont(font) .setLabel(" ") .setImage(img3); cp5.addButton("Relay_OFF") .setSize (300, 50) .setPosition(50, 190) .setFont(font) .setLabel(" ") .setImage(img4); cp5.addButton("Zapros_sostoyaniya") .setSize (300, 50) .setPosition(50, 260) .setFont(font) .setLabel(" ") .setImage(img5); recived=cp5.addTextfield(" ") .setSize(380,100) .setPosition(10, 340) .setColorValueLabel(0) .setFont(font) .setColorBackground(color(255, 255, 255)); cp5.addButton("temps") .setSize (380, 50) .setPosition(10, 500) .setColorBackground(color(70, 100, 0)) .setColorForeground(color(0, 0, 0)) .setFont(font) .setLabel("") .setImage(img6); } void settings(){ size(400, 560); } void draw() { background(fon); fill(0, 0, 0); textFont(font); text(" ", 135, 30); int s = second(); int m = minute(); int h = hour(); int d = day(); int mo = month(); int y = year(); DateTab = str(d)+ "." + str(mo) + "." + str(y) + (" ") + str(h) + (":") + str(m) + (":") + str(s); if ( port.available() > 0){ val = port.readString(); if(data2==0){ // - , recived.setText(val); // - com , - . } /* data2 - , Second Applet textfield . */ } sa = new SecondApplet(); } void Relay_1(){ port.write("1"); } void Relay_2(){ port.write("2"); } void Relay_ON(){ port.write("3"); } void Relay_OFF(){ port.write("0"); } void Zapros_sostoyaniya(){ data2=0; port.write("4"); } void save123(){ // data2=1; port.write("4"); delay(600); port.available(); Dat=DateTab + " " + val; table2 = loadTable("data/Journaltemp.ods"); // table2.setString(0, 0, "t"); // 0.0 table2.removeColumn(0); /* 0, */ TableRow newRow = table2.addRow(); // newRow.setString(0, Dat); /* 0 ( )*/ saveTable(table2, "data/Journaltemp.ods"); // data2=0; } void temps(){ PApplet.runSketch(args, sa); // Second Applet } public class SecondApplet extends PApplet { public void setup(){ surface.setTitle(" "); surface.setIcon(titlebaricon); font2 = createFont("Arial", 20); /* , , ..*/ ax = new ControlP5(this); ax.addButton("test1") .setSize(159, 70) .setPosition(1, 300) .setFont(font2) .setLabel(""); ax.addButton("test2") .setSize(158, 70) .setPosition(161, 300) .setFont(font2) .setLabel(""); ax.addButton("test3") .setSize(159, 70) .setPosition(320, 300) .setFont(font2) .setLabel(""); ax.addButton("test4") .setSize(159, 70) .setPosition(480, 300) .setFont(font2) .setLabel(""); ax.addButton("test5") .setSize(159, 70) .setPosition(640, 300) .setFont(font2) .setLabel(""); ax.addButton("obj") .setSize (790, 50) .setPosition(5, 540) .setColorBackground(color(70, 100, 0)) .setColorForeground(color(0, 0, 0)) .setFont(font) .setLabel(""); recived1 = ax.addTextfield(" ") .setSize(157, 70) .setPosition(2, 370) .setColorValueLabel(0) .setFont(font) .setColorBackground(color(255, 255, 255)); recived2=ax.addTextfield(" ") .setSize(156, 70) .setPosition(162, 370) .setColorValueLabel(0) .setFont(font) .setColorBackground(color(255, 255, 255)); recived3=ax.addTextfield(" ") .setSize(157, 70) .setPosition(321, 370) .setColorValueLabel(0) .setFont(font) .setColorBackground(color(255, 255, 255)); recived4=ax.addTextfield(" ") .setSize(157, 70) .setPosition(481, 370) .setColorValueLabel(0) .setFont(font) .setColorBackground(color(255, 255, 255)); recived5=ax.addTextfield(" ") .setSize(157, 70) .setPosition(641, 370) .setColorValueLabel(0) .setFont(font) .setColorBackground(color(255, 255, 255)); } public void settings() { size(800, 600); // } public void draw() { background(fon2); // )) textFont(font2); } public void test1(){ recived1.setText(" 11111"); } public void test2(){ recived2.setText(" 22222"); } public void test3(){ recived3.setText(" 33333"); // Second Applet } public void test4(){ recived4.setText(" 44444"); } public void test5(){ recived5.setText(" 55555"); } public void obj(){ save123(); /* */ } public void exitActual(){} // [X] . } // , [X].