File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 44 # - push
55 - pull_request
66
7-
87jobs :
98 compile-sketch :
109 runs-on : ubuntu-latest
@@ -94,12 +93,16 @@ jobs:
9493 - name : Compile Sketch
9594 uses : arduino/compile-sketches@v1.1.0
9695 with :
96+ github-token : ${{ secrets.GITHUB_TOKEN }}
9797 platforms : ${{ matrix.board.platforms }}
9898 fqbn : ${{ matrix.board.fqbn }}
9999 libraries : |
100100 - source-path: ./
101+ # Add library dependencies here:
102+ - source-url: https://github.com/sparkfun/SparkFun_Toolkit.git
103+ # - name: name-of-library-registered-with-arduino-library-manager
101104 sketch-paths : |
102- - examples/Example01_Basic_SingleShot
105+ - examples/Example05_AlternateAddress
103106 enable-warnings-report : true
104107 enable-deltas-report : true
105108 verbose : true
Original file line number Diff line number Diff line change @@ -126,12 +126,17 @@ bool SfeADS1219Driver::readConversion()
126126 if (result)
127127 {
128128 // Data is 3-bytes (24-bits), big-endian (MSB first).
129- _adcResult = rawBytes[0 ];
130- _adcResult = (_adcResult << 8 ) | rawBytes[1 ];
131- _adcResult = (_adcResult << 8 ) | rawBytes[2 ];
129+ union {
130+ int32_t i32 ;
131+ uint32_t u32 ;
132+ } iu32; // Use a union to avoid signed / unsigned ambiguity
133+ iu32.u32 = rawBytes[0 ];
134+ iu32.u32 = (iu32.u32 << 8 ) | rawBytes[1 ];
135+ iu32.u32 = (iu32.u32 << 8 ) | rawBytes[2 ];
132136 // Preserve the 2's complement.
133- if (_adcResult & (1 << 23 ))
134- _adcResult |= 0xFF000000 ;
137+ if (0x00100000 == (iu32.u32 & 0x00100000 ))
138+ iu32.u32 = iu32.u32 | 0xFF000000 ;
139+ _adcResult = iu32.i32 ; // Store the signed result
135140 }
136141 return result;
137142}
Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ class SfeADS1219Driver
230230
231231 ads1219_gain_config_t _adcGain; // Local configuration value. ADC gain - needed for conversion to mV.
232232
233- int32_t _adcResult; // Local store for the ADC conversion result. 24-Bit, shifted left for correct 2's complement
233+ int32_t _adcResult; // Local store for the ADC conversion result. 24-Bit, 2's complement
234234};
235235
236236class SfeADS1219ArdI2C : public SfeADS1219Driver
You can’t perform that action at this time.
0 commit comments