#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
// Incluye el archivo que contiene los datos de los fotogramas
#include "animacion.h"
// --- Pines para la pantalla TFT ---
#define TFT_CS 15
#define TFT_DC 2
#define TFT_RST 4
// --- Objeto de la pantalla ---
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// --- Configuración de la animación ---
//!! IMPORTANTE: AJUSTA ESTOS VALORES
#define FRAME_WIDTH 200 // Ancho de tus imágenes (200)
#define FRAME_HEIGHT 200 // Alto de tus imágenes (200)
#define FRAME_COUNT 4 // <--- CAMBIA ESTO por tu número total de fotogramas
#define ANIM_DELAY 100 // Milisegundos entre fotogramas (ajusta para más velocidad)
//!! IMPORTANTE: Un arreglo de punteros que apunta a cada fotograma.
//!! Asegúrate de que los nombres aquí coincidan EXACTAMENTE con los que generaste
//!! y pegaste en animacion.h
const uint16_t* const frameArray[FRAME_COUNT] = {
frame_00_delay_0_06s,
frame_01_delay_0_06s,
frame_02_delay_0_06s,
frame_03_delay_0_06s,
frame_04_delay_0_06s,
frame_05_delay_0_06s,
// Si tienes más o menos fotogramas, ajusta esta lista
};
int currentFrame = 0;
void setup() {
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
}
void loop() {
// Calcula la posición para centrar la animación
int16_t startX = (tft.width() - FRAME_WIDTH) / 2;
int16_t startY = (tft.height() - FRAME_HEIGHT) / 2;
// Dibuja el fotograma actual en la pantalla desde PROGMEM
tft.drawRGBBitmap(startX, startY, frameArray[currentFrame], FRAME_WIDTH, FRAME_HEIGHT);
// Avanza al siguiente fotograma
currentFrame++;
if (currentFrame >= FRAME_COUNT) {
currentFrame = 0; // Vuelve al inicio
}
delay(ANIM_DELAY);
}