Easy Migration from Arduino IDE to Platform IO - Page 1
Forum section: electronics / general

author: jcrubin
author_rank: Frequent Contributor
timestamp: July 18, 2020, 07:24:07 pm
content: As I use more than one IDE for the development of code for the ESP32, I would like to demonstrate, alternatively the benefits of platform IO, as opposed to Arduino IDE, if you are a more seasoned developer who is looking for more features. One will find that the installation and time to get up and running is also significantly quicker by comparison. This is by no means an attack or slight on Arduino IDE, just an alternative. I still use Arduino IDE in many smaller projects and demos, but not for larger complex ones.The video goes into the specifics as to the ground up installation of platform IO and connected to the same TTGO T-display device as in the last project.For this specific demonstration, there will be no importation, I will be doing a cut and paste do demonstrate compatibility, showing all that is required to accomplish this task. Most of which should be obvious. One notable difference is the addition of Arduino.h in the include section which will be needed in platform.io.Another important file platformio.ini allows for a non centralized configuration per project , per device. This is different from Arduino's global based config. This is revisited as library configs and serial speed configs are demonstrated. Libraries are not installed per se, but compiled in on a per project basis. This file provides more value than this, also compile time options, which was useful for TFT_ESPI setting all display parameters within that file under build_flags.As we compile with no errors after our work we end up with the same output product on the device. I do however find a strange issue which ill get into in the follow on video before I expand on Platformio.DEMO CODE and platformio.ini example at:https://technocoma.blogspot.com/p/blog-page_18.html

author: brucehoult
author_rank: Super Contributor
timestamp: July 18, 2020, 08:54:14 pm
content: Nice.If you're having to #include <Arduino.h> yourself then presumably this means choosing the "arduino" framework in platformio doesn't include an Arduino C preprocessor in the build process.That means that you may have to change your C code by reordering functions or adding forward declarations. The Arduino IDE scans your source code and automatically adds forward declarations for everything right after the #include <Arduino.h" that it adds.

author: jcrubin
author_rank: Frequent Contributor
timestamp: July 25, 2020, 01:14:54 pm
content: That's correct , some of my code does require per-declaration or reorder.

author: jcrubin
author_rank: Frequent Contributor
timestamp: July 25, 2020, 01:15:56 pm
content: We continue with part two of the Arduino IDE to PlatformIO series. I'd stopped part 1 becuase in the last video I'd found something unexpected. It would seem that there is an inconsistency between the two but only when serial output is added on the terminal. This is manifested only when the terminal is activated, where the interrupt for GPIO 0 is disabled as it flips to the second window option. If I attempt the reset button after this the result is also unexpected with a waiting for download indication, requiring a second press. While clearly there is something special about GPIO 0 on the TTGO, its not expressed the same between Arduino IDE and platformIO. This was tested by moving that control off to another GPIO and retesting. This move solved the issue.The Code is posted here for others to retry --https://technocoma.blogspot.com/p/test-programme-2-of-2.htmlGetting past this issue, we can talk about some of the reasons I've migrated to PlatformIO, one primary reason being library development which simply doesn't exist in Arduino IDE. Local libraries are easily added into projects as shown. A demonstration of how PlatformIO autocompletes information , methods and parameters is immediately seen, as well as navigation to definitions, constructions , methods, functions.SPIFFS data upload is also simplified in Platform IO with no special add-ons nor software installations allowing for a push from a data directory from within our project. Then requesting Upload file system image. The verbose output of the activity shown that everything worked as expected.Another feature for people creating libraries is GIT integration allowing for library modification and pushing to git in a manner which allows for the library to appear in the Arduino library manager, and by extension also in platformio.At this point developers would be encouraged to discover the many features for themselves.