IDF Component

User avatar
urbanze
Posts: 269
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

IDF Component

Postby urbanze » Tue Sep 12, 2017 2:14 am

Hi guys! I have a big simple question. Why in IDF Component tutorial (https://github.com/espressif/arduino-es ... mponent.md) , if I don't select arduino auto start, I need to put "InitArduino()" in app_main, why? What that do? I try with and without this function, and both worked very well and similar.

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

Re: IDF Component

Postby kolban » Tue Sep 12, 2017 3:11 am

When I read docs and the developer provides "instructions" on how to setup, I usually trust their judgement on what that means. If we look at the following source code:

https://github.com/espressif/arduino-es ... misc.c#L80

We see what initArduino() apparently does. It doesn't look very big and at a minimum, it seems to initialize NVS flash support and then call init() and initVariant(). So that's "technically" what it does. Logically, I think the intent is to perform whatever initialization the Arduino libraries may need.

If we look at the auto start code found here:

https://github.com/espressif/arduino-es ... in.cpp#L24

We see it does the same thing (i.e. calls initArduino() before passing control to setup/loop.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
urbanze
Posts: 269
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: IDF Component

Postby urbanze » Tue Sep 12, 2017 12:03 pm

kolban wrote:When I read docs and the developer provides "instructions" on how to setup, I usually trust their judgement on what that means. If we look at the following source code:

https://github.com/espressif/arduino-es ... misc.c#L80

We see what initArduino() apparently does. It doesn't look very big and at a minimum, it seems to initialize NVS flash support and then call init() and initVariant(). So that's "technically" what it does. Logically, I think the intent is to perform whatever initialization the Arduino libraries may need.

If we look at the auto start code found here:

https://github.com/espressif/arduino-es ... in.cpp#L24

We see it does the same thing (i.e. calls initArduino() before passing control to setup/loop.
Yeah, I see this code's, thank's for reply! I will test some arduino libraries with and without this function to see what happens and post observations ..

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

Re: IDF Component

Postby kolban » Tue Sep 12, 2017 2:25 pm

I'm of a mind set that says if the developer of a library says "call XYZ()" before using the library then I had better "call XYZ()" before using it. I'm afraid I'm missing the notion of even asking the question "Why are we calling XYZ()"?

My doctor told me, "Don't drink grapefruit juice while taking this medicine". I have no intention of drinking grapefruit juice while taking the drug "just to see what happens" :-)
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

User avatar
urbanze
Posts: 269
Joined: Sat Jun 10, 2017 9:55 pm
Location: Brazil

Re: IDF Component

Postby urbanze » Tue Sep 12, 2017 4:30 pm

kolban wrote:I'm of a mind set that says if the developer of a library says "call XYZ()" before using the library then I had better "call XYZ()" before using it. I'm afraid I'm missing the notion of even asking the question "Why are we calling XYZ()"?

My doctor told me, "Don't drink grapefruit juice while taking this medicine". I have no intention of drinking grapefruit juice while taking the drug "just to see what happens" :-)
Of course, developers who understand better and tell us what to do, exactly like their medical example, however it is interesting to understand the reasons for future if necessary, identify errors, bugs or methods to increase code effectiveness. For now, all tests I did with some libraries of Arduino core worked without any problems .. I will continue to analyze.

Who is online

Users browsing this forum: No registered users and 41 guests