From e3d28cbb2bbf0c65af4d3d57e649f7ef0a6cbdb6 Mon Sep 17 00:00:00 2001
From: zhyinch <zhyinch@gmail.com>
Date: 星期六, 13 八月 2022 21:50:01 +0800
Subject: [PATCH] 1

---
 Src/application/dw_app.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c
index babb107..0bc8c12 100644
--- a/Src/application/dw_app.c
+++ b/Src/application/dw_app.c
@@ -766,7 +766,9 @@
 //			tyncpoll_time = (tagslotpos--%max_slotpos)*slottime;
 	}
 }
-
+extern float nomove_count;
+uint8_t pack_length = 0,pack_index = 0,pack_msgtype = 0;
+uint8_t motor_flag;
 void NearPoll(void)
 {
 	
@@ -790,9 +792,15 @@
 
 	recbase_num=0;
 //	motor_state=0;
+    if(motor_keeptime>0)
+    {
+        motor_flag = 1;
+    }else{
+        motor_flag = 0;
+    }
 	
 	tx_near_msg[BATTARY_IDX] = bat_percent;
-	tx_near_msg[BUTTON_IDX] = userkey_state|stationary_flag<<1|gotosleep_flag<<2;
+	tx_near_msg[BUTTON_IDX] = userkey_state|stationary_flag<<1|gotosleep_flag<<2|motor_flag<<5;
 	tx_near_msg[SEQUENCE_IDX] = frame_seq_nb;
   tx_near_msg[SEQUENCEH_IDX] = (frame_seq_nb++)>>8;
 	tx_near_msg[NEARBASENUM_INDEX] = nearbase_num;
@@ -1017,7 +1025,7 @@
 
 			if(para_update)
 			{
-			uint8_t pack_length = 0,pack_index = 0,pack_msgtype = 0;
+			
 				pack_msgtype = rec_remotepara[0];
 				pack_index = rec_remotepara[1];
 				pack_length = rec_remotepara[2];
@@ -1025,11 +1033,12 @@
 				{
 					if( pack_index == MOTOR_ONTIME_INDEX)
 					{
-                        if(motor_keeptime==0)
+                       // if(motor_keeptime==0)
                             motor_keeptime = rec_remotepara[3];
 					}else{
                         if(pack_index<200)
                         {
+													nomove_count = 0;
                             memcpy((uint8_t*)&g_com_map + pack_index, &rec_remotepara[3], pack_length);
                             //返回一个error状态
                             //SendComMap(pack_datalen,pack_index);
@@ -1085,7 +1094,7 @@
 		dwt_starttx(DWT_START_TX_IMMEDIATE | DWT_RESPONSE_EXPECTED);//开启发送,发送完成后等待一段时间开启接收,等待时间在dwt_setrxaftertxdelay中设置
 	while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到成功接收或者发生错误
 	{ 
-		IdleTask();
+//		IdleTask();
 		
 	};
 		if(status_reg==0xffffffff)
@@ -1147,8 +1156,6 @@
 	//LED0_ON;
 	SPIx_CS_GPIO->BRR = SPIx_CS;
 	delay_us(700);
-   // GetPressAndHeight();
-   // intheight = Height*100;
 	SPIx_CS_GPIO->BSRR = SPIx_CS;
 	id =  dwt_readdevid() ;
 	    while (DWT_DEVICE_ID != id) 
@@ -1158,7 +1165,7 @@
         IdleTask();	
         if(error_times++>20)
         {
-            printf("DW ID ERROR.\r\n");
+            //printf("DW ID ERROR.\r\n");
             SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader   
         }
     }
@@ -1187,6 +1194,8 @@
 			break;
 		case NEARPOLL:	
 			NearPoll();
+		//	GetPressAndHeight();
+			//intheight = Height*100;
 			break;
         case SINGLEPOLL:
             Poll();

--
Gitblit v1.9.3