Skip to content

Commit

Permalink
Docs: Fix Arduino as IDF Component instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz committed Dec 14, 2023
1 parent 29cde94 commit 6d5c388
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docs/source/esp-idf_component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,17 @@ After the setup you can save and exit:
- Close confirmation window [Enter] or [Space] or [Esc]
- Quit [Q]

Option 1. Using Arduino setup() and loop()
******************************************
As the Arduino libraries use C++ features, you will need to swap some file extensions from ``.c`` to ``.cpp``:

- In main folder rename file `main.c` to `main.cpp`.
- In main folder open file `CMakeLists.txt` and change `main.c` to `main.cpp` as described below.

- In main folder open file `CMakeList.txt` and change `main.c` to `main.cpp` as described below.
Option 1. Using Arduino setup() and loop()
******************************************

- Your main.cpp should be formatted like any other sketch.
Your main.cpp should be formatted like any other sketch. Don't forget to include ``Arduino.h``.

.. code-block:: c
.. code-block:: cpp
//file: main.cpp
#include "Arduino.h"
Expand All @@ -102,14 +103,14 @@ Option 1. Using Arduino setup() and loop()
Option 2. Using ESP-IDF appmain()
*********************************

In main.c or main.cpp you need to implement ``app_main()`` and call ``initArduino();`` in it.
In main.cpp you need to implement ``app_main()`` and call ``initArduino();`` in it.

Keep in mind that setup() and loop() will not be called in this case.
Furthermore the ``app_main()`` is single execution as a normal function so if you need an infinite loop as in Arduino place it there.

.. code-block:: cpp
//file: main.c or main.cpp
//file: main.cpp
#include "Arduino.h"
extern "C" void app_main()
Expand Down Expand Up @@ -141,7 +142,7 @@ Build, flash and monitor

- After a successful flash, you may need to press the RST button again

- To terminate the serial monitor press [Ctrl] + [ ] ]
- To terminate the serial monitor press ``Ctrl`` + ``]``

Logging To Serial
-----------------
Expand Down Expand Up @@ -179,7 +180,7 @@ Download the library:

.. code-block:: bash
cd ~/esp/esp-idf/components/arduino-esp32/
cd ~/esp/esp-idf/components/arduino/
git clone --recursive git@github.com:Author/new_library.git libraries/new_library
Expand Down

0 comments on commit 6d5c388

Please sign in to comment.