英文:
Why is the debug log output of Acc data different from the showcase app results?
问题
Currently, I am working on a Movesense acceleration sensor. I want the data for each axis inside the sensor to be the same as the axis data shown in the ACC graph in the showcase app. I'm getting the data. I checked that data in the debug log output but the values are different from the ACC graph. I'm not sure what I'm doing wrong.
In addition, there is another issue. I've declared the variables for each axis in float. For example, float x, float y, float z. If I'm printing each variable with %f or %0.6f, I'm getting an empty value in the debug log output. If I'm using %d instead of %f, it gives the result, but the values aren't matching with the showcase app output.
I'm attaching the debug log output video and the showcase app output screenshot. please check that as well.
video: Movesense ACC data debug log error
Showcase app Image: https://i.stack.imgur.com/Zueft.jpg
Code link: https://drive.google.com/file/d/1A29ZWY8E3oUsp0cfPqubfbApjoCYybWh/view?usp=share_link
So how can I get the correct x, y, and z-axis values inside the sensor?
英文:
Currently, I am working on a Movesense acceleration sensor. I want the data for each axis inside the sensor to be the same as the axis data shown in the ACC graph in the showcase app. I'm getting the data. I checked that data in the debug log output but the values are different from the ACC graph. I'm not sure what I'm doing wrong.
In addition, there is another issue. I've declared the variables for each axis in float. For example, float x, float y, float z. If I'm printing each variable with %f or %0.6f, I'm getting an empty value in the debug log output. If I'm using %d instead of %f, it gives the result, but the values aren't matching with the showcase app output.
I'm attaching the debug log output video and the showcase app output screenshot. please check that as well.
video: Movesense ACC data debug log error
Showcase app Image: https://i.stack.imgur.com/Zueft.jpg
Code link: https://drive.google.com/file/d/1A29ZWY8E3oUsp0cfPqubfbApjoCYybWh/view?usp=share_link
So how can I get the correct x, y, and z-axis values inside the sensor?
答案1
得分: 0
以下是翻译好的部分:
"原因是 sensor 上的 snprinf 格式化(DEBUGLOG 宏调用的部分)不支持浮点数格式(%f)。它试图将相同的数字打印为整数,这显然是错误的,因为它是一个浮点数。
要获取一些传感器值的概念,可以使用以下样式:
DEBUGLOG("test: %d", (int)(acc.x*10))
这会将数字打印为整数(大了 10 倍,但其他方面是正确的)"。
英文:
The reason is that the snprinf formatting on sensor (which the DEBUGLOG macro calls) does not support formatting of floating point numbers (%f). The tries to print the same number as integer which is obviously wrong since it's a float.
To get some kind of idea of sensor values, use the following style:
DEBUGLOG("test: %d", (int)(acc.x*10))
which prints out the numbers as integer (10 timest too big, but otherwise correct).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论