Updated readme and added two new sketches

This commit is contained in:
Frederik Vanggaard 2016-04-04 21:47:09 +02:00
parent c9650010e7
commit 8e051c51d7
3 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,14 @@
OPC opc;
color c = color(0,0,255);
void setup() {
size(500, 500, P3D);
opc = new OPC(this, "127.0.0.1", 7890);
opc.ledGrid8x8(0, width/2, height/2, height / 16.0, 0, false);
}
void draw() {
background(0);
}

View File

@ -0,0 +1,31 @@
OPC opc;
color c = color(0,0,255);
void setup() {
size(500, 500, P3D);
opc = new OPC(this, "127.0.0.1", 7890);
opc.ledGrid8x8(0, width/2, height/2, height / 16.0, 0, false);
}
void draw() {
background(0);
for (int i = 0; i < 8; i++) {
opc.setPixel(i+8*0, color(255,0,0));
opc.setPixel(i+8*1, color(0,255,0));
opc.setPixel(i+8*2, color(0,0,255));
opc.setPixel(i+8*3, color(127,0,0));
opc.setPixel(i+8*4, color(0,127,0));
opc.setPixel(i+8*5, color(0,0,127));
opc.setPixel(i+8*6, color(100,100,100));
opc.setPixel(i+8*7, color(200,200,200));
}
opc.writePixels();
}

View File

@ -91,3 +91,46 @@ Connect the USB power to your computer and you should now be able to move your m
If you don't have a USB cable with header pins on you can use a regular 5V ~2A power supply. Connect the ground and 5V pin from the NeoPixel matrix to the power supply and run the Processing sketch for the same result.
![](http://www.drudoo.com/wp-content/uploads/2016/03/Photo-Feb-15-7-10-31-PM-e1456939241663.jpg)
## Making your own sketch
Lets try and set up an empty sketch using the template below:
OPC opc;
void setup() {
size(500, 500, P3D);
opc = new OPC(this, "127.0.0.1", 7890);
opc.ledGrid8x8(0, width/2, height/2, height / 16.0, 0, false);
}
void draw() {
background(0);
}
Here the important part is the ledGrid8x8 line. First we have a 0, this indicated that we have connected the led matrix to connector 0 on the fadecandy. Next we need to define the center of the matrix. This is done using `width/2` and `height/2`. We also need to define the spacing between each LED. The spacing is approximately one LED in size, so we can use `height/16`. The next 0 is the rotation. Since we just use the default rotation we dont need to change this. `false` means that all the LEDs point in the same direction.
If we run this nothing will really happen except we get a black screen with 8x8 dots on.
We can change the individual colors using `setPixel(index, color)` in the draw function.
opc.setPixel(0, color(255,0,0));
The above code changes the color of the first pixel to red.
opc.setPixel(10, color(0,255,0));
The above code changes the 11th pixel to green.
This should make sense and be easy to work with.
Unfortunately each pixel does have a bit of color bleeding to nearby pixels, this can be prevented using a printed separator or another time of plate in front.
## Another example
It is easy to test and identify different fadecandy's using the port the fadecandy is set up to. Just go to `localhost:port` and play around
http://localhost:7890