utils.cpp 460 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

#include "utils.h"

String __FloatToString(float value, int dp)
{
    char buf[33];
    if (!isnan(value))
    {
        dtostrf(value, dp + 2, dp, buf);
        return String(buf);
    }
    else
    {
        return String(NAN_STRING);
    }
}

18

19 20 21 22 23
String FloatToString(float value, int decimal_places)
{
    return __FloatToString(value, decimal_places);
}

24

25 26 27 28 29
String FloatToString(float value)
{
    return __FloatToString(value, FLOAT_STR_DECIMAL_PLACES);
}