mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 14:59:24 -05:00
allow negative heading in maths
This commit is contained in:
parent
62df30eae3
commit
542879b74b
@ -344,11 +344,13 @@ adsb_vel decode_frame_velo(ADSBFrame& frame){
|
||||
if((frame_data[7]&0x80) >> 7) velo_ns *= -1; //check ns direction sign
|
||||
|
||||
velo.speed = sqrt(velo_ns*velo_ns + velo_ew*velo_ew);
|
||||
|
||||
if(velo.speed){
|
||||
//calculate heading in degrees from ew/ns velocities
|
||||
velo.heading = (uint16_t)(atan2(velo_ew,velo_ns) * 180.0 / pi);
|
||||
int16_t heading_temp = (int16_t)(atan2(velo_ew,velo_ns) * 180.0 / pi);
|
||||
// We don't want negative values but a 0-360 scale.
|
||||
if (velo.heading < 0) velo.heading += 360.0;
|
||||
if (heading_temp < 0) heading_temp += 360.0;
|
||||
velo.heading = (uint16_t)heading_temp;
|
||||
}
|
||||
|
||||
}else if(velo_type == 3 || velo_type == 4){ //Airspeed
|
||||
|
Loading…
Reference in New Issue
Block a user