Page 1 of 1

chprintf broken ???

Posted: Tue Aug 09, 2016 11:30 am
by Tabulous
it seems the field width no longer works on chprintf....

i.e.

in chibios 2.6 i used to display the time and date on the console like this

chprintf(chp, "Time : %.2d:%.2d:%.2d\r\n", gps->hrs, gps->min, gps->sec);
chprintf(chp, "Date : %.2d/%.2d/%.2d\r\n", gps->day, gps->mon, gps->year);

note the ".2" to ensure two chars are used, giving output of

01:02:03
04/05/06


using the same code on 16.1 you get this, seems to not work anymore ????

1:2:3
4/5/6

Re: chprintf broken ???

Posted: Tue Aug 09, 2016 12:26 pm
by Giovanni
Hi,

The "." was not standard, now you can specify the size of the field as %02d

Giovanni

Re: chprintf broken ???

Posted: Tue Aug 09, 2016 12:46 pm
by Tabulous
Giovanni wrote:Hi,

The "." was not standard, now you can specify the size of the field as %02d

Giovanni


cool thanks :-)

Re: chprintf broken ???

Posted: Sun Aug 21, 2016 10:55 am
by Tabulous
Tabulous wrote:
Giovanni wrote:Hi,

The "." was not standard, now you can specify the size of the field as %02d

Giovanni


cool thanks :-)


so how do i go about displaying floats with varying lengths of precision ? as i see it the chprintf is set by define FLOAT_PRECISION and this is all you can do.

i.e. i have a GPS Lat/long that i want to 7 decimal places, but i have a voltage that i only need 1 or 2 decimal places ?

Re: chprintf broken ???

Posted: Sun Aug 21, 2016 11:08 am
by Giovanni
The dot is valid for precision.

Giovanni

Re: chprintf broken ???

Posted: Sun Aug 21, 2016 11:23 am
by Tabulous
Giovanni wrote:The dot is valid for precision.

Giovanni


cool :-)