Skip to content

Commit c0c687c

Browse files
authored
Docs: Fix Arduino as IDF Component instructions (espressif#9001)
1 parent da6325d commit c0c687c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Diff for: docs/en/esp-idf_component.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ After the setup you can save and exit:
7373
- Close confirmation window [Enter] or [Space] or [Esc]
7474
- Quit [Q]
7575

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

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

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

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

85-
.. code-block:: c
86+
.. code-block:: cpp
8687
8788
//file: main.cpp
8889
#include "Arduino.h"
@@ -102,14 +103,14 @@ Option 1. Using Arduino setup() and loop()
102103
Option 2. Using ESP-IDF appmain()
103104
*********************************
104105

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

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

110111
.. code-block:: cpp
111112
112-
//file: main.c or main.cpp
113+
//file: main.cpp
113114
#include "Arduino.h"
114115
115116
extern "C" void app_main()
@@ -141,7 +142,7 @@ Build, flash and monitor
141142

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

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

146147
Logging To Serial
147148
-----------------
@@ -179,7 +180,7 @@ Download the library:
179180

180181
.. code-block:: bash
181182
182-
cd ~/esp/esp-idf/components/arduino-esp32/
183+
cd ~/esp/esp-idf/components/arduino/
183184
git clone --recursive git@github.com:Author/new_library.git libraries/new_library
184185
185186

0 commit comments

Comments
 (0)