From f603e50972a701a41c17fc97c9c82f85b6639200 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期四, 12 十一月 2020 11:29:41 +0800 Subject: [PATCH] 增加基站转点距离,增加主基站最后回复。 --- Src/main.c | 44 +++++++++++++++++++++++++++----------------- 1 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Src/main.c b/Src/main.c index acac73c..cd4693f 100644 --- a/Src/main.c +++ b/Src/main.c @@ -29,7 +29,7 @@ #include "global_param.h" #include "TrackingDiff.h" #include "dw_app.h" -//#define DEBUG_MODE +#define DEBUG_MODE /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -123,11 +123,8 @@ // LED_TR_OFF; current_time=GetLPTime(); //motor_state=2; - if(g_com_map[MOTOR_ONTIME]>0) - { - g_com_map[MOTOR_ONTIME]--; - motor_state = 1; - } +if(g_com_map[MOTOR_ENABLE]) +{ switch(motor_state) {case 0: MOTOR_OFF; @@ -148,6 +145,7 @@ MOTOR_OFF; break; } +} if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) { nomove_count = 0; @@ -212,8 +210,8 @@ u16 current_slotnum; extern int32_t offsettimeus; -#define FIXSLOT -#define FIXSLOTPOS 3 +//#define FIXSLOT +#define FIXSLOTPOS 8 u16 slotpos_intoatl; uint16_t bigslot_num; uint8_t fix_slotpos =FIXSLOTPOS; @@ -252,26 +250,29 @@ Usart1ParseDataCallback = UsartParseDataHandler; parameter_init(); //deca_sleep(1000); - g_com_map[VERSION] = 0x0205; + g_com_map[VERSION] = 0x0209; #ifdef DEBUG_MODE // g_com_map[DEV_ROLE]=1; // g_com_map[DEV_ID]=0x123; // g_com_map[COM_INTERVAL]=100; // g_com_map[MAX_REPORT_ANC_NUM]=1; // g_com_map[NOMOVESLEEP_TIME]=10; - g_com_map[IMU_ENABLE]=0; - g_com_map[COM_INTERVAL]=100; + // g_com_map[IMU_ENABLE]=0; + //g_com_map[COM_INTERVAL]=50; #endif //g_com_map[NOMOVESLEEP_TIME]=10; - // g_com_map[COM_INTERVAL]=100; +// g_com_map[IMU_ENABLE]=0; +// g_com_map[COM_INTERVAL]=50; if(g_com_map[COM_INTERVAL]==0) { g_com_map[COM_INTERVAL]=100; } - if(module_power>MAX_RFPOWER) - {module_power=MAX_RFPOWER;} - if(module_power<0) - {module_power=0;} + if(g_com_map[IMU_THRES]>10) + {g_com_map[IMU_THRES]=2;} + if(g_com_map[POWER]>MAX_RFPOWER) + {g_com_map[POWER]=MAX_RFPOWER;} + if(g_com_map[POWER]<0) + {g_com_map[POWER]=0;} module_power = g_com_map[POWER]; imu_enable=g_com_map[IMU_ENABLE]; motor_enable=g_com_map[MOTOR_ENABLE]; @@ -426,7 +427,8 @@ } if(m_bEUARTTxEn==0&&waitusart_timer==0) { -#ifndef DEBUG_MODE +#ifndef DEBUG_MODE + if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); #endif } @@ -816,6 +818,7 @@ extern u16 tagslotpos; extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag; float key_keeptime; +extern float motor_ontime; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { static uint8_t i=0; @@ -824,6 +827,13 @@ current_slotnum++; SetNextPollTime(tagslotpos); nomove_count+=(float)g_com_map[COM_INTERVAL]/1000; + if(motor_ontime>0) + { + motor_ontime-=(float)1/tag_frequency; + motor_state = 2; + }else{ + motor_state = 0; + } if(!GET_USERKEY) { key_keeptime+=(float)g_com_map[COM_INTERVAL]/1000; -- Gitblit v1.9.3