diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4d2bde3..c8d4ccb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,30 +66,36 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: arduino/compile-sketches@v1 + - name: Cache pip + uses: actions/cache@v2 with: - verbose: true - fqbn: esp8266:esp8266:nodemcu - platforms: | - - name: esp8266:esp8266 - source-url: http://arduino.esp8266.com/stable/package_esp8266com_index.json - version: 2.7.4 - libraries: | - - name: WiFiManager - version: 2.0.3-alpha - - name: FastLED - version: 3.4.0 - - name: TM1637 - version: 1.2.0 - sketch-paths: | - - firmware/firmware.ino - cli-compile-flags: | - - --export-binaries + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Cache PlatformIO + uses: actions/cache@v2 + with: + path: ~/.platformio + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + + - name: Set up Python + uses: actions/setup-python@v2 + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + + - name: Run PlatformIO + working-directory: ${{github.workspace}}/firmware + run: pio run - uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: firmware/build/esp8266.esp8266.nodemcu/firmware.ino.bin - asset_name: firmware-$tag.ino.nodemcu.bin + file: firmware/.pio/build/nodemcu/firmware.bin + asset_name: firmware-$tag.nodemcu.bin tag: ${{ github.ref }} prerelease: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 63bdb31..fc32d71 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,6 @@ name: Test -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [ push, pull_request ] env: BUILD_TYPE: Debug @@ -33,20 +29,28 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: arduino/compile-sketches@v1 + - name: Cache pip + uses: actions/cache@v2 with: - verbose: true - fqbn: esp8266:esp8266:nodemcu - platforms: | - - name: esp8266:esp8266 - source-url: http://arduino.esp8266.com/stable/package_esp8266com_index.json - version: 2.7.4 - libraries: | - - name: WiFiManager - version: 2.0.3-alpha - - name: FastLED - version: 3.4.0 - - name: TM1637 - version: 1.2.0 - sketch-paths: | - - firmware/firmware.ino + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Cache PlatformIO + uses: actions/cache@v2 + with: + path: ~/.platformio + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + + - name: Set up Python + uses: actions/setup-python@v2 + + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + + - name: Run PlatformIO + working-directory: ${{github.workspace}}/firmware + run: pio run diff --git a/doc/QuickStart.md b/doc/QuickStart.md index 09b6287..7d666f0 100644 --- a/doc/QuickStart.md +++ b/doc/QuickStart.md @@ -26,7 +26,7 @@ This will be referred to `` below. #### Option 1: Download firmware from Releases page -1. Download `firmware-vXXX.ino.nodemcu.bin` from the [Releases] page. +1. Download `firmware-vXXX.nodemcu.bin` from the [Releases] page. 2. Install esptool by running `pip3 install esptool` 3. Run the following command (replacing `` and `` with the appropriate values): @@ -37,8 +37,11 @@ esptool.py --chip esp8266 --port --baud 115200 --before default_reset --a #### Option 2: Compile firmware manually 1. Set up the development environment as described in [this document](../firmware/README.md). -2. Open `firmware.ino` in the Arduino IDE. -3. `Menu` / `Sketch` / `Upload` +2. Run the command + +``` +pio run --target upload --upload-port +``` ### Connect the device to your Wi-Fi network diff --git a/firmware/.gitignore b/firmware/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/firmware/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/firmware/CMakeLists.txt b/firmware/CMakeLists.txt index c8e245d..f277b49 100644 --- a/firmware/CMakeLists.txt +++ b/firmware/CMakeLists.txt @@ -19,9 +19,9 @@ endif() add_library (lib_firmware INTERFACE) target_sources (lib_firmware INTERFACE - stdextra.h - lib_firmware.h - ArduinoJson-v6.18.0.h + include/stdextra.h + include/lib_firmware.h + include/ArduinoJson-v6.18.0.h ) target_include_directories (lib_firmware INTERFACE "${CMAKE_CURRENT_SOURCE_DIRECTORY}") diff --git a/firmware/README.md b/firmware/README.md index 5d6b50e..5fdf55e 100644 --- a/firmware/README.md +++ b/firmware/README.md @@ -1,11 +1,19 @@ -## Setting up arduino for development +## Setting up the development environment -https://www.instructables.com/Steps-to-Setup-Arduino-IDE-for-NODEMCU-ESP8266-WiF/ +The first step is to install PlatformIO by following [this article][platformio-install]. -Libraries to install: -- [WiFiManager by tzapu,tablatronix](https://github.com/tzapu/WiFiManager) -- [FastLED by Daniel Garcia](http://fastled.io) -- [TM1637 by Avishay Orpaz](https://github.com/avishorp/TM1637) +PlatformIO takes care of the following: + +- install cross compiler environment for nodemcu +- install libraries CheckMeet depends on +- compile the project + +The following command needs to be issued to achieve this after PlatformIO +was installed. + +``` +pio run +``` The bootloaders seem to communicate using 74880 baud so we use it as well. @@ -19,6 +27,8 @@ https://github.com/nodemcu/nodemcu-devkit/blob/master/Drivers/CH341SER_WINDOWS.z Note: board is NodeMCU v0.9 +[platformio-install]: https://docs.platformio.org/en/latest//core/installation.html + ## Running the unit tests For Mac (and probably Linux) run the helper script `test.sh`. diff --git a/firmware/catch/catch_firmware.cpp b/firmware/catch/catch_firmware.cpp index 5b20b35..e20fbcb 100644 --- a/firmware/catch/catch_firmware.cpp +++ b/firmware/catch/catch_firmware.cpp @@ -1,6 +1,6 @@ #include "catch.hpp" -#include "lib_firmware.h" +#include "include/lib_firmware.h" TEST_CASE( "rnd() returns 4" ) { REQUIRE( rnd() == 4 ); diff --git a/firmware/catch/catch_serialnames.cpp b/firmware/catch/catch_serialnames.cpp index f5a4d4a..7297497 100644 --- a/firmware/catch/catch_serialnames.cpp +++ b/firmware/catch/catch_serialnames.cpp @@ -1,6 +1,6 @@ #include "catch.hpp" -#include "serialnames.h" +#include "include/serialnames.h" TEST_CASE( "computeNameForId() works" ) { REQUIRE( computeNameForId(0xa451be) == "TealFrenchCuteLion"); diff --git a/firmware/catch/catch_stdextra.cpp b/firmware/catch/catch_stdextra.cpp index 26e29c6..5e4775e 100644 --- a/firmware/catch/catch_stdextra.cpp +++ b/firmware/catch/catch_stdextra.cpp @@ -1,6 +1,6 @@ #include "catch.hpp" -#include "stdextra.h" +#include "include/stdextra.h" TEST_CASE( "fmt() works" ) { REQUIRE( fmt("Hello, %s!", "World") == "Hello, World!" ); diff --git a/firmware/ArduinoJson-v6.18.0.h b/firmware/include/ArduinoJson-v6.18.0.h similarity index 100% rename from firmware/ArduinoJson-v6.18.0.h rename to firmware/include/ArduinoJson-v6.18.0.h diff --git a/firmware/lib_firmware.h b/firmware/include/lib_firmware.h similarity index 100% rename from firmware/lib_firmware.h rename to firmware/include/lib_firmware.h diff --git a/firmware/serialnames.h b/firmware/include/serialnames.h similarity index 100% rename from firmware/serialnames.h rename to firmware/include/serialnames.h diff --git a/firmware/stdextra.h b/firmware/include/stdextra.h similarity index 100% rename from firmware/stdextra.h rename to firmware/include/stdextra.h diff --git a/firmware/platformio.ini b/firmware/platformio.ini new file mode 100644 index 0000000..333c3e5 --- /dev/null +++ b/firmware/platformio.ini @@ -0,0 +1,18 @@ +; 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 + +[env:nodemcu] +platform = espressif8266@2.6.2 +board = nodemcu +framework = arduino +lib_deps = + tzapu/WiFiManager@0.16.0 + fastled/FastLED@3.4.0 + smougenot/TM1637@0.0.0-alpha+sha.9486982048 diff --git a/firmware/firmware.ino b/firmware/src/main.cpp similarity index 100% rename from firmware/firmware.ino rename to firmware/src/main.cpp