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

platformio init #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
44 changes: 7 additions & 37 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,31 @@
branches:
- master
workflow_dispatch:
env:
SKETCHES_REPORTS_PATH: sketches-reports
SKETCHES_REPORTS_ARTIFACT_NAME: sketches-reports
jobs:
compile_firmware:
compile_grid_detector:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Compile firmware
- name: Compile Grid Detector firmware
uses: ./.github/workflows/firmware-compile
with:
enable-warnings-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
project-folder: grid_detector
- name: Copy bin file
run: |
cp -f ${{ github.workspace }}/src/grid_detector/build/esp32.esp32.esp32/grid_detector.ino.bin ${{ github.workspace }}/grid_detector.bin
cp -f ${{ github.workspace }}/grid_detector/.pio/build/grid_detector/firmware.bin ${{ github.workspace }}/grid_detector.bin
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
name: grid_detector.bin
path: ${{ github.workspace }}/grid_detector.bin
- name: Upload reports
uses: actions/upload-artifact@v4
with:
name: ${{ env.SKETCHES_REPORTS_ARTIFACT_NAME }}
path: ${{ env.SKETCHES_REPORTS_PATH }}
memory_usage_change:
compile_flasher:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Memory usage change
- name: Compile Flasher firmware
uses: ./.github/workflows/firmware-compile
with:
enable-deltas-report: true
- name: Report Delta to PR
uses: arduino/report-size-deltas@v1
lint_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint check
uses: arduino/arduino-lint-action@v1
with:
path: ${{ github.workspace }}/src/grid_detector
verbose: true
compliance: specification
report-file: ${{ github.workspace }}/lint-report.json
- name: Upload lint report
uses: actions/upload-artifact@v4
with:
name: lint-report
path: ${{ github.workspace }}/lint-report.json
project-folder: flasher
# run_black:
# runs-on: ubuntu-latest
# steps:
Expand Down
58 changes: 21 additions & 37 deletions .github/workflows/firmware-compile/action.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
name: 'Firmware Compile Action'
description: 'Unzip libraries and compile firmware'
description: 'Compile firmware'
inputs:
enable-warnings-report:
description: 'Enable warnings report'
default: 'false'
enable-deltas-report:
description: 'Enable deltas report'
default: 'false'
sketches-report-path:
description: 'Sketches report path'
default: 'sketches-reports'
project-folder:
description: 'Project folder'
default: 'grid_detector'
permissions:
contents: read
pull-requests: write
runs:
using: 'composite'
steps:
- name: Unzip libraries
shell: bash
run: |
unzip -q ${{ github.workspace }}/libs/ArduinoAsync-master.zip -d ${{ github.workspace }}/libs/
- name: Compile firmware
uses: arduino/compile-sketches@v1
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio-${{ hashFiles(format('{0}/{1}', inputs.project-folder, 'platformio.ini')) }}
- uses: actions/setup-python@v5
with:
sketch-paths: |
- ${{ github.workspace }}/src/grid_detector
fqbn: esp32:esp32:esp32
platforms: |
- name: esp32:esp32
source-url: https://github.com/espressif/arduino-esp32/releases/download/2.0.17/package_esp32_index.json
version: 2.0.17
libraries: |
- source-path: ${{ github.workspace }}/libs/ArduinoAsync-master
- name: ArduinoJson
version: 7.0.4
- name: ArduinoWebsockets
version: 0.5.3
- name: WiFiManager
version: 2.0.17
enable-warnings-report: ${{ inputs.enable-warnings-report }}
enable-deltas-report: ${{ inputs.enable-deltas-report }}
sketches-report-path: ${{ inputs.sketches-report-path }}
cli-compile-flags: |
- --export-binaries
- --warnings=default
python-version: '3.12'
- name: Install PlatformIO Core
shell: bash
run: pip install --upgrade platformio
- name: Build ${{ inputs.project-folder }}
shell: bash
run: pio run -d ${{ inputs.project-folder }}
24 changes: 14 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ jobs:
uses: actions/checkout@v4
- name: Replace version and connection type in firmware source
run: |
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/#define WIFI ./#define WIFI 1/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/#define ETHERNET ./#define ETHERNET 0/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
sed -i 's/#define WIFI ./#define WIFI 1/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
sed -i 's/#define ETHERNET ./#define ETHERNET 0/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
- name: Compile firmware
uses: ./.github/workflows/firmware-compile
with:
project-folder: grid_detector
- name: Copy bin to upload
run: |
cp -f ${{ github.workspace }}/src/grid_detector/build/esp32.esp32.esp32/grid_detector.ino.bin ${{ github.workspace }}/Grid_Detector_WiFi_${{ inputs.release-version }}.bin
cp -f ${{ github.workspace }}/grid_detector/.pio/build/grid_detector/firmware.bin ${{ github.workspace }}/Grid_Detector_WiFi_${{ inputs.release-version }}.bin
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
Expand All @@ -37,14 +39,16 @@ jobs:
uses: actions/checkout@v4
- name: Replace version and connection type in firmware source
run: |
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/#define WIFI ./#define WIFI 0/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/#define ETHERNET ./#define ETHERNET 1/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
sed -i 's/#define WIFI ./#define WIFI 0/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
sed -i 's/#define ETHERNET ./#define ETHERNET 1/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
- name: Compile firmware
uses: ./.github/workflows/firmware-compile
with:
project-folder: grid_detector
- name: Copy bin to upload
run: |
cp -f ${{ github.workspace }}/src/grid_detector/build/esp32.esp32.esp32/grid_detector.ino.bin ${{ github.workspace }}/Grid_Detector_ETH_${{ inputs.release-version }}.bin
cp -f ${{ github.workspace }}/grid_detector/.pio/build/grid_detector/firmware.bin ${{ github.workspace }}/Grid_Detector_ETH_${{ inputs.release-version }}.bin
- name: Upload firmware
uses: actions/upload-artifact@v4
with:
Expand All @@ -61,7 +65,7 @@ jobs:
uses: actions/checkout@v4
- name: Replace version in firmware source
run: |
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/src/grid_detector/grid_detector.ino
sed -i 's/VERSION = ".*";/VERSION = "${{ inputs.release-version }}";/' ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
- name: Download firmware WiFi
uses: actions/download-artifact@v4
with:
Expand All @@ -77,7 +81,7 @@ jobs:
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Release ${{ inputs.release-version }}"
file_pattern: ${{ github.workspace }}/src/grid_detector/grid_detector.ino
file_pattern: ${{ github.workspace }}/grid_detector/src/GridDetector.cpp
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
Expand Down
5 changes: 5 additions & 0 deletions flasher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
18 changes: 18 additions & 0 deletions flasher/platformio.ini
Original file line number Diff line number Diff line change
@@ -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:flasher]
platform = [email protected]
board = esp32dev
framework = arduino
monitor_speed = 115200
; board_build.partitions = min_spiffs.csv
; lib_deps =
; https://github.com/tzapu/[email protected]
24 changes: 12 additions & 12 deletions src/id_flasher/id_flasher.ino → flasher/src/IdFlasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ const char* firmwareUrl = ""; // http firmware URL

String identifier = "changeme"; //change identifier to actual value

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");

updateFirmware();
}

void updateFirmware() {
preferences.begin("storage", false);
preferences.putString("id", identifier);
Expand Down Expand Up @@ -71,3 +59,15 @@ void updateFirmware() {

void loop() {
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");

updateFirmware();
}
5 changes: 5 additions & 0 deletions grid_detector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
21 changes: 21 additions & 0 deletions grid_detector/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; 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:grid_detector]
platform = [email protected]
board = esp32dev
framework = arduino
monitor_speed = 115200
; board_build.partitions = min_spiffs.csv
lib_deps =
https://github.com/MatheusAlvesA/ArduinoAsync.git
https://github.com/bblanchon/[email protected]
https://github.com/gilmaimon/[email protected]
https://github.com/tzapu/[email protected]
Loading