avr-libc double to string conversion
Add support for dtostre according to #27
| | |
| | | #define HAVE_STRNICMP 0 |
| | | #endif |
| | | |
| | | /* AVR libc */ |
| | | #if defined(__AVR_LIBC_VERSION__) |
| | | #define HAVE_DTOSTRE |
| | | #endif |
| | | |
| | | /* ======== test strnlen ======== */ |
| | | #ifndef HAVE_STRNLEN |
| | | #define HAVE_STRNLEN 1 |
| | |
| | | #define SCPI_strncasecmp(s1, s2, l) OUR_strncasecmp((s1), (s2), (l)) |
| | | #endif |
| | | |
| | | #if HAVE_DTOSTRE |
| | | #define SCPI_doubleToStr(v, s, l) strlen(dtostre((v), (s), 6, DTOSTR_PLUS_SIGN | DTOSTRE_ALWAYS_SIGN | DTOSTR_UPPERCASE)) |
| | | #else |
| | | #define SCPI_doubleToStr(v, s, l) snprintf((s), (l), "%lg", (v)) |
| | | #endif |
| | | |
| | | |
| | | #ifdef __cplusplus |
| | | } |
| | | #endif |
| | |
| | | * @return number of bytes written to str (without '\0') |
| | | */ |
| | | size_t doubleToStr(double val, char * str, size_t len) { |
| | | return snprintf(str, len, "%lg", val); |
| | | return SCPI_doubleToStr(val, str, len); |
| | | } |
| | | |
| | | /** |