diff --git a/doc/processing_opc_client.md b/doc/processing_opc_client.md index 214ed49c5b10bb276a2c8410cf90651b99239e0a..f1300c5f289d4ffbbfc33724c5f2703acf8152eb 100644 --- a/doc/processing_opc_client.md +++ b/doc/processing_opc_client.md @@ -144,6 +144,14 @@ This section lists all public methods available on the OPC object: ---- +* *color* = **opc.getPixel**(*index*) + * Retrieves the color stored for a single LED pixel. + * For LEDs mapped to on-screen pixels, this returns the color we sampled on the previous frame. + * **index**: The index number for this LED, starting with zero + * **color**: A Processing color object (24-bit) + +---- + * **opc.writePixels**() * Send all buffered pixels to the OPC server * If any pixels have been mapped on-screen, this happens automatically after every draw() diff --git a/examples/processing/grid24x8z_clouds/OPC.pde b/examples/processing/grid24x8z_clouds/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_clouds/OPC.pde +++ b/examples/processing/grid24x8z_clouds/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_dot/OPC.pde b/examples/processing/grid24x8z_dot/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_dot/OPC.pde +++ b/examples/processing/grid24x8z_dot/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_flashy_rings/OPC.pde b/examples/processing/grid24x8z_flashy_rings/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_flashy_rings/OPC.pde +++ b/examples/processing/grid24x8z_flashy_rings/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_rings/OPC.pde b/examples/processing/grid24x8z_rings/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_rings/OPC.pde +++ b/examples/processing/grid24x8z_rings/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_rings_leapmotion/OPC.pde b/examples/processing/grid24x8z_rings_leapmotion/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_rings_leapmotion/OPC.pde +++ b/examples/processing/grid24x8z_rings_leapmotion/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_sequencer/OPC.pde b/examples/processing/grid24x8z_sequencer/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_sequencer/OPC.pde +++ b/examples/processing/grid24x8z_sequencer/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_text/OPC.pde b/examples/processing/grid24x8z_text/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_text/OPC.pde +++ b/examples/processing/grid24x8z_text/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid24x8z_waves/OPC.pde b/examples/processing/grid24x8z_waves/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid24x8z_waves/OPC.pde +++ b/examples/processing/grid24x8z_waves/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid8x8_dot/OPC.pde b/examples/processing/grid8x8_dot/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid8x8_dot/OPC.pde +++ b/examples/processing/grid8x8_dot/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/grid8x8_orbits/OPC.pde b/examples/processing/grid8x8_orbits/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/grid8x8_orbits/OPC.pde +++ b/examples/processing/grid8x8_orbits/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/strip64_dot/OPC.pde b/examples/processing/strip64_dot/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/strip64_dot/OPC.pde +++ b/examples/processing/strip64_dot/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/strip64_flames/OPC.pde b/examples/processing/strip64_flames/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/strip64_flames/OPC.pde +++ b/examples/processing/strip64_flames/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/strip64_unmapped/OPC.pde b/examples/processing/strip64_unmapped/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/strip64_unmapped/OPC.pde +++ b/examples/processing/strip64_unmapped/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly. diff --git a/examples/processing/template/OPC.pde b/examples/processing/template/OPC.pde index 630fb681aedf8da4f7c4afb99cd1768eb87e6ebe..917035d46c7e60be569b8cec80e21363f2bf88da 100644 --- a/examples/processing/template/OPC.pde +++ b/examples/processing/template/OPC.pde @@ -283,6 +283,17 @@ public class OPC packetData[offset + 2] = (byte) c; } + // Read a pixel from the output buffer. If the pixel was mapped to the display, + // this returns the value we captured on the previous frame. + color getPixel(int number) + { + int offset = 4 + number * 3; + if (packetData == null || packetData.length < offset + 3) { + return 0; + } + return (packetData[offset] << 16) | (packetData[offset + 1] << 8) | packetData[offset + 2]; + } + // Transmit our current buffer of pixel values to the OPC server. This is handled // automatically in draw() if any pixels are mapped to the screen, but if you haven't // mapped any pixels to the screen you'll want to call this directly.