I can not figure out the syntax to print a float that has 3 decimal places. I found this very useful snippet of code to get a float value from a keypad:
while (1) { //get digits
byte digit = checkKeyBuffer(); //get a keypress from the user
if (digit >= 0 && digit <= 9) { //a digit
if (DP == 0) {
Entry = Entry * 10;
Entry = Entry + digit;
}
if (DP > 0) {
digit = digit / pow(10, DP);
digit = Entry + digit;
DP = DP + 1;
}
break;
}
else if (digit == keyAsterisk) { //decimal point
DP = 1;
break;
}
} //end while getting digits
To print it to my LCD I tried something like this:
sprintf(theBuffer, "%03d", Entry);
disp.lcd_print(theBuffer);
But this doesn't print anything to the right of the decimal. Is there a simple way to do this?