Hi! I'm having trouble compiling my sketch using a simple code to upload into a ESP32+TFT 240 x 240 display.
I splitted the gif frames into 3 parts (wpl1, wpl2 and wpl3) in order to reduce the file size.
Error redefinition of 'int frames' just pops up when verify it. I have no much coding experience and any help and hints are much appreciated.
Please see below my code:
#include <SPI.h>
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI();
#include "wpl1.h"
#include "wpl2.h"
#include "wpl3.h"
void setup() {
// put your setup code here, to run once:
tft.init();
tft.setRotation(0);
tft.setSwapBytes(true);
tft.fillScreen(TFT_WHITE);
}
void loop() {
// put your main code here, to run repeatedly:
//for (int i = 0; i < frames; i++)
{
delay(2000);
tft.pushImage(0, 0, 230, 173, wpl1[i]);
tft.pushImage(0, 0, 230, 173, wpl2[1]);
tft.pushImage(0, 0, 230, 173, wpl3[1]);
}
}
Below the error:
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:9:0:
wpl2.h:1:5: error: redefinition of 'int frames'
int frames=4;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:8:0:
sketch\wpl1.h:1:5: note: 'int frames' previously defined here
int frames=4;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:9:0:
wpl2.h:2:5: error: redefinition of 'int animation_width'
int animation_width=230;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:8:0:
sketch\wpl1.h:2:5: note: 'int animation_width' previously defined here
int animation_width=230;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:9:0:
wpl2.h:3:5: error: redefinition of 'int animation_height'
int animation_height=173;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:8:0:
sketch\wpl1.h:3:5: note: 'int animation_height' previously defined here
int animation_height=173;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:10:0:
wpl3.h:1:5: error: redefinition of 'int frames'
int frames=4;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:8:0:
sketch\wpl1.h:1:5: note: 'int frames' previously defined here
int frames=4;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:10:0:
wpl3.h:2:5: error: redefinition of 'int animation_width'
int animation_width=230;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:8:0:
sketch\wpl1.h:2:5: note: 'int animation_width' previously defined here
int animation_width=230;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:10:0:
wpl3.h:3:5: error: redefinition of 'int animation_height'
int animation_height=173;
^
In file included from C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino:8:0:
sketch\wpl1.h:3:5: note: 'int animation_height' previously defined here
int animation_height=173;
^
C:\Users\eduardo.santacruz\OneDrive - Marel\Documents\Arduino\WPL9000\WPL9000\WPL9000.ino: In function 'void loop()':
WPL9000:28:40: error: 'i' was not declared in this scope
tft.pushImage(0, 0, 230, 173, wpl1[i]);
^
exit status 1
redefinition of 'int frames'