From 03c3a1878df2cb6a72fdffa393c9e453f6e1b6ac Mon Sep 17 00:00:00 2001
From: WXK <287788329@qq.com>
Date: 星期五, 03 十一月 2023 16:40:00 +0800
Subject: [PATCH] 版本v2.11,修改防撞基站剔除机制。

---
 Src/main.c |   61 +++++++++++++++++++++++++-----
 1 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/Src/main.c b/Src/main.c
index 276f3c4..1f917c9 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -31,7 +31,7 @@
 
 #define NSH1 0x0001
 #define GP   0x0002
-//#define DEBUG_MODE
+#define DEBUG_MODE
 /* USER CODE END Includes */
 
 /* Private typedef -----------------------------------------------------------*/
@@ -94,6 +94,7 @@
 extern float nomove_count;
 float motor_keeptime;
 uint8_t imu_enable,motor_enable;	
+uint8_t chongqi_num;
 u16 GetLPTime(void)
 {
 	u16 count=HAL_LPTIM_ReadCounter(&hlptim1);
@@ -234,8 +235,8 @@
 	hardware_pici= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2);
 	hardware_type= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4);
 	//deca_sleep(1000);
-	g_com_map[VERSION] = (2<<8)|5;
-    
+	g_com_map[VERSION] = (2<<8)|11;
+//    g_com_map[COM_INTERVAL]=200;
 //	g_com_map[DEV_ID]=0x7;
 #ifdef DEBUG_MODE
 //	g_com_map[DEV_ROLE]=1;
@@ -271,13 +272,13 @@
 	current_time=GetLPTime();
     nomovesleep_time = g_com_map[NOMOVESLEEP_TIME];
     interval = g_com_map[COM_INTERVAL];
-    if(active_flag==0)
-	{   
-        interval=1000;
-		imu_enable=1;
-		nomovesleep_time = 10;
-		motor_enable=0;
-	}
+//    if(active_flag==0)
+//	{   
+//        interval=1000;
+//		imu_enable=1;
+//		nomovesleep_time = 10;
+//		motor_enable=0;
+//	}
     tag_frequency = 1000/interval;
 		if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, slot_startcount) != HAL_OK)  //system time is 1010ms   1 puls=30.518us
   {
@@ -354,6 +355,8 @@
 {
 		//SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader   
 }
+uint8_t i;
+uint8_t uwb_tx[300]={0,};
 /* USER CODE END 0 */
 
 /**
@@ -410,7 +413,10 @@
 	{
 	 Error_Handler();
 	}
-   
+   for(i=0;i<255;i++)
+    {
+    uwb_tx[i]=i;
+    }
 	
 //	HAL_Delay(2000);
 //	mcu_sleep();
@@ -448,6 +454,7 @@
 //		HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_RESET);
 //		}
 //		LED_TR_BLINK;
+            chongqi_num=0;
 			__disable_irq();
 		if(bat_percent>15)
 		{	LED_TB_ON;
@@ -918,16 +925,48 @@
 extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag;
 float key_keeptime;
 extern float motor_ontime,button_delay;
+uint32_t tagdisterror_list[TAG_NUM_IN_SYS];
+extern uint16_t taglist_num;
+extern int32_t tagdist_list[TAG_NUM_IN_SYS];
+extern uint16_t tagid_list[TAG_NUM_IN_SYS];
+void Up_tagdisterror_list_Poll()
+{
+    static uint8_t r=0;
+    static uint8_t t=0;
+    for(r=0;r<taglist_num;r++)
+    {
+        tagdisterror_list[r]++;
+        if(tagdisterror_list[r]>10)
+        {
+            for(t=r;t<taglist_num;t++)
+            {
+            tagdist_list[t]=tagdist_list[t+1];
+            tagid_list[t]=tagid_list[t+1];
+            tagdisterror_list[t]=tagdisterror_list[t+1];
+            taglist_num=taglist_num-1;
+            }
+        }
+    }
+}
 void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim)
 {
 	static uint8_t i=0;
 	SystemClock_Config();
 	g_start_send_flag=1;
+    chongqi_num++;
+    if(chongqi_num>20)
+    {NVIC_SystemReset();}
 //	current_slotnum++;
 //	SetNextPollTime(tagslotpos);
     if(button_delay<1)
     button_delay+=1/(float)tag_frequency;
 	nomove_count+=1/(float)tag_frequency;
+//Up_tagdisterror_list_Poll();
+//    memset(tagdist_list,0,taglist_num);
+//    memset(tagid_list,0,taglist_num);
+//    taglist_num=0;
+    TagListUpdate();
+     bubble_sort(tagdist_list,taglist_num);
 	if(motor_keeptime>0)
 	{	
         motor_keeptime-=1/(float)tag_frequency;

--
Gitblit v1.9.3