Closed maciek252 closed 4 years ago
Hi maciek252
I have not looked at this code for some time. It was mostly test code for other projects, but of course we want it to be correct. A test file from you would be useful, and I'll take a look
Ok, I found a problem with 10^. I'll post v0.12 when I can
For me this is working:
(instead of bit32Extract)
I've found it in the internet, it would be better to make this macro into a function.
I coded a simple function, but I like the code you show there. 😊
Maybe I'll include BT and Wifi.
Thank you for reporting this ugly bug. I mixed up my languages. No excuse.
uint32_t TenToPwr(uint8_t pwr) {
uint32_t ttp = 1;
for (int i = 1 ; i<=pwr ; i++) {
ttp*=10;
}
return ttp;
}
fr_vy = bit32Unpack(fr_payload,1,7) * TenToPwr(bit32Unpack(fr_payload,0,1));
sorted
Hi,
Frsky 5006: Range=0.00 Roll=-16.80deg Pitch=-3.80deg Frsky 5006: Range=0.00 Roll=-16.80deg Pitch=419337.21deg Frsky 5006: Range=0.00 Roll=-16.80deg Pitch=419337.40deg Frsky 5006: Range=0.00 Roll=-16.80deg Pitch=419337.40deg
I've ported the library (FrSky part) to Kotlin to use in an android app. But there were numbers as above. So I've run it on arduino and here the problem still occurs. The same data are displayed correctly by the Taranis's yaapu telemetry script.
Moreover, I get only 0.0 yaw angle on arduino (and values alternating between correct and 419000-somethings on Kotlin).
FrSky 5005: v_veloc=0.0 h_veloc=170240.0 yaw_angle=0.0 FrSky 5005: v_veloc=0.0 h_veloc=170240.0 yaw_angle=0.0 FrSky 5005: v_veloc=0.0 h_veloc=168960.0 yaw_angle=0.0 FrSky 5005: v_veloc=0.0 h_veloc=170240.0 yaw_angle=0.0 FrSky 5005: v_veloc=0.0 h_veloc=171520.0 yaw_angle=0.0 FrSky 5005: v_veloc=0.0 h_veloc=171520.0 yaw_angle=0.0
EDIT:
I think that there's a bug in the bit32Extract implementation. When I test in lua the value I've read from the serial port and displayed on Arduino, I get:
bit32.extract(44302336,17,11)=338 338*0.2 gives around 67, what's consistent with what I see on Taranis yaapu (and with what a compass shows). However, the arduino sketch reports yaw_angle=0.0