fnBufferDec()

CHAR *fnBufferDec(signed long slNumberToConvert, unsigned char ucStyle, CHAR *ptrBuf);

slNumberToConvert is a signed long value to be converted to an ASCII decimal string in the output buffer pointed to by ptrBuf.
The conversion style is defined by ucStyle, which can be a mixture of following flags:
The function returns a pointer to the last character in the buffer (generally the NULL-terminator). This pointer allows simple concatenation since following string fragments can be added using this pointer.

Examples

CHAR buf[50];
CHAR *ptrBuf = buf;
ptrBuf = fnBufferDec(-125000, (DISPLAY_NEGATIVE), ptrBuf);
ptrBuf = fnBufferDec(125000, (LEADING_SPACE | WITH_CR_LF), ptrBuf);



Result in buf[50] = "-125000 125000\r\n"

Example of formating time output

extern CHAR *fnUpTime(CHAR *cValue)
{
    unsigned long ulUpTimeSecs = (uTaskerSystemTick / SEC);
    unsigned long ulUpTime     = ulUpTimeSecs /60/60/24;                 // the up time in days
    CHAR *cPtr;

    cPtr = fnBufferDec(ulUpTime, 0, cValue);
    *cPtr++ = ' ';
    *cPtr++ = 'D';
    *cPtr++ = 'a';
    *cPtr++ = 'y';
    *cPtr++ = 's';
    *cPtr++ = ' ';
    ulUpTimeSecs -= (ulUpTime * 60*60*24);                               // minus the days
    ulUpTime = (ulUpTimeSecs / (60*60));                                 // the UP time in hours
    cPtr = fnBufferDec(ulUpTime, 0, cPtr);
    *cPtr++ = ':';
    ulUpTimeSecs -= (ulUpTime * 60*60);                                  // minus the hours
    ulUpTime = (ulUpTimeSecs / (60));                                    // the UP time in minutes
    cPtr = fnBufferDec(ulUpTime, LEADING_ZERO, cPtr);
    *cPtr++ = ':';
    ulUpTimeSecs -= (ulUpTime * 60);                                     // minus the minutes
    cPtr = fnBufferDec(ulUpTimeSecs, LEADING_ZERO, cPtr);

    return cPtr;
}

Related functions

fnDebugDec();
fnBufferHex();
fnHexStrHex();
fnDecStrHex();




Please use the µTasker forum to ask specific questions.