Explorar o código

利用位移来判断跳的动作,测试通过

jianboliang %!s(int64=4) %!d(string=hai) anos
pai
achega
f5cec9b7b7

+ 82 - 39
smart_shoes/nRF5_SDK_17.0.0_9d13099/examples/proprietary_rf/esb_prx/press_down_detect.c

@@ -2,6 +2,8 @@
 #include <stdint.h>
 #include <string.h>
 
+extern void gpio_mt_run(uint32_t tim);
+
 #define PRESS_LEGTH 15
 #define DETECT_DOWN_SIZE 2
 
@@ -241,7 +243,7 @@ int press_down_detect_new(int index, int left_press, int right_press)
             
 		}
 
-		if (now_mean_min_val < last_mean_min_val || left_press < left_press_low + 100000 || right_press < right_press_low + 100000)
+		if (now_mean_min_val < last_mean_min_val || left_press < left_press_low + 200000 || right_press < right_press_low + 200000)
 		{
 			mean_up = 0;
             mean_up_true = 0;
@@ -257,8 +259,8 @@ int press_down_detect_new(int index, int left_press, int right_press)
         
         //if(mean_up_true > 20 && mean_max_val - mean_min_val > 500000)
         if(mean_up_true > 15 && 
-          (right_max_val - right_min_val > 750000 || left_max_val - left_min_val > 750000)
-          && mean_max_val - mean_min_val > 200000)
+          (right_max_val - right_min_val > 600000 && left_max_val - left_min_val > 600000)
+         )
         {
             is_down = 1;
         }
@@ -305,40 +307,29 @@ int press_down_detect_new(int index, int left_press, int right_press)
     return 0;
 }
 
-
-
-short press_jump_detect(int index)
+short press_jump_detect(short *h_pos, short *s_pos)
 {
-    if(left_press_data[(index - 1) % PRESS_LEGTH] < left_press_low + 100000)
-    {
-        left_up_count = left_up_count + 1;
-    }
-    else
-    {
-        left_up_count = 0;
-    }
-    if(right_press_data[(index - 1) % PRESS_LEGTH] < right_press_low + 100000)
-    {
-        right_up_count = right_up_count + 1;
-    }
-    else
-    {
-        right_up_count = 0;
-    }
-    
-    
-	if(index >= 10)
+	if(h_pos[2] > 0)
 	{
-		int max_left_press  = max_press_window(left_press_data,  PRESS_LEGTH);
-		int max_right_press = max_press_window(right_press_data, PRESS_LEGTH);
-
-		if( left_up_count < 10 && left_up_count> 0 &&
-			right_up_count < 10  &&   right_up_count > 0&&
-			(right_press_data[(index - 1) % PRESS_LEGTH] - max_right_press < -1000000
-			 || left_press_data[(index - 1) % PRESS_LEGTH] - max_left_press < -1000000)
-			 )
-        {
-			if(last_jump_stage == 0)
+		left_up_count = left_up_count + 1;
+	}
+	else
+	{
+		left_up_count = 0;
+	}
+	
+	if(s_pos[2] > 0)
+	{
+		right_up_count = right_up_count + 1;
+	}
+	else
+	{
+		right_up_count = 0;
+	}
+	
+	if(right_up_count > 0 && left_up_count > 0)
+	{
+			if(last_jump_stage == 0 && right_up_count < 15 && left_up_count < 15)
 			{
 				jump_count = jump_count + 1;
 				
@@ -348,16 +339,66 @@ short press_jump_detect(int index)
 			}
 			
 			return 0;
-            
-        }
-        
 	}
-	
+		
 	last_jump_stage = 0;
 	
 	return 0;
+	
 }
 
+
+//short press_jump_detect(int index)
+//{
+//    if(left_press_data[(index - 1) % PRESS_LEGTH] < left_press_low + 100000)
+//    {
+//        left_up_count = left_up_count + 1;
+//    }
+//    else
+//    {
+//        left_up_count = 0;
+//    }
+
+//    if(right_press_data[(index - 1) % PRESS_LEGTH] < right_press_low + 100000)
+//    {
+//        right_up_count = right_up_count + 1;
+//    }
+//    else
+//    {
+//        right_up_count = 0;
+//    }
+//    
+//    
+//	if(index >= 10)
+//	{
+//		int max_left_press  = max_press_window(left_press_data,  PRESS_LEGTH);
+//		int max_right_press = max_press_window(right_press_data, PRESS_LEGTH);
+
+//		if( left_up_count> 4 && right_up_count > 4
+////			(right_press_data[(index - 1) % PRESS_LEGTH] - max_right_press < -1000000
+////			 || left_press_data[(index - 1) % PRESS_LEGTH] - max_left_press < -1000000)
+//			 )
+//        {
+//			if(last_jump_stage == 0)
+//			{
+//				jump_count = jump_count + 1;
+//				
+//				last_jump_stage = 1;
+//				
+//				return 1;
+//			}
+//			
+//			return 0;
+//            
+//        }
+//        
+//	}
+//	
+//	last_jump_stage = 0;
+//	
+//	return 0;
+//}
+
 void press_minimum_eval(int left_press, int right_press, short h_pos_z, short s_pos_z)
 {
 	if(right_press > right_press_max_val)
@@ -421,6 +462,8 @@ void press_minimum_eval(int left_press, int right_press, short h_pos_z, short s_
 		left_press_max_val = 0;
 		right_press_max_val = 0;
 		
+//		gpio_mt_run(500);
+		
 	}
 }
 

+ 10 - 7
smart_shoes/nRF5_SDK_17.0.0_9d13099/examples/proprietary_rf/esb_prx/process_result.c

@@ -37,15 +37,18 @@ void sen_data_pos(void)
 	uint8_t L=0;
 	
 	static short count = 0;
-	buf[L++] = (uint8_t)(h_pos[0]>>8);
-	buf[L++] = (uint8_t)(h_pos[0]>>0);
-	
-	buf[L++] = (uint8_t)(h_pos[1]>>8);
-	buf[L++] = (uint8_t)(h_pos[1]>>0);
+//	buf[L++] = (uint8_t)(h_pos[0]>>8);
+//	buf[L++] = (uint8_t)(h_pos[0]>>0);
+//	
+//	buf[L++] = (uint8_t)(h_pos[1]>>8);
+//	buf[L++] = (uint8_t)(h_pos[1]>>0);
 	
 	buf[L++] = (uint8_t)(h_pos[2]>>8);
 	buf[L++] = (uint8_t)(h_pos[2]>>0);
 	
+	buf[L++] = (uint8_t)(s_pos[2]>>8);
+	buf[L++] = (uint8_t)(s_pos[2]>>0);
+	
 	buf[L++] = (uint8_t)(count>>8);
 	buf[L++] = (uint8_t)(count>>0);
 	count ++;
@@ -147,7 +150,7 @@ void sen_data_left_press(void)
 }
 void send_data_to_pc(void)
 {
-	sen_data_press();
+	sen_data_pos();
 	
 }
 
@@ -188,7 +191,7 @@ void process_motion()
 
 	short jump_tag  = 0;
 	
-	jump_tag  = press_jump_detect(time_stamp);
+	jump_tag  = press_jump_detect(h_pos , s_pos);
 	
 	if (jump_tag)
 	{

+ 1 - 2
smart_shoes/nRF5_SDK_17.0.0_9d13099/examples/proprietary_rf/esb_prx/process_result.h

@@ -27,9 +27,8 @@ extern int16_t s_pos[3];
 
 extern void  press_minimum_eval(int, int, short, short);
 extern short press_down_detect_new(int, int, int);
-extern short press_jump_detect(int);
+extern short press_jump_detect(short*, short*);
 extern short footPDR(int, float*, float*, int, short*, short*);
 extern void send_protocol(uint8_t ,uint8_t ,uint8_t* ,uint8_t );
 
-
 #endif