summaryrefslogtreecommitdiff
path: root/gui/src/ofApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src/ofApp.cpp')
-rw-r--r--gui/src/ofApp.cpp152
1 files changed, 123 insertions, 29 deletions
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index d99300c..797f729 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -4,7 +4,7 @@
//--------------------------------------------------------------
void ofApp::setup(){
- if (dmx.connect("tty.usbserial-ENP6ESY9")){
+ if (dmx.connect("tty.usbserial-ENP6ESY9",120)){
printf("DMX connected!\n");
//sbx1 - 16chan at 1
@@ -15,17 +15,25 @@ void ofApp::setup(){
//par2 - shutter, intensirty, R, G, B, white at 70
//par3 - shutter, intensirty, R, G, B, white at 76
- map.push_back(dmxMap(&dmx,66,67,68,65,0.1,0.1));
- map.push_back(dmxMap(&dmx,72,73,74,71,0.5,0.1));
- map.push_back(dmxMap(&dmx,78,79,80,77,0.9,0.1));
+ // R, G, B, white, dimmer, shutter
+
+ map.push_back(USBdmxMap(&dmx,80,0.1,0.1));
+ map.push_back(USBdmxMap(&dmx,90,0.5,0.1));
+ map.push_back(USBdmxMap(&dmx,100,0.9,0.1));
+ map.push_back(USBdmxMap(&dmx,110,0.5,0.5));
}
- else printf("DMX not connected.\n");
+ else printf("USB DMX not connected.\n");
+
+ //artnet.setup("10.7.186.17");
+ //memset(dmx_data,0,512);
midiIn.listPorts();
midiIn.openPort(0);
midiIn.addListener(this);
- dmxIntensity=0;
+ dmxIntensity=255;
+
+ next_update=ofGetElapsedTimef()+5.0f;
}
//--------------------------------------------------------------
@@ -41,12 +49,8 @@ void ofApp::update(){
void ofApp::updateOutput(ofEventArgs & args){
images.update();
+ images2.update();
- if (dmx.isConnected()){
- for (auto m=map.begin();m!=map.end();m++){
- m->update(dmxIntensity);
- }
- }
}
@@ -54,13 +58,27 @@ void ofApp::updateOutput(ofEventArgs & args){
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(0,0,0);
- images.drawGui();
+ images.drawGui(0,0);
+ images2.drawGui(0,200);
}
void ofApp::drawOutput(ofEventArgs & args){
ofBackground(0,0,0);
images.drawOutput();
+ images2.drawOutput();
+
+ if (dmx.isConnected()&&ofGetElapsedTimef()>next_update){
+ //if (dmx.isConnected()&&()){
+ for (auto m=map.begin();m!=map.end();m++){
+ m->update(dmxIntensity);
+
+ }
+ //artnet.sendDmx("10.7.175.170", dmx_data, 512);
+
+ next_update=ofGetElapsedTimef()+0.2f;
+ }
+
}
@@ -105,48 +123,109 @@ void ofApp::newMidiMessage(ofxMidiMessage& msg) {
//column 0 for general controls
- if (msg.channel==1&&msg.control==1){
+ int offet=0;
+
+ if (msg.channel==1&&msg.control==1+offet){
//pot 0
//from .9 to 1.1 but reaching numbers very near 1
-
- images.decayFactor=1.0 - (pow(2.0f,((float)msg.value-64)/8)/pow(2,8));
-
- //printf("Val %i, decay: %f \n",msg.value,sf);
+ float signed_value=(float)msg.value-64;
+ if (signed_value<0){
+ images.decayFactor=1.0 + (pow(4.0f,abs(signed_value)/8)/pow(4,8));
+ }
+ else {
+ images.decayFactor=1.0 - (pow(4.0f,(signed_value)/8)/pow(4,8));
+ }
+ images2.decayFactor=images.decayFactor;
+
+ printf("Val %i, decay: %f \n",msg.value,images.decayFactor);
}
- if (msg.channel==1&&msg.control==65){
+ if (msg.channel==1&&msg.control==65+offet){
//top button 0
}
- if (msg.channel==1&&msg.control==73){
+ if (msg.channel==1&&msg.control==73+offet){
//bottom button 0
}
- if (msg.channel==1&&msg.control==81){
+ if (msg.channel==1&&msg.control==81+offet){
//fader 0
dmxIntensity=msg.value*2;
+ printf("Val %i, dmx intensity: %i \n",msg.value,dmxIntensity);
}
-//column 1 for image set 0
+//column 5 for image set 0
+
+ offet=4;
- if (msg.channel==1&&msg.control==2){
+ if (msg.channel==1&&msg.control==1+offet){
//pot 1
}
- if (msg.channel==1&&msg.control==66){
+ if (msg.channel==1&&msg.control==65+offet){
//top button 1
images.additive=(msg.value==127);
}
- if (msg.channel==1&&msg.control==74){
+ if (msg.channel==1&&msg.control==73+offet){
//bottom button 1
}
- if (msg.channel==1&&msg.control==82){
+ if (msg.channel==1&&msg.control==81+offet){
//fader 1
images.intensity=((float)msg.value)/127.0f;
}
+//column 6 for image set 1
+
+ offet=5;
+
+ if (msg.channel==1&&msg.control==1+offet){
+ //pot 1
+ }
+ if (msg.channel==1&&msg.control==65+offet){
+ //top button 1
+ images.additive=(msg.value==127);
+ }
+ if (msg.channel==1&&msg.control==73+offet){
+ //bottom button 1
+ }
+ if (msg.channel==1&&msg.control==81+offet){
+ //fader 1
+ images2.intensity=((float)msg.value)/127.0f;
+ }
+
+//column 1 for more controls
+ offet=1;
+
+ if (msg.channel==1&&msg.control==1+offet){
+ //pot 1
+ images.fitFactor=1.0f+(((float)msg.value-64)/64.0f);
+ images2.fitFactor=1.0f+(((float)msg.value-64)/64.0f);
+
+ printf("Val %i, fitfactor: %f \n",msg.value,images.fitFactor);
+ }
+ if (msg.channel==1&&msg.control==65+offet){
+ //top button 1
+
+ }
+ if (msg.channel==1&&msg.control==73+offet){
+ //bottom button 1
+ }
+ if (msg.channel==1&&msg.control==81+offet){
+ //fader 1
+
+ }
+
}
//--------------------------------------------------------------
void ofApp::keyPressed(ofKeyEventArgs &keyargs){
images.keyPressed(keyargs);
+
+
+}
+
+void ofApp::outputKeyPressed(ofKeyEventArgs &args){
+ if(args.key == ' '){
+ outputFS=!outputFS;
+ ofSetFullscreen(outputFS);
+ }
}
//--------------------------------------------------------------
@@ -161,17 +240,26 @@ void ofApp::mouseMoved(int x, int y ){
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
- images.mouseDragged(x,y,button);
+ if (y<ofGetHeight()/2){
+ images.mouseDragged(x,y,button);
+ }
+ else images2.mouseDragged(x,y,button);
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
- images.mousePressed(x,y,button);
+ if (y<ofGetHeight()/2){
+ images.mousePressed(x,y,button);
+ }
+ else images2.mousePressed(x,y,button);
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
- images.mouseReleased(x,y,button);
+ if (y<ofGetHeight()/2){
+ images.mouseReleased(x,y,button);
+ }
+ else images2.mouseReleased(x,y,button);
}
//--------------------------------------------------------------
@@ -192,6 +280,7 @@ void ofApp::windowResized(int w, int h){
void ofApp::outputWindowResized(ofResizeEventArgs &resizeargs){
//printf("Output window: %i,%i \n",resizeargs.width,resizeargs.height);
images.outputSize=ofPoint(resizeargs.width,resizeargs.height);
+ images2.outputSize=ofPoint(resizeargs.width,resizeargs.height);
}
//--------------------------------------------------------------
@@ -209,7 +298,12 @@ void ofApp::dragEvent(ofDragInfo dragInfo){
}
filenames=filenames+*f;
- images.add(*f,dragInfo.position);
+ if (dragInfo.position.y<200){
+ images.add(*f,dragInfo.position);
+ }
+ else images2.add(*f,dragInfo.position);
+
+
}
}