Created
January 5, 2015 00:30
-
-
Save mlabbe/a67951308e5e6b92e7fc to your computer and use it in GitHub Desktop.
My DMX lighting API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofxLightFactory.h" | |
#include "lighthardware.h" | |
void lightApp::setup() { | |
count = 0; | |
ofSetFrameRate(40); | |
dmxController.universe.connect(0); | |
// setup lights | |
spotlight = new MonopriceLEDPinSpotlight(1); | |
spotlight->Attach(dmxController); | |
spotlight->Attach(visSpotlight); | |
lights.Add(spotlight); | |
stagelight = new MonopricePar64StageLight(spotlight->GetNumChannels()+1); | |
stagelight->Attach(dmxController); | |
stagelight->Attach(visStagelight); | |
stagelight->SetChannelValue( CHANNEL_HEADFUNCTION, 128); | |
lights.Add(stagelight); | |
// setup vis | |
visSpotlight.origin.set(50,50); | |
visStagelight.origin.set(250,50); | |
visStagelight.radius = 48.0f; | |
coloredLights.AddSubset(lights); | |
lights.PrintTable(); | |
} | |
void lightApp::exit() { | |
lights.DeleteAll(); | |
dmxController.universe.update(); | |
} | |
void lightApp::update() { | |
} | |
void lightApp::draw() { | |
int level1 = ofMap(sin(ofGetElapsedTimef() * 5), -1, 1, 0, 255); | |
int level2 = ofMap(sin(ofGetElapsedTimef() * 8), -1, 1, 0, 255); | |
ofColor spotlightColor = spotlight->GetColor(); | |
spotlightColor.r = level1; | |
spotlightColor.g = level1/2; | |
spotlightColor.b = 0; | |
spotlightColor.a = level2; | |
coloredLights.SetColor(spotlightColor); | |
visSpotlight.Draw(); | |
visStagelight.Draw(); | |
dmxController.universe.update(); | |
++count; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment