diff options
| author | Tim Redfern <tim@getdrop.com> | 2017-09-01 15:57:45 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2017-09-01 15:57:45 +0100 |
| commit | 5ebbcf534eb74469f09d5822f4d99478efe84794 (patch) | |
| tree | 864cb0598111224f12a3fc8c1f5b7f44b8bd85b4 /gui/src/ofApp.h | |
| parent | 14da9cce8d665d2872b76909e8abc001a9921297 (diff) | |
working DMX
Diffstat (limited to 'gui/src/ofApp.h')
| -rw-r--r-- | gui/src/ofApp.h | 89 |
1 files changed, 76 insertions, 13 deletions
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index 20116a1..181c4c7 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -2,22 +2,34 @@ #include "ofMain.h" #include "ofxDmx.h" +//#include "ofxArtnet.h" #include "ofxMidi.h" #include "chainImage.h" -class dmxMap{ +class USBdmxMap{ //resolution independent DMX colour tracker public: - dmxMap(){ + USBdmxMap(){ } - dmxMap(ofxDmx *_dmx,int _chan_R,int _chan_G,int _chan_B,int _chan_intensity,float _x,float _y){ + USBdmxMap(ofxDmx *_dmx,int chan_base,float _x,float _y){ dmx=_dmx; - chan_R=_chan_R; - chan_G=_chan_G; - chan_B=_chan_B; - chan_intensity=_chan_intensity; + + // R, G, B, white, dimmer, shutter + + // dimmer, shutter, R, G, B, white + + + chan_intensity=chan_base; + chan_shutter=chan_base+1; + chan_R=chan_base+2; + chan_G=chan_base+3; + chan_B=chan_base+4; + chan_white=chan_base+5; + + //dmx->setLevel(chan_shutter,15,0); + //dmx->update(); x=_x; y=_y; } @@ -25,17 +37,57 @@ class dmxMap{ unsigned char color[3]; glReadPixels(x*ofGetWidth() , ofGetHeight() - (y*ofGetHeight()) , 1 , 1 , GL_RGB , GL_UNSIGNED_BYTE , color); //printf("dmxMap %i,%i: colour %i %i %i\n",x,y,color[0],color[1],color[2]); - dmx->setLevel(chan_R, color[0]); - dmx->setLevel(chan_G, color[1]); - dmx->setLevel(chan_B, color[2]); - dmx->setLevel(chan_intensity, intensity); + + dmx->setLevel(chan_R,color[0]); //,0); + dmx->setLevel(chan_G,color[1]); //,0); + dmx->setLevel(chan_B,color[2]); //,0); + dmx->setLevel(chan_white,0); //,0); + dmx->setLevel(chan_intensity,intensity); //,0); + dmx->setLevel(chan_shutter,255); //,0); dmx->update(); + + printf("Dmx: %i,%i,%i @ %i \n",color[0],color[1],color[2],intensity); } - int chan_R, chan_G, chan_B, chan_intensity; + int chan_R, chan_G, chan_B, chan_intensity, chan_shutter, chan_white; float x,y; ofxDmx *dmx; }; +class ArtnetDmxMap{ + //resolution independent DMX colour tracker + public: + ArtnetDmxMap(){ + } + ArtnetDmxMap(unsigned char *_dmx_data,int chan_base,float _x,float _y){ + dmx_data=_dmx_data; + chan_shutter=chan_base; + chan_intensity=chan_base+1; + chan_R=chan_base+2; + chan_G=chan_base+3; + chan_B=chan_base+4; + + //dmx->setLevel(chan_shutter,15,0); + //dmx->update(); + x=_x; + y=_y; + } + void update(int intensity){ + unsigned char color[3]; + glReadPixels(x*ofGetWidth() , ofGetHeight() - (y*ofGetHeight()) , 1 , 1 , GL_RGB , GL_UNSIGNED_BYTE , color); + //printf("dmxMap %i,%i: colour %i %i %i\n",x,y,color[0],color[1],color[2]); + dmx_data[chan_shutter]=255; + dmx_data[chan_intensity]=intensity; + dmx_data[chan_R]=color[0]; + dmx_data[chan_G]=color[1]; + dmx_data[chan_B]=color[2]; + + //printf("Dmx: %i,%i,%i @ %i \n",color[0],color[1],color[2],intensity); + } + int chan_R, chan_G, chan_B, chan_intensity, chan_shutter; + float x,y; + unsigned char *dmx_data; +}; + class ofApp : public ofBaseApp, public ofxMidiListener{ public: @@ -46,6 +98,8 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ void drawOutput(ofEventArgs & args); void exit(); + void outputKeyPressed(ofKeyEventArgs & args); + void keyPressed(ofKeyEventArgs &keyargs); void keyReleased(int key); void mouseMoved(int x, int y ); @@ -62,9 +116,14 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ vector<string> arguments; chainImageSet images; + chainImageSet images2; ofxDmx dmx; - vector<dmxMap> map; + //ofxArtnet artnet; + + //unsigned char dmx_data[512]; + + vector<USBdmxMap> map; void newMidiMessage(ofxMidiMessage& eventArgs); ofxMidiIn midiIn; @@ -72,4 +131,8 @@ class ofApp : public ofBaseApp, public ofxMidiListener{ int dmxIntensity; + bool outputFS; + + float next_update; + }; |
