Skip to content

Commit

Permalink
Add build action and new-style version info
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcomm authored Aug 20, 2023
1 parent 3f55585 commit 32cc54e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 15 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/make-hex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Compile Arduino files to hex

on:
push:
pull_request:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- label: "uno"
fqbn: "arduino:avr:uno"
build-dir: "arduino.avr.uno"
- label: "nano"
fqbn: "arduino:avr:nano"
build-dir: "arduino.avr.nano"
- label: "leonardo"
fqbn: "arduino:avr:leonardo"
build-dir: "arduino.avr.leonardo"
- label: "atmega328pb"
fqbn: "MiniCore:avr:328:variant=modelPB"
build-dir: "MiniCore.avr.328"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Print ref
run: echo ${{ github.ref }}
- name: Set VERSION
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
- name: Set HEX_FILENAME
run: echo "HEX_FILENAME=dmcomm-original-${{ env.VERSION }}-${{ matrix.label }}.hex" >> $GITHUB_ENV
- name: Write build info
run: >
echo '#define DMCOMM_BUILD_INFO
F("name = dmcomm-original\r\nversion = ${{ env.VERSION }}\r\nboard = ${{ matrix.label }}")'
> dmcomm/dmcomm_build_info.h
- name: Compile sketch
uses: arduino/compile-sketches@v1
with:
fqbn: "${{ matrix.fqbn }}"
sketch-paths: |
- dmcomm
libraries:
cli-compile-flags: |
- --export-binaries
platforms: |
- name: "arduino:avr"
- name: "MiniCore:avr"
source-url: "https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json"
- name: Copy hex
run: cp dmcomm/build/${{ matrix.build-dir }}/dmcomm.ino.hex ${{ env.HEX_FILENAME }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.label }}
path: ${{ env.HEX_FILENAME }}
- name: Attach to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: ${{ env.HEX_FILENAME }}
28 changes: 13 additions & 15 deletions dmcomm/dmcomm.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
*/


#define VERSION F("dmcomm v4.0+wip")
//optionally define BUILD_INFO in compiler flags, e.g. commit ID, board ID
#include "dmcomm_build_info.h"


//pin assignments
Expand Down Expand Up @@ -862,21 +861,20 @@ void loop() {
static byte buffer[command_buffer_size];

int i;
bool info = false;

//process serial input
i = serialRead(buffer);
if (i > 0) {
Serial.print(F("got "));
Serial.print(i, DEC);
Serial.print(F(" bytes: "));
Serial.write(buffer, i);
Serial.print(F(" -> "));
if (buffer[0] == '?') {
Serial.println(F("[version]"));
Serial.println(VERSION);
#ifdef BUILD_INFO
Serial.println(BUILD_INFO);
#endif
if ((buffer[0] == 'i' || buffer[0] == 'I') && buffer[1] == '\0') {
Serial.println(DMCOMM_BUILD_INFO);
info = true;
} else {
Serial.print(F("got "));
Serial.print(i, DEC);
Serial.print(F(" bytes: "));
Serial.write(buffer, i);
Serial.print(F(" -> "));
}
if (buffer[0] == 't' || buffer[0] == 'T') {
Serial.println(F("[test voltages]"));
Expand Down Expand Up @@ -953,15 +951,15 @@ void loop() {
Serial.print(numPackets);
Serial.print(F(" packets]"));
}
if (!active) {
if (!active && !info) {
Serial.print(F("(paused)"));
}
Serial.println();
if (active && goFirst) {
delay(gofirst_repeat_ms);
}
}

//do it
startLog();
initDmTimes(timingID);
Expand Down
6 changes: 6 additions & 0 deletions dmcomm/dmcomm_build_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is part of the DMComm project by BladeSabre. License: MIT.

// This file is intended to be overwritten by the build CI.
// Does not have its own include guards, should be checked by includer.

#define DMCOMM_BUILD_INFO F("name = dmcomm-original")

0 comments on commit 32cc54e

Please sign in to comment.