Images wont render properly and errors that i do not know what they mean

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.

Please post the entire error message, as it explains where in the code the error was encountered.

Also post the code for "house.h", using code tags.

Error message

/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 not a valid variable name in C.

I know, i changed it to "house" for simplicity because i got tired of copy-pasting it.
And do note that i do not know c.

No, you really haven't.

Sorry, then how do i really change it because in my house.h file says:// Generated from : house.png

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.

Alr thanks, i will try to understand :slight_smile:

Post the code, using code tags. Also post a link to the tutorial you were following.

yt tutorial: https://youtu.be/R-qFKemDFyM?si=d_2OfWk6Js5C0ary
the arduino says that i cannot paste/enter more than 12000 digits, i out 15675
The error now says:

/home/izi/Arduino/image_lilygo/house.c:16:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PROGMEM'
   16 | const unsigned short house[16384] PROGMEM={
      |                                   ^~~~~~~

exit status 1

Compilation error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PROGMEM'

There is an error in the code. Until you post it, or a shortened example that reproduces the error, forum members can't help and you are on your own.

ok, i'll try.
I think i found the error, it's in the first few lines of the code:

// Generated by   : ImageConverter 565 Online
// Generated from : house.png
// Time generated : Sun, 02 Mar 25 18:59:21 +0100  (Server timezone: CET)
// Image Size     : 128x128 pixels
// Memory usage   : 32768 bytes


#if defined(__AVR__)
    #include <avr/pgmspace.h>
#elif defined(__PIC32MX__)
    #define PROGMEM
#elif defined(__arm__)
    #define PROGMEM
#endif

const unsigned short house[16384] PROGMEM={

I think that theconst unsigned short house[16384] PROGMEM={ is doing the error, but im not sure

Exactly which board did you select in the Arduino IDE?

Exactly LilyGo T-Display

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.

With an ESP32, you can just remove the "PROGMEM", it is only needed for AVR processors.

The use of a .c file instead of .cpp doesn't seem to handle the code for PROGMEM properly, even if you include the Arduino.h header.