diff --git a/Hyt2/APP/Device/Device_angle/get_angle.c b/Hyt2/APP/Device/Device_angle/get_angle.c index fa1bc50..cf77ded 100644 --- a/Hyt2/APP/Device/Device_angle/get_angle.c +++ b/Hyt2/APP/Device/Device_angle/get_angle.c @@ -2882,17 +2882,25 @@ static char ptz_hori_get_angle_a() // tem4 = tem4 + 360.0; // } } - if(tem4 == 360.0)///////解决既显示360又显示角度0的问题 + //避免出现异常 + for(uint8_t i = 0; i < 3; i++) { - tem4 = 0; - } - if(tem4 < 0) - { - tem4 = tem4 + 360.0; - } - if(tem4>360.0) - { - tem4 = tem4 - 360.0; + if(tem4 == 360.0)///////解决既显示360又显示角度0的问题 + { + tem4 = 0; + } + else if( tem4 < 0 ) + { + tem4 = tem4 + 360.0; + } + else if( tem4 > 360.0 ) + { + tem4 = tem4 - 360.0; + } + if (tem4 >=0 && tem4 <= 360.0) + { + break; + } } g_ptz.hori_angle_actual = tem4;