avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?


From: Richard Urwin
Subject: Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?
Date: Mon, 19 Sep 2005 01:29:45 +0100
User-agent: KMail/1.7.2

On Monday 19 Sep 2005 00:12, Vincent Trouilliez wrote:
> > On Sun, 2005-09-18 at 16:54 -0500, David Kelly wrote:
> > > ...I don't use printf() so I haven't used printf_P()
> >
> > But how do you do then ?
>
> Well, now I think of it, there is at least one case where I won't be
> able to use printf, well I think.
> printf_P() is nice to printf my strings easily from program space,
> and formatting integer numbers works well as far as I can see (just
> tested it). However I am not gonna use floating points routines in my
> program, as most of the engine parameters are simple unsigned
> integers, and only a very few need to be displayed as floating point,
> like for example manifold air pressure  / MAP, but still, the car's
> engine management returns it as an 8 bit integer. So I will for
> example just need to display the integer "154", put the decimal point
> where required to display a nice "1.54" (Bar). But I don't suppose
> printf can place a decimal point when formatting/displaying integer
> numbers ?
> That would be too good to be true ? So I will have to write my own
> little "lcd_print_float()" function I guess...

I share your pain. I recently had to write one that not only did that, 
but it used a comma instead of a point.

The only alternative is:

printf ("%d.%03d", x / 1000, x % 1000)

I don't know the capabilities of avr libc, I hope it copes with the 
leading zero format.

There is an even more advanced format to make the field size a 
parameter, but I don't know it off the top of my head. One thing is 
certain; if you used it you'd end up writing traditional C - totally 
unreadable by mortal beings. ;-)

-- 
Richard Urwin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]