Skip to content

Commit

Permalink
Merge pull request #21 from brainmachine/develop
Browse files Browse the repository at this point in the history
ArtNet support
  • Loading branch information
brainmachine authored Feb 3, 2018
2 parents 8ebad84 + dec90a2 commit 8110098
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 336 deletions.
17 changes: 8 additions & 9 deletions LightWork_Mapper/Animator.pde
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* //<>//
/*
* Animator
*
* This Class handles timing and generates the state and color of all connected LEDs
Expand Down Expand Up @@ -42,7 +42,6 @@ public class Animator {
ledIndex = 0; // TODO: resetInternalVariables() method?
testIndex = 0;
frameCounter = 0;
//resetPixels();
}

AnimationMode getMode() {
Expand Down Expand Up @@ -79,7 +78,7 @@ public class Animator {
l[i]=leds.get(i).c;
}
return l;
}
} //<>// //<>//


//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -113,7 +112,7 @@ public class Animator {
// Advance the internal counter
frameCounter++;

//send pixel data over network
// Send pixel data over network
if (mode!=AnimationMode.OFF && network.isConnected) {
network.update(this.getPixels());
}
Expand All @@ -132,14 +131,14 @@ public class Animator {
leds.get(i).setColor(col);
}

if (frameCounter == 0) return; // Avoid the first LED going off too quickly //<>//
if (frameCounter%this.frameSkip==0)ledIndex++; // use frameskip to delay animation updates
if (frameCounter == 0) return; // Avoid the first LED going off too quickly //<>// //<>//
if (frameCounter%this.frameSkip==0)ledIndex++; // use frameskip to delay animation updates //<>// //<>//

// Stop at end of LEDs
if (ledIndex >= leds.size()) {
this.setMode(AnimationMode.OFF);
} //<>//
}
}
} //<>// //<>//

// Set all LEDs to the same colour (useful to turn them all on or off).
void setAllLEDColours(color col) {
Expand All @@ -148,7 +147,7 @@ public class Animator {
}
}

//LED pre-flight test. Cycle: White, Red, Green, Blue.
// LED pre-flight test. Cycle: White, Red, Green, Blue.
void test() {
testIndex++;

Expand Down
7 changes: 4 additions & 3 deletions LightWork_Mapper/BinaryPattern.pde
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ public class BinaryPattern {
BinaryPattern() {
numBits = 10;
animationPatternLength = 10;
frameNum = 0; // Used for animation
readIndex = 0; // Used by the detector to write bits
writeIndex = 0;
frameNum = 0; // Used for animation
readIndex = 0; // Used by the detector to read bits
writeIndex = 0; // Used by the detector to write bits
previousState = 0;
detectedState = 0;

// TODO: Review initial capacity
decodedString = new StringBuffer(10); // Init with capacity
decodedString.append("W123456789");

Expand Down
8 changes: 2 additions & 6 deletions LightWork_Mapper/Blob.pde
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @author: Jordi Tost (@jorditost)
*
* University of Applied Sciences Potsdam, 2014
*
* Modified by Leó Stefánsson
*/

class Blob {
Expand Down Expand Up @@ -51,16 +53,10 @@ class Blob {
//set draw location based on displayed camera position, accounts for moving cam in UI
float x = map(r.x, 0, (float)camWidth, (float)camArea.x, camArea.x+camArea.width);
float y = map(r.y, 0, (float)camHeight, (float)camArea.y, camArea.y+camArea.height);
//float opacity = map(timer+1, 0, 255, 0, 127);

//fill(0, 255, 0, opacity);
noFill();
stroke(255, 0, 0);
rect(x, y, r.width, r.height);
//fill(255, 0, 0);
//textSize(12);
//text(id+ ": "+detectedPattern.decodedString.toString(), x+30, y);
//stroke(0, 255, 0);
}

void update(Contour newContour) {
Expand Down
12 changes: 2 additions & 10 deletions LightWork_Mapper/BlobManager.pde
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class BlobManager {
float distanceThreshold = 2;
int lifetime = 200;

//ArrayList<Contour> contours;
// List of detected contours parsed as blobs (every frame)
ArrayList<Contour> newBlobs;
// List of my blob objects (persistent)
Expand All @@ -36,15 +35,11 @@ class BlobManager {
void update(PImage cvOutput) {
contourFinder.loadImage(cvOutput);

// Find all contours
//blobCV.loadImage(opencv.getSnapshot());
//ArrayList<Contour> contours = opencv.findContours();

// Filter contours, remove contours that are too big or too small
// The filtered results are our 'Blobs' (Should be detected LEDs)
ArrayList<Contour> newBlobs = filterContours(contourFinder.findContours()); // Stores all blobs found in this frame

// Note: newBlobs is actually of the Contours datatype
// Note: newBlobs is of the Contours type
// Register all the new blobs if the blobList is empty
if (blobList.isEmpty()) {
//println("Blob List is Empty, adding " + newBlobs.size() + " new blobs.");
Expand Down Expand Up @@ -102,7 +97,7 @@ class BlobManager {
}

// Update the blob age
//for (int i = blobList.size()-1; i > 0; i--) {
// TODO: Reverse iteration
for (int i = 0; i < blobList.size(); i++) {
Blob b = blobList.get(i);
b.countDown();
Expand All @@ -113,7 +108,6 @@ class BlobManager {
}

void display() {

for (Blob b : blobList) {
strokeWeight(1);
b.display();
Expand Down Expand Up @@ -156,6 +150,4 @@ class BlobManager {

return blobs;
}


}
Loading

0 comments on commit 8110098

Please sign in to comment.