@@ -99,7 +99,7 @@ bool FeedData::ulongValue(unsigned long* value) {
9999 #else
100100 *value = strtoul (_value, &endptr, 10 );
101101 #endif
102- return (*_value != 0 && *endptr == 0 );
102+ return (*_value != 0 && *endptr == 0 );
103103}
104104
105105bool FeedData::floatValue (float * value) {
@@ -149,27 +149,35 @@ bool Adafruit_IO_Feed::send(unsigned long value) {
149149 return _adapter->send (_name, _converted, _key, false );
150150}
151151
152- bool Adafruit_IO_Feed::send (float value) {
153- // Convert float to string using scientific notation, then send the value
152+ bool Adafruit_IO_Feed::send (float value, int precision ) {
153+ // Convert float to string using scientific notation, then send the value
154154 // (being careful not to quote it).
155155 memset (_converted, 0 , sizeof (_converted));
156156 #if defined(ARDUINO_ARCH_AVR)
157157 // Use avrlibc dtostre function on AVR platforms.
158158 dtostre (value, _converted, 10 , 0 );
159+ #elif defined(ESP8266)
160+ // ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
161+ // but accept a hint as to how many decimals of precision are desired.
162+ dtostrf (value, 0 , precision, _converted);
159163 #else
160164 // Otherwise fall back to snprintf on other platforms.
161165 snprintf (_converted, sizeof (_converted)-1 , " %f" , value);
162166 #endif
163167 return _adapter->send (_name, _converted, _key, false );
164168}
165169
166- bool Adafruit_IO_Feed::send (double value) {
167- // Convert double to string using scientific notation, then send the value
170+ bool Adafruit_IO_Feed::send (double value, int precision ) {
171+ // Convert double to string using scientific notation, then send the value
168172 // (being careful not to quote it).
169173 memset (_converted, 0 , sizeof (_converted));
170174 #if defined(ARDUINO_ARCH_AVR)
171175 // Use avrlibc dtostre function on AVR platforms.
172176 dtostre (value, _converted, 10 , 0 );
177+ #elif defined(ESP8266)
178+ // ESP8266 Arduino only implements dtostrf and not dtostre. Use dtostrf
179+ // but accept a hint as to how many decimals of precision are desired.
180+ dtostrf (value, 0 , precision, _converted);
173181 #else
174182 // Otherwise fall back to snprintf on other platforms.
175183 snprintf (_converted, sizeof (_converted)-1 , " %f" , value);
0 commit comments