Overview
We will be using a small Processing class to translate our realtime animations into low-level commands for Phipps’ Color Kinetics lighting system. The diagram below outlines how our software and hardware system is organized.
Code
First, download the example from Github.
The code below shows how to use the LightManager and Light classes. As you can see, you only need to instantiate one LightManager object. In setup, you need to initialize that object and call the init
function, which requires two parameters, the IP address and PORT of the OSC-Kinet translator (provided by Jake).
In the draw()
loop, you can then choose to send the data to the lights and to draw the lights. You can also change the size of the light’s smoothing buffer. This will change the amount of time it takes the light to “smooth” into the desired color. This can help with smoothing our your animations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
int roomWidth = 30; int roomLength = 100; int lightActualLength = 4; PImage room; // Color of the brush to increment through hue. int col; boolean sending; boolean bDrawLights; LightManager lightManager; void setup() { // 1 pixel = 1 inch (technically) size(1200, 360); background(0); lightManager = new LightManager(); lightManager.init("192.168.1.101", 12345); // Set up variables room = loadImage("roomimage.png"); } void draw() { background(0); colorMode(HSB); ellipseMode(CENTER); fill(col%255, 255, 255); ellipse(mouseX, mouseY, 200, 200); colorMode(RGB); col++; if (sending) lightManager.sendMessages(); if (bDrawLights) lightManager.display(); } void keyPressed() { if (key == 's') { sending = !sending; } if(key == 'd'){ bDrawLights = !bDrawLights; } } |