Hi dialog engineer:
当我调试传感器数据,我发现that a problem to solve difficultly.
when i use the angle func( ex: acos, atan....) to process the float digit, and i use arch_printf() func to print the float digit for my application, i see the warning: "FATAL: unsupported printf character: f.", so my question is how to output the float digit to uart for debug?
short gx; short gy; short gz;
short ax; short ay; short az;
short Axyz; float angleX; float angleY; float angleZ;
MPU_Get_Gyroscope(&gx, &gy, &gz);
MPU_Get_Accelerometer(&ax, &ay, &az);
Axyz = ax * ax + ay * ay + az * az;
angleX = acos((double)(ax/sqrt(Axyz))) * 57.295780f;
angleY = acos((double)(ay/sqrt(Axyz))) * 57.295780f;
angleZ = acos((double)(az/sqrt(Axyz))) * 57.295780f;
arch_printf("%f, %f, %f\r\n", angleX, angleY , angleZ );
when the sensor run, the console output : "FATAL: unsupported printf character: f., FATAL: unsupported printf character: f., FATAL: unsupported printf character: f."
i check the arch_printf(), find that arch_printf() does not support formart float & double.
so how can i debug the float data with arch_printf()?
pls help me, ths.
Hi liliou26,
The arch_printf() functions doesnt support printing floating point characters as you ve seen, a quick solution to this could be to divide and modulo the value by 10 in order to find the integer part of the floating point value, subtract the integer value from the original value so that you have only the decimal numbers and then multiply the floating point values with multiples of 10 depending on the decimal numbers of accurancy that you would like to have and then print both results as integers. There are quite a few ways to do this which are more sophisticated than the rough one mentioned above depending on the accurancy or reliability that you would like to have on your printing. By searching the web you will be able to find lots of information.
Thanks MT_dialog
I have understood the method you descript, Tks MT_dialog.