fs::File::read(uint16_t*, int) - Fehler mit ESP32

Moin,

ich habe ein Projekt aus dem Internet, mit dem man über eine WebApp eine LED Matrix animieren kann. Ausgelegt ist das Projekt für ein Arduino Micro, sollte jedoch auch mit den meisten anderen Boards wie z.B. mit einem ESP 32 klappen.

Lustigerweise funktioniert das Hochladen mit normalen Arduino Boards, jedoch nicht mit meinem ESP 32. Folgende Fehlermeldung taucht immer auf:

Arduino: 1.8.15 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None"

In file included from C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/platforms/esp/32/clockless_rmt_esp32.h:116,

                 from C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/platforms/esp/32/fastled_esp32.h:8,

                 from C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/platforms.h:36,

                 from C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/FastLED.h:52,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:4:

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32/tools/sdk/esp32/include/esp_hw_support/include/esp_intr.h:16:2: warning: #warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead [-Wcpp]

 #warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead

  ^~~~~~~

In file included from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:4:

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/FastLED.h:14:21: note: #pragma message: FastLED version 3.004.000

 #    pragma message "FastLED version 3.004.000"

                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

In file included from C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/FastLED.h:65,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:4:

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/fastspi.h:135:23: note: #pragma message: No hardware SPI pins defined.  All SPI access will default to bitbanged output

 #      pragma message "No hardware SPI pins defined.  All SPI access will default to bitbanged output"

                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino: In function 'void readNextStep(fs::File*)':

LedAppArdu:83:27: error: no matching function for call to 'fs::File::read(uint16_t*, int)'

   file->read(&numColors, 2);

                           ^

In file included from C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\SD\src/SD.h:17,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:3:

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note: candidate: 'virtual int fs::File::read()'

     int read() override;

         ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note:   candidate expects 0 arguments, 2 provided

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note: candidate: 'size_t fs::File::read(uint8_t*, size_t)'

     size_t read(uint8_t* buf, size_t size);

            ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note:   no known conversion for argument 1 from 'uint16_t*' {aka 'short unsigned int*'} to 'uint8_t*' {aka 'unsigned char*'}

LedAppArdu:89:25: error: no matching function for call to 'fs::File::read(CRGB*, int)'

     file->read(&color, 3);

                         ^

In file included from C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\SD\src/SD.h:17,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:3:

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note: candidate: 'virtual int fs::File::read()'

     int read() override;

         ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note:   candidate expects 0 arguments, 2 provided

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note: candidate: 'size_t fs::File::read(uint8_t*, size_t)'

     size_t read(uint8_t* buf, size_t size);

            ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note:   no known conversion for argument 1 from 'CRGB*' to 'uint8_t*' {aka 'unsigned char*'}

LedAppArdu:91:28: error: no matching function for call to 'fs::File::read(uint16_t*, int)'

     file->read(&num_leds, 2);

                            ^

In file included from C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\SD\src/SD.h:17,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:3:

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note: candidate: 'virtual int fs::File::read()'

     int read() override;

         ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note:   candidate expects 0 arguments, 2 provided

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note: candidate: 'size_t fs::File::read(uint8_t*, size_t)'

     size_t read(uint8_t* buf, size_t size);

            ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note:   no known conversion for argument 1 from 'uint16_t*' {aka 'short unsigned int*'} to 'uint8_t*' {aka 'unsigned char*'}

LedAppArdu:96:29: error: no matching function for call to 'fs::File::read(uint16_t*, int)'

       file->read(&led_idx, 2);

                             ^

In file included from C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\SD\src/SD.h:17,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:3:

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note: candidate: 'virtual int fs::File::read()'

     int read() override;

         ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:57:9: note:   candidate expects 0 arguments, 2 provided

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note: candidate: 'size_t fs::File::read(uint8_t*, size_t)'

     size_t read(uint8_t* buf, size_t size);

            ^~~~

C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\FS\src/FS.h:60:12: note:   no known conversion for argument 1 from 'uint16_t*' {aka 'short unsigned int*'} to 'uint8_t*' {aka 'unsigned char*'}

In file included from C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/FastLED.h:48,

                 from C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:4:

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/fastpin.h: In instantiation of 'class FastPin<6>':

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/platforms/esp/32/clockless_rmt_esp32.h:306:23:   required from 'class ClocklessController<6, 60, 150, 90, (EOrder)66, 0, false, 5>'

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/chipsets.h:578:7:   required from 'class WS2812Controller800Khz<6, (EOrder)66>'

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/FastLED.h:103:52:   required from 'class WS2812<6, (EOrder)66>'

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/FastLED.h:302:39:   required from 'static CLEDController& CFastLED::addLeds(CRGB*, int, int) [with CHIPSET = WS2812; unsigned char DATA_PIN = 6; EOrder RGB_ORDER = (EOrder)66]'

C:\Users\Comp\Documents\Arduino\LedAppArdu\LedAppArdu.ino:143:56:   required from here

C:\Users\Comp\Documents\Arduino\libraries\FastLED\src/fastpin.h:210:24: error: static assertion failed: Invalid pin specified

  static_assert(validpin(), "Invalid pin specified");

                ~~~~~~~~^~

Mehrere Bibliotheken wurden für "SD.h" gefunden

 Benutzt: C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\hardware\espressif\esp32\libraries\SD

 Nicht benutzt: C:\Users\Comp\Documents\Arduino\libraries\SD-master

 Nicht benutzt: C:\Users\Comp\Desktop\arduino-1.8.15-windows\arduino-1.8.15\libraries\SD

 Nicht benutzt: C:\Users\Comp\Documents\Arduino\libraries\SD

exit status 1

no matching function for call to 'fs::File::read(uint16_t*, int)'

Leider reichen meine derzeitigen Kenntnisse nicht dafür aus den Fehler zu finden, weswegen ich euch um Hilfe bitte. Ich bin für jede Anregung oder Lösung dankbar :slight_smile:

Hier noch der Code falls relevant:

/* Written guide by bennyd93 (https://github.com/bennyd93): https://github.com/hansjny/Natural-Nerd/blob/master/arduino/readme.md */
#include <SPI.h>
#include <SD.h>
#include <FastLED.h>

#define DATA_PIN 6
#define BUTTON_PIN 2

/* If LEDS_PER_SECTION is 1, the number of sections is your amount of LEDs */
#define ROWS 12

/* LED PIN */
#define LEDS_PER_ROW 32

#define NUM_LEDS LEDS_PER_ROW*ROWS

#define BRIGHTNESS_DIVIDER 3

//The CS pin on the SDCARD
#define CHIP_SELECT SS

CRGB leds[NUM_LEDS];

uint8_t stepsInAnimation = 0;
uint8_t currentStep = 1;
uint16_t bytesRead = 0;


File root;
File readFile;

volatile bool change_animation = false;

unsigned long last_interrupt;
char fname[12];

bool selectFile() {
  File entry = root.openNextFile();
  while(!entry) {
    root.rewindDirectory();
    entry.close();
    entry = root.openNextFile();
  }

  bool found = false;
  memcpy(&fname, entry.name(), strlen(entry.name()) + 1);
  if (fname[strlen(fname) - 1] == 'N' && fname[strlen(fname) - 2] == 'I' && fname[strlen(fname) - 3] == 'B' && fname[strlen(fname) - 4] == '.') {
    found = true;

  }
  entry.close();
  return found;
}

void find_new_animation() {
  int i = 0;
  while(!selectFile()) {
    if (i++ == 100) {
      //This is ugly. It's here so it tries a few times before giving up. 
      break;
    }
  }
  readFile.close();
  readFile = SD.open(fname);
  bytesRead = 0;
  animationInit(readFile);
}

void button_click() 
{
 if (millis() - last_interrupt > 250) {
  last_interrupt = millis();
  change_animation = true;
 }
}


void readNextStep(File *file) 
{
  uint16_t numColors;
  file->read(&numColors, 2);
  bytesRead += 2;
  for (int i = 0; i < numColors; i++) 
  { 
    CRGB color;
    uint16_t num_leds;
    file->read(&color, 3);
    bytesRead+= 3;
    file->read(&num_leds, 2);
    bytesRead += 2;
    uint16_t led_idx;
    for (int j = 0; j < num_leds; j++) 
    {
      file->read(&led_idx, 2);
      bytesRead += 2;
      set_led(led_idx, CRGB(color.r / BRIGHTNESS_DIVIDER, color.g / BRIGHTNESS_DIVIDER, color.b / BRIGHTNESS_DIVIDER));
      
    }
  }
}

void animationInit(File dataFile) {
  if (dataFile) 
  {
    if (dataFile.available()) 
    {
      dataFile.read(&stepsInAnimation, 1);
      bytesRead++;
      readNextStep(&dataFile);
    }
  }
}

void led_clear() 
{
  for (int i = 0; i < NUM_LEDS; i++) 
  {
    leds[i] = CRGB(0, 0, 0);
  }
}

/* This function is here to fix the issue with led strips
 *  going in a snake pattern, and not all starting on the same side,
 *  as well as fixing that the "top" of the led matrix, is the 
 *  bottom when it was soldered. Basically flipping every second
 *  row horizontally, and flipping the entire thing vertically.
 */
void set_led(uint16_t i, CRGB color) {
  uint8_t x;
  uint8_t y;
  y = (ROWS - 1) - (i / LEDS_PER_ROW);
  x = i % LEDS_PER_ROW;  
  if (y % 2 == 0)
    leds[y * LEDS_PER_ROW + x] = color;
  else
    leds[y * LEDS_PER_ROW + (LEDS_PER_ROW - 1) - x] = color;
}

void setup() 
{
  FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
  leds[0] = CRGB(255, 255, 255);

  while (!SD.begin(CHIP_SELECT)) 
  {
    delay(1000);
  }
  
  root = SD.open("/");
  find_new_animation();
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), button_click, FALLING);
}

void readNext(File f) 
{
  //Start from beginning
  if (currentStep >= stepsInAnimation) 
  {
    f.seek(1);
    currentStep = 1;
    bytesRead = 1;
  }
  else 
  {
    currentStep++;
  }
  readNextStep(&f);
}

void loop() {
   if (change_animation) {
    find_new_animation();
    change_animation = false;
   }
   
   led_clear();  
   readNext(readFile);
   FastLED.show();
   delay(100);
}```

Warnung esp_intr.h ist veraltet, bitte fügen Sie esp_intr_alloc.h ein Dies weist Sie an, eine andere Bibliothek zu verwenden. Ich würde dort anfangen.

Wie kommst du da drauf, dass es auch mit einem ESP32 klappen sollte ?
Bedenke, der ESP32 ist mit einer total anderen Hardware bestückt.

Gerade was die Verbindung mit einer Web App (von der ich im Code übrigens nichts sehe) angeht, sollten sich Arduino Micro und ESP unterscheiden.
Auch die SD Library würde ich auf einem ESP nicht verwenden (müssen).