split main .ino fine into multiple sub files
Some checks failed
Arduino Pong CI / build (macos-latest) (push) Has been cancelled
Arduino Pong CI / build (ubuntu-latest) (push) Has been cancelled
Arduino Pong CI / build (windows-latest) (push) Has been cancelled

This commit is contained in:
andrea
2026-03-15 19:56:20 +01:00
parent a938adff31
commit 5eeb735364
8 changed files with 193 additions and 159 deletions

26
pong_render.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <Arduino.h>
#include "config.h"
void render_matrix(byte frame[MATRIX_HEIGHT][MATRIX_WIDTH], int p1_start, int p2_start, int &need_refresh, int ball_x, int ball_y) {
if (!need_refresh) return;
need_refresh= 0;
// clear
for (int x=0; x < MATRIX_WIDTH; x++) {
for (int y=0; y < MATRIX_HEIGHT; y++) {
frame[y][x]= 0;
}
}
// players coords
for (int i= p1_start; i < p1_start+BAR_LENGTH; i++) {
frame[i][0]= 1;
}
for (int i= p2_start; i < p2_start+BAR_LENGTH; i++) {
frame[i][MATRIX_WIDTH-1]= 1;
}
// ball coords
frame[ball_y][ball_x]= 1;
}