Wo fehlt das if und wo kommt der ESP32 her

Hallo zusammen,

ich benötige mal wieder euren Rat :smiling_face_with_tear:
Ich versuche gerade ein Beispiel aus GFX Libary for Arduino zum Laufen zu bringen.
Da verwende ich einen ESP32-S3, dazu die erste Frage.

Mit #elif defined(ESP32) wird ja geprüft welches Board ich verwende,
ist die Quelle dazu oben die Boardauswahl oder woher bekommt die IDE diese Info.

Wenn die IDE diese Info dann hat, muß ich ja die Parameter zu meiner SD Karte eintragen.
Die hängt parallel zum TFT am SPI dran und ist eine normale SD Karte, deshalb habe ich SPIFFS usw. aktiviert und die entsprechenden GPIOs eingetragen.
SD..MMC habe ich keine, deshalb die vier Zeilen auskommentiert gelassen.
Benötige ich auch die FFAT und LittleFS dazu? Das sollte ich aber auch ausprobieren können sobald das if an der richtigen Stelle vor dem else in Zeile 161 ist.
Das ist meine zweite Frage wo muss ich das if setzen damit die Fehlermeldung weg ist.

ich bekomme da immer diese Fehlermeldung in Zeile 161

ImgViewerJpeg_V1.ino:161:5: error: 'else' without a previous 'if'
  161 |   } else {
      |     ^~~~

So sieht das bei mir aus :roll_eyes:

Das ist der unveränderte Teil des Beispieles welchen ich eben auf meine Hardware anpassen muss, so wie ich es im Bild oben gemacht habe.

void setup()
{
#ifdef DEV_DEVICE_INIT
  DEV_DEVICE_INIT();
#endif

  Serial.begin(115200);
  // Serial.setDebugOutput(true);
  // while(!Serial);
  Serial.println("Arduino_GFX JPEG Image Viewer example");

  // Init Display
  if (!gfx->begin())
  {
    Serial.println("gfx->begin() failed!");
  }
  gfx->fillScreen(RGB565_BLACK);

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

/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
  if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(TARGET_RP2040) || defined(PICO_RP2350)
  if (!LittleFS.begin())
  // if (!SD.begin(SS))
#elif defined(ESP32)
  // if (!FFat.begin())
  if (!LittleFS.begin())
  // if (!SPIFFS.begin())
  // SPI.begin(12 /* CLK */, 13 /* D0/MISO */, 11 /* CMD/MOSI */);
  // if (!SD.begin(10 /* CS */, SPI))
  // pinMode(10 /* CS */, OUTPUT);
  // digitalWrite(10 /* CS */, HIGH);
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
  // if (!SD_MMC.begin("/root", true /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_DEFAULT))
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */, 14 /* D1 */, 15 /* D2 */, 10 /* D3/CS */);
  // if (!SD_MMC.begin("/root", false /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_HIGHSPEED))
#elif defined(ESP8266)
  if (!LittleFS.begin())
  // if (!SD.begin(SS))
#else
  if (!SD.begin())
#endif
  {
    Serial.println(F("ERROR: File System Mount Failed!"));
    gfx->println(F("ERROR: File System Mount Failed!"));
  }
  else
  {
    unsigned long start = millis();
    jpegDraw(JPEG_FILENAME, jpegDrawCallback, true /* useBigEndian */,
             0 /* x */, 0 /* y */, gfx->width() /* widthLimit */, gfx->height() /* heightLimit */);
    Serial.printf("Time used: %lu\n", millis() - start);
  }

  delay(5000);
}

Vielen Dank für eure Ratschläge :folded_hands:

Aus der betreffenden boards.txt und platform.txt

Dann solltest du uns deinen kompletten Sketch zeigen.
Aber bitte nicht als Foto.
Und nein, LittleFS brauchst du dafür nicht.

Ich hatte gehofft der Code-Ausschnitt unter dem Bild reicht,
aber ich stelle gerne das Ganze hier rein.
Die 4 Bilder für die SD Karte habe ich aber weg gelassen.
Danke :innocent:

 /*******************************************************************************
 * JPEG Image Viewer
 * This is a simple JPEG image viewer example
 * Image Source: https://github.blog/2014-11-24-from-sticker-to-sculpture-the-making-of-the-octocat-figurine/
 *
 * Dependent libraries:
 * JPEGDEC: https://github.com/bitbank2/JPEGDEC.git
 *
 * Setup steps:
 * 1. Change your LCD parameters in Arduino_GFX setting
 * 2. Upload JPEG file
 *   FFat (ESP32):
 *     upload FFat (FatFS) data with ESP32 Sketch Data Upload:
 *     ESP32: https://github.com/lorol/arduino-esp32fs-plugin
 *   LittleFS (ESP32 / ESP8266 / Pico):
 *     upload LittleFS data with ESP8266 LittleFS Data Upload:
 *     ESP32: https://github.com/lorol/arduino-esp32fs-plugin
 *     ESP8266: https://github.com/earlephilhower/arduino-esp8266littlefs-plugin
 *     Pico: https://github.com/earlephilhower/arduino-pico-littlefs-plugin.git
 *   SPIFFS (ESP32):
 *     upload SPIFFS data with ESP32 Sketch Data Upload:
 *     ESP32: https://github.com/lorol/arduino-esp32fs-plugin
 *   SD:
 *     Most Arduino system built-in support SD file system.
 *     Wio Terminal require extra dependant Libraries:
 *     - Seeed_Arduino_FS: https://github.com/Seeed-Studio/Seeed_Arduino_FS.git
 *     - Seeed_Arduino_SFUD: https://github.com/Seeed-Studio/Seeed_Arduino_SFUD.git
 ******************************************************************************/
#define JPEG_FILENAME "/PIC-1.jpg"

/*******************************************************************************
 * Start of Arduino_GFX setting
 *
 * Arduino_GFX try to find the settings depends on selected board in Arduino IDE
 * Or you can define the display dev kit not in the board list
 * Defalult pin list for non display dev kit:
 * Arduino Nano, Micro and more: CS:  9, DC:  8, RST:  7, BL:  6, SCK: 13, MOSI: 11, MISO: 12
 * ESP32 various dev board     : CS:  5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
 * ESP32-C3 various dev board  : CS:  7, DC:  2, RST:  1, BL:  3, SCK:  4, MOSI:  6, MISO: nil
 * ESP32-S2 various dev board  : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
 * ESP32-S3 various dev board  : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
 * ESP8266 various dev board   : CS: 15, DC:  4, RST:  2, BL:  5, SCK: 14, MOSI: 13, MISO: 12
 * Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
 * RTL8720 BW16 old patch core : CS: 18, DC: 17, RST:  2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
 * RTL8720_BW16 Official core  : CS:  9, DC:  8, RST:  6, BL:  3, SCK: 10, MOSI: 12, MISO: 11
 * RTL8722 dev board           : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
 * RTL8722_mini dev board      : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI:  9, MISO: 10
 * Seeeduino XIAO dev board    : CS:  3, DC:  2, RST:  1, BL:  0, SCK:  8, MOSI: 10, MISO:  9
 * Teensy 4.1 dev board        : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
 ******************************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
#include <FT6336.h>

#define GFX_BL 39  // DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin

/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
//#if defined(DISPLAY_DEV_KIT)
//Arduino_GFX *gfx = create_default_Arduino_GFX();
//#else /* !defined(DISPLAY_DEV_KIT) */

/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
//Arduino_DataBus *bus = create_default_Arduino_DataBus();

/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
//Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false /* IPS */);


Arduino_DataBus *bus = new Arduino_ESP32SPI(12 /* DC/RS */, 46 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */);  //, VSPI /* spi_num */);  funktioniert mit ESP32-S3


Arduino_GFX *gfx = new Arduino_ST7796(bus, 38 /* RST */, 1 /* rotation */);  // funktioniert mit ESP32-S3

//Arduino_Canvas_Indexed *canvasGfx = new Arduino_Canvas_Indexed(480 /* width */, 320 /* height */, gfx);

//#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
 * End of Arduino_GFX setting
 ******************************************************************************/

/* Wio Terminal */
//#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
//#include <Seeed_FS.h>
//#include <SD/Seeed_SD.h>
//#elif defined(TARGET_RP2040) || defined(PICO_RP2350)
//#include <LittleFS.h>
//#include <SD.h>
//#elif defined(ESP32)
#include <FFat.h>
#include <LittleFS.h>
#include <SPIFFS.h>
#include <SD.h>
//#include <SD_MMC.h>
//#elif defined(ESP8266)
//#include <LittleFS.h>
//#include <SD.h>
//#else
//#include <SD.h>
//#endif

#include "JpegFunc.h"

// pixel drawing callback
static int jpegDrawCallback(JPEGDRAW *pDraw) {
  // Serial.printf("Draw pos = %d,%d. size = %d x %d\n", pDraw->x, pDraw->y, pDraw->iWidth, pDraw->iHeight);
  gfx->draw16bitBeRGBBitmap(pDraw->x, pDraw->y, pDraw->pPixels, pDraw->iWidth, pDraw->iHeight);
  return 1;
}

void setup() {
#ifdef DEV_DEVICE_INIT
  DEV_DEVICE_INIT();
#endif

  Serial.begin(115200);
  // Serial.setDebugOutput(true);
  // while(!Serial);
  Serial.println("Arduino_GFX JPEG Image Viewer example");

  // Init Display
  if (!gfx->begin()) {
    Serial.println("gfx->begin() failed!");
  }
  gfx->fillScreen(RGB565_BLACK);

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

/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
  if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(TARGET_RP2040) || defined(PICO_RP2350)
  if (!LittleFS.begin())
  // if (!SD.begin(SS))
#elif defined(ESP32)
  if (!FFat.begin())
  if (!LittleFS.begin())
  if (!SPIFFS.begin())
    SPI.begin(14 /* CLK */, 12 /* D0/MISO */, 13 /* CMD/MOSI */);
  if (!SD.begin(10 /* CS */, SPI))
    pinMode(10 /* CS */, OUTPUT);
  digitalWrite(10 /* CS */, HIGH);
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
  // if (!SD_MMC.begin("/root", true /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_DEFAULT))
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */, 14 /* D1 */, 15 /* D2 */, 10 /* D3/CS */);
  // if (!SD_MMC.begin("/root", false /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_HIGHSPEED))
#elif defined(ESP8266)
  if (!LittleFS.begin())
  if (!SD.begin(SS))
#else
  if (!SD.begin())
#endif
  {
    Serial.println(F("ERROR: File System Mount Failed!"));
    gfx->println(F("ERROR: File System Mount Failed!"));
  } else {
    unsigned long start = millis();
    jpegDraw(JPEG_FILENAME, jpegDrawCallback, true /* useBigEndian */,
             0 /* x */, 0 /* y */, gfx->width() /* widthLimit */, gfx->height() /* heightLimit */);
    Serial.printf("Time used: %lu\n", millis() - start);
  }

  delay(5000);
}

void loop() {
  int w = gfx->width();
  int h = gfx->height();

  unsigned long start = millis();

  jpegDraw(JPEG_FILENAME, jpegDrawCallback, true /* useBigEndian */,
           random(w * 2) - w /* x */,
           random(h * 2) - h /* y */,
           w /* widthLimit */, h /* heightLimit */);

  Serial.printf("Time used: %lu\n", millis() - start);

  delay(1000);
}

und die zugehörige: JpegFunc.h

/*******************************************************************************
 * JPEGDEC related function
 *
 * Dependent libraries:
 * JPEGDEC: https://github.com/bitbank2/JPEGDEC.git
 ******************************************************************************/
#ifndef _JPEGFUNC_H_
#define _JPEGFUNC_H_

#include <JPEGDEC.h>

static JPEGDEC _jpeg;
static File _f;
static int _x, _y, _x_bound, _y_bound;

static void *jpegOpenFile(const char *szFilename, int32_t *pFileSize)
{
    // Serial.println("jpegOpenFile");
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
    _f = SD.open(szFilename, "r");
#elif defined(TARGET_RP2040) || defined(PICO_RP2350)
    _f = LittleFS.open(szFilename, "r");
    // _f = SDFS.open(szFilename, "r");
#elif defined(ESP32)
    // _f = FFat.open(szFilename, "r");
    _f = LittleFS.open(szFilename, "r");
    // _f = SPIFFS.open(szFilename, "r");
    // _f = SD.open(szFilename, "r");
    // _f = SD_MMC.open(szFilename, "r");
#elif defined(ESP8266)
    _f = LittleFS.open(szFilename, "r");
    // _f = SD.open(szFilename, "r");
#else
    _f = SD.open(szFilename, FILE_READ);
#endif
    *pFileSize = _f.size();
    return &_f;
}

static void jpegCloseFile(void *pHandle)
{
    // Serial.println("jpegCloseFile");
    File *f = static_cast<File *>(pHandle);
    f->close();
}

static int32_t jpegReadFile(JPEGFILE *pFile, uint8_t *pBuf, int32_t iLen)
{
    // Serial.printf("jpegReadFile, iLen: %d\n", iLen);
    File *f = static_cast<File *>(pFile->fHandle);
    size_t r = f->read(pBuf, iLen);
    return r;
}

static int32_t jpegSeekFile(JPEGFILE *pFile, int32_t iPosition)
{
    // Serial.printf("jpegSeekFile, pFile->iPos: %d, iPosition: %d\n", pFile->iPos, iPosition);
    File *f = static_cast<File *>(pFile->fHandle);
    f->seek(iPosition);
    return iPosition;
}

static void jpegDraw(
    const char *filename, JPEG_DRAW_CALLBACK *jpegDrawCallback, bool useBigEndian,
    int x, int y, int widthLimit, int heightLimit)
{
    _x = x;
    _y = y;
    _x_bound = _x + widthLimit - 1;
    _y_bound = _y + heightLimit - 1;

    _jpeg.open(filename, jpegOpenFile, jpegCloseFile, jpegReadFile, jpegSeekFile, jpegDrawCallback);

    // scale to fit height
    int _scale;
    int iMaxMCUs;
    float ratio = (float)_jpeg.getHeight() / heightLimit;
    if (ratio <= 1)
    {
        _scale = 0;
        iMaxMCUs = widthLimit / 16;
    }
    else if (ratio <= 2)
    {
        _scale = JPEG_SCALE_HALF;
        iMaxMCUs = widthLimit / 8;
    }
    else if (ratio <= 4)
    {
        _scale = JPEG_SCALE_QUARTER;
        iMaxMCUs = widthLimit / 4;
    }
    else
    {
        _scale = JPEG_SCALE_EIGHTH;
        iMaxMCUs = widthLimit / 2;
    }
    _jpeg.setMaxOutputSize(iMaxMCUs);
    if (useBigEndian)
    {
        _jpeg.setPixelType(RGB565_BIG_ENDIAN);
    }
    _jpeg.decode(x, y, _scale);
    _jpeg.close();
}

#endif // _JPEGFUNC_H_

Ich habe mal die inaktiven Zeilen rausgeworfen:

Vor Zeile 158, also vor der geschweiften Klammer.

Im Original ist nur if (!LittleFS.begin()) aktiv, dann paßt das.

Im Beispiel ImgViewerMjpeg_ESP32_JPEG.ino sieht es nicht besser aus:


  // if (!FFat.begin(false, ROOT))
  if (!LittleFS.begin(false, ROOT))
  // if (!SPIFFS.begin(false, ROOT))
  // SPI.begin(12 /* CLK */, 13 /* D0/MISO */, 11 /* CMD/MOSI */);
  // if (!SD.begin(10 /* CS */, SPI, 80000000L, ROOT))
  // pinMode(10 /* CS */, OUTPUT);
  // digitalWrite(SD_CS, HIGH);
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
  // if (!SD_MMC.begin(ROOT, true /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_DEFAULT))
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */, 14 /* D1 */, 15 /* D2 */, 10 /* D3/CS */);
  // if (!SD_MMC.begin(ROOT, false /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_HIGHSPEED))
  {
    Serial.println(F("ERROR: File System Mount Failed!"));
    gfx->println(F("ERROR: File System Mount Failed!"));
  }
  else
  {
...

Ich weiß nicht, was sich der Bibliotheksentwickler gedacht hat :thinking:

Vermutlich benötigst Du sowas:

  SPI.begin(12 /* CLK */, 13 /* D0/MISO */, 11 /* CMD/MOSI */);
  if (!SD.begin(10 /* CS */, SPI, 80000000L, ROOT))
  {
    Serial.println(F("ERROR: File System Mount Failed!"));
    gfx->println(F("ERROR: File System Mount Failed!"));
  }
  else
  {

Nimm mal das

/*******************************************************************************
 * JPEG Image Viewer
 * This is a simple JPEG image viewer example
 * Image Source: https://github.blog/2014-11-24-from-sticker-to-sculpture-the-making-of-the-octocat-figurine/
 *
 * Dependent libraries:
 * JPEGDEC: https://github.com/bitbank2/JPEGDEC.git
 *
 * Setup steps:
 * 1. Change your LCD parameters in Arduino_GFX setting
 * 2. Upload JPEG file
 *   FFat (ESP32):
 *     upload FFat (FatFS) data with ESP32 Sketch Data Upload:
 *     ESP32: https://github.com/lorol/arduino-esp32fs-plugin
 *   LittleFS (ESP32 / ESP8266 / Pico):
 *     upload LittleFS data with ESP8266 LittleFS Data Upload:
 *     ESP32: https://github.com/lorol/arduino-esp32fs-plugin
 *     ESP8266: https://github.com/earlephilhower/arduino-esp8266littlefs-plugin
 *     Pico: https://github.com/earlephilhower/arduino-pico-littlefs-plugin.git
 *   SPIFFS (ESP32):
 *     upload SPIFFS data with ESP32 Sketch Data Upload:
 *     ESP32: https://github.com/lorol/arduino-esp32fs-plugin
 *   SD:
 *     Most Arduino system built-in support SD file system.
 *     Wio Terminal require extra dependant Libraries:
 *     - Seeed_Arduino_FS: https://github.com/Seeed-Studio/Seeed_Arduino_FS.git
 *     - Seeed_Arduino_SFUD: https://github.com/Seeed-Studio/Seeed_Arduino_SFUD.git
 ******************************************************************************/
#define JPEG_FILENAME "/PIC-1.jpg"

/*******************************************************************************
 * Start of Arduino_GFX setting
 *
 * Arduino_GFX try to find the settings depends on selected board in Arduino IDE
 * Or you can define the display dev kit not in the board list
 * Defalult pin list for non display dev kit:
 * Arduino Nano, Micro and more: CS:  9, DC:  8, RST:  7, BL:  6, SCK: 13, MOSI: 11, MISO: 12
 * ESP32 various dev board     : CS:  5, DC: 27, RST: 33, BL: 22, SCK: 18, MOSI: 23, MISO: nil
 * ESP32-C3 various dev board  : CS:  7, DC:  2, RST:  1, BL:  3, SCK:  4, MOSI:  6, MISO: nil
 * ESP32-S2 various dev board  : CS: 34, DC: 38, RST: 33, BL: 21, SCK: 36, MOSI: 35, MISO: nil
 * ESP32-S3 various dev board  : CS: 40, DC: 41, RST: 42, BL: 48, SCK: 36, MOSI: 35, MISO: nil
 * ESP8266 various dev board   : CS: 15, DC:  4, RST:  2, BL:  5, SCK: 14, MOSI: 13, MISO: 12
 * Raspberry Pi Pico dev board : CS: 17, DC: 27, RST: 26, BL: 28, SCK: 18, MOSI: 19, MISO: 16
 * RTL8720 BW16 old patch core : CS: 18, DC: 17, RST:  2, BL: 23, SCK: 19, MOSI: 21, MISO: 20
 * RTL8720_BW16 Official core  : CS:  9, DC:  8, RST:  6, BL:  3, SCK: 10, MOSI: 12, MISO: 11
 * RTL8722 dev board           : CS: 18, DC: 17, RST: 22, BL: 23, SCK: 13, MOSI: 11, MISO: 12
 * RTL8722_mini dev board      : CS: 12, DC: 14, RST: 15, BL: 13, SCK: 11, MOSI:  9, MISO: 10
 * Seeeduino XIAO dev board    : CS:  3, DC:  2, RST:  1, BL:  0, SCK:  8, MOSI: 10, MISO:  9
 * Teensy 4.1 dev board        : CS: 39, DC: 41, RST: 40, BL: 22, SCK: 13, MOSI: 11, MISO: 12
 ******************************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <U8g2lib.h>
#include <Arduino_GFX_Library.h>
//#include <FT6336.h>

#define GFX_BL 39  // DF_GFX_BL // default backlight pin, you may replace DF_GFX_BL to actual backlight pin

/* More dev device declaration: https://github.com/moononournation/Arduino_GFX/wiki/Dev-Device-Declaration */
//#if defined(DISPLAY_DEV_KIT)
//Arduino_GFX *gfx = create_default_Arduino_GFX();
//#else /* !defined(DISPLAY_DEV_KIT) */

/* More data bus class: https://github.com/moononournation/Arduino_GFX/wiki/Data-Bus-Class */
//Arduino_DataBus *bus = create_default_Arduino_DataBus();

/* More display class: https://github.com/moononournation/Arduino_GFX/wiki/Display-Class */
//Arduino_GFX *gfx = new Arduino_ILI9341(bus, DF_GFX_RST, 3 /* rotation */, false /* IPS */);


Arduino_DataBus *bus = new Arduino_ESP32SPI(12 /* DC/RS */, 46 /* CS */, 14 /* SCK */, 13 /* MOSI */, GFX_NOT_DEFINED /* MISO */);  //, VSPI /* spi_num */);  funktioniert mit ESP32-S3


Arduino_GFX *gfx = new Arduino_ST7796(bus, 38 /* RST */, 1 /* rotation */);  // funktioniert mit ESP32-S3

//Arduino_Canvas_Indexed *canvasGfx = new Arduino_Canvas_Indexed(480 /* width */, 320 /* height */, gfx);

//#endif /* !defined(DISPLAY_DEV_KIT) */
/*******************************************************************************
 * End of Arduino_GFX setting
 ******************************************************************************/

/* Wio Terminal */
//#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
//#include <Seeed_FS.h>
//#include <SD/Seeed_SD.h>
//#elif defined(TARGET_RP2040) || defined(PICO_RP2350)
//#include <LittleFS.h>
//#include <SD.h>
//#elif defined(ESP32)
#include <FFat.h>
#include <LittleFS.h>
//#include <SPIFFS.h>
#include <SD.h>
//#include <SD_MMC.h>
//#elif defined(ESP8266)
//#include <LittleFS.h>
//#include <SD.h>
//#else
//#include <SD.h>
//#endif

#include "JpegFunc.h"

// pixel drawing callback
static int jpegDrawCallback(JPEGDRAW *pDraw) {
  // Serial.printf("Draw pos = %d,%d. size = %d x %d\n", pDraw->x, pDraw->y, pDraw->iWidth, pDraw->iHeight);
  gfx->draw16bitBeRGBBitmap(pDraw->x, pDraw->y, pDraw->pPixels, pDraw->iWidth, pDraw->iHeight);
  return 1;
}

void setup() {
#ifdef DEV_DEVICE_INIT
  DEV_DEVICE_INIT();
#endif

  Serial.begin(115200);
  // Serial.setDebugOutput(true);
  // while(!Serial);
  Serial.println("Arduino_GFX JPEG Image Viewer example");

  // Init Display
  if (!gfx->begin()) {
    Serial.println("gfx->begin() failed!");
  }
  gfx->fillScreen(RGB565_BLACK);

#ifdef GFX_BL
  pinMode(GFX_BL, OUTPUT);
  digitalWrite(GFX_BL, HIGH);
#endif
/* Wio Terminal */
#if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
  if (!SD.begin(SDCARD_SS_PIN, SDCARD_SPI, 4000000UL))
#elif defined(TARGET_RP2040) || defined(PICO_RP2350)
  if (!LittleFS.begin())
  // if (!SD.begin(SS))
#elif defined(ESP32)
  // if (!FFat.begin())
  if (!LittleFS.begin())
  // if (!SPIFFS.begin())
  // SPI.begin(12 /* CLK */, 13 /* D0/MISO */, 11 /* CMD/MOSI */);
  // if (!SD.begin(10 /* CS */, SPI))
  // pinMode(10 /* CS */, OUTPUT);
  // digitalWrite(10 /* CS */, HIGH);
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
  // if (!SD_MMC.begin("/root", true /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_DEFAULT))
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */, 14 /* D1 */, 15 /* D2 */, 10 /* D3/CS */);
  // if (!SD_MMC.begin("/root", false /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_HIGHSPEED))
#elif defined(ESP8266)
  if (!LittleFS.begin())
  // if (!SD.begin(SS))
#else
  if (!SD.begin())
#endif
  {
    Serial.println(F("ERROR: File System Mount Failed!"));
    gfx->println(F("ERROR: File System Mount Failed!"));
  }
  else
  {
    unsigned long start = millis();
    jpegDraw(JPEG_FILENAME, jpegDrawCallback, true /* useBigEndian */,
             0 /* x */, 0 /* y */, gfx->width() /* widthLimit */, gfx->height() /* heightLimit */);
    Serial.printf("Time used: %lu\n", millis() - start);
  }

  delay(5000);
}

void loop() {
  int w = gfx->width();
  int h = gfx->height();

  unsigned long start = millis();

  jpegDraw(JPEG_FILENAME, jpegDrawCallback, true /* useBigEndian */,
           random(w * 2) - w /* x */,
           random(h * 2) - h /* y */,
           w /* widthLimit */, h /* heightLimit */);

  Serial.printf("Time used: %lu\n", millis() - start);

  delay(1000);
}

Kompiliert für ESP32 S3

  Der Sketch verwendet 393869 Bytes (30%) des Programmspeicherplatzes. Das Maximum sind 1310720 Bytes.

Globale Variablen verwenden 37380 Bytes (11%) des dynamischen Speichers, 290300 Bytes für lokale Variablen verbleiben. Das Maximum sind 327680 Bytes.

So an bei, warum nimmst du die Arduino GFX ?
Dein Display ist doch ein 3,5 oder ein 4", da wurde ich die TFT_eSPI nehmen.

if (!LittleFS.begin())

Das paßt meines Erachtens nicht zusammen, LittleFS ist nicht SD. Daher hatte ich in #5 SD.begin vorgeschlagen. LittleFS ist ja bekanntlich das Dateisystem des ESPs. Ob das zusätzlich benötigt wird, wäre zu klären. Es müßte dann in der Speicheraufteilung berücksichtigt werden.

Ja, ich sitze gerade dran und probiere das aus.
Mit deiner Lösung bekomme ich keinen Fehler mehr beim kompilieren lädt auch den auf den S3 und dann bekomme ich wie von mir erwartet auf dem Display die Meldung
ERROR: File System Mount Failed!
Die jpeg liegen ja auf der nicht aktivierten SD Karte,welche über SPI mit dem TFT am ESP hängt.
Deshalb brauche ich wohl diese 5 Zeilen um das dem S3 auch bekannt zu machen

so funktioniert es noch

  if (!SPIFFS.begin())
  SPI.begin(12 /* CLK */, 13 /* D0/MISO */, 11 /* CMD/MOSI */);
  //if (!SD.begin(10 /* CS */, SPI))
  //pinMode(10 /* CS */, OUTPUT);
  //digitalWrite(10 /* CS */, HIGH);

und sobald ich die Zeile mit SD.begin einkommentiere bekomme ich keinen Fehler beim kompilieren aber nur noch komische Streifen auf dem Bildschirm also keinen Text mehr.
Da passiert dann was auf dem SPI.

Sobald ich eine der zwei letzten Zeilen einkommentiere kommt der Fehler

error: 'else' without a previous 'if'
  161 |   } else {

wenn ich das aber so mit pinMode und digitalWrite vor dem SD.begin mache
kommt diese else Fehlermeldung nicht mehr, er kompiliert und schiebt den Coder rüber.
So ist das auch für gleich darunter für die SD_MMC gemacht.

#elif defined(ESP32)
  //if (!FFat.begin())
  //if (!LittleFS.begin())
  if (!SPIFFS.begin())
    SPI.begin(12 /* CLK */, 13 /* D0/MISO */, 11 /* CMD/MOSI */);
  pinMode(10 /* CS */, OUTPUT);
  digitalWrite(10 /* CS */, HIGH);
  if (!SD.begin(10 /* CS */, SPI))
  //pinMode(10 /* CS */, OUTPUT);
  //digitalWrite(10 /* CS */, HIGH);
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */);
  // if (!SD_MMC.begin("/root", true /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_DEFAULT))
  // SD_MMC.setPins(12 /* CLK */, 11 /* CMD/MOSI */, 13 /* D0/MISO */, 14 /* D1 */, 15 /* D2 */, 10 /* D3/CS */);
  // if (!SD_MMC.begin("/root", false /* mode1bit */, false /* format_if_mount_failed */, SDMMC_FREQ_HIGHSPEED))
#elif defined(ESP8266)

Funkioniert aber trotzdem nicht wirklich, im seriellen Monitor kommt

13:59:40.827 -> Arduino_GFX JPEG Image Viewer example
13:59:41.463 -> E (651) SPIFFS: mount failed, -10025
13:59:42.075 -> ERROR: File System Mount Failed!
13:59:47.094 -> Time used: 0

Hat mir dazu jemand eine Idee ?

Ich probiere jetzt auch noch FFat und LittleFS aus ob sich da noch was ändert.

Danke

Du solltest doch erst mal erklären, wozu du Spiffs oder LittleFS benötigst.
Wenn überhaupt, solltest du LittleFS verwenden, da Spiffs nicht mehr unterstützt wird.

Schau mal in Dein jpegOpenFile(). Wenn ESP32 definiert ist, erwartet es das Bild im LITTLEFS:

#elif defined(ESP32)
    // _f = FFat.open(szFilename, "r");
    _f = LittleFS.open(szFilename, "r");
    // _f = SPIFFS.open(szFilename, "r");
    // _f = SD.open(szFilename, "r");
    // _f = SD_MMC.open(szFilename, "r");

Nur wenn keines der angegebenen Systeme definiert ist, landet man Ende von allein in

#else
    _f = SD.open(szFilename, FILE_READ);

Wenn Du also von der SD-Karte lesen willst, lass den ganzen SPIFFS/LITTLEFS-Kram weg und ent-kommentiere die Zeile mit SD.open.

Es ist übrigens auch keine gute Idee, beide Flash-Systeme gleichzeitig anzuziehen:

#include <LittleFS.h>
#include <SPIFFS.h>

SPIFFS ist veraltet, LittleFS ist der Nachfolger.

Ja die TFT_eSPI von Bodmer hatte ich auch schon probiert, auf dem normalen ESP32 hat das auch prima funktioniert aber auf dem ESP32-S3-WROOM-1 N16R8 leider nicht mehr.

Ich habe da auch mehrere kleine 2,8 Zoll TFT mit normalem ESP32 mit TFT_eSPI im Einsatz und verwende die gerne.

Habe dann längere Zeit mit den Beispielen von Bodmer auf dem S3 probiert das aber nicht zum Laufen gebracht.
Das Display ist ein 4.0" SPI TFT C-Touch Modul mit dem Treiber ST7796.
Dabei habe ich hier im Internationalen Forum auch einiges zu meinem Fehlerbild und auch bei Bodmer dazu gefunden das der ESP32-S3 und SPI Displays Probleme machen und das an der ESP32 Boardsoftware liegen soll. Ich nutze da die aktuellste 3.3.2

Deshalb habe ich mal die Arduino GFX probiert und die hat gleich gefunzt.

Habe gerade aber nochmal nach den Quellen für meine Fehlerangaben gesucht und bin hier drauf gestoßen ESP32-S3 Wroom: Probleme mit ESPI
Da wart ihr ja auch schon alle mit involviert, hat das so noch Bestand nur mit der alten 2.0.17
oder geht da auch schon was neueres.

Ja, aus meiner Sicht und meinen letzten Informationen hat das noch Bestand.
Und bitte noch die Frage zu Spiffs und LittleFS beantworten.

Ja das war ja auch mein Gedanke, was brauche ich davon überhaupt, dann habe ich beides zuerst mal einzeln dann zusammen rein genommen, es hat sich aber nichts verändert bzw. verbessert.

Da du nicht beantwortest, wozu du es verwenden könntest, dann lass es einfach weg.
Wie schon mehrfach geschrieben wurde, für die SD-Karte brauchst du es nicht.

OK wie sind die Einstellungen in der IDE? Das meinte ich

Ich habe keine Probleme mit ESP32 S3 + Arduino GFX + LittleFS

Dan warum des ganze mit SPIFS und LittleFS ?
Nimm doch Beispiel für SD., und baue das um.
ach ja hier meine User_Setup für S3 mit TFT_eSPI
User_Setup_S3.h (15.9 KB)
sogar für ST7796

Das sind meine, nahezu identisch zu dir, Partitionsschema ist ja recht unkritisch solange man noch kleine Sketche hat.
Das ist mein Standart welche ich für diverse Prpjekte mit dem S3 nutze.

OK was für Core? Ich nutze nur IDE 1.8.19 mit 2.0.17
Weis nicht ob die Arduino GFX ist freigegeben für Core 3.xx, TFT_eSPI definitiv nicht.
Morgen sollte ich zeit finden + freien ESP32S§ + Display mit ST7796, sollte es noch da sein. Noch was die GFX sollte die 1.6.0 sein

Das überschneidet sich jetzt etwas, aber ich hatte mich gerade drangesetzt.

Da habe ich ein funktionierendes Beispiel mit ESP32-S3 und ST7796:

Beispiel
#include <Streaming.h>      // https://github.com/janelia-arduino/Streaming
#include "FS.h"
#include "SD.h"
#include <SPI.h>
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI();       // Invoke custom library
#define TFT_GREY 0x5AEB // New colour
#define PIN_NEOPIXEL 48

#define SD_CS 9

void setup() {
  Serial.begin(115200);
  tft.init();
  tft.setRotation(2);

  ausgabe();

  if (!SD.begin(SD_CS)) {
    Serial.println("Card Mount Failed");
    return;
  }
  uint8_t cardType = SD.cardType();

  if (cardType == CARD_NONE) {
    Serial.println("No SD card attached");
    return;
  }

  Serial.print("SD Card Type: ");
  if (cardType == CARD_MMC) {
    Serial.println("MMC");
  } else if (cardType == CARD_SD) {
    Serial.println("SDSC");
  } else if (cardType == CARD_SDHC) {
    Serial.println("SDHC");
  } else {
    Serial.println("UNKNOWN");
  }

  uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  Serial.printf("SD Card Size: %lluMB\n", cardSize);

  listDir(SD, "/", 0);
}

void ausgabe() {
  neopixelWrite(PIN_NEOPIXEL, 0, RGB_BRIGHTNESS, 0); // Green
  Serial << "\nStart" << endl;
  Serial << "TFT_CS     : " << TFT_CS   << endl;
  Serial << "TFT_MOSI   : " << TFT_MOSI << endl;
  Serial << "TFT_SCLK   : " << TFT_SCLK << endl;
  Serial << "TFT_MISO   : " << TFT_MISO << endl;
  Serial << "TFT_DC     : " << TFT_DC   << endl;
  Serial << "TFT_RST    : " << TFT_RST  << endl;
  Serial << "TFT_BL     : " << TFT_BL   << endl;
  Serial << "TOUCH_CS   : " << TOUCH_CS << endl;
  Serial << "TFT_WIDTH  : " << TFT_WIDTH  << endl;
  Serial << "TFT_HEIGHT : " << TFT_HEIGHT << endl;
  Serial << "SD-CS      : " << SD_CS    << endl;
}

void loop() {
  neopixelWrite(PIN_NEOPIXEL, 0, 0, RGB_BRIGHTNESS); // Blue
  // Fill screen with random colour so we can see the effect of printing with and without
  // a background colour defined
  tft.fillScreen(random(0xFFFF));
  //tft.fillScreen(TFT_GREY);

  // Set "cursor" at top left corner of display (0,0) and select font 2
  // (cursor will move to next line automatically during printing with 'tft.println'
  //  or stay on the line is there is room for the text with tft.print)
  tft.setCursor(0, 0, 2);
  // Set the font colour to be white with a black background, set text size multiplier to 1
  tft.setTextColor(TFT_WHITE, TFT_BLACK);  tft.setTextSize(1);
  // We can now plot text on screen using the "print" class
  tft.println("Hello World!");

  // Set the font colour to be yellow with no background, set to font 7
  tft.setTextColor(TFT_YELLOW); tft.setTextFont(7);
  tft.println(1234.56);

  // Set the font colour to be red with black background, set to font 4
  tft.setTextColor(TFT_RED, TFT_BLACK);    tft.setTextFont(4);
  tft.println((long)3735928559, HEX); // Should print DEADBEEF

  // Set the font colour to be green with black background, set to font 4
  tft.setTextColor(TFT_GREEN, TFT_BLACK);
  tft.setTextFont(4);
  tft.println("Groop");
  tft.println("I implore thee,");

  // Change to font 2
  tft.setTextFont(2);
  tft.println(F("my foonting turlingdromes.")); // Can store strings in FLASH to save RAM
  tft.println("And hooptiously drangle me");
  tft.println("with crinkly bindlewurdles,");
  // This next line is deliberately made too long for the display width to test
  // automatic text wrapping onto the next line
  tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!");

  // Test some print formatting functions
  float fnumber = 123.45;
  // Set the font colour to be blue with no background, set to font 4
  tft.setTextColor(TFT_BLUE);    tft.setTextFont(4);
  tft.print("Float = "); tft.println(fnumber);           // Print floating point number
  tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
  tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal

  neopixelWrite(PIN_NEOPIXEL, RGB_BRIGHTNESS, 0, 0); // Red
  delay(5000);
}

void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
  Serial.printf("Listing directory: %s\n", dirname);

  File root = fs.open(dirname);
  if (!root) {
    Serial.println("Failed to open directory");
    return;
  }
  if (!root.isDirectory()) {
    Serial.println("Not a directory");
    return;
  }

  File file = root.openNextFile();
  while (file) {
    if (file.isDirectory()) {
      Serial.print("  DIR : ");
      Serial.println(file.name());
      if (levels) {
        listDir(fs, file.path(), levels - 1);
      }
    } else {
      Serial.print("  FILE: ");
      Serial.print(file.name());
      Serial.print("  SIZE: ");
      Serial.println(file.size());
    }
    file = root.openNextFile();
  }
}
Anzeige
Start
TFT_CS     : 10
TFT_MOSI   : 11
TFT_SCLK   : 12
TFT_MISO   : 13
TFT_DC     : 14
TFT_RST    : 5
TFT_BL     : 4
TOUCH_CS   : -1
TFT_WIDTH  : 320
TFT_HEIGHT : 480
SD-CS      : 9
SD Card Type: SDHC
SD Card Size: 3716MB
Listing directory: /
  DIR : System Volume Information
FILE: earth.mjpeg  SIZE: 645355

TFT-CS ist an 10 und SD-CS an 9.

Ich nutze IDE 1.8.19.

die Aktuelle 2.3.6

wie oben erwähnt, ich weiss nicht wofür ich die brauchen könnte,
hab die nur ausprobiert ob sich was verbessert. Ich dachte FS wäre vieleicht was mit Filesystem und damit könnten die Files von der SD Karte geholt werden. Ist aber wohl nicht so.

Danke für das Setup