/* ESP32 Bitmap animation
Displays a animated bitmap
*/
#include <TFT_eSPI.h>
#include <SPI.h> // this is needed for display
#include "Image.h"
// The display also uses hardware SPI, plus #9 & #10
#define TFT_CS 15
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
#define FRAME_DELAY (42)
#define FRAME_WIDTH (32)
#define FRAME_HEIGHT (32)
#define FRAME_COUNT (sizeof(frames) / sizeof(frames[0]))
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library with default width and height
TFT_eSprite img = TFT_eSprite(&tft);
void setup(void) {
Serial.begin(115200);
tft.begin();
tft.setRotation(0);
Serial.println("TFT set up");
img.createSprite(240, 200);
}
void loop() {
renderAnimationFrame();
}
int frame = 0;
void renderAnimationFrame() {
img.fillRect(48, 16, FRAME_WIDTH, FRAME_HEIGHT, TFT_BLACK);
img.drawBitmap(48, 16, frames[frame], FRAME_WIDTH, FRAME_HEIGHT, TFT_WHITE);
frame = (frame + 1) % FRAME_COUNT;
img.pushSprite(0,0);
}