public void draw() { background(0); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { if ((i & 1) == 0) { // even rows white grid[i][j].display(255); } else { // odd rows gray grid[i][j].display(220); } } } if (play == true) { int j; if (millis() - starttime < delaytime) { count_up = (millis() - starttime); count_down = delaytime - count_up; steptimer = floor(4 / (delaytime / count_up)); fill(0); // textSize(12); // text(steptimer, mouseX, mouseY); for (j = 0; j < rows; j++) { grid[steptimer][j].display(120); if (grid[steptimer][j].active) { grid[steptimer][j].trigger(steptimer, j); } } switch (steptimer) { case 0: uno = PApplet.parseByte(unbinary("00010001")); due = PApplet.parseByte(unbinary("00010001")); break; case 1: uno = PApplet.parseByte(unbinary("00100010")); due = PApplet.parseByte(unbinary("00100010")); break; case 2: uno = PApplet.parseByte(unbinary("01000100")); due = PApplet.parseByte(unbinary("01000100")); break; case 3: uno = PApplet.parseByte(unbinary("10001000")); due = PApplet.parseByte(unbinary("10001000")); break; } print(binary(uno)); println(binary(due)); myPort.write(due); myPort.write(uno); myPort.write(','); } else { starttime = millis(); j = 0; } for (int i = 0; i < cols; i++) { for (int k = 0; k < rows; k++) { if (grid[i][k].active) { // even rows white if ((i + 4 * k) < 8) { uno |= (1 << i + 4 * k); } else { due |= (1 << (i + 4 * k) - 8); } } else { // odd rows gray if ((i + 4 * k) < 8) { uno &= ~(1 << i + 4 * k); // chiedete a vanzati [email protected] } else { due &= ~(1 << (i + 4 * k) - 8); } } } } } // print(binary(uno)); // print(binary(due)); myPort.write(due); myPort.write(uno); myPort.write(','); println(); }