优化272表冠校准 2925/target/2 2927/1 2927/head
authorpenglei <1624952103@qq.com>
Mon, 15 Dec 2025 09:00:10 +0000 (17:00 +0800)
committerpenglei <1624952103@qq.com>
Mon, 15 Dec 2025 09:00:10 +0000 (17:00 +0800)
code/sdk/zhihui/drivers/rotary_encoder/hx3508/hx3508.c

index 7105816..fe0e629 100644 (file)
@@ -134,7 +134,9 @@ void hx3508_get_sum_y(float *data)
 {
     if(sum_deltay && coffy!= 0 && data != 0 && sum_deltay != 0)
     {
-        g_sum_y = 360/(float)sum_deltay * 1000 * coffy;
+        printf("sum_deltay : %d coffy : %.3f\n",sum_deltay,coffy);
+        // g_sum_y = 360/(float)sum_deltay * 1200 * coffy;
+        g_sum_y = (float)sum_deltay/1200.0f * 360.0f* coffy;
         // printf("sum_deltay : %d\n",sum_deltay);
         // printf("g_sum_y : %.3f,coffy : %.3f\n",g_sum_y,coffy);
         *data = -g_sum_y;
@@ -580,14 +582,18 @@ void ots_data_handler(void *p_event_data, uint16_t event_size)
     }
     else
     {  
-        timer_cnt++;
-        if (timer_cnt >= 200)  // 20*10 = // 200ms:200ms内sensor没有检测到表冠转动就会关闭定时器重新开启中断响应
+        if(!factory_flag)
         {
-            // printf("hx3508 enter int mode\n");
-            ots_timer_stop();           // 关闭定时器
-            uapi_pin_set_ie(INT_PIN,HAL_PIO_IE_ENBALE);
-            timer_cnt = 0;
+            timer_cnt++;
+            if (timer_cnt >= 200)  // 20*10 = // 200ms:200ms内sensor没有检测到表冠转动就会关闭定时器重新开启中断响应
+            {
+                // printf("hx3508 enter int mode\n");
+                ots_timer_stop();           // 关闭定时器
+                uapi_pin_set_ie(INT_PIN,HAL_PIO_IE_ENBALE);
+                timer_cnt = 0;
+            }
         }
+        
         if (stand_still == 0) 
         {
             //上次是转动,上报状态改变