Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/compile-blink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# CHANGE program/lib/aux as needed
program:
- src: 'blink'
lib: 'DeviceNameHelperRK MyLib'
lib: 'DeviceNameHelperRK/src MyLib/src'
aux: ''
# CHANGE platforms as needed
platform:
Expand All @@ -31,6 +31,7 @@ jobs:

# workflow call
uses: ./.github/workflows/compile.yaml
secrets: inherit
with:
platform: ${{ matrix.platform.name }}
version: ${{ matrix.platform.version }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/compile-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# CHANGE program/lib/aux as needed
program:
- src: 'controller'
lib: 'LoggerCore DeviceNameHelperRK FileHelperRK SequentialFileRK PublishQueueExtRK SparkFun_Qwiic_OpenLog_Arduino_Library'
lib: 'LoggerCore/src DeviceNameHelperRK/src FileHelperRK/src SequentialFileRK/src PublishQueueExtRK/src SparkFun_Qwiic_OpenLog_Arduino_Library/src'
aux: ''
# CHANGE platforms as needed
platform:
Expand All @@ -30,6 +30,7 @@ jobs:

# workflow call
uses: ./.github/workflows/compile.yaml
secrets: inherit
with:
platform: ${{ matrix.platform.name }}
version: ${{ matrix.platform.version }}
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/compile-i2c_scanner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# name of the job
name: Compile i2c scanner

# specify which paths to watch for changes
on:
push:
paths:
- src/i2c_scanner
- .github/workflows/compile.yaml
- .github/workflows/compile-i2c_scanner.yaml

# run compile via the compile.yaml
jobs:
compile:
strategy:
fail-fast: false
matrix:
# CHANGE program/lib/aux as needed
program:
- src: 'i2c_scanner'
lib: ''
aux: ''
# CHANGE platforms as needed
platform:
- {name: 'photon', version: '2.3.1'}
- {name: 'argon', version: '4.2.0'}
- {name: 'p2', version: '6.3.2'}

# program name
name: ${{ matrix.program.src }}-${{ matrix.platform.name }}-${{ matrix.platform.version }}

# workflow call
uses: ./.github/workflows/compile.yaml
secrets: inherit
with:
platform: ${{ matrix.platform.name }}
version: ${{ matrix.platform.version }}
src: ${{ matrix.program.src }}
lib: ${{ matrix.program.lib }}
aux: ${{ matrix.program.aux }}
3 changes: 2 additions & 1 deletion .github/workflows/compile-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# CHANGE program/lib/aux as needed
program:
- src: 'publish'
lib: 'DeviceNameHelperRK FileHelperRK SequentialFileRK PublishQueueExtRK SparkFun_Qwiic_OpenLog_Arduino_Library'
lib: 'DeviceNameHelperRK/src FileHelperRK/src SequentialFileRK/src PublishQueueExtRK/src SparkFun_Qwiic_OpenLog_Arduino_Library/src'
aux: 'LoggerCore/src/LoggerPlatform* LoggerCore/src/LoggerUtils* LoggerCore/src/LoggerPublisher* LoggerCore/src/LoggerSD*'
# CHANGE platforms as needed
platform:
Expand All @@ -30,6 +30,7 @@ jobs:

# workflow call
uses: ./.github/workflows/compile.yaml
secrets: inherit
with:
platform: ${{ matrix.platform.name }}
version: ${{ matrix.platform.version }}
Expand Down
40 changes: 24 additions & 16 deletions .github/workflows/compile.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Compile Firmware
name: Base workflow_call for compile actions

on:
workflow_call:
Expand Down Expand Up @@ -41,13 +41,13 @@ jobs:
echo "Including libraries:"
for lib in ${{ inputs.lib }}; do
if [ -d "$lib" ]; then
echo " - $lib/src/*"
mv $lib/src/* ${{ inputs.src }}
echo " - $lib/*"
mv $lib/* ${{ inputs.src }}
elif [ -d "lib/$lib" ]; then
echo " - lib/$lib/src/*"
mv lib/$lib/src/* ${{ inputs.src }}
echo " - lib/$lib/*"
mv lib/$lib/* ${{ inputs.src }}
else
echo " - could not find $lib, make sure the library exists"
echo " - could not find $lib, make sure the folder exists"
fi
done
echo "Including auxiliary resources:"
Expand All @@ -56,7 +56,8 @@ jobs:
mv $aux ${{ inputs.src }}
done

- name: Compile in cloud
- name: Compile in cloud (on master)
if: ${{ github.ref == 'refs/heads/master' }}
id: compile
uses: particle-iot/compile-action@v1
with:
Expand All @@ -65,20 +66,27 @@ jobs:
device-os-version: ${{ inputs.version }}
sources-folder: ${{ inputs.src }}

- name: Move binary
- name: Move cloud binary
if: ${{ github.ref == 'refs/heads/master' }}
run: |
mv ${{ steps.compile.outputs.firmware-path }} ${{ inputs.src }}/${{ inputs.src }}-${{ inputs.platform }}-${{ inputs.version }}.bin

- name: Compile locally # if not on master or if cloud compile failed
if: ${{ failure() || github.ref != 'refs/heads/master' }}
id: localcompile
uses: particle-iot/compile-action@v1
with:
particle-platform-name: ${{ inputs.platform }}
device-os-version: ${{ inputs.version }}
sources-folder: ${{ inputs.src }}

- name: Move local binary
if: ${{ github.ref != 'refs/heads/master' }}
run: |
mv ${{ steps.localcompile.outputs.firmware-path }} ${{ inputs.src }}/${{ inputs.src }}-${{ inputs.platform }}-${{ inputs.version }}.bin

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.src }}-${{ inputs.platform }}-${{ inputs.version }}
path: ${{ inputs.src }}

- name: Compile locally to debug
if: ${{ failure() }}
uses: particle-iot/compile-action@v1
with:
particle-platform-name: ${{ inputs.platform }}
device-os-version: ${{ inputs.version }}
sources-folder: ${{ inputs.src }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ bin/*.bin
.DS_Store

# gemfile
Gemfile.lock
Gemfile.lock

# credentials
credentials
79 changes: 79 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"C_Cpp.default.configurationProvider": "particle.particle-vscode-core",
"C_Cpp.errorSquiggles": "enabled",
"C_Cpp.dimInactiveRegions": false,
"particle.targetPlatform": "p2", // needs to be defined for IntelliSense to work
"particle.firmwareVersion": "6.2.1", // needs to be defined for IntelliSense to work
"editor.tabSize": 4,
"files.associations": {
"__config": "cpp",
"__cxx_version": "cpp",
"__locale": "cpp",
"cstdlib": "cpp",
"memory_resource": "cpp",
"locale": "cpp",
"ostream": "cpp",
"system_error": "cpp",
"typeinfo": "cpp",
"vector": "cpp",
"__bit_reference": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__functional_base": "cpp",
"__hash_table": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tuple": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"cmath": "cpp",
"complex": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"__memory": "cpp",
"__functional_03": "cpp",
"*.hold": "cpp",
"__verbose_abort": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"span": "cpp",
"variant": "cpp"
}
}
7 changes: 4 additions & 3 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ bin_folder = "bin"

# program
last_bin = Dir.glob(File.join(bin_folder, '*.bin')).select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
program = File.basename(last_bin).split('-').first
puts "\nINFO: Setting up guard to re-compile '#{program}' when there are code changes in:"
program, platform, version = File.basename(last_bin).split('-')
version = version.chomp('.bin')
puts "\nINFO: Setting up guard to re-compile '#{program}' for #{platform} #{version} when there are code changes in:"

# workflow
workflow_path = File.join(".github", "workflows", "compile-#{program}.yaml")
Expand All @@ -32,7 +33,7 @@ end
puts "\n"

# guard
guard 'rake', :task => 'autoCompile', :run_on_start => false, wait_for_changes: true, :task_args => [program] do
guard 'rake', :task => 'autoCompile', :run_on_start => false, wait_for_changes: true, :task_args => [program, platform, version] do
watch_paths.each do |pattern|
watch(Regexp.new(pattern))
end
Expand Down
5 changes: 5 additions & 0 deletions LoggerCore/src/LoggerPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

#include "Particle.h"

// address issue where this is not defined anymore in newer firmware
#ifndef PLATFORM_PHOTON
#define PLATFORM_PHOTON 0
#endif

// file helper to get at flash system usage
// dependencies.FileHelperRK=0.0.3
#include "FileHelperRK.h"
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The following firmware is included in the repository to provide frequently used
| Program | *main* branch | *dev* branch |
| :------- | :--- | :--- |
| blink | ![blink](https://github.com/KopfLab/LabLoggerLibs/actions/workflows/compile-blink.yaml/badge.svg?branch=main) | ![blink-dev](https://github.com/KopfLab/LabLoggerLibs/actions/workflows/compile-blink.yaml/badge.svg?branch=dev) |
| i2c_scanner | ![blink](https://github.com/KopfLab/LabLoggerLibs/actions/workflows/compile-i2c_scanner.yaml/badge.svg?branch=main) | ![blink-dev](https://github.com/KopfLab/LabLoggerLibs/actions/workflows/compile-i2c_scanner.yaml/badge.svg?branch=dev) |
| publish | ![publish](https://github.com/KopfLab/LabLoggerLibs/actions/workflows/compile-publish.yaml/badge.svg?branch=main) | ![publish-dev](https://github.com/KopfLab/LabLoggerLibs/actions/workflows/compile-publish.yaml/badge.svg?branch=dev) |

### Compile
Expand Down Expand Up @@ -53,6 +54,17 @@ The configuration for individual programs is managed via their compile workflow

The workflow YAML additionally specifies which folders to watch for changes to trigger the automatic rebuild on GitHub in the `push` -> `paths` setting. This information is also used by the [Guardfile](Guardfile) to figure out which files should trigger an automatic rebuild during development. Use `rake PROGRAM` to compile a program for the first time and then activate automatic re-compiles by running `bundle exec guard`. It will figure out which program was last build, pull the folders to watch out of the workflow YAML and trigger re-compile if anything changes.

To add a new program (`myprog`):

- work in a development git branch (e.g. `dev-myprog`)
- create a sub folder `src/myprog` that includes a `project.properties` file with `name=myprog` and a list of commented out dependencies
- if there are any new dependencies, add them to the table at the end of the `README.md`, and as git submodules in the lib/ folder via `cd lib` + `git submodule add https://github.com/...`
- add a YAML workflow for github actions in `.github/workflows/compile-myprog.yaml` (see e.g. `i2c_scanner` as example) that lists the `src`, `lib` and `aux` needed to compile the program
- add a task in the `Rakefile` under the `### PROGRAM ###` subheading that's simply `task :myprog => :compile`
- test compilation with `rake myprog`, fix issues in the sources (`src/myprog/`) and with libraries as needed until it compiles successfully
- use `bundle exec guard` to continue development with auto compilation
- once the program works as intended and compiles correctly via GitHub actions (https://github.com/kopflab/LabLoggerLibs/actions), add it to the list of firmware in the `README.md` with the github actions badges to `main` and `dev` (whichever dev branch is the correct one, e.g. `dev-myprog`)

## Libraries

### LoggerCore
Expand All @@ -79,4 +91,7 @@ The following third-party software is used in the ***LabLogger*** libraries:
| LoggerCore | PublishQueueExtRK | https://github.com/rickkas7/PublishQueueExtRK | MIT |
| LoggerCore | SparkFun_Qwiic_OpenLog_Arduino_Library | https://github.com/sparkfun/SparkFun_Qwiic_OpenLog_Arduino_Library | MIT |
| LoggerOled | Adafruit_SSD1306 | https://github.com/adafruit/Adafruit_SSD1306 | BSD |
| LoggerOled | Adafruit-GFX-Library | https://github.com/adafruit/Adafruit-GFX-Library | BSD |
| LoggerOled | Adafruit_BusIO | https://github.com/adafruit/Adafruit_BusIO | MIT |


Loading