void Rain::draw(RGBMatrix &matrix) { // fade out the whole board for(int i = 0 ; i < LED_ROWS ; i++) for(int j = 0 ; j < LED_COLS ; j++) matrix.blend(i, j, 16, 0, 0, 0); // draw the new positions for(int i = 0 ; i < num_drops ; i++) { const float px = drops[i][0]; const float py = drops[i][1]; const int x = px; const int y = py; /* const int xf = (px - x) * 256; const int yf = (py - y) * 256; matrix.blend(x+0, y+0, sqrt((256 - xf)*(256-yf)), colors[i]); matrix.blend(x+0, y+1, sqrt((256 - xf)*(yf)), colors[i]); matrix.blend(x+1, y+0, sqrt((xf)*(256-yf)), colors[i]); matrix.blend(x+1, y+1, sqrt((xf)*(yf)), colors[i]); */ matrix.blend(x+0, y+0, 64, colors[i]); } }
void Pixels::draw(RGBMatrix &matrix) { // interpolate from our last packet to the new packet // over the time frame in the packet long now = millis(); long rx_delta = now - rx_millis; Serial.println(rx_delta); int blend = 0; if (rx_delta > pixels.blend_time) { blend = 255; } else if (rx_delta < 0) { blend = 0; } else { blend = (255 * rx_delta) / pixels.blend_time; } unsigned offset = 0; for(int row = 0 ; row < LED_ROWS ; row++) { for(int col = 0 ; col < LED_COLS ; col++, offset++) { int r = pixels.pixels[3*offset + 0]; int g = pixels.pixels[3*offset + 1]; int b = pixels.pixels[3*offset + 2]; matrix.blend(row, col, blend, r, g, b); } } }