Here is a simple one that can handle bit, nibble and byte variables -
it outputs to a parallel LCD function that I wrote, but it will work
just as well to a serial port. Note, you should be able to extend it to
work with a WORD variable by extending the highest "10's" position to be
10000 instead of 100.
It isn't particularly sophisticated, it can't handle negative numbers
for instance, but it is a decent starting point.
DLC
void printData(byte wt)
{
//Print out a byte, nibble or bit value to LCD
//This simply outputs one character at a time by finding the
//digit in the 100 place (255 is highest number) and
//works down to the 1's place. No leading zeros are output.
byte wTemp;
byte bTemp;
byte mTemp;
bTemp = 0;
mTemp = 0;
wTemp = 100;
While(wTemp > 0)
{
mTemp = wt/wTemp;
If((mTemp > 0) | (bTemp == 1) | (wTemp == 1))
{
wt = wt - mTemp * wTemp;
bTemp = 1; //Now print trailing zeros
LCD.Value = mTemp + 48; //convert to ASCII character
} //end If
If(wTemp == 1)
{
wTemp = 0;
}
Else
{
wTemp = wTemp /10;
} //end If
} //end While
} //end Sub
Brian Lloyd wrote:
> On Mar 17, 2008, at 1:27 PM, ooPIC Tech Support wrote:
>
>
>> I'm not at home at the moment, but I have some routines that handle
>> bit, byte and word variables out to the serial port. Nothing quite so
>> elaborate as you discuss though. I can post them if you wish.
>>
>
> I am not building a report generator. ;-) Anything would be great.
> Thanks.
>
> OTOH str$() should work just fine. I missed it because I was searching
> in the language and object references, not the programmer's guide. My
> apologies to everyone for asking a question I could have found the
> answer to myself.
>
> --
>
> Brian Lloyd Granite Bay Montessori
> brian AT gbmontessori DOT com 9330 Sierra College Blvd.
> +1.916.367.2131 (voice) Roseville, CA 95661, USA
>
http://www.gbmontessori.com
>
> I fly because it releases my mind from the tyranny of petty things . . .
> — Antoine de Saint-Exupéry
>
> PGP key ID: 12095C52A32A1B6C
> PGP key fingerprint: 3B1D BA11 4913 3254 B6E0 CC09 1209 5C52 A32A 1B6C
>
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>
--
------------------------------------------------------
Dennis Clark ooPIC Tech Support
www.oopic.com
------------------------------------------------------
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
No comments:
Post a Comment