Ultra-Small, Low-Power, I2C-Compatible, 860-SPS, 16-Bit ADCs With Internal Reference, Oscillator, and Programmable Comparator
Diff: ADS111X.cpp
- Revision:
- 3:4a9619b441f0
- Parent:
- 2:aecccd48773a
- Child:
- 4:7853bced749c
diff -r aecccd48773a -r 4a9619b441f0 ADS111X.cpp --- a/ADS111X.cpp Thu Jun 18 16:11:01 2020 +0000 +++ b/ADS111X.cpp Fri Jun 19 10:16:03 2020 +0000 @@ -963,15 +963,15 @@ */ ADS111X::ADS111X_status_t ADS111X::ADS111X_GetConversion ( ADS111X_data_t* myD ) { - double myGain = 0.0; - double myFactor = 0.0; + float myGain = 0.0; + float myFactor = 0.0; ADS111X_status_t aux = ADS111X_SUCCESS; /* Get the raw conversion value */ - aux = ADS111X_GetRawConversion ( &(myD->conversion) ); + aux = ADS111X::ADS111X_GetRawConversion ( &myD->conversion ); /* Set up the gain accordingly */ - switch ( myD->device ) + switch ( _device ) { case DEVICE_ADS1113: myGain = 2.048; @@ -1015,20 +1015,20 @@ if ( myD->conversion.raw_conversion == 0x8000 ) { myFactor = myGain; + myD->conversion.conversion = (float)( -myFactor ); } else if ( myD->conversion.raw_conversion == 0x7FFF ) { myFactor = ( myGain * ( 32768.0 - 1.0 ) ) / 32768.0; + myD->conversion.conversion = (float)( myFactor ); } else { - myFactor = myGain / 32768.0; + myFactor = (float)( myGain / 32768.0 ); + myD->conversion.conversion = (float)( myFactor * myD->conversion.raw_conversion ); } - /* Result */ - myD->conversion.conversion = (float)( myFactor * myD->conversion.raw_conversion ); - return aux; }