espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.42k stars 7.37k forks source link

include esp-dsp header in a sketch #7710

Open parlotto opened 1 year ago

parlotto commented 1 year ago

Board

ESP32 dev module

Device Description

esp32 dev module alone

Hardware Configuration

nothing connected

Version

v2.0.6

IDE Name

Arduino IDE , platformIO

Operating System

linux

Flash frequency

80 MHz

PSRAM enabled

yes

Upload speed

921600

Description

How to correctly include esp-dsp header files in a sktech ? They are in the directory tools/sdk/esp32/include/esp-dsp/modules/iir/include/... but I can't find a way to correctly include them in a sketch. Pointing the absolute location on my disk seams to work but It is not a portable solution.

Sketch

#include "/home/philippe/.arduino15/packages/esp32/hardware/esp32/2.0.6/tools/sdk/esp32/include/esp-dsp/modules/iir/include/dsps_biquad_gen.h" 

void setup() {
  Serial.begin(115200);
  float coeffs[15]={0},f=0.4,qFactor=4;
dsps_biquad_gen_lpf_f32(coeffs, f,  qFactor);

for (int i=0;i<15;i++){
  Serial.printf("%f \n",coeffs[i]);
}
}

void loop() {

}

Debug Message

# with the ugly include line I have this error
/home/philippe/Arduino/sketch_jan12a/sketch_jan12a.ino: In function 'void setup()':
sketch_jan12a:6:1: error: 'dsps_biquad_gen_lpf_f32' was not declared in this scope
 dsps_biquad_gen_lpf_f32(coeffs, f,  qFactor);
 ^~~~~~~~~~~~~~~~~~~~~~~
exit status 1
'dsps_biquad_gen_lpf_f32' was not declared in this scope

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

parlotto commented 1 year ago

Sorry, I was using arduino 1.8. It works on arduino 2.0.3 by simply a #include But still not make it work on platformIO.

Jason2866 commented 1 year ago

Nothing special for Platformio. This works.

#include <Arduino.h>
#include <dsps_biquad_gen.h>

void setup() {
  Serial.begin(115200);
  float coeffs[15]={0},f=0.4,qFactor=4;
dsps_biquad_gen_lpf_f32(coeffs, f,  qFactor);

for (int i=0;i<15;i++){
  Serial.printf("%f \n",coeffs[i]);
}
}

void loop() {

}
parlotto commented 1 year ago

in Platformio I still have an error :

src/main.cpp:3:29: fatal error: dsps_biquad_gen.h: No such file or directory

platformio.ini content is :

[env:lolin_d32] platform = https://github.com/platformio/platform-espressif32.git board = lolin_d32 framework = arduino monitor_speed = 115200 monitor_filters = esp32_exception_decoder arduino-esp32.gitframework = arduino

mrengineer7777 commented 1 year ago

Try this environment: [env:lolin_d32_test] board = lolin_d32 monitor_speed = 115200 platform = espressif32 framework = arduino monitor_filters = esp32_exception_decoder

Also try closing and reopening VSCode. PIO manages the include paths for VSCode, but sometimes it takes reopening VSCode for them to be fixed.

parlotto commented 1 year ago

Same error with this environment even after restarting VSCode. thank you for you help

mrengineer7777 commented 1 year ago

The following compiles for me.

platformio.ini

[env:lolin_d32_test]
board = lolin_d32
monitor_speed = 115200
platform = espressif32
framework = arduino
monitor_filters = esp32_exception_decoder

main.cpp

#include <Arduino.h>
#include "dsps_biquad_gen.h" 

void setup() {
  Serial.begin(115200);
  float coeffs[15]={0},f=0.4,qFactor=4;
dsps_biquad_gen_lpf_f32(coeffs, f,  qFactor);

for (int i=0;i<15;i++){
  Serial.printf("%f \n",coeffs[i]);
}
}

void loop() {
}
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.3% (used 13944 bytes from 327680 bytes)
Flash: [=         ]  11.0% (used 144777 bytes from 1310720 bytes)
Building .pio\build\lolin_d32_test\firmware.bin
esptool.py v4.3
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.