wuerfelbaum/test/test.pde

66 lines
1.2 KiB
Text
Raw Permalink Normal View History

2020-11-24 13:58:35 +00:00
import processing.serial.*;
static int FRAMERATE=20;
int fadetime=1000/FRAMERATE /10 *4; //fadetime in centiseconds SMOOOOTH
Serial sPort;
//int boxnum = 1+2+3+4+5+6+7;
int boxnum=50;
color box[] = new color[boxnum];
int boxid[] = new int[boxnum];
float testcolorhue=0;
float time=0;
void setup() {
size(200, 200);
frameRate(FRAMERATE);
for (int i=0;i<boxnum;i++) {
boxid[i]=i;
//box[i] = color(100,255,255);
}
String portName = Serial.list()[0];
print(portName);
sPort = new Serial(this, portName, 115200);
colorMode(HSB, 255);
}
void draw() {
delay(200);
/*
for (int i=0;i<boxnum;i++) {
boxid[i]=i;
box[i] = color(100,255,255);
}*/
testcolorhue+=4;
testcolorhue%=256;
for (int i=0;i<boxnum;i++) {
box[i] = color(int(testcolorhue),255,255);
}
sendToWuerfels();
}
void sendToWuerfels() {
for (int i=0;i<boxnum;i++) {
//print(str(i)+"="+str(brightness(box[i]))+", ");
sPort.write("B,"+str(boxid[i])+","+str(fadetime)+","+int(red(box[i]))+","+int(green(box[i]))+","+int(blue(box[i]))+"\n");
print("B,"+str(boxid[i])+","+str(fadetime)+","+int(red(box[i]))+","+int(green(box[i]))+","+int(blue(box[i]))+"\n");
}
println();
}