From 015a946bd0d6dd3c47834ceaf778eb660e843c9f Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 4 Dec 2019 02:17:50 +0000 Subject: [PATCH 1/6] Setup PlatformIO and TravisCI --- .gitignore | 1 + .travis.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/README | 39 +++++++++++++++++++++++++++++ lib/README | 46 ++++++++++++++++++++++++++++++++++ platformio.ini | 41 ++++++++++++++++++++++++++++++ src/main.cpp | 5 ++++ test/README | 11 +++++++++ 7 files changed, 210 insertions(+) create mode 100644 .travis.yml create mode 100644 include/README create mode 100644 lib/README create mode 100644 platformio.ini create mode 100644 src/main.cpp create mode 100644 test/README diff --git a/.gitignore b/.gitignore index db03415..7558808 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .pioenvs +.pio .clang_complete .gcc-flags.json diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c503e81 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +language: python +python: + - "2.7" + +sudo: false +cache: + directories: + - "~/.platformio" + +install: + - pip install -U platformio + - platformio update + +script: + - platformio run -e nodemcuv2 -e esp32 + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/include/README b/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..d2de2c0 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,41 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[common] +lib_deps = + ArduinoJson@5.13.4 + +[env:nodemcuv2] +platform = https://github.com/platformio/platform-espressif8266.git +board = d1_mini +framework = arduino +monitor_speed = 115200 +build_flags = -std=c++11, -Wl,-Teagle.flash.4m3m.ld, -D PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH, -DARDUINO_ARCH_ESP8266 +lib_ldf_mode = deep +board_build.f_flash = 80000000L +upload_speed = 115200 +lib_deps = ${common.lib_deps} +test_filter = embedded + +[env:esp32] +platform = https://github.com/platformio/platform-espressif32.git +board = esp-wrover-kit +framework = arduino +board_build.partitions = noota_3g.csv +build_flags = -std=c++11, -DARDUINO_ARCH_ESP32 +lib_ldf_mode = deep +lib_deps = ${common.lib_deps} +test_filter = embedded + +[env:native] +platform = native +lib_ldf_mode = deep +build_flags = -std=c++11 -DUNIT_TEST +test_filter = common diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..dd251cc --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,5 @@ +#include "ConfigManager.h" + +void setup() { } + +void loop() { } diff --git a/test/README b/test/README new file mode 100644 index 0000000..df5066e --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html From 0d8f8341a986c3fed9861d0edccbb3a3fba23c58 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Fri, 6 Dec 2019 20:22:56 +0000 Subject: [PATCH 2/6] Drop empty directories --- include/README | 39 --------------------------------------- lib/README | 46 ---------------------------------------------- test/README | 11 ----------- 3 files changed, 96 deletions(-) delete mode 100644 include/README delete mode 100644 lib/README delete mode 100644 test/README diff --git a/include/README b/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/test/README b/test/README deleted file mode 100644 index df5066e..0000000 --- a/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PIO Unit Testing and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PIO Unit Testing: -- https://docs.platformio.org/page/plus/unit-testing.html From 2c7453d70409773c38f41c6925674791cef16f41 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Fri, 6 Dec 2019 20:44:15 +0000 Subject: [PATCH 3/6] Use a more modern version of python --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c503e81..a818e6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ language: python python: - - "2.7" + - "3.7.5" sudo: false cache: From eb959fb0a045da6fea64ffa1ba3e9a4bbc87f061 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 11 Dec 2019 18:24:38 +0000 Subject: [PATCH 4/6] Cleanup TravisCI config --- .travis.yml | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index a818e6a..785345f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,17 +13,6 @@ # * User Guide for `platformio ci` command # < https://docs.platformio.org/page/userguide/cmd_ci.html > # -# -# Please choose one of the following templates (proposed below) and uncomment -# it (remove "# " before each line) or use own configuration according to the -# Travis CI documentation (see above). -# - - -# -# Template #1: General project. Test it using existing `platformio.ini`. -# - language: python python: - "3.7.5" @@ -38,30 +27,4 @@ install: - platformio update script: - - platformio run -e nodemcuv2 -e esp32 - - -# -# Template #2: The project is intended to be used as a library with examples. -# - -# language: python -# python: -# - "2.7" -# -# sudo: false -# cache: -# directories: -# - "~/.platformio" -# -# env: -# - PLATFORMIO_CI_SRC=path/to/test/file.c -# - PLATFORMIO_CI_SRC=examples/file.ino -# - PLATFORMIO_CI_SRC=path/to/test/directory -# -# install: -# - pip install -U platformio -# - platformio update -# -# script: -# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N + - platformio ci --lib="./src" -c platformio.ini ./examples/simple/ From 256d1346dc921e41459ca5e23bf82421b2d63060 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 11 Dec 2019 18:39:34 +0000 Subject: [PATCH 5/6] Only need nodemcuv2 and esp32 environments, for now. --- platformio.ini | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/platformio.ini b/platformio.ini index d2de2c0..e52187c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1,12 +1,5 @@ -;PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html +[platformio] +default_envs = nodemcuv2 [common] lib_deps = @@ -33,9 +26,3 @@ build_flags = -std=c++11, -DARDUINO_ARCH_ESP32 lib_ldf_mode = deep lib_deps = ${common.lib_deps} test_filter = embedded - -[env:native] -platform = native -lib_ldf_mode = deep -build_flags = -std=c++11 -DUNIT_TEST -test_filter = common From e8ccad2ebb3ac3bafc21f8c89c75aad0b783a158 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 11 Dec 2019 18:39:55 +0000 Subject: [PATCH 6/6] Don't need main.cpp anymore. --- src/main.cpp | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/main.cpp diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index dd251cc..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "ConfigManager.h" - -void setup() { } - -void loop() { }