You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
1.7 KiB
105 lines
1.7 KiB
import dmxP512.*;
|
|
import processing.serial.*;
|
|
import controlP5.*;
|
|
import oscP5.*;
|
|
import netP5.*;
|
|
|
|
OscP5 oscP5;
|
|
NetAddress myRemoteLocation;
|
|
int OSC_PORT=8888;
|
|
|
|
ControlP5 cp5;
|
|
|
|
DmxP512 dmxOutput;
|
|
int universeSize=128;
|
|
String DMXPRO_PORT="COM3";//case matters ! on windows port must be upper cased.
|
|
int DMXPRO_BAUDRATE=115000;
|
|
|
|
|
|
int LIGHT_COUNT=1;
|
|
Light[] lights;
|
|
|
|
|
|
int last_enter_time=0;
|
|
|
|
|
|
void setup(){
|
|
|
|
size(400, 400, JAVA2D);
|
|
load();
|
|
|
|
|
|
dmxOutput=new DmxP512(this,universeSize,false);
|
|
try{
|
|
dmxOutput.setupDmxPro(DMXPRO_PORT,DMXPRO_BAUDRATE);
|
|
}catch(Exception e){
|
|
println(e);
|
|
}
|
|
|
|
|
|
lights=new Light[LIGHT_COUNT];
|
|
for(int i=0;i<LIGHT_COUNT;++i){
|
|
lights[i]=new Light(i*3+1);
|
|
}
|
|
|
|
setupControl();
|
|
|
|
oscP5 = new OscP5(this,OSC_PORT);
|
|
}
|
|
|
|
void draw(){
|
|
|
|
background(0);
|
|
|
|
drawLight();
|
|
|
|
|
|
|
|
for(int i=0;i<LIGHT_COUNT;++i){
|
|
lights[i].update();
|
|
}
|
|
|
|
|
|
|
|
pushStyle();
|
|
fill(0,180,180);
|
|
textSize(20);
|
|
text(nfc(frameRate,2), 50, height-50);
|
|
popStyle();
|
|
|
|
|
|
}
|
|
//<>//
|
|
|
|
void drawLight(){
|
|
pushMatrix();
|
|
//translate(width/2, 0);
|
|
|
|
for(int i=0;i<LIGHT_COUNT;++i){
|
|
lights[i].draw(0,i*height/LIGHT_COUNT, width,height/LIGHT_COUNT);
|
|
}
|
|
|
|
popMatrix();
|
|
}
|
|
|
|
void updateLight(float val){
|
|
for(int i=0;i<LIGHT_COUNT;++i){
|
|
lights[i].setColor(val);
|
|
}
|
|
}
|
|
|
|
void oscEvent(OscMessage theOscMessage) {
|
|
/* print the address pattern and the typetag of the received OscMessage */
|
|
String addr=theOscMessage.addrPattern();
|
|
float value=float(theOscMessage.get(0).stringValue());
|
|
|
|
print("### received an osc message.");
|
|
print(" addrpattern: "+addr);
|
|
println(" val:"+value);
|
|
|
|
|
|
if(addr.equals("/light")){
|
|
updateLight(value);
|
|
}
|
|
|
|
}
|
|
|