Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Fix Arduino as IDF Component instructions #9001

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions docs/en/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 [email protected]:Author/new_library.git libraries/new_library


Expand Down
Loading