int xRes = 100; // number of rows of powermates int yRes = 100; // number of columns of powermates int totalDevices = xRes*yRes; // total number of devices int displaySize = 5; // sets size of the applet window dependent on Res int lowRange = 0; // lowest brightness (min 0) int highRange = 500; // highest brightness (max 255) int xSize = (xRes+1) * displaySize; int ySize = (yRes+1) * displaySize; int xMid = xSize/2; int yMid = ySize/2; int[][] lightArray; float[][] v; float[][] r0; float[][] r1; float[][] r2; LightGrid lightGrid; //PowerMateController pmc; //Listener listener; float counter = 0.0; float distMeter = 50.0; boolean dirOut = false; void setup(){ size(xSize, ySize); ellipseMode(CENTER_DIAMETER); colorMode(RGB,255); noStroke(); lightArray = new int[xRes][yRes]; v = new float[xRes][yRes]; r0 = new float[xRes][yRes]; r1 = new float[xRes][yRes]; r2 = new float[xRes][yRes]; //listener = new Listener(); //pmc = new PowerMateController(listener); //pmc.initializePowerMates(); //pmc.startListening(); //pmc.testDevices(); // cycles through devices in numerical order lightGrid = new LightGrid(xRes, yRes); } void loop(){ background(0); lightGrid.exist(); findRipples(); setLightGrid(); swapBuffers(); counter += 1.0; distMeter += 8.0; } void findRipples(){ for (int y=1; y= lowRange + 2){ lightGrid.light[sentDevice].bb -= 2; } println("turned knob " + sentDevice + " left"); } void knobRight(int sentDevice){ if (lightGrid.light[sentDevice].bb <= highRange - 2){ lightGrid.light[sentDevice].bb += 2; } println("turned knob " + sentDevice + " right"); }*/ // MAIN LIGHT GRID CLASS // // class LightGrid{ Light[][] light; int xNum; int yNum; int xClicked; int yClicked; LightGrid(int sentXRes, int sentYRes){ xNum = sentXRes; yNum = sentYRes; light = new Light[xRes][yRes]; for (int y=0; y 5){ clicked = false; counter = 0.0; }*/ findBrightness(); render(); } void findBrightness(){ //dist = findDistance(x, y, lightGrid.xClicked, lightGrid.yClicked); //bb = (int)((sin((50 - dist + (counter * 50.0) + 20.0)/50.0) * ((highRange - lowRange)/2.0) + ((highRange - lowRange)/2.0)) - counter*2.0); //if (clicked){ // bb = int(sin(counter) * (highRange - lowRange)); // } bb = constrain(bb, lowRange, highRange); } void render(){ //fill(0,0,highRange,bb/5.0); //ellipse(x, y, displaySize, displaySize); //fill(0,0,highRange,bb/3.0); //ellipse(x, y, displaySize*.8, displaySize*.8); fill(0,0,bb); ellipse(x, y, displaySize, displaySize); //stroke(0,0,bb*2.0); //point(x,y); //fill(0,0,0); //ellipse(x, y, displaySize*.5, displaySize*.5); } } /* class Listener implements PMListener { public void buttonPressed(int device){ int theDevice = device; knobPressed(theDevice); } public void knobTurnedLeft(int device){ int theDevice = device; knobRight(theDevice); } public void knobTurnedRight(int device){ int theDevice = device; knobLeft(theDevice); } } */ float findDistance(float x1, float y1, float x2, float y2){ float xd = x1 - x2; float yd = y1 - y2; float td = sqrt(xd * xd + yd * yd); return td; } /* // Safely close the sound engine upon Browser shutdown. public void stop(){ pmc.closePowerMates(); super.stop(); } */ //