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
7 changes: 5 additions & 2 deletions .github/workflows/compile-sketch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
# - push
- pull_request


jobs:
compile-sketch:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -94,12 +93,16 @@ jobs:
- name: Compile Sketch
uses: arduino/compile-sketches@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: ${{ matrix.board.platforms }}
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/Example01_Basic_SingleShot
- examples/Example05_AlternateAddress
enable-warnings-report: true
enable-deltas-report: true
verbose: true
Expand Down
15 changes: 10 additions & 5 deletions src/SparkFun_ADS1219.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; // 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 (_adcResult & (1 << 23))
_adcResult |= 0xFF000000;
if (0x00100000 == (iu32.u32 & 0x00100000))
iu32.u32 = iu32.u32 | 0xFF000000;
_adcResult = iu32.i32; // Store the signed result
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SparkFun_ADS1219.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down