import controlP5.*;
import hypermedia.net.*;
ControlP5 cp5;
UDP udp;
String ip = "192.168.0.5";
int port = 8888;
void setup() {
size(300, 500);
udp = new UDP( this, port );
udp.listen(true);
cp5 = new ControlP5(this);
cp5.setFont(createFont("Ubuntu", 10));
// Питание гирлянды
cp5.addToggle("power_changed")
.setPosition(10, 10)
.setSize(40, 20)
.setLabel("Питание")
.setMode(ControlP5.SWITCH);
cp5.addSlider("brightness_changed")
.setPosition(10, 60)
.setLabel("Яркость")
.setSize(100, 20)
.setValue(255)
.setRange(0, 255);
cp5.addSlider("speed_changed")
.setPosition(10, 100)
.setLabel("Скорость эффекта")
.setSize(100, 20)
.setValue(75)
.setRange(0, 100);
}
void draw() {
background(30);
}
void power_changed(boolean pwr) {
pwr = !pwr;
String pack = "power " + str(pwr);
udp.send( pack, ip, port );
}
void brightness_changed(int bright) {
String pack = "brightness " + str(bright);
udp.send( pack, ip, port );
}
void speed_changed(int speed) {
String pack = "speed " + str(speed);
udp.send( pack, ip, port );
}