From 4c238bdcddb3af36e7e4416425749d01d3cf4ef5 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 13 Dec 2023 11:14:30 +0000 Subject: [PATCH 1/6] Avoid ambiguity --- src/SparkFun_ADS1219.cpp | 15 ++++++++++----- src/SparkFun_ADS1219.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/SparkFun_ADS1219.cpp b/src/SparkFun_ADS1219.cpp index 62a19d0..7b35524 100644 --- a/src/SparkFun_ADS1219.cpp +++ b/src/SparkFun_ADS1219.cpp @@ -126,12 +126,17 @@ bool SfeADS1219Driver::readConversion() if (result) { // Data is 3-bytes (24-bits), big-endian (MSB first). - _adcResult = rawBytes[0]; - _adcResult = (_adcResult << 8) | rawBytes[1]; - _adcResult = (_adcResult << 8) | rawBytes[2]; + union { + int32_t i32; + uint32_t u32; + } iu32; + iu32.u32 = rawBytes[0]; + iu32.u32 = (iu32.u32 << 8) | rawBytes[1]; + iu32.u32 = (iu32.u32 << 8) | rawBytes[2]; // Preserve the 2's complement. - if (_adcResult & (1 << 23)) - _adcResult |= 0xFF000000; + if (0x00100000 == (iu32.u32 & 0x00100000)) + iu32.u32 = iu32.u32 | 0xFF000000; + _adcResult = iu32.i32; // Store the result } return result; } diff --git a/src/SparkFun_ADS1219.h b/src/SparkFun_ADS1219.h index 7564be9..07f9a5f 100644 --- a/src/SparkFun_ADS1219.h +++ b/src/SparkFun_ADS1219.h @@ -230,7 +230,7 @@ class SfeADS1219Driver ads1219_gain_config_t _adcGain; // Local configuration value. ADC gain - needed for conversion to mV. - int32_t _adcResult; // Local store for the ADC conversion result. 24-Bit, shifted left for correct 2's complement + int32_t _adcResult; // Local store for the ADC conversion result. 24-Bit, 2's complement }; class SfeADS1219ArdI2C : public SfeADS1219Driver From ce54537456d748cc992c48cf272748eefb09d13b Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 13 Dec 2023 11:28:43 +0000 Subject: [PATCH 2/6] Update SparkFun_ADS1219.cpp --- src/SparkFun_ADS1219.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SparkFun_ADS1219.cpp b/src/SparkFun_ADS1219.cpp index 7b35524..f0566e7 100644 --- a/src/SparkFun_ADS1219.cpp +++ b/src/SparkFun_ADS1219.cpp @@ -129,14 +129,14 @@ bool SfeADS1219Driver::readConversion() union { int32_t i32; uint32_t u32; - } iu32; + } iu32; // Use a union to avoid signed / unsigned ambiguity iu32.u32 = rawBytes[0]; iu32.u32 = (iu32.u32 << 8) | rawBytes[1]; iu32.u32 = (iu32.u32 << 8) | rawBytes[2]; // Preserve the 2's complement. if (0x00100000 == (iu32.u32 & 0x00100000)) iu32.u32 = iu32.u32 | 0xFF000000; - _adcResult = iu32.i32; // Store the result + _adcResult = iu32.i32; // Store the signed result } return result; } From b8b37aa84bc84955b7d223196bf141128afc49a9 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 13 Dec 2023 11:37:34 +0000 Subject: [PATCH 3/6] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index e093abb..5bba947 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -99,7 +99,7 @@ jobs: libraries: | - source-path: ./ sketch-paths: | - - examples/Example01_Basic_SingleShot + - examples/Example05_AlternateAddress enable-warnings-report: true enable-deltas-report: true verbose: true From 0214331ac4ba0eafbd8a7a3ded4eb5f331ff2cb0 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 13 Dec 2023 11:41:42 +0000 Subject: [PATCH 4/6] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 5bba947..96f57ac 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -92,7 +92,7 @@ jobs: run: echo running on branch ${GITHUB_REF##*/} - name: Compile Sketch - uses: arduino/compile-sketches@v1.1.0 + uses: arduino/compile-sketches@v1 with: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} From ff328dd7f724f73cb9c980d79abd3838997b64d9 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 13 Dec 2023 11:59:15 +0000 Subject: [PATCH 5/6] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 96f57ac..c9b5035 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -4,7 +4,6 @@ on: # - push - pull_request - jobs: compile-sketch: runs-on: ubuntu-latest @@ -92,8 +91,9 @@ jobs: run: echo running on branch ${GITHUB_REF##*/} - name: Compile Sketch - uses: arduino/compile-sketches@v1 + uses: arduino/compile-sketches@v1.1.0 with: + github-token: ${{ secrets.GITHUB_TOKEN }} platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | From f84b4a6837bb414183dae78d4f46fc3cb99d9615 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 13 Dec 2023 12:11:37 +0000 Subject: [PATCH 6/6] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index c9b5035..73051f0 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -98,6 +98,9 @@ jobs: fqbn: ${{ matrix.board.fqbn }} libraries: | - source-path: ./ + # Add library dependencies here: + - source-url: https://github.com/sparkfun/SparkFun_Toolkit.git + # - name: name-of-library-registered-with-arduino-library-manager sketch-paths: | - examples/Example05_AlternateAddress enable-warnings-report: true