@@ -182,14 +182,14 @@ void AdafruitIO_Data::setValue(float value, double lat, double lon, double ele,
182
182
183
183
#if defined(ARDUINO_ARCH_AVR)
184
184
// Use avrlibc dtostre function on AVR platforms.
185
- dtostre (value, _value, 10 , 0 );
185
+ dtostre (value, _value, precision , 0 );
186
186
#elif defined(ESP8266)
187
187
// ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
188
188
// but accept a hint as to how many decimals of precision are desired.
189
189
dtostrf (value, 0 , precision, _value);
190
190
#else
191
191
// Otherwise fall back to snprintf on other platforms.
192
- snprintf (_value, sizeof (_value)- 1 , " %f " , value);
192
+ snprintf (_value, sizeof (_value) - 1 , " %0.*f " , precision , value);
193
193
#endif
194
194
195
195
setLocation (lat, lon, ele);
@@ -201,14 +201,14 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele,
201
201
202
202
#if defined(ARDUINO_ARCH_AVR)
203
203
// Use avrlibc dtostre function on AVR platforms.
204
- dtostre (value, _value, 10 , 0 );
204
+ dtostre (value, _value, precision , 0 );
205
205
#elif defined(ESP8266)
206
206
// ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
207
207
// but accept a hint as to how many decimals of precision are desired.
208
208
dtostrf (value, 0 , precision, _value);
209
209
#else
210
210
// Otherwise fall back to snprintf on other platforms.
211
- snprintf (_value, sizeof (_value)- 1 , " %f " , value);
211
+ snprintf (_value, sizeof (_value) - 1 , " %0.*f " , precision , value);
212
212
#endif
213
213
214
214
setLocation (lat, lon, ele);
0 commit comments