#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#define TFT_CS 5
#define TFT_DC 2
#define TFT_RST 4
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
int hexSize = 12;
void drawHexagon(int x, int y, int r, uint16_t color) {
float angle;
int x0, y0, x1, y1;
for (int i = 0; i < 6; i++) {
angle = PI / 3 * i;
x0 = x + r * cos(angle);
y0 = y + r * sin(angle);
angle = PI / 3 * (i + 1);
x1 = x + r * cos(angle);
y1 = y + r * sin(angle);
tft.drawLine(x0, y0, x1, y1, color);
}
}
void drawGraphene() {
tft.fillScreen(ILI9341_BLACK);
int offsetX = hexSize * 2;
int offsetY = hexSize * 1.7;
for (int row = 0; row < 12; row++) {
for (int col = 0; col < 16; col++) {
int x = col * offsetX + (row % 2) * hexSize;
int y = row * offsetY;
drawHexagon(x + 40, y + 40, hexSize, ILI9341_CYAN);
}
}
}
void setup() {
tft.begin();
tft.setRotation(1);
drawGraphene();
}
void loop() {
// Animación simple (opcional)
}