Missing but not missing graphic.h?

Hello, I have the 1.28 round lcd. I'm trying a demo code to try it. I'm also using an esp8266 processor. The sketch is at https://github.com/VolosR/watchESP I also have the TFT_eSPI-2.4.72 library which includes the graphics library here https://www.arduino.cc/reference/en/libraries/tft_espi/

When I compile it I get that error stating no graphic.h file. This is the sketch unmodded below.

// 'Boing' ball demo

#define SCREENWIDTH 320
#define SCREENHEIGHT 240

#include "graphic.h"

#include <TFT_eSPI.h> // Hardware-specific library

TFT_eSPI tft = TFT_eSPI();       // Invoke custom library

#define BGCOLOR    0xAD75
#define GRIDCOLOR  0xA815
#define BGSHADOW   0x5285
#define GRIDSHADOW 0x600C
#define RED        0xF800
#define WHITE      0xFFFF

#define YBOTTOM  123  // Ball Y coord at bottom
#define YBOUNCE -3.5  // Upward velocity on ball bounce

// Ball coordinates are stored floating-point because screen refresh
// is so quick, whole-pixel movements are just too fast!
float ballx     = 20.0, bally     = YBOTTOM, // Current ball position
      ballvx    =  0.8, ballvy    = YBOUNCE, // Ball velocity
      ballframe = 3;                         // Ball animation frame #
int   balloldx  = ballx, balloldy = bally;   // Prior ball position

// Working buffer for ball rendering...2 scanlines that alternate,
// one is rendered while the other is transferred via DMA.
uint16_t renderbuf[2][SCREENWIDTH];

uint16_t palette[16]; // Color table for ball rotation effect

uint32_t startTime, frame = 0; // For frames-per-second estimate

void setup() {
  Serial.begin(115200);
//  while(!Serial);

  tft.begin();
  tft.setRotation(3); // Landscape orientation, USB at bottom right
  tft.setSwapBytes(false);
  // Draw initial framebuffer contents:
  //tft.setBitmapColor(GRIDCOLOR, BGCOLOR);
  tft.fillScreen(BGCOLOR);

  tft.initDMA();

  tft.drawBitmap(0, 0, (const uint8_t *)background, SCREENWIDTH, SCREENHEIGHT, GRIDCOLOR);

  startTime = millis();
}

void loop() {

  balloldx = (int16_t)ballx; // Save prior position
  balloldy = (int16_t)bally;
  ballx   += ballvx;         // Update position
  bally   += ballvy;
  ballvy  += 0.06;          // Update Y velocity
  if((ballx <= 15) || (ballx >= SCREENWIDTH - BALLWIDTH))
    ballvx *= -1;            // Left/right bounce
  if(bally >= YBOTTOM) {     // Hit ground?
    bally  = YBOTTOM;        // Clip and
    ballvy = YBOUNCE;        // bounce up
  }

  // Determine screen area to update.  This is the bounds of the ball's
  // prior and current positions, so the old ball is fully erased and new
  // ball is fully drawn.
  int16_t minx, miny, maxx, maxy, width, height;
  // Determine bounds of prior and new positions
  minx = ballx;
  if(balloldx < minx)                    minx = balloldx;
  miny = bally;
  if(balloldy < miny)                    miny = balloldy;
  maxx = ballx + BALLWIDTH  - 1;
  if((balloldx + BALLWIDTH  - 1) > maxx) maxx = balloldx + BALLWIDTH  - 1;
  maxy = bally + BALLHEIGHT - 1;
  if((balloldy + BALLHEIGHT - 1) > maxy) maxy = balloldy + BALLHEIGHT - 1;

  width  = maxx - minx + 1;
  height = maxy - miny + 1;

  // Ball animation frame # is incremented opposite the ball's X velocity
  ballframe -= ballvx * 0.5;
  if(ballframe < 0)        ballframe += 14; // Constrain from 0 to 13
  else if(ballframe >= 14) ballframe -= 14;

  // Set 7 palette entries to white, 7 to red, based on frame number.
  // This makes the ball spin
  for(uint8_t i=0; i<14; i++) {
    palette[i+2] = ((((int)ballframe + i) % 14) < 7) ? WHITE : RED;
    // Palette entries 0 and 1 aren't used (clear and shadow, respectively)
  }

  // Only the changed rectangle is drawn into the 'renderbuf' array...
  uint16_t c, *destPtr;
  int16_t  bx  = minx - (int)ballx, // X relative to ball bitmap (can be negative)
           by  = miny - (int)bally, // Y relative to ball bitmap (can be negative)
           bgx = minx,              // X relative to background bitmap (>= 0)
           bgy = miny,              // Y relative to background bitmap (>= 0)
           x, y, bx1, bgx1;         // Loop counters and working vars
  uint8_t  p;                       // 'packed' value of 2 ball pixels
  int8_t bufIdx = 0;

  // Start SPI transaction and drop TFT_CS - avoids transaction overhead in loop
  tft.startWrite();

  // Set window area to pour pixels into
  tft.setAddrWindow(minx, miny, width, height);

  // Draw line by line loop
  for(y=0; y<height; y++) { // For each row...
    destPtr = &renderbuf[bufIdx][0];
    bx1  = bx;  // Need to keep the original bx and bgx values,
    bgx1 = bgx; // so copies of them are made here (and changed in loop below)
    for(x=0; x<width; x++) {
      if((bx1 >= 0) && (bx1 < BALLWIDTH) &&  // Is current pixel row/column
         (by  >= 0) && (by  < BALLHEIGHT)) { // inside the ball bitmap area?
        // Yes, do ball compositing math...
        p = ball[by][bx1 / 2];                // Get packed value (2 pixels)
        c = (bx1 & 1) ? (p & 0xF) : (p >> 4); // Unpack high or low nybble
        if(c == 0) { // Outside ball - just draw grid
          c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDCOLOR : BGCOLOR;
        } else if(c > 1) { // In ball area...
          c = palette[c];
        } else { // In shadow area...
          c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDSHADOW : BGSHADOW;
        }
      } else { // Outside ball bitmap, just draw background bitmap...
        c = background[bgy][bgx1 / 8] & (0x80 >> (bgx1 & 7)) ? GRIDCOLOR : BGCOLOR;
      }
      *destPtr++ = c<<8 | c>>8; // Store pixel color
      bx1++;  // Increment bitmap position counters (X axis)
      bgx1++;
    }

    tft.pushPixelsDMA(&renderbuf[bufIdx][0], width); // Push line to screen

    // Push line to screen (swap bytes false for STM/ESP32)
    //tft.pushPixels(&renderbuf[bufIdx][0], width);

    bufIdx = 1 - bufIdx;
    by++; // Increment bitmap position counters (Y axis)
    bgy++;
  }
  //if (random(100) == 1) delay(2000);
  tft.endWrite();
  //delay(5);
  // Show approximate frame rate
  if(!(++frame & 255)) { // Every 256 frames...
    uint32_t elapsed = (millis() - startTime) / 1000; // Seconds
    if(elapsed) {
      Serial.print(frame / elapsed);
      Serial.println(" fps");
    }
  }
}

I'm unsure what to do now sense I have never ran into this problem befor where the file is in my library and yet it's stating it is not there. Can someone please help me out?

Joseph

The compiler will look for a file called graphic.h in the sketch directory first. Is that file there? If it's not there, the compiler will look in the standard directories for that file. If it can't find it there, you will get the error.

So you have to figure out where that specific file is. Where di you get that sketch from?

That sketch does not look like the sketch that you posted.

I'm sorry the link one is incorrect. The sketch I posted is the right one.

You don't answer the question - are you sure that the file "graphics.h" is in the sketch folder?

The graphic.h file is in the library folder file. which I already stated with the library.

Are you run this example right from library examples or copy it to the another folder?
The graphics.h file MUST BE in the same folder with your sketch. If it not - copy it from the library folder to the sketch directory.

The sketch is from another wenbsite. I can not find the site again. I saved the sketch in the sketch folder. The grahpics.h file is in the TFT_eSPI-2.4.72 folder that is part of the library I saved.

Sorry, I know that my english is not clear.
Copy the graphics.h file in the same directory as the sketch

That's all I can help you

Hello, I tried that and gotthe same error. That was the first thing I did.

the file has name "graphics.h" not "graphic.h"

The Include is graphic.h and the file name is graphic.h. Both have the same name.

I have the sketch in the sketch folder called watch and the graphic.h file in the same folder. When I open it in ide it tells me the sketch needs to be in a folder so it made a new folder and put that sketch in it. When I compiled it gave me the same error missing graphic.h file. However when I put the graphic.h file within the same new folder as the sketch I get this error now.

c:/users/jjc/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.3-gcc10.3-9bcba0b/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: sketch\watch.ino.cpp.o:(.text.setup+0x18): undefined reference to `_ZN8TFT_eSPI7initDMAEb'
c:/users/jjc/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.3-gcc10.3-9bcba0b/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: sketch\watch.ino.cpp.o: in function `setup':
C:\Users\jJc\AppData\Local\Temp\arduino_modified_sketch_480288/watch.ino:41: undefined reference to `_ZN8TFT_eSPI7initDMAEb'
c:/users/jjc/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.3-gcc10.3-9bcba0b/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: sketch\watch.ino.cpp.o:(.text.loop+0x8c): undefined reference to `_ZN8TFT_eSPI13pushPixelsDMAEPtj'
c:/users/jjc/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.3-gcc10.3-9bcba0b/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: sketch\watch.ino.cpp.o: in function `loop':
C:\Users\jJc\AppData\Local\Temp\arduino_modified_sketch_480288/watch.ino:119: undefined reference to `_ZN8TFT_eSPI13pushPixelsDMAEPtj'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Generic ESP8266 Module.

Just an update. In the TFT_eSPI-2.4.72 library is the original sketch it is the same as the one I found online. I just tried to compile it and got the same error message. So something is wrong with the library.

I doubt why DMA is here... ESP8266 doesn't have DMA.
Are you sure that this sketch is compatible with ESP8266?

But I know nothing about this library... perhaps it just a name of function...
Sorry
no more ideas

My esp8266 is there and So is the screen. I have in Ide under D1 mini or clone. Before I tried to compile this sketched I tried another one and it worked and screen came on. So I know my IDE is set correctly.

I'm unsure myself.

Here's the location of the graphic.h in the library example.

  • Check the location on your PC to see if it exists with the boing_ball.ino example.
  • You're not running the exact same example ... try their original example
  • It compiles here on wokwi with an ESP32 ... should also work on your ESP8266

I tried it on that site and got the same error

sketch.ino:29:10: fatal error: graphic.h: No such file or directory
#include "graphic.h"
^~~~~~~~~~~
compilation terminated.

Error during build: exit status 1

You need to upload the file (graphic.h).

Weird ... couldn't save the wokwi simulation after uploading the file, so I renamed and saved the simulation. Try it now.

graphic.h is not part of the library, it's part of the example. This should be the content of your sketch directory.

2022/09/06  02:33 AM    <DIR>          .
2022/09/06  02:33 AM    <DIR>          ..
2022/08/25  10:41 AM             6 727 boing_ball.ino
2022/08/25  10:41 AM           101 436 graphic.h

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.