SD card on a 4.0

SteveSFX

Well-known member
Am I correct in thinking I can connect an SD card socket directly to a 4.0 without any other parts?

The pinout of a MicroSD I believe are:

1 NC Not used
2 CS Chip Select
3 COPI Controller-out, Peripheral-in (MOSI)
4 VDD Positive Supply
5 CLOCK Serial Clock (SCK)
6 GND Ground
7 CIPO Controller-in, Peripheral-out (MISO)
8 NC Not used


Maybe a low value buffer resistor on the data lines?

I have some MicroSD card adapters here, but they have the 5v to 3.3v regs and the level shifting IC that I don't believe I need.

Thanks!
 
Correct. I've done that and it works great. Direct connection on all logic lines, but I used a separate 3.3V regulator to power the uSD card just in case. You could likely get away w/o the separate regulator but it was cheap insurance.
 
Thanks. I have a separate 1A 3.3v regulator on the breadboard already, so I will use that.
Thank you
 
You can also use the micro SD card solder pads underneath the Teensy 4.0. Back before the Teensy 4.1 came out, various people were soldering flexible cables to attach the SD card reader, and there were some PCBs that made this easier to do. But just attaching a simple SPI micro SD card reader is a lot simpler.
 
Direct connection of the 4 SPI signals works fine.

If you use an adaptor board with a buffer chip, you might need to reduce the SPI clock speed. To see how, click File > Examples > SD > SdFat_Usage. Some buffer chips are fast enough to work at 24 MHz, but others can only manage 8 MHz.

Using the 6 SDIO signals on the bottom side of Teensy 4.0 allows for higher speed. Those must be directly connected.
 
I give up.
Made an SD board using just an SD card slot. It is a blank pcb meant to have a level shifting ic on it. All running at 3.3v
Tested all pins and all fine.

Connected to my NEW 4.0 with Oled display and zip. Now the OLED on the SPI bus doesn't do anything (even with the SD card disconnected). I don't get it.
Only playing with 3.3v, so should not have damaged anything. 4.0 is spewing out Serial instructions in the serial monitor, so I can only assume piggy backing the mosi, miso and sck pins to the SD card made it an unhappy screen.

Done with wasting money on this frustrating hobby. Time to take up fishing
 
If you change your mind and want to figure out why it didn't work, we could probably help much more if you show us the wiring with photos and clear diagrams.
 
Sorry... I was fishing...

Direct connection to the SPI pins didn't work and stopped the Oled working (which is still playing up). I didn't want to use the direct SD card connections under the 4.0, as they are pain to access when breadboarding.
Can only imagine it's an issue with it not releasing the comms lines or something? No idea.

I ended up using a standard 5v SD card module that I had which included the level shifter and a 3.3v reg. That worked, just seems unnecessary level shifting and another 3.3v reg.

The Oled... not idea. It went blank and now only works after every new code upload, so I assume it's a reset issue.

I have been trying to find graphics and flash memory libraries for the 4.0 and its madly frustrating. Every one I have found so far has issues and will not compile for various reasons (undefined this, that and the other)
 
Again as Paul mentioned, it is sort of hard for anyone to help much, with so little information. I know the hardware SD works with no additional hardware.

My best luck was with using some of the FRDM4236 boards: http://www.trainer4edu.com/edubase_teensy/frdm_4236.html
For soldering them... But as soon at T4.1 was out there...

There are lots of graphics libraries out there... Also some flash stuff... So question is which Displays? What libraries are you trying?

How are you trying to use Flash libraries? SPI Flash I assume? What type? How is it hooked up... Will LittleFS library work for you?
 
Don't know! Lol

I have an odd round display that is lovely, but being a pain to work with.
I don't really know enough about flash comms to do this properly, so I am stabbing around in the dark a bit.
The main problem I am having is any library that might be useful to me (as in, I can use an example to work out how it works) fails to compile. Yet to find a flash memory example for images that I can compile on my 4.0.
I have a 4.1 here, but not the room to fit it in the project, hence the 4.0 with separate sd card module.
 
:D

But still nothing here, that anyone can help you with as there are no clues at all.

I have an odd round display that is lovely, but being a pain to work with.
Have you used this display in the past with different processors? Do you have a link to where you can purchase one?
Do you have a library that has been used for it by something?

Code:
The main problem I am having is any library that might be useful to me (as in, I can use an example to work out how it works) fails to compile
What library? Link to it? Example sketch?
Maybe show the error messages?
 
I didn't want to repeat what is being discussed on another thread.... but OK:

This is the screen: GC9A01

https://www.amazon.co.uk/gp/product/B08V5538C6/ref=sw_img_1?smid=A3U321I9X7C9XA&th=1

This is my currently working code to trial it (basic):

Code:
/*******************************************************************************
   Start of Arduino_GFX setting
 ******************************************************************************/


#include <Arduino_GFX_Library.h>
#include <SD.h>

File root;

#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
// PJRC Teensy 4.x
#define TFT_CS 10                        // Used to be pin 39  // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 9                         // Used to be pin 41
#define TFT_RST 8                        // Used to be pin 40
#define TFT_BL 7                         // Used to be pin 22              
#endif

// SD card CS = 5

delay(100);

Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS);


/***************************************
   Start of Canvas (framebuffer)                                                                     WHAT THE F### DOES THIS ALL MEAN ? ###############################################################
 **************************************/
// 16-bit color Canvas (240x320 resolution only works for ESP32 with PSRAM)
// Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas(240 /* width */, 320 /* height */, output_display);

// Indexed color Canvas, mask_level: 0-2, larger mask level mean less color variation but can have faster index mapping
// Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas_Indexed(240 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */, MAXMASKLEVEL /* mask_level */);

// 3-bit color Canvas, R1G1B1, 8 colors
// Arduino_G *output_display = new Arduino_ILI9488_3bit(bus, GFX_NOT_DEFINED /* RST */, 1 /* rotation */, false /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas_3bit(480 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */);

// Mono color Canvas
// Arduino_G *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
// Arduino_GFX *gfx = new Arduino_Canvas_Mono(240 /* width */, 320 /* height */, output_display, 0 /* output_x */, 0 /* output_y */);
/***************************************
   End of Canvas (framebuffer)
 **************************************/


// GC9A01 IPS LCD 240x240
//Arduino_GFX *gfx = new Arduino_GC9A01(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, 7 /* RST */, 0 /* rotation */, true /* IPS */);                    // Possibly need to enable this instead ? ###########################################    


/*******************************************************************************
   End of GFX setting
 ******************************************************************************/

int32_t w, h, n, n1, cx, cy, cx1, cy1, cn, cn1;
uint8_t tsa, tsb, tsc, ds;



//##################### SETUP ###############################################################################################################################################################

void setup()
{
  Serial.begin(115200);

//------------------------------------ SD CARD -----------------------------------------------------


  Serial.print("Initializing SD card...");

  if (!SD.begin(5)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);

  Serial.println("done!");


//-------------------------------------- GFX -------------------------------------------------------


  
  // while(!Serial);
  Serial.println("Arduino_GFX library Test!");

  gfx->begin();
  // gfx->begin(80000000); /* specify data bus speed */

  w = gfx->width();
  h = gfx->height();
  n = min(w, h);
  n1 = n - 1;
  cx = w / 2;
  cy = h / 2;
  cx1 = cx - 1;
  cy1 = cy - 1;
  cn = min(cx1, cy1);
  cn1 = cn - 1;
  tsa = ((w <= 176) || (h <= 160)) ? 1 : (((w <= 240) || (h <= 240)) ? 2 : 3); // text size A
  tsb = ((w <= 240) || (h <= 220)) ? 1 : 2;                                    // text size B
  tsc = ((w <= 220) || (h <= 220)) ? 1 : 2;                                    // text size C
  ds = (w <= 160) ? 9 : 12;                                                    // digit size

#ifdef TFT_BL
  pinMode(TFT_BL, OUTPUT);
  digitalWrite(TFT_BL, HIGH);
#endif
}

static inline uint32_t micros_start() __attribute__((always_inline));
static inline uint32_t micros_start()
{
  uint8_t oms = millis();
  while ((uint8_t)millis() == oms)
    ;
  return micros();
}

//##################### MAIN LOOP ##########################################################################################################################################################

void loop(void)
{

  
  Serial.println(F("Benchmark\tmicro-secs"));

  int32_t usecFillScreen = testFillScreen();
  serialOut(F("Screen fill\t"), usecFillScreen, 100, true);

  int32_t usecText = testText();
  serialOut(F("Text\t"), usecText, 3000, true);

  int32_t usecPixels = testPixels();
  serialOut(F("Pixels\t"), usecPixels, 100, true);

  int32_t usecLines = testLines();
  serialOut(F("Lines\t"), usecLines, 100, true);

  int32_t usecFastLines = testFastLines();
  serialOut(F("Horiz/Vert Lines\t"), usecFastLines, 100, true);

  int32_t usecFilledRects = testFilledRects();
  serialOut(F("Rectangles (filled)\t"), usecFilledRects, 100, false);

  int32_t usecRects = testRects();
  serialOut(F("Rectangles (outline)\t"), usecRects, 100, true);

  int32_t usecFilledTrangles = testFilledTriangles();
  serialOut(F("Triangles (filled)\t"), usecFilledTrangles, 100, false);

  int32_t usecTriangles = testTriangles();
  serialOut(F("Triangles (outline)\t"), usecTriangles, 100, true);

  int32_t usecFilledCircles = testFilledCircles(10);
  serialOut(F("Circles (filled)\t"), usecFilledCircles, 100, false);

  int32_t usecCircles = testCircles(10);
  serialOut(F("Circles (outline)\t"), usecCircles, 100, true);

  int32_t usecFilledArcs = testFillArcs();
  serialOut(F("Arcs (filled)\t"), usecFilledArcs, 100, false);

  int32_t usecArcs = testArcs();
  serialOut(F("Arcs (outline)\t"), usecArcs, 100, true);

  int32_t usecFilledRoundRects = testFilledRoundRects();
  serialOut(F("Rounded rects (filled)\t"), usecFilledRoundRects, 100, false);

  int32_t usecRoundRects = testRoundRects();
  serialOut(F("Rounded rects (outline)\t"), usecRoundRects, 100, true);

#ifdef CANVAS
  uint32_t start = micros_start();
  gfx->flush();
  int32_t usecFlush = micros() - start;
  serialOut(F("flush (Canvas only)\t"), usecFlush, 0, false);
#endif

  Serial.println(F("Done!"));

  uint16_t c = 4;
  int8_t d = 1;
  for (int32_t i = 0; i < h; i++)
  {
    gfx->drawFastHLine(0, i, w, c);
    c += d;
    if (c <= 4 || c >= 11)
    {
      d = -d;
    }
  }

  gfx->setCursor(0, 0);

  gfx->setTextSize(tsa);
  gfx->setTextColor(MAGENTA);
  gfx->println(F("Arduino GFX PDQ"));

  if (h > w)
  {
    gfx->setTextSize(tsb);
    gfx->setTextColor(GREEN);
    gfx->print(F("\nBenchmark "));
    gfx->setTextSize(tsc);
    if (ds == 12)
    {
      gfx->print(F("   "));
    }
    gfx->println(F("micro-secs"));
  }

  gfx->setTextSize(1);
  printnice(F("Screen fill "), usecFillScreen);
  printnice(F("Text        "), usecText);
  printnice(F("Pixels      "), usecPixels);
  printnice(F("Lines       "), usecLines);
  printnice(F("H/V Lines   "), usecFastLines);
  printnice(F("Rectangles F"), usecFilledRects);
  printnice(F("Rectangles  "), usecRects);
  printnice(F("Triangles F "), usecFilledTrangles);
  printnice(F("Triangles   "), usecTriangles);
  printnice(F("Circles F   "), usecFilledCircles);
  printnice(F("Circles     "), usecCircles);
  printnice(F("Arcs F      "), usecFilledArcs);
  printnice(F("Arcs        "), usecArcs);
  printnice(F("RoundRects F"), usecFilledRoundRects);
  printnice(F("RoundRects  "), usecRoundRects);

  if ((h > w) || (h > 240))
  {
    gfx->setTextSize(tsc);
    gfx->setTextColor(GREEN);
    gfx->print(F("\nBenchmark Complete!"));
  }

#ifdef CANVAS
  gfx->flush();
#endif

  delay(60 * 1000L);
}

void serialOut(const __FlashStringHelper *item, int32_t v, uint32_t d, bool clear)
{
#ifdef CANVAS
  gfx->flush();
#endif
  Serial.print(item);
  if (v < 0)
  {
    Serial.println(F("N/A"));
  }
  else
  {
    Serial.println(v);
  }
  delay(d);
  if (clear)
  {
    gfx->fillScreen(BLACK);
  }
}

void printnice(const __FlashStringHelper *item, long int v)
{
  gfx->setTextSize(tsb);
  gfx->setTextColor(CYAN);
  gfx->print(item);

  gfx->setTextSize(tsc);
  gfx->setTextColor(YELLOW);
  if (v < 0)
  {
    gfx->println(F("      N / A"));
  }
  else
  {
    char str[32] = {0};
#ifdef RTL8722DM
    sprintf(str, "%d", (int)v);
#else
    sprintf(str, "%ld", v);
#endif
    for (char *p = (str + strlen(str)) - 3; p > str; p -= 3)
    {
      memmove(p + 1, p, strlen(p) + 1);
      *p = ',';
    }
    while (strlen(str) < ds)
    {
      memmove(str + 1, str, strlen(str) + 1);
      *str = ' ';
    }
    gfx->println(str);
  }
}

int32_t testFillScreen()
{
  uint32_t start = micros_start();
  // Shortened this tedious test!
  gfx->fillScreen(WHITE);
  gfx->fillScreen(RED);
  gfx->fillScreen(GREEN);
  gfx->fillScreen(BLUE);
  gfx->fillScreen(BLACK);

  return micros() - start;
}

int32_t testText()
{
  uint32_t start = micros_start();
  gfx->setCursor(0, 0);

  gfx->setTextSize(1);
  gfx->setTextColor(WHITE, BLACK);
  gfx->println(F("Hello World!"));

  gfx->setTextSize(2);
  gfx->setTextColor(gfx->color565(0xff, 0x00, 0x00));
  gfx->print(F("RED "));
  gfx->setTextColor(gfx->color565(0x00, 0xff, 0x00));
  gfx->print(F("GREEN "));
  gfx->setTextColor(gfx->color565(0x00, 0x00, 0xff));
  gfx->println(F("BLUE"));

  gfx->setTextSize(tsa);
  gfx->setTextColor(YELLOW);
  gfx->println(1234.56);

  gfx->setTextColor(WHITE);
  gfx->println((w > 128) ? 0xDEADBEEF : 0xDEADBEE, HEX);

  gfx->setTextColor(CYAN, WHITE);
  gfx->println(F("Groop,"));

  gfx->setTextSize(tsc);
  gfx->setTextColor(MAGENTA, WHITE);
  gfx->println(F("I implore thee,"));

  gfx->setTextSize(1);
  gfx->setTextColor(NAVY, WHITE);
  gfx->println(F("my foonting turlingdromes."));

  gfx->setTextColor(DARKGREEN, WHITE);
  gfx->println(F("And hooptiously drangle me"));

  gfx->setTextColor(DARKCYAN, WHITE);
  gfx->println(F("with crinkly bindlewurdles,"));

  gfx->setTextColor(MAROON, WHITE);
  gfx->println(F("Or I will rend thee"));

  gfx->setTextColor(PURPLE, WHITE);
  gfx->println(F("in the gobberwartsb"));

  gfx->setTextColor(OLIVE, WHITE);
  gfx->println(F("with my blurglecruncheon,"));

  gfx->setTextColor(DARKGREY, WHITE);
  gfx->println(F("see if I don't!"));

  gfx->setTextSize(2);
  gfx->setTextColor(RED);
  gfx->println(F("Size 2"));

  gfx->setTextSize(3);
  gfx->setTextColor(ORANGE);
  gfx->println(F("Size 3"));

  gfx->setTextSize(4);
  gfx->setTextColor(YELLOW);
  gfx->println(F("Size 4"));

  gfx->setTextSize(5);
  gfx->setTextColor(GREENYELLOW);
  gfx->println(F("Size 5"));

  gfx->setTextSize(6);
  gfx->setTextColor(GREEN);
  gfx->println(F("Size 6"));

  gfx->setTextSize(7);
  gfx->setTextColor(BLUE);
  gfx->println(F("Size 7"));

  gfx->setTextSize(8);
  gfx->setTextColor(PURPLE);
  gfx->println(F("Size 8"));

  gfx->setTextSize(9);
  gfx->setTextColor(PINK);
  gfx->println(F("Size 9"));

  return micros() - start;
}

int32_t testPixels()
{
  uint32_t start = micros_start();

  for (int16_t y = 0; y < h; y++)
  {
    for (int16_t x = 0; x < w; x++)
    {
      gfx->drawPixel(x, y, gfx->color565(x << 3, y << 3, x * y));
    }
#ifdef ESP8266
    yield(); // avoid long run triggered ESP8266 WDT restart
#endif
  }

  return micros() - start;
}

int32_t testLines()
{
  uint32_t start;
  int32_t x1, y1, x2, y2;

  start = micros_start();

  x1 = y1 = 0;
  y2 = h - 1;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = w - 1;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x1 = w - 1;
  y1 = 0;
  y2 = h - 1;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = 0;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x1 = 0;
  y1 = h - 1;
  y2 = 0;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = w - 1;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x1 = w - 1;
  y1 = h - 1;
  y2 = 0;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = 0;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  return micros() - start;
}

int32_t testFastLines()
{
  uint32_t start;
  int32_t x, y;

  start = micros_start();

  for (y = 0; y < h; y += 5)
  {
    gfx->drawFastHLine(0, y, w, RED);
  }
  for (x = 0; x < w; x += 5)
  {
    gfx->drawFastVLine(x, 0, h, BLUE);
  }

  return micros() - start;
}

int32_t testFilledRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();

  for (i = n; i > 0; i -= 6)
  {
    i2 = i / 2;

    gfx->fillRect(cx - i2, cy - i2, i, i, gfx->color565(i, i, 0));
  }

  return micros() - start;
}

int32_t testRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();
  for (i = 2; i < n; i += 6)
  {
    i2 = i / 2;
    gfx->drawRect(cx - i2, cy - i2, i, i, GREEN);
  }

  return micros() - start;
}

int32_t testFilledCircles(uint8_t radius)
{
  uint32_t start;
  int32_t x, y, r2 = radius * 2;

  start = micros_start();

  for (x = radius; x < w; x += r2)
  {
    for (y = radius; y < h; y += r2)
    {
      gfx->fillCircle(x, y, radius, MAGENTA);
    }
  }

  return micros() - start;
}

int32_t testCircles(uint8_t radius)
{
  uint32_t start;
  int32_t x, y, r2 = radius * 2;
  int32_t w1 = w + radius;
  int32_t h1 = h + radius;

  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros_start();

  for (x = 0; x < w1; x += r2)
  {
    for (y = 0; y < h1; y += r2)
    {
      gfx->drawCircle(x, y, radius, WHITE);
    }
  }

  return micros() - start;
}

int32_t testFillArcs()
{
  int16_t i, r = 360 / cn;
  uint32_t start = micros_start();

  for (i = 6; i < cn; i += 6)
  {
    gfx->fillArc(cx1, cy1, i, i - 3, 0, i * r, RED);
  }

  return micros() - start;
}

int32_t testArcs()
{
  int16_t i, r = 360 / cn;
  uint32_t start = micros_start();

  for (i = 6; i < cn; i += 6)
  {
    gfx->drawArc(cx1, cy1, i, i - 3, 0, i * r, WHITE);
  }

  return micros() - start;
}

int32_t testFilledTriangles()
{
  uint32_t start;
  int32_t i;

  start = micros_start();

  for (i = cn1; i > 10; i -= 5)
  {
    gfx->fillTriangle(cx1, cy1 - i, cx1 - i, cy1 + i, cx1 + i, cy1 + i,
                      gfx->color565(0, i, i));
  }

  return micros() - start;
}

int32_t testTriangles()
{
  uint32_t start;
  int32_t i;

  start = micros_start();

  for (i = 0; i < cn; i += 5)
  {
    gfx->drawTriangle(
      cx1, cy1 - i,     // peak
      cx1 - i, cy1 + i, // bottom left
      cx1 + i, cy1 + i, // bottom right
      gfx->color565(0, 0, i));
  }

  return micros() - start;
}

int32_t testFilledRoundRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();

  for (i = n1; i > 20; i -= 6)
  {
    i2 = i / 2;
    gfx->fillRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(0, i, 0));
  }

  return micros() - start;
}

int32_t testRoundRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();

  for (i = 20; i < n1; i += 6)
  {
    i2 = i / 2;
    gfx->drawRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(i, 0, 0));
  }

  return micros() - start;
}


//-------------------------------------- SD CARD CONTENTS -------------------------------------------------------

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}

I extracted that code above from the Arduino_GFX_Library.h Examples Library. This is now working on a Teensy 4.0 with external SD card connected to the default SPI pins, except for the CS which is declared above.

Had some issues with getting the screen to initalise. Seems ok at the moment. (That is why there are two initalisation lines with one commented out 'Possibly need to enable this instead'). Toggling these statements seems to bring the screen back when it fails and I don't understand why yet.

No idea what that commented out code is regarding 'Start of Canvas (framebuffer)' means. Left it in there until I know what it does (or whether I could use it).

My final destination is to hopefully load 240x240 images from the SD card, or from external external flash memory (25Q128JVSQ). Not got those involved yet, as I have not got any clue how to imlement that yet.

Someone has suggested the LVGL library, but I just cannot get that to compile at all. Throws up missing directories etc.

Tried this.... https://github.com/skpang/Teensy40_lvgl_demo_widgets
Would not compile

Been reading this to see if it could help:

https://learn.adafruit.com/adafruit-gfx-graphics-library/loading-images

But not so far. It too will not compile (I know its not really meant for this processor/screen, but it does do what I need).
Throws up: C:\Users\steve\Documents\Arduino\libraries\Adafruit_ImageReader_Library\Adafruit_ImageReader_EPD.h:18:38: fatal error: Adafruit_ImageReader.EPD.h: No such file or directory

But the directory appears to be there. This is the example. Commented out the incorrect screen.

Code:
// Adafruit_ImageReader test for Adafruit ST7789 320x240 TFT Breakout for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// parrot.bmp, miniwoof.bmp and wales.bmp.
// As written, this uses the microcontroller's SPI interface for the screen
// (not 'bitbang') and must be wired to specific pins (e.g. for Arduino Uno,
// MOSI = pin 11, MISO = 12, SCK = 13). Other pins are configurable below.

#include <Adafruit_GFX.h>         // Core graphics library
//#include <Adafruit_ST7789.h>      // Hardware-specific library for ST7789
#include <Arduino_GFX_Library.h>
#include <SdFat.h>                // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h>    // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions

// Comment out the next line to load from SPI/QSPI flash instead of SD card:
#define USE_SD_CARD

// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.

#define SD_CS    5 // SD card select pin
#define TFT_CS  10 // TFT select pin
#define TFT_DC   9 // TFT display/command pin
#define TFT_RST  8 // Or set to -1 and connect to Arduino RESET pin

#if defined(USE_SD_CARD)
  SdFat                SD;         // SD card filesystem
  Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
  // SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
  #if defined(__SAMD51__) || defined(NRF52840_XXAA)
    Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
      PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
  #else
    #if (SPI_INTERFACES_COUNT == 1)
      Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
    #else
      Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
    #endif
  #endif
  Adafruit_SPIFlash    flash(&flashTransport);
  FatFileSystem        filesys;
  Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif

Adafruit_ST7789      tft    = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_Image       img;        // An image loaded into RAM
int32_t              width  = 0, // BMP image dimensions
                     height = 0;

void setup(void) {

  ImageReturnCode stat; // Status from image-reading functions

  Serial.begin(9600);
  while(!Serial);       // Wait for Serial Monitor before continuing

  tft.init(240, 240);           // Init ST7789 172x320

  // The Adafruit_ImageReader constructor call (above, before setup())
  // accepts an uninitialized SdFat or FatFileSystem object. This MUST
  // BE INITIALIZED before using any of the image reader functions!
  Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
  // SD card is pretty straightforward, a single call...
  if(!SD.begin(SD_CS, SD_SCK_MHZ(10))) { // Breakouts require 10 MHz limit due to longer wires
    Serial.println(F("SD begin() failed"));
    for(;;); // Fatal error, do not continue
  }
#else
  // SPI or QSPI flash requires two steps, one to access the bare flash
  // memory itself, then the second to access the filesystem within...
  if(!flash.begin()) {
    Serial.println(F("flash begin() failed"));
    for(;;);
  }
  if(!filesys.begin(&flash)) {
    Serial.println(F("filesys begin() failed"));
    for(;;);
  }
#endif
  Serial.println(F("OK!"));

  // Fill screen blue. Not a required step, this just shows that we're
  // successfully communicating with the screen.
  tft.fillScreen(ST77XX_BLUE);

  // Load full-screen BMP file 'adabot.bmp' at position (0,0) (top left).
  // Notice the 'reader' object performs this, with 'tft' as an argument.
  Serial.print(F("Loading adabot.bmp to screen..."));
  stat = reader.drawBMP("/adabot.bmp", tft, 0, 0);
  reader.printStatus(stat);   // How'd we do?

  // Query the dimensions of image 'miniwoof.bmp' WITHOUT loading to screen:
  Serial.print(F("Querying miniwoof.bmp image size..."));
  stat = reader.bmpDimensions("/miniwoof.bmp", &width, &height);
  reader.printStatus(stat);   // How'd we do?
  if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
    Serial.print(F("Image dimensions: "));
    Serial.print(width);
    Serial.write('x');
    Serial.println(height);
  }

  // Load small BMP 'wales.bmp' into a GFX canvas in RAM. This should fail
  // gracefully on Arduino Uno and other small devices, meaning the image
  // will not load, but this won't make the program stop or crash, it just
  // continues on without it. Should work on Arduino Mega, Zero, etc.
  Serial.print(F("Loading wales.bmp to canvas..."));
  stat = reader.loadBMP("/wales.bmp", img);
  reader.printStatus(stat); // How'd we do?

  delay(2000); // Pause 2 seconds before moving on to loop()
}

void loop() {
  for(int r=0; r<4; r++) { // For each of 4 rotations...
    tft.setRotation(r);    // Set rotation
    tft.fillScreen(0);     // and clear screen

    // Load 4 copies of the 'miniwoof.bmp' image to the screen, some
    // partially off screen edges to demonstrate clipping. Globals
    // 'width' and 'height' were set by bmpDimensions() call in setup().
    for(int i=0; i<4; i++) {
      reader.drawBMP("/miniwoof.bmp", tft,
        (tft.width()  * i / 3) - (width  / 2),
        (tft.height() * i / 3) - (height / 2));
    }

    delay(1000); // Pause 1 sec.

    // Draw 50 Welsh dragon flags in random positions. This has no effect
    // on memory-constrained boards like the Arduino Uno, where the image
    // failed to load due to insufficient RAM, but it's NOT fatal.
    for(int i=0; i<50; i++) {
      // Rather than reader.drawBMP() (which works from SD card),
      // a different function is used for RAM-resident images:
      img.draw(tft,                                    // Pass in tft object
        (int16_t)random(-img.width() , tft.width()) ,  // Horiz pos.
        (int16_t)random(-img.height(), tft.height())); // Vert pos
      // Reiterating a prior point: img.draw() does nothing and returns
      // if the image failed to load. It's unfortunate but not disastrous.
    }

    delay(2000); // Pause 2 sec.
  }

I know the screen driver is probably incorrect, but I was going to look at that after getting it to compile. This above is the example with the pins changed to mine.

Also tried several other libraries, but just lost track now of what. I will keep plodding
 
I ordered one from Ebay... Should be here in ??? days estimate from 25-July 5...

Will play more when I get it...
 
Well I was tinkering with the Adafruit image loader that didn't complile.

After Googling away, it turns out it also needs this library to work: https://github.com/adafruit/Adafruit_EPD

Would be really helpful if that mentioned that.

But now the SD.fat won't work:

#error ENABLE_EXTENDED_TRANSFER_CLASS must be set to 1 in SdFat SdFatConfig.h
#error FAT12_SUPPORT must be set to 1 in SdFat SdFatConfig.h

But, it won't let me edit and save those changes in SdFatConfig.h. Quite frankly, this whole thing is frustrating and sucks.

So I know SD.h works, so I suppose I could try and insert that instead, but I fear I am heading down a dead end here anyway.

I have several libraries and what appears to be 3 versions of SDfat. One of which is called SdFat_-_Adafruit_Fork, which is apparently the one this is supposed to use..... but it doesn't.
I tried adding the path and got a whole pile of errors. WHY do they call the libraries the same goddam name. I can see no reference to SdFat_-_Adafruit_Fork in the code above, so how does it know to head for that one?
Are they assuming we will just delete all our other SD.fat stuff so that theirs will work? OR, am I understanding this entirely wrong?

3 hrs = zip progress
 
Sorry, I will try to help more when I get the display... Note though I will probably implement it starting off from one of our drivers that myself and @mjs513 @wwatson have implemented.
Probably my ili9341_t3n or maybe the ST7789_t... code depending on more of on how close the SPI communications are on is this display to another display.


As for for example viewing SD files on the display. We do have a few examples of this using current stuff, mostly in our testing of MTP stuff, but MTP is mostly secondary...

Examples:
https://github.com/KurtE/MTP_Teensy/blob/main/examples/mtp_tft_picture_view/mtp_tft_picture_view.ino
This was part of the next one, but striped it down to only stuff that is contained within the Teensyduino release. Like ILI9341_t3...
(Slight lie) as MTP_Teensy is not integrated yet...

Or more fun/advanced version that @mjs513 and myself have played with:
https://github.com/KurtE/mtp_tft_picture_view/blob/main/mtp_tft_picture_view.ino

This one is setup for several different display libraries (under #ifdef) plus it has integrated code to decode JPEG and PNG files and the like.

Again as for Flash... Again assuming this is some form of Flash memory probably connected through SPI. Again you might look at the library LittleFS.
Which again is included with current releases of Teensyduino.
Or the most up to date version is probably: https://github.com/PaulStoffregen/LittleFS
Which handles several types of Flash chips (list in readme file on the github project)
There are several examples. Note Some of them need to know which SPI Flash you are using, but there is a cheat class that does this for you...
Where example may have section like:
Code:
LittleFS_SPIFlash   sFlash;  
//LittleFS_SPINAND    sNand;
//LittleFS_SPIFram    sFram;
And you uncomment one... And see if it work.

For example of cheating: There is simple Example 4 under MTP_Teensy
Note: I removed comments here to shorten post

Code:
#include "SD.h"
#include <LittleFS.h>
#include <MTP_Teensy.h>


#define SD_ChipSelect BUILTIN_SDCARD  // Teensy 3.6, 4.1 and some Micromod carrier boards
//#define SD_ChipSelect  10;

SDClass sd;

// This creates an LittleFS_SPI instance for each chip
LittleFS_SPI lfs_spi_list[] = {{3}, {4}, {5}, {6}};

void setup() {
  // start up MTPD early which will if asked tell the MTP
  // host that we are busy, until we have finished setting
  // up...
  Serial.begin(2000000);
  MTP.begin();

  // Open serial communications and wait for port to open:
  while (!Serial && millis() < 5000) {
    // wait for serial port to connect.
  }

  if (CrashReport) {
    Serial.print(CrashReport);
  }

  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);

  Serial.printf("%u Initializing MTP Storage list ...", millis());


  // Now lets try our list of LittleFS SPI?
  for (uint8_t i = 0; i < (sizeof(lfs_spi_list) / sizeof(lfs_spi_list[0])); i++) {
    pinMode(lfs_spi_list[i].csPin_, OUTPUT);
    digitalWrite(lfs_spi_list[i].csPin_, HIGH);
  }

  for (uint8_t i = 0; i < (sizeof(lfs_spi_list) / sizeof(lfs_spi_list[0])); i++) {
    if (lfs_spi_list[i].begin()) {
      MTP.addFilesystem(*lfs_spi_list[i].fs(), lfs_spi_list[i].displayName());
    } else {
      Serial.printf("Storage not added for pin %d\n", lfs_spi_list[i].csPin_);
    }
  }

  if (sd.begin(SD_ChipSelect)) {
    MTP.addFilesystem(sd, "SDCard");
  } else {
    Serial.println("No SD card available");
  }

  Serial.printf("%u Storage list initialized.\n", millis());
}


void loop() {
  MTP.loop();
}
This looks for Flash chips on pins 3, 4, 5, 6 and if found adds them to MTP list... Also adds SD
 
Thanks for that. I will look into that further.

After an afternoon of bashing through library after library with different issues with each one, I managed to cobble something together that works...

Ignore all the Gyro and demo graphics stuff

Code:
#include <Arduino_GFX_Library.h>
#include <MPU6050_light.h>                                              // Gyro library
#include <SD.h>

File root;                                                              // SD card root directory

MPU6050 mpu(Wire);                                                      // MPU6050 Gyro = 0x68

#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
// PJRC Teensy 4.x
#define TFT_CS 10                        // Used to be pin 39           // GFX_NOT_DEFINED for display without CS pin
#define TFT_DC 9                         // Used to be pin 41
#define TFT_RST 8                        // Used to be pin 40
#define TFT_BL 7                         // Used to be pin 22              
#endif

#define ledring 6
#define piezo 21
#define sidelights 20
#define rota 15
#define rotb 16
#define rotsw 17
// SD card CS = 5

#define PNG_FILENAME "/TG2.png"                                         // Temp PNG file to load

Arduino_DataBus *bus = new Arduino_HWSPI(TFT_DC, TFT_CS);

// GC9A01 IPS LCD 240x240
//Arduino_GFX *gfx = new Arduino_GC9A01(bus, TFT_RST, 0 /* rotation */, true /* IPS */);
Arduino_GFX *gfx = new Arduino_GC9A01(bus, 7 /* RST */, 0 /* rotation */, true /* IPS */);




//---------------- Set up the PNG display variables -------------------

#include <PNGdec.h>
PNG png;
int16_t wi, hi, xOffset, yOffset;                                       // Offset not required for the round screen

File pngFile;                                                           // File to access a PNG image on the SD card

//----------------- Graphics variables --------------------------------

int32_t w, h, n, n1, cx, cy, cx1, cy1, cn, cn1;
uint8_t tsa, tsb, tsc, ds;


//----------------------- Gyro ----------------------------------------

int TestGyroTimer;                                                                                            // Timer to test the gyro at boot
int GyroPitch;                                                                                                // Data from the Gyro
int GyroRoll;




//--------------------------------- Accessing a PNG file from the SD card ----------------------------------------------

void *myOpen(const char *filename, int32_t *size)
{
  pngFile = SD.open(filename, FILE_READ);

  if (!pngFile || pngFile.isDirectory())
  {
    Serial.println(F("ERROR: Failed to open " PNG_FILENAME " file for reading"));
    gfx->println(F("ERROR: Failed to open " PNG_FILENAME " file for reading"));
  }
  else
  {
    *size = pngFile.size();
    Serial.printf("Opened '%s', size: %d\n", filename, *size);
  }

  return &pngFile;
}

void myClose(void *handle)
{
  if (pngFile)
    pngFile.close();
}


int32_t myRead(PNGFILE *handle, uint8_t *buffer, int32_t length)
{
  if (!pngFile)
    return 0;
  return pngFile.read(buffer, length);
}

int32_t mySeek(PNGFILE *handle, int32_t position)
{
  if (!pngFile)
    return 0;
  return pngFile.seek(position);
}

static inline uint32_t micros_start() __attribute__((always_inline));
static inline uint32_t micros_start()
{
  uint8_t oms = millis();
  while ((uint8_t)millis() == oms)
    ;
  return micros();
}

// Function to draw pixels to the display
void PNGDraw(PNGDRAW *pDraw)
{
  uint16_t usPixels[320];
  uint8_t usMask[320];

  png.getLineAsRGB565(pDraw, usPixels, PNG_RGB565_LITTLE_ENDIAN, 0x00000000);
  png.getAlphaMask(pDraw, usMask, 1);
  gfx->draw16bitRGBBitmap(xOffset, yOffset + pDraw->y, usPixels, usMask, pDraw->iWidth, 1);
}



//##################### SETUP ###############################################################################################################################################################

void setup()
{
  Serial.begin(115200);

  Wire.begin();                                                                                                                        // Set this as master I2c device


  //--------------------------------- MPU6050 Gyro -----------------------------------------------


  byte status = mpu.begin();                                                                                                           // Stop everything if could not connect to MPU6050

  Serial.print(F("MPU6050 status: "));
  Serial.println(status);

  while (status != 0) {
    TestGyroTimer++;
    delay(10000);
    if (TestGyroTimer > 1000) {
      Serial.print(F("GYRO ERROR"));
    }
  }


  Serial.println(F("Calculating offsets, do not move MPU6050"));                                                                       // Gyro and accelerometer calibration


  mpu.setAccConfig(3);                                                                                                                 //  0 = 2g, 1= 4g,  2 = 8g,  3 = 16g           SET THE ACCELEROMETER FORCE

  delay(1000);
  mpu.calcOffsets(true, true);

  Serial.println("Calibration complete!\n");


  GyroPitch = mpu.getAccAngleY();                                                                                                      // Get the submarines angle at boot
  GyroRoll = mpu.getAccAngleX();
  Serial.print(F("Vehicle initial pitch: ")); Serial.println(GyroPitch);
  Serial.print(F("Vehicle initial roll: ")); Serial.println(GyroRoll);





  //------------------------------------ SD CARD -----------------------------------------------------


  Serial.print("Initializing SD card...");

  if (!SD.begin(5)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);

  Serial.println("done!");



  //-------------------------------------- GFX -------------------------------------------------------



  // while(!Serial);
  Serial.println("Arduino_GFX library Test!");

  gfx->begin();

  w = gfx->width();
  h = gfx->height();
  n = min(w, h);
  n1 = n - 1;
  cx = w / 2;
  cy = h / 2;
  cx1 = cx - 1;
  cy1 = cy - 1;
  cn = min(cx1, cy1);
  cn1 = cn - 1;
  tsa = ((w <= 176) || (h <= 160)) ? 1 : (((w <= 240) || (h <= 240)) ? 2 : 3); // text size A
  tsb = ((w <= 240) || (h <= 220)) ? 1 : 2;                                    // text size B
  tsc = ((w <= 220) || (h <= 220)) ? 1 : 2;                                    // text size C
  ds = (w <= 160) ? 9 : 12;                                                    // digit size

#ifdef TFT_BL
  pinMode(TFT_BL, OUTPUT);
  digitalWrite(TFT_BL, HIGH);
#endif


  // ------------------- Draw a PNG gauge ------------------

  unsigned long start = millis();
  int rc;
  rc = png.open(PNG_FILENAME, myOpen, myClose, myRead, mySeek, PNGDraw);
  if (rc == PNG_SUCCESS)
  {
    int16_t pw = png.getWidth();
    int16_t ph = png.getHeight();
    Serial.print("Image width: "); Serial.println(pw);
    Serial.print("Image height: "); Serial.println(ph);

    xOffset = 0;
    yOffset = 0;

    rc = png.decode(NULL, 0);

    Serial.printf("Draw offset: (%d, %d), time used: %lu\n", xOffset, yOffset, millis() - start);
    Serial.printf("image specs: (%d x %d), %d bpp, pixel type: %d\n", png.getWidth(), png.getHeight(), png.getBpp(), png.getPixelType());
    png.close();
  }

  delay(5000);

}


//##################### MAIN LOOP ##########################################################################################################################################################

void loop(void)
{

  mpu.update();

  GyroPitch = mpu.getAccAngleY();                                                                               // Get the vehicles angle
  GyroRoll = mpu.getAccAngleX();


  Serial.println(F("Benchmark\tmicro-secs"));

  int32_t usecFillScreen = testFillScreen();
  serialOut(F("Screen fill\t"), usecFillScreen, 100, true);

  int32_t usecText = testText();
  serialOut(F("Text\t"), usecText, 3000, true);

  int32_t usecPixels = testPixels();
  serialOut(F("Pixels\t"), usecPixels, 100, true);

  int32_t usecLines = testLines();
  serialOut(F("Lines\t"), usecLines, 100, true);

  int32_t usecFastLines = testFastLines();
  serialOut(F("Horiz/Vert Lines\t"), usecFastLines, 100, true);

  int32_t usecFilledRects = testFilledRects();
  serialOut(F("Rectangles (filled)\t"), usecFilledRects, 100, false);

  int32_t usecRects = testRects();
  serialOut(F("Rectangles (outline)\t"), usecRects, 100, true);

  int32_t usecFilledTrangles = testFilledTriangles();
  serialOut(F("Triangles (filled)\t"), usecFilledTrangles, 100, false);

  int32_t usecTriangles = testTriangles();
  serialOut(F("Triangles (outline)\t"), usecTriangles, 100, true);

  int32_t usecFilledCircles = testFilledCircles(10);
  serialOut(F("Circles (filled)\t"), usecFilledCircles, 100, false);

  int32_t usecCircles = testCircles(10);
  serialOut(F("Circles (outline)\t"), usecCircles, 100, true);

  int32_t usecFilledArcs = testFillArcs();
  serialOut(F("Arcs (filled)\t"), usecFilledArcs, 100, false);

  int32_t usecArcs = testArcs();
  serialOut(F("Arcs (outline)\t"), usecArcs, 100, true);

  int32_t usecFilledRoundRects = testFilledRoundRects();
  serialOut(F("Rounded rects (filled)\t"), usecFilledRoundRects, 100, false);

  int32_t usecRoundRects = testRoundRects();
  serialOut(F("Rounded rects (outline)\t"), usecRoundRects, 100, true);

#ifdef CANVAS
  uint32_t start = micros_start();
  gfx->flush();
  int32_t usecFlush = micros() - start;
  serialOut(F("flush (Canvas only)\t"), usecFlush, 0, false);
#endif

  Serial.println(F("Done!"));

  uint16_t c = 4;
  int8_t d = 1;
  for (int32_t i = 0; i < h; i++)
  {
    gfx->drawFastHLine(0, i, w, c);
    c += d;
    if (c <= 4 || c >= 11)
    {
      d = -d;
    }
  }

  gfx->setCursor(0, 0);

  gfx->setTextSize(tsa);
  gfx->setTextColor(MAGENTA);
  gfx->println(F("Arduino GFX PDQ"));

  if (h > w)
  {
    gfx->setTextSize(tsb);
    gfx->setTextColor(GREEN);
    gfx->print(F("\nBenchmark "));
    gfx->setTextSize(tsc);
    if (ds == 12)
    {
      gfx->print(F("   "));
    }
    gfx->println(F("micro-secs"));
  }

  gfx->setTextSize(1);
  printnice(F("Screen fill "), usecFillScreen);
  printnice(F("Text        "), usecText);
  printnice(F("Pixels      "), usecPixels);
  printnice(F("Lines       "), usecLines);
  printnice(F("H/V Lines   "), usecFastLines);
  printnice(F("Rectangles F"), usecFilledRects);
  printnice(F("Rectangles  "), usecRects);
  printnice(F("Triangles F "), usecFilledTrangles);
  printnice(F("Triangles   "), usecTriangles);
  printnice(F("Circles F   "), usecFilledCircles);
  printnice(F("Circles     "), usecCircles);
  printnice(F("Arcs F      "), usecFilledArcs);
  printnice(F("Arcs        "), usecArcs);
  printnice(F("RoundRects F"), usecFilledRoundRects);
  printnice(F("RoundRects  "), usecRoundRects);

  if ((h > w) || (h > 240))
  {
    gfx->setTextSize(tsc);
    gfx->setTextColor(GREEN);
    gfx->print(F("\nBenchmark Complete!"));
  }

#ifdef CANVAS
  gfx->flush();
#endif

  delay(60 * 1000L);
}

void serialOut(const __FlashStringHelper *item, int32_t v, uint32_t d, bool clear)
{
#ifdef CANVAS
  gfx->flush();
#endif
  Serial.print(item);
  if (v < 0)
  {
    Serial.println(F("N/A"));
  }
  else
  {
    Serial.println(v);
  }
  delay(d);
  if (clear)
  {
    gfx->fillScreen(BLACK);
  }
}

void printnice(const __FlashStringHelper *item, long int v)
{
  gfx->setTextSize(tsb);
  gfx->setTextColor(CYAN);
  gfx->print(item);

  gfx->setTextSize(tsc);
  gfx->setTextColor(YELLOW);
  if (v < 0)
  {
    gfx->println(F("      N / A"));
  }
  else
  {
    char str[32] = {0};
#ifdef RTL8722DM
    sprintf(str, "%d", (int)v);
#else
    sprintf(str, "%ld", v);
#endif
    for (char *p = (str + strlen(str)) - 3; p > str; p -= 3)
    {
      memmove(p + 1, p, strlen(p) + 1);
      *p = ',';
    }
    while (strlen(str) < ds)
    {
      memmove(str + 1, str, strlen(str) + 1);
      *str = ' ';
    }
    gfx->println(str);
  }
}

int32_t testFillScreen()
{
  uint32_t start = micros_start();
  // Shortened this tedious test!
  gfx->fillScreen(WHITE);
  gfx->fillScreen(RED);
  gfx->fillScreen(GREEN);
  gfx->fillScreen(BLUE);
  gfx->fillScreen(BLACK);

  return micros() - start;
}

int32_t testText()
{
  uint32_t start = micros_start();
  gfx->setCursor(0, 0);

  gfx->setTextSize(1);
  gfx->setTextColor(WHITE, BLACK);
  gfx->println(F("Hello World!"));

  gfx->setTextSize(2);
  gfx->setTextColor(gfx->color565(0xff, 0x00, 0x00));
  gfx->print(F("RED "));
  gfx->setTextColor(gfx->color565(0x00, 0xff, 0x00));
  gfx->print(F("GREEN "));
  gfx->setTextColor(gfx->color565(0x00, 0x00, 0xff));
  gfx->println(F("BLUE"));

  gfx->setTextSize(tsa);
  gfx->setTextColor(YELLOW);
  gfx->println(1234.56);

  gfx->setTextColor(WHITE);
  gfx->println((w > 128) ? 0xDEADBEEF : 0xDEADBEE, HEX);

  gfx->setTextColor(CYAN, WHITE);
  gfx->println(F("Groop,"));

  gfx->setTextSize(tsc);
  gfx->setTextColor(MAGENTA, WHITE);
  gfx->println(F("I implore thee,"));

  gfx->setTextSize(1);
  gfx->setTextColor(NAVY, WHITE);
  gfx->println(F("my foonting turlingdromes."));

  gfx->setTextColor(DARKGREEN, WHITE);
  gfx->println(F("And hooptiously drangle me"));

  gfx->setTextColor(DARKCYAN, WHITE);
  gfx->println(F("with crinkly bindlewurdles,"));

  gfx->setTextColor(MAROON, WHITE);
  gfx->println(F("Or I will rend thee"));

  gfx->setTextColor(PURPLE, WHITE);
  gfx->println(F("in the gobberwartsb"));

  gfx->setTextColor(OLIVE, WHITE);
  gfx->println(F("with my blurglecruncheon,"));

  gfx->setTextColor(DARKGREY, WHITE);
  gfx->println(F("see if I don't!"));

  gfx->setTextSize(2);
  gfx->setTextColor(RED);
  gfx->println(F("Size 2"));

  gfx->setTextSize(3);
  gfx->setTextColor(ORANGE);
  gfx->println(F("Size 3"));

  gfx->setTextSize(4);
  gfx->setTextColor(YELLOW);
  gfx->println(F("Size 4"));

  gfx->setTextSize(5);
  gfx->setTextColor(GREENYELLOW);
  gfx->println(F("Size 5"));

  gfx->setTextSize(6);
  gfx->setTextColor(GREEN);
  gfx->println(F("Size 6"));

  gfx->setTextSize(7);
  gfx->setTextColor(BLUE);
  gfx->println(F("Size 7"));

  gfx->setTextSize(8);
  gfx->setTextColor(PURPLE);
  gfx->println(F("Size 8"));

  gfx->setTextSize(9);
  gfx->setTextColor(PINK);
  gfx->println(F("Size 9"));

  return micros() - start;
}

int32_t testPixels()
{
  uint32_t start = micros_start();

  for (int16_t y = 0; y < h; y++)
  {
    for (int16_t x = 0; x < w; x++)
    {
      gfx->drawPixel(x, y, gfx->color565(x << 3, y << 3, x * y));
    }
#ifdef ESP8266
    yield(); // avoid long run triggered ESP8266 WDT restart
#endif
  }

  return micros() - start;
}

int32_t testLines()
{
  uint32_t start;
  int32_t x1, y1, x2, y2;

  start = micros_start();

  x1 = y1 = 0;
  y2 = h - 1;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = w - 1;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x1 = w - 1;
  y1 = 0;
  y2 = h - 1;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = 0;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x1 = 0;
  y1 = h - 1;
  y2 = 0;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = w - 1;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x1 = w - 1;
  y1 = h - 1;
  y2 = 0;
  for (x2 = 0; x2 < w; x2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  x2 = 0;
  for (y2 = 0; y2 < h; y2 += 6)
  {
    gfx->drawLine(x1, y1, x2, y2, BLUE);
  }
#ifdef ESP8266
  yield(); // avoid long run triggered ESP8266 WDT restart
#endif

  return micros() - start;
}

int32_t testFastLines()
{
  uint32_t start;
  int32_t x, y;

  start = micros_start();

  for (y = 0; y < h; y += 5)
  {
    gfx->drawFastHLine(0, y, w, RED);
  }
  for (x = 0; x < w; x += 5)
  {
    gfx->drawFastVLine(x, 0, h, BLUE);
  }

  return micros() - start;
}

int32_t testFilledRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();

  for (i = n; i > 0; i -= 6)
  {
    i2 = i / 2;

    gfx->fillRect(cx - i2, cy - i2, i, i, gfx->color565(i, i, 0));
  }

  return micros() - start;
}

int32_t testRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();
  for (i = 2; i < n; i += 6)
  {
    i2 = i / 2;
    gfx->drawRect(cx - i2, cy - i2, i, i, GREEN);
  }

  return micros() - start;
}

int32_t testFilledCircles(uint8_t radius)
{
  uint32_t start;
  int32_t x, y, r2 = radius * 2;

  start = micros_start();

  for (x = radius; x < w; x += r2)
  {
    for (y = radius; y < h; y += r2)
    {
      gfx->fillCircle(x, y, radius, MAGENTA);
    }
  }

  return micros() - start;
}

int32_t testCircles(uint8_t radius)
{
  uint32_t start;
  int32_t x, y, r2 = radius * 2;
  int32_t w1 = w + radius;
  int32_t h1 = h + radius;

  // Screen is not cleared for this one -- this is
  // intentional and does not affect the reported time.
  start = micros_start();

  for (x = 0; x < w1; x += r2)
  {
    for (y = 0; y < h1; y += r2)
    {
      gfx->drawCircle(x, y, radius, WHITE);
    }
  }

  return micros() - start;
}

int32_t testFillArcs()
{
  int16_t i, r = 360 / cn;
  uint32_t start = micros_start();

  for (i = 6; i < cn; i += 6)
  {
    gfx->fillArc(cx1, cy1, i, i - 3, 0, i * r, RED);
  }

  return micros() - start;
}

int32_t testArcs()
{
  int16_t i, r = 360 / cn;
  uint32_t start = micros_start();

  for (i = 6; i < cn; i += 6)
  {
    gfx->drawArc(cx1, cy1, i, i - 3, 0, i * r, WHITE);
  }

  return micros() - start;
}

int32_t testFilledTriangles()
{
  uint32_t start;
  int32_t i;

  start = micros_start();

  for (i = cn1; i > 10; i -= 5)
  {
    gfx->fillTriangle(cx1, cy1 - i, cx1 - i, cy1 + i, cx1 + i, cy1 + i,
                      gfx->color565(0, i, i));
  }

  return micros() - start;
}

int32_t testTriangles()
{
  uint32_t start;
  int32_t i;

  start = micros_start();

  for (i = 0; i < cn; i += 5)
  {
    gfx->drawTriangle(
      cx1, cy1 - i,     // peak
      cx1 - i, cy1 + i, // bottom left
      cx1 + i, cy1 + i, // bottom right
      gfx->color565(0, 0, i));
  }

  return micros() - start;
}

int32_t testFilledRoundRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();

  for (i = n1; i > 20; i -= 6)
  {
    i2 = i / 2;
    gfx->fillRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(0, i, 0));
  }

  return micros() - start;
}

int32_t testRoundRects()
{
  uint32_t start;
  int32_t i, i2;

  start = micros_start();

  for (i = 20; i < n1; i += 6)
  {
    i2 = i / 2;
    gfx->drawRoundRect(cx - i2, cy - i2, i, i, i / 8, gfx->color565(i, 0, 0));
  }

  return micros() - start;

}

//########################################################################################################################################################################


//-------------------------------------- SD CARD CONTENTS -------------------------------------------------------

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}





// ---------------------------------------------- Piezo --------------------------------------------------------------
void SFX () {
  tone(piezo, 900, 100);
}

This loads nice 240x240 PNG files immediatley off the SD card.
Just now need to add the ability to load from Flash

Gauges-1.png
 
As soon as I try to #include <MTP_Teensy.h> (I have upgraded to the latest Teensy loader)
.... I get this faceful

Code:
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:37:0: warning: "FILE_READ" redefined

 #define FILE_READ  0

 ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:23:0: note: this is the location of the previous definition

 #define FILE_READ O_READ

 ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:38:0: warning: "FILE_WRITE" redefined

 #define FILE_WRITE 1

 ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:24:0: note: this is the location of the previous definition

 #define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)

 ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:75:10: error: reference to 'File' is ambiguous

  virtual File openNextFile(uint8_t mode=0) = 0;

          ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:47:7: note: candidates are: class File

 class File;

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h: In member function 'File File::openNextFile(uint8_t)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:211:19: error: 'class FileImpl' has no member named 'openNextFile'

   return (f) ? f->openNextFile(mode) : *this;

                   ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h: At global scope:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:271:10: error: reference to 'File' is ambiguous

  virtual File open(const char *filename, uint8_t mode = FILE_READ) = 0;

          ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:286:2: error: reference to 'File' is ambiguous

  File open(const String &filepath, uint8_t mode = FILE_READ) {

  ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:170:10: error: reference to 'File' is ambiguous

  virtual File openNextFile(uint8_t mode=0) {

          ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:255:2: error: reference to 'File' is ambiguous

  File open(const char *filepath, uint8_t mode = FILE_READ) {

  ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:730:11: error: reference to 'File' is ambiguous

   virtual File open(const char *filename, uint8_t mode = FILE_READ) { return File();}

           ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:756:11: error: reference to 'File' is ambiguous

   virtual File open(const char *filename, uint8_t mode = FILE_READ) { return pfs->open(filename, mode); }

           ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:791:11: error: reference to 'File' is ambiguous

   virtual File open(const char *filename, uint8_t mode = FILE_READ) { return pfs->open(filename, mode); }

           ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Teensy.h:45:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:12:

C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Storage.h:146:2: error: reference to 'File' is ambiguous

  File open(uint32_t store, const char *filename, uint32_t mode) {

  ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Teensy.h:45:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:12:

C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Storage.h:239:2: error: reference to 'File' is ambiguous

  File index_;

  ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Teensy.h:45:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:12:

C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Storage.h:240:2: error: reference to 'File' is ambiguous

  File file_;

  ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

In file included from C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Teensy.h:45:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:12:

C:\Users\steve\Documents\Arduino\libraries\MTP_Teensy-main\src/MTP_Storage.h:241:2: error: reference to 'File' is ambiguous

  File child_;

  ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

Gauges_v11:49: error: reference to 'File' is ambiguous
 File pngFile;                                                           // File to access a PNG image on the SD card

 ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

Gauges_v11:50: error: reference to 'File' is ambiguous
 File root;                                                              // SD card root directory

 ^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

Gauges_v11:860: error: variable or field 'printDirectory' declared void
 void printDirectory(File dir, int numTabs) {

                     ^

Gauges_v11:860: error: reference to 'File' is ambiguous
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

Gauges_v11:860: error: expected primary-expression before 'int'
 void printDirectory(File dir, int numTabs) {

                               ^

Gauges_v11: In function 'void* myOpen(const char*, int32_t*)':
Gauges_v11:71: error: 'pngFile' was not declared in this scope
   pngFile = SD.open(filename, FILE_READ);

   ^

Gauges_v11: In function 'void myClose(void*)':
Gauges_v11:89: error: 'pngFile' was not declared in this scope
   if (pngFile)

       ^

Gauges_v11: In function 'int32_t myRead(PNGFILE*, uint8_t*, int32_t)':
Gauges_v11:96: error: 'pngFile' was not declared in this scope
   if (!pngFile)

        ^

Gauges_v11:98: error: 'pngFile' was not declared in this scope
   return pngFile.read(buffer, length);

          ^

Gauges_v11: In function 'int32_t mySeek(PNGFILE*, int32_t)':
Gauges_v11:103: error: 'pngFile' was not declared in this scope
   if (!pngFile)

        ^

Gauges_v11:105: error: 'pngFile' was not declared in this scope
   return pngFile.seek(position);

          ^

Gauges_v11: In function 'void setup()':
Gauges_v11:211: error: 'root' was not declared in this scope
   root = SD.open("/");

   ^

Gauges_v11:213: error: 'printDirectory' was not declared in this scope
   printDirectory(root, 0);

                         ^

C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino: At global scope:

Gauges_v11:860: error: variable or field 'printDirectory' declared void
 void printDirectory(File dir, int numTabs) {

                     ^

Gauges_v11:860: error: reference to 'File' is ambiguous
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\LittleFS\src/LittleFS.h:25:0,

                 from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:11:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/FS.h:106:7: note: candidates are: class File

 class File final : public Stream {

       ^

In file included from C:\Users\steve\Documents\Arduino\Ford Ranger Gauges 2022\Gauges_v11\Gauges_v11.ino:10:0:

C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h:28:9: note:                 class SDLib::File

   class File : public Stream {

         ^

Gauges_v11:860: error: expected primary-expression before 'int'
 void printDirectory(File dir, int numTabs) {

                               ^

reference to 'File' is ambiguous

I'll be leaving that for now then
 
Try changing the order of the includes.

If that doesn't help, please give us a way to reproduce the problem. Even if the program seems trivial, please post a complete program so we can just copy it into Arduino and click Verify to get the same errors.

Also, I know you said you upgraded to the latest version of the software, but perhaps rather than saying you have the latest you can tell us specifically which version number you see when you click Help > About in Arduino? These sorts of details matter.
 
Arduino 1.8.9
Teensy 1.57 Beta1 (As required by the #include <MTP_Teensy.h> suggested above)

Loathed to update my Arduino IDE because it breaks so many things. Above this version breaks quite a lot of my touchscreen routines on other projects. This is the one I have found to be the 'middle ground'.

The code in post #16 compiles and works. Add #include <LittleFS.h> and that breaks it as above.

I will try them in a different order tomorrow. Thanks all
 
Loathed to update my Arduino IDE because it breaks so many things. Above this version breaks quite a lot of my touchscreen routines on other projects. This is the one I have found to be the 'middle ground'.
You can always preserve your current Arduino environment, do your tests, and if necessary put the original back. I use this scheme:-
1: Click and open Program Files (x86)
2: Right click Arduino and select Copy
3: Right click "open space" and click paste
4: Enter an administrator password if asked
5: Let the copy process run
6: You will now have a directory called Arduino - Copy.
7: Rename it to something describing it's current state, perhaps Arduino before Teensyduino 1.57b3 test install

To be sure this works I have just done it as I am documenting how to do it!

To go back to previous setup.
1: Rename or Delete the Arduino directory.
2: Rename the saved directory created in the process above as Arduino.

In 1 above I prefer Rename, carry out 2 then Delete the renamed directory.
 
@BriComp -Good safe approach.

What I typically do, is to: use the windows Zip file download options, and I unzip them at the root of my drive (C: SSD... or D: hard...), I then Right drag the Arduino IDE exe file the task bar and add it.
I also drag a link to my folder to the Quick Access area of the explorer to make it easy to get back to...

Then I simply tell the Teensyduino install which one I wish to install in...

So I often have multiple releases that I have links in Taskbar and in my explorer window. Currently in Taskbar I have 1.8.19 and I have IDE2 RC7 and IDE2 Daily which I just updated to todays
 
@SteveSFX
This looks a little strange to me. Looks like your sketch is using the SD library that is in your libraries folder.
Code:
C:\Users\steve\Documents\Arduino\libraries\SD\src/SD.h

You might want to check if you have an extra copy there and delete it so it will use the Teensy Library.
 
Quite possibly it is using the wrong sd library, but does that matter? I hate changing things when it's working!

As for all that faff trying to use other versions of the IDE..... life's too short! lol
 
Quite possibly it is using the wrong sd library, but does that matter? I hate changing things when it's working!

As for all that faff trying to use other versions of the IDE..... life's too short! lol

well, does kind of matter if you are using SD with the T4's. With the Teensy libraries the SD library is linked to the SDfat library and LittleFS and MTP are all integrated with the FS stuff for the Teensy. That;s proably why you are getting the conflict errors that you are seeing.
 
Back
Top