marlin
"The LCD can display only around max 320.00 but the users want to see more fine grained steps
It is an 16 bit integer overflow problem. Issue 201: https://github.com/MarlinFirmware/Marlin/issues/201"
Bug fixed by commit 31873ec707d
| Type | IntegerOverflow |
| Config | "ULTRA_LCD" (1st degree) |
| Fix-in | code |
| Location | lcd/ |
#include <stdio.h>
#ifdef ULTRA_LCD
// convert float to string with +1234.5 format
char *ftostr51(float x)
{
int16_t xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/10000)%10+'0';
conv[2]=(xx/1000)%10+'0';
conv[3]=(xx/100)%10+'0';
conv[4]=(xx/10)%10+'0';
conv[5]='.';
conv[6]=(xx)%10+'0';
conv[7]=0;
return conv;
}
#endif
int main(int argc, char **argv)
{
ftostr51(512.5);
return 0;
}
diff --git a/simple/31873ec.c b/simple/31873ec.c
--- a/simple/31873ec.c
+++ b/simple/31873ec.c
@@ -4,7 +4,7 @@
// convert float to string with +1234.5 format
char *ftostr51(float x)
{
- int16_t xx=x*10;
+ long xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/10000)%10+'0';
#include <stdio.h>
int main(int argc, char **argv)
{
#ifdef ULTRA_LCD
float x = 512.5f;
int16_t xx=x*10;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
conv[1]=(xx/10000)%10+'0';
conv[2]=(xx/1000)%10+'0';
conv[3]=(xx/100)%10+'0';
conv[4]=(xx/10)%10+'0';
conv[5]='.';
conv[6]=(xx)%10+'0';
conv[7]=0;
printf("%l", conv);
#endif
return 0;
}
. call ultralcd.pde:2667: char *ftostr51(float &x) . ERROR ultralcd.pde:2669 int xx=x*10;