chprintf broken ???

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

chprintf broken ???

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chprintf broken ???

Post by Giovanni »

Hi,

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

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: chprintf broken ???

Post by Tabulous »

Giovanni wrote:Hi,

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

Giovanni


cool thanks :-)
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: chprintf broken ???

Post 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 ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chprintf broken ???

Post by Giovanni »

The dot is valid for precision.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: chprintf broken ???

Post by Tabulous »

Giovanni wrote:The dot is valid for precision.

Giovanni


cool :-)
Post Reply