#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// --- DRAWING CONSTANTS ---
// We center the 64x64 game board on the 128x64 screen
const int BOARD_X = 32; // Start drawing at x=32 to center it
const int CELL_SIZE = 21; // Each box is 21x21 pixels
void setup() {
Serial.begin(115200);
// Initialize OLED
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.setTextColor(WHITE);
// Draw the Grid immediately to test
drawGrid();
display.display();
}
void loop() {
// Nothing here yet
}
// --- VISUAL FUNCTION ---
void drawGrid() {
// Draw Vertical Lines
display.drawLine(BOARD_X + CELL_SIZE, 0, BOARD_X + CELL_SIZE, 63, WHITE);
display.drawLine(BOARD_X + CELL_SIZE*2, 0, BOARD_X + CELL_SIZE*2, 63, WHITE);
// Draw Horizontal Lines
display.drawLine(BOARD_X, CELL_SIZE, BOARD_X + CELL_SIZE*3, CELL_SIZE, WHITE);
display.drawLine(BOARD_X, CELL_SIZE*2, BOARD_X + CELL_SIZE*3, CELL_SIZE*2, WHITE);
}