#elif without #if need help please

Hi everyone.
the sketch from: ESP32 cam - Capture and send image over esp-now - YouTube
of 'ImgViewerJpeg' got error, need help please.

the code from 143 to 165 copy from video.

Thanks
Adam

#include <Arduino_GFX_Library.h>

#define GFX_BL 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_GFX *gfx = new Arduino_GC9A01(bus, 7 /* RST */, 3 /* rotation */, true /* IPS */);

#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(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#include <LittleFS.h>
#include <SD.h>
#elif defined(ESP32)
#include <FFat.h>

#include <SPIFFS.h>
#include <SD.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()
{
  Serial.begin(115200);
  // while (!Serial);
  Serial.println("JPEG Image Viewer");

  // Init Display
  gfx->begin();
  gfx->fillScreen(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(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
  if (!LittleFS.begin())
  // if (!SD.begin(SS))
#elif defined(ESP32)
  // if (!FFat.begin())
 //// if (!LittleFS.begin())
   if (!SPIFFS.begin())
  // if (!SD.begin(SS))
#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();

    // read JPEG file header   ////X1 adam 20220914 
    jpegClass.draw(
/* Wio Terminal */ /////////////////////////// THIS SECTION different from: ImgViewerBmp_N

if defined(ARDUINO_ARCH_SAMD) && defined(SEEED_GROVE_UI_WIRELESS)
       &SD,
#elif defined(ARDUINO_RASPBERRY_PI_PICO)
       &LittleFS,
     // &SDFS,
#elif defined(ESP32)
      // &FFat,
     // &LittleFS,
      &SPIFFS,
     // &SD, 
#endif defined(ESP8266)
       &LittleFS,
     // &SDFS,
#else
       &SD,
#endif

       (char *) /* ////X1 adam 20220914 between added by screen of  https://www.youtube.com/watch?v=0s4Bm9Ar42U&t=335s */ 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);
}

ERROR:

Arduino: 1.8.16 (Windows 7), Board: "AI Thinker ESP32-CAM, 240MHz (WiFi/BT), QIO, Huge APP (3MB No OTA/1MB SPIFFS), 80MHz, None"


In file included from C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2Card.h:26,

                 from C:\Program Files (x86)\Arduino\libraries\SD\src/utility/SdFat.h:29,

                 from C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:20,

                 from C:\Users\HUA.DELLV-PC\Documents\Arduino\ImgViewerJpeg_add\ImgViewerJpeg_add.ino:82:

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2PinMap.h:524:2: error: #error Architecture or board not supported.

 #error Architecture or board not supported.

  ^~~~~

ImgViewerJpeg_add:147:2: error: #elif without #if

 #elif defined(ARDUINO_RASPBERRY_PI_PICO)

  ^~~~

ImgViewerJpeg_add:150:2: error: #elif without #if

 #elif defined(ESP32)

  ^~~~

ImgViewerJpeg_add:155:2: error: #endif without #if

 #endif defined(ESP8266)

  ^~~~~

ImgViewerJpeg_add:158:2: error: #else without #if

 #else

  ^~~~

ImgViewerJpeg_add:160:2: error: #endif without #if

 #endif

  ^~~~~

exit status 1

#elif without #if



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

line 145

should be
#If defined...

1 Like

GREAT.
Thank you b707.

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