paulfjujo
Advanced Member level 4
- Joined
- Jun 9, 2008
- Messages
- 1,469
- Helped
- 298
- Reputation
- 596
- Reaction score
- 286
- Trophy points
- 1,363
- Location
- France 01800
- Activity points
- 10,644
hello,
this kind of conversion will not work in every cases
example in post #16 will work only for value > 0 and < 99.9999
bad if 0.3244 => gives 00.3244 and bad for 199.1234 => gives 99.1234
example in post #20 is the same case , not cover all values..
and you must add 0x30 or '0' to the digit value to get an ascii
i suppose your Lcd_chr as parameters as ( line number, caractere position, caractere)
and when you use Lcd_chr_cp('.'); you write on the current cursor position ?
Do you have automatic increment of cursor inside your LCD init ?
so a lot of pending probem !
my last opinion about this thread.. use the code in post #7
allready tested in many application..
Check if you have automatic increment of cursor after writing a car on the LCD.
To write the ascii result of float
Put the cursor at the begining of a line
after just use Lcd_chr_cp(car);, no need to put again line number and X position.
this kind of conversion will not work in every cases
example in post #16 will work only for value > 0 and < 99.9999
bad if 0.3244 => gives 00.3244 and bad for 199.1234 => gives 99.1234
example in post #20 is the same case , not cover all values..
and you must add 0x30 or '0' to the digit value to get an ascii
Code:
Lcd_chr(4,3,0+digit);
must be
Lcd_chr(4,3,'0'+digit);
i suppose your Lcd_chr as parameters as ( line number, caractere position, caractere)
and when you use Lcd_chr_cp('.'); you write on the current cursor position ?
Do you have automatic increment of cursor inside your LCD init ?
so a lot of pending probem !
my last opinion about this thread.. use the code in post #7
allready tested in many application..
Check if you have automatic increment of cursor after writing a car on the LCD.
To write the ascii result of float
Put the cursor at the begining of a line
after just use Lcd_chr_cp(car);, no need to put again line number and X position.
Code:
unsigned char CRam1[32];
float F1;
int k;
.. see float conversion in post #7 ....
F1=0.3244;
....
fltToa(F1,CRam1,4); // 4 decimales
k=strlen(CRam1;
// put here LCD function to put the cursor position at line 4,0
......
for (i=0;i<k;i++)
{
Lcd_chr_cp(CRam1[i]);
}