ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Jan 05, 2005 6:51 am |
|
|
Code: | //-----------------------------------------------------------------------------
// Converts a single BCD-character to an int8.
//-----------------------------------------------------------------------------
int8 Int2Bcd(int8 val)
{
return ((val / 10) << 4) + (val % 10);
}
//-----------------------------------------------------------------------------
// Converts a single BCD-character to an int8.
//-----------------------------------------------------------------------------
int8 Bcd2Int(int8 BCD)
{
return (10 * (BCD >> 4)) + (BCD & 0x0F);
} |
For an int32 you'l l have to call these functions 4 times, for example
Code: | int8 bcd, i;
int32 LargeValue;
for (i=4; i!=0; i--)
{
bcd = int2bcd( make8(LargeValue, i-1) );
putc(bcd); // Send to LCD
)
|
|
|