Skip to content

Commit

Permalink
- Updated example code
Browse files Browse the repository at this point in the history
  • Loading branch information
DHaylock committed Jul 5, 2017
1 parent bae38ec commit 6e3f8f5
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 37 deletions.
2 changes: 1 addition & 1 deletion example_chaining/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//========================================================================
int main( ){
ofSetupOpenGL(1000,800,OF_WINDOW); // <-------- setup the GL context
ofSetupOpenGL(700,400,OF_WINDOW); // <-------- setup the GL context

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
Expand Down
54 changes: 29 additions & 25 deletions example_chaining/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ void ofApp::setup()
defaultEffects.setup(opcClient.getStageCenterX(), opcClient.getStageCenterY(), opcClient.getStageWidth(), opcClient.getStageHeight());

// Setup the Grabbing positions
for (int y = 0; y < 5; y++) {
for (int x = 0; x < 5; x++) {
for (int y = 0; y < 5; y++)
{
for (int x = 0; x < 5; x++)
{
ringOrigins.push_back(ofVec2f(25+(x*50),25+(y*50)));
}
}

// Setup the rings
for (int i = 0; i < ringOrigins.size(); i++) {
for (int i = 0; i < ringOrigins.size(); i++)
{
neoPixels.insert(std::pair<int, ofxNeoPixelObject*>(i,new ofxNeoPixelRing(ringOrigins[i].x,ringOrigins[i].y, 12, 20)));
}
}
Expand All @@ -42,31 +45,28 @@ void ofApp::update()
opcClient.endStage();

// New Get Method
for (int i = 0; i < neoPixels.size(); i++) {
for (int i = 0; i < neoPixels.size(); i++)
{
opcClient.getStagePixels(neoPixels.at(i)->getPixelCoordinates(), neoPixels.at(i)->colors);
}

// If the client is not connected do not try and send information
if (!opcClient.isConnected()) {
if (!opcClient.isConnected())
{
// Will continue to try and reconnect to the Pixel Server
opcClient.tryConnecting();
}
else {
for (int i = 0; i < 5; i++) {
vector <vector<ofColor> > bank;
if(i == 0) {
for (int unit = 0; unit < 4; unit++) {
bank.push_back(neoPixels[unit]->colorData());
}
opcClient.writeChannel(i,opcClient.getChainedNeopixels(bank));
}
else {
for (int unit = (i*5); unit < (i*5)+4; unit++) {
bank.push_back(neoPixels[unit]->colorData());
}
opcClient.writeChannel(i,opcClient.getChainedNeopixels(bank));
}
}
else
{
for (int i = 0; i < 5; i++)
{
vector <vector<ofColor> > desiredPixels;
for (int unit = 0+(i*4); unit < 4+(i*4); unit++)
{
desiredPixels.push_back(neoPixels[unit]->colorData());
}
opcClient.writeChannel(i+1,opcClient.getChainedPixelData(desiredPixels));
}
}
}
//--------------------------------------------------------------
Expand All @@ -76,7 +76,8 @@ void ofApp::draw()
opcClient.drawStage(hide);

// Show the grabber area
for (int i = 0; i < neoPixels.size(); i++) {
for (int i = 0; i < neoPixels.size(); i++)
{
neoPixels.at(i)->drawGrabRegion(hide);
neoPixels.at(i)->draw(opcClient.getStageWidth()+ringOrigins[i].x+25,ringOrigins[i].y);
}
Expand All @@ -91,13 +92,16 @@ void ofApp::draw()
//--------------------------------------------------------------
void ofApp::keyPressed(int key)
{
if (key == OF_KEY_LEFT) {
if (key == OF_KEY_LEFT)
{
effect--;
}
if (key == OF_KEY_RIGHT) {
if (key == OF_KEY_RIGHT)
{
effect++;
}
if (key == ' ') {
if (key == ' ')
{
hide = !hide;
}
}
Expand Down
5 changes: 3 additions & 2 deletions example_generic_neopixels/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ void ofApp::update()
}
else {
// Write out the first set of data
for (int i = 0; i < neoPixelObjects.size(); i++) {
opcClient.writeChannel(i, neoPixelObjects[i]->colorData());
for (int i = 0; i < neoPixelObjects.size(); i++)
{
opcClient.writeChannel(i+1, neoPixelObjects[i]->colorData());
}
}
}
Expand Down
28 changes: 26 additions & 2 deletions example_multiple_fadecandy_units/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,36 @@ void ofApp::update()
defaultEffects.draw(effect);

opcClient.endStage();

//
// mergedColor.clear();
//
// Get Objects
for (int i = 0; i < neoPixelObjects.size(); i++)
{
opcClient.getStagePixels(neoPixelObjects.at(i)->getPixelCoordinates(), neoPixelObjects.at(i)->colors);
}
//
// // If the client is not connected do not try and send information
// if (!opcClient.isConnected())
// {
// // Will continue to try and reconnect to the Pixel Server
// opcClient.tryConnecting();
// }
// else
// {
// // Loop through the NeoPixel Objects and store the number of pixels in each one
// // Then copy the color data across from each object on to the end of the merge vector
// for (int i = 0; i < neoPixelObjects.size(); i++)
// {
// // I know this is resource heavy but insert was causing odd issues with the size of the Vector
// for(int e = 0; e < neoPixelObjects.at(i)->colorData().size(); e++)
// {
// mergedColor.push_back(neoPixelObjects.at(i)->colorData()[e]);
// }
// }
//
// opcClient.autoWriteData(mergedColor);
// }

// If the client is not connected do not try and send information
if (!opcClient.isConnected())
Expand All @@ -86,7 +110,7 @@ void ofApp::update()
// Write out the first set of data
for (int i = 0; i < neoPixelObjects.size(); i++)
{
opcClient.writeChannel(i, neoPixelObjects[i]->colorData());
opcClient.writeChannel(i+1, neoPixelObjects[i]->colorData());
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions example_multiple_fadecandy_units/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class ofApp : public ofBaseApp{

int effect;
bool hide;

vector <ofColor> mergedColor;
};
5 changes: 3 additions & 2 deletions example_multiple_ofxNeoPixelStrips/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ void ofApp::update()
}
else {
// Write out the data
for (int i = 0; i < strips.size(); i++) {
opcClient.writeChannel(i, strips[i].colorData());
for (int i = 0; i < strips.size(); i++)
{
opcClient.writeChannel(i+1, strips[i].colorData());
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions example_ofxNeoPixelCustomObject/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ void ofApp::update()
else
{
// Write out the first set of data
for (int i = 0; i < neoPixelObjects.size(); i++)
{
opcClient.writeChannel(i, neoPixelObjects[i]->colorData());
}
// for (int i = 0; i < neoPixelObjects.size(); i++)
// {
// opcClient.writeChannel(i+1, neoPixelObjects[i]->colorData());
// }
opcClient.autoWriteData(neoPixelObjects[0]->colorData());
}
}

Expand Down
2 changes: 1 addition & 1 deletion example_shaders/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ofApp::update()
// Write out the first set of data
for (int i = 0; i < neoPixelObjects.size(); i++)
{
opcClient.writeChannel(i, neoPixelObjects[i]->colorData());
opcClient.writeChannel(i+1, neoPixelObjects[i]->colorData());
}
}
}
Expand Down

0 comments on commit 6e3f8f5

Please sign in to comment.