#include adc.h

frax84
Posts: 42
Joined: Thu Jan 07, 2016 11:26 am

#include adc.h

Postby frax84 » Thu Jan 19, 2017 5:50 pm

Hello,
I'm using Eclipse Neon.2 and i need to use ADC and BLE for my project.
I started from gatt_example and with a little of work i have been able to fully compile and flash the project on my devkit. I'm trying to add the adc part so this is what i did:

1) I added to the "include" paths of the project properties: "${IDF_PATH}/components/driver/include/driver" that is the folder where "adc.h" is
2) I called the needed code (setting width, attenuation and get voltage). Please note that functions have been recognized and can be explored with the hotkey (CTRL+click)

The problem is that when i try to compile i get error "adc.h no such file or directory". Please note that if i CTRL+click on "adc.h" in the include i can explore the library. I just don't understand how is possible that i'm able to explore the files and the function but i get this error.

Any suggestion?
Thank you!
Frax

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: #include adc.h

Postby loboris » Thu Jan 19, 2017 6:04 pm

Add include path ${IDF_PATH}/components/driver/include
and use

Code: Select all

#include "driver/adc.h"

frax84
Posts: 42
Joined: Thu Jan 07, 2016 11:26 am

Re: #include adc.h

Postby frax84 » Fri Jan 20, 2017 9:34 am

It works! Thank you very much.
Can anyone explain me why the way i did was not right?

Frax

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: #include adc.h

Postby kolban » Fri Jan 20, 2017 10:07 am

The Eclipse environment allows us to supply a set of directories which the "editor" searches for entry assist and validation. Thus when you edited your Eclipse environment paths, the editor was able to find them and any warning you had about unresolved includes (as produced by the editor) went away. However, if you are using the out-of-the-box ESP-IDF build system and just running "make" then that uses its own build directories locations that are dynamically located based on the ESP-IDF component concept see ...

http://esp-idf.readthedocs.io/en/latest ... ystem.html

The ESP-IDF build system knows nothing about the paths you set to satisfy the Eclipse editor.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

frax84
Posts: 42
Joined: Thu Jan 07, 2016 11:26 am

Re: #include adc.h

Postby frax84 » Fri Jan 20, 2017 11:20 am

I see,
so, if i well understand, it's not important that the path i set is correct. It's important that the "syntax" i use in the #include is the same one the pre-built ESP-IDF expects. Can you confirm?

Thank you as usual :D
Frax

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: #include adc.h

Postby kolban » Fri Jan 20, 2017 5:12 pm

Frax,
Yes sir ... that's correct. By and large, the directory that is called:

<component>/include

Is added to the include lookup path in the build system.

So if there is a component called XYZ then <XYZ>/include will be in the build path.

If we look at the "driver" component ... we see that it has an include directory which ... itself ... has a directory called "driver" within it ... hence the need to #include <driver/adc.h>
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

frax84
Posts: 42
Joined: Thu Jan 07, 2016 11:26 am

Re: #include adc.h

Postby frax84 » Sat Jan 21, 2017 8:50 am

Understood!
Thank you!

frax

Who is online

Users browsing this forum: metala and 121 guests