Skip to content

Commit

Permalink
Merge pull request #77 from brentru/add-prec
Browse files Browse the repository at this point in the history
add prec. points to sending AVR and non-avr (SAMD/ESP32) targets
  • Loading branch information
brentru committed Jan 28, 2019
2 parents 88e837a + a5b90f6 commit ac625aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit IO Arduino
version=2.7.22
version=2.7.23
author=Adafruit
maintainer=Adafruit <adafruitio@adafruit.com>
sentence=Arduino library to access Adafruit IO.
Expand Down
8 changes: 4 additions & 4 deletions src/AdafruitIO_Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ void AdafruitIO_Data::setValue(float value, double lat, double lon, double ele,

#if defined(ARDUINO_ARCH_AVR)
// Use avrlibc dtostre function on AVR platforms.
dtostre(value, _value, 10, 0);
dtostre(value, _value, precision, 0);
#elif defined(ESP8266)
// ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
// but accept a hint as to how many decimals of precision are desired.
dtostrf(value, 0, precision, _value);
#else
// Otherwise fall back to snprintf on other platforms.
snprintf(_value, sizeof(_value)-1, "%f", value);
snprintf(_value, sizeof(_value) - 1, "%0.*f", precision, value);
#endif

setLocation(lat, lon, ele);
Expand All @@ -201,14 +201,14 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele,

#if defined(ARDUINO_ARCH_AVR)
// Use avrlibc dtostre function on AVR platforms.
dtostre(value, _value, 10, 0);
dtostre(value, _value, precision, 0);
#elif defined(ESP8266)
// ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
// but accept a hint as to how many decimals of precision are desired.
dtostrf(value, 0, precision, _value);
#else
// Otherwise fall back to snprintf on other platforms.
snprintf(_value, sizeof(_value)-1, "%f", value);
snprintf(_value, sizeof(_value) - 1, "%0.*f", precision, value);
#endif

setLocation(lat, lon, ele);
Expand Down

0 comments on commit ac625aa

Please sign in to comment.