PIC > LCD > Displaying string and int value

I've been messing.. My routine probably wont do what you need... You will need the "dirty" Ftoa() then you can see whats happening, once you know you can switch to sprintf..

C:
char * ftoa(float f, int * status)
{
    static char        buf[17];
    char *            cp = buf;
    unsigned long    l, rem;

    if(f < 0) {
        *cp++ = '-';
        f = -f;
    }
    l = (unsigned long)f;
    f -= (float)l;
    rem = (unsigned long)(f * 1e6);
    sprintf(cp, "%lu.%6.6lu", l, rem);
    return buf;
}

I have used this and its good enough to view whats going on..
 
Merci Ian,
Will try and understand. But unfortunately I think sprintf doesn’t run on PIC 16F ... Will switch soon to 18 F ...
 
All three are available to you... You have to select them ( separately ) from the library manager.


They are normally not included.. When the compiler asks "include all libraries" you would have said no..
 
All three are available to you... You have to select them ( separately ) from the library manager.
View attachment 133807

They are normally not included.. When the compiler asks "include all libraries" you would have said no..
Merci.
I already used this way while trying to run a former code with sprintf with 16F877 and 887. Could only use sprintl or sprinti.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…