zhunk 1 год назад
Родитель
Сommit
1134d29419
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      Application_cbd_apm32f1/applications/hmi.c

+ 3 - 2
Application_cbd_apm32f1/applications/hmi.c

@@ -1390,7 +1390,7 @@ void thread1_signal_handler(int sig)
             }
             g_initial_move = false;
         } else {
-            if(current_sharpness< g_last_sharpness){    //持续3次清晰度降低,调整行进方向
+            if(current_sharpness< (g_last_sharpness+0.5f)){    //持续3次清晰度降低,调整行进方向
                 counter_sharpness_reduce++;
                 LOG_I("[对焦] 清晰度下降,次数:%d", counter_sharpness_reduce);
                 if(counter_sharpness_reduce>=3){
@@ -1436,7 +1436,7 @@ void thread1_signal_handler(int sig)
 
 
         /* 终止条件检测 */
-        if (stepSize < 1 || maxIterations <= 0 || g_peak_counter >= 3) {
+        if (maxIterations <= 0 || g_peak_counter >= 3) {
             LOG_I("[对焦] 完成搜索,最佳位置:%d (清晰度:%.2f)", g_best_pos, g_best_sharpness);
             if (g_peak_counter >= 3) {
                 LOG_I("[对焦] 连续三次波动确认峰值");
@@ -1447,6 +1447,7 @@ void thread1_signal_handler(int sig)
             {
                 maxIterations = 120;
                 dir = !dir;
+                current_pos = 0;
             }else{
                 char *c0 = makeJson_Warn("auto_focus","auto_focus");
                 DTU_Write("%s",c0);