File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -151,7 +151,15 @@ bool SCD30::setForcedRecalibrationFactor(uint16_t concentration)
151
151
float SCD30::getTemperatureOffset (void )
152
152
{
153
153
uint16_t response = readRegister (COMMAND_SET_TEMPERATURE_OFFSET);
154
- return (((float )response) / 100.0 );
154
+
155
+ union
156
+ {
157
+ int16_t signed16;
158
+ uint16_t unsigned16;
159
+ } signedUnsigned; // Avoid any ambiguity casting int16_t to uint16_t
160
+ signedUnsigned.signed16 = response;
161
+
162
+ return (((float )signedUnsigned.signed16 ) / 100.0 );
155
163
}
156
164
157
165
// Set the temperature offset. See 1.3.8.
@@ -163,6 +171,7 @@ bool SCD30::setTemperatureOffset(float tempOffset)
163
171
uint16_t unsigned16;
164
172
} signedUnsigned; // Avoid any ambiguity casting int16_t to uint16_t
165
173
signedUnsigned.signed16 = tempOffset * 100 ;
174
+
166
175
return sendCommand (COMMAND_SET_TEMPERATURE_OFFSET, signedUnsigned.unsigned16 );
167
176
}
168
177
You can’t perform that action at this time.
0 commit comments