Hello, i am following a yt tutorial that quickly and briefly explains how to put images and custom fonts onto lilygo t display. i have double-checked the code on the video and the code in my sketch, and whenever i try to upload it says:Compilation error: expected '=', ',', ';', 'asm' or '__attribute__' before '-' token.
Here's the sketch:
#include <TFT_eSPI.h>
#include "house.h"
TFT_eSPI tft = TFT_eSPI();
void setup() {
tft.init();
tft.fillScreen(TFT_BLACK);
tft.setSwapBytes(true);
tft.pushImage(0,0,128,128,house);
}
void loop() {
//nothing to do here
}
and i would like to upload attachment but the forum says:"new users cannot upload attachments", but its basically just an 128x128px converted.
/home/izi/Arduino/image_lilygo/house.c:16:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '-' token
16 | const unsigned short Awicons-Vista-Artistic-2-Hot-Home.128[16384] PROGMEM={
| ^
In file included from /home/izi/Arduino/image_lilygo/image_lilygo.ino:2:
/home/izi/Arduino/image_lilygo/house.h:16:29: error: expected initializer before '-' token
16 | const unsigned short Awicons-Vista-Artistic-2-Hot-Home.128[16384] PROGMEM={
| ^
/home/izi/Arduino/image_lilygo/image_lilygo.ino: In function 'void setup()':
/home/izi/Arduino/image_lilygo/image_lilygo.ino:9:29: error: 'house' was not declared in this scope
9 | tft.pushImage(0,0,128,128,house);
| ^~~~~
exit status 1
Compilation error: expected '=', ',', ';', 'asm' or '__attribute__' before '-' token
house.h code:
i can post it here, but it has more than 1000 lines of code because it is an image
This is a great example of using the TFT_eSPI library to display an image. I’m curious: How is the house array structured in the house.h file? Is it a raw pixel array, or is it encoded in a specific format like BMP or PNG? Also, have you considered using compression techniques to reduce the size of the image data for microcontrollers with limited flash memory?
From my limited knowledge of screens, because i am just getting into that field, i think it is a raw pixel array because it has a lot of 0x0000, and so on.
And i do not know nor use any compression techniques.
That's a comment and has no bearing on what you've named the array.
Read the error. Think about what it's telling you. Take a few minutes and read the rules of naming variables in C at the link I provided. Change the name.
You have both a house.c and house.h. Looks like they contain the same thing. At this point, you have fixed the .h, but not the .c. You don't need the .c, but the compiler will try to build it anyway, because it is in the sketch directory. If you don't want to delete it, you can move it -- maybe to your home directory /home/izi, so that it is nowhere in your sketchbook.
It's odd that the generated code is an array of short. If "it has a lot of 0x0000", then it could still work, but it's not the most portable. The resulting file is smaller though.
Hi @izi0ddr. Please open your "image_lilygo" sketch in Arduino IDE and then tell us whether you see a tab named "house.c" in the tabs above the editor panel.
Please also tell use which version of Arduino IDE you are using (e.g., "2.3.4"). The version is shown on the window title bar and also in the dialog that opens when you select Help > About (or Arduino IDE > About Arduino IDE for macOS users) from the Arduino IDE menus.
I ask for this information because I want to give you the appropriate instructions for the IDE version you are using.