From 3a1d007b19b92f62bbbb8f14cbbdb26a61ac05f5 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期五, 25 十二月 2020 13:47:54 +0800 Subject: [PATCH] V2.19 下发震动功能 --- Src/main.c | 59 +++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Src/main.c b/Src/main.c index 2afbd19..2b5cc59 100644 --- a/Src/main.c +++ b/Src/main.c @@ -88,6 +88,7 @@ uint16_t lastpoll_count,interval_count,slot_startcount,tag_frequency,lastpoll_time,current_time; extern uint8_t module_power; extern float nomove_count; +float motor_keeptime; uint8_t imu_enable,motor_enable; u16 GetLPTime(void) { @@ -104,9 +105,10 @@ Error_Handler(); } } +u16 current_time; uint8_t state5v; void IdleTask(void) -{u16 current_time; +{ UART_CheckReceive(); UART_CheckSend(); @@ -125,6 +127,12 @@ //motor_state=2; if(g_com_map[MOTOR_ENABLE]) { + if(motor_keeptime>0) + { + motor_state = 2; + }else{ + motor_state = 0; + } switch(motor_state) {case 0: MOTOR_OFF; @@ -209,7 +217,7 @@ u16 current_slotnum; extern int32_t offsettimeus; -#define FIXSLOT +//#define FIXSLOT #define FIXSLOTPOS 2 u16 slotpos_intoatl; uint16_t bigslot_num; @@ -255,7 +263,8 @@ Usart1ParseDataCallback = UsartParseDataHandler; parameter_init(); //deca_sleep(1000); - g_com_map[VERSION] = 0x0210; + g_com_map[VERSION] = 0x0213; +// g_com_map[DEV_ID]=0x11; #ifdef DEBUG_MODE // g_com_map[DEV_ROLE]=1; // g_com_map[DEV_ID]=0x11; @@ -266,8 +275,8 @@ //g_com_map[COM_INTERVAL]=50; #endif //g_com_map[NOMOVESLEEP_TIME]=10; - g_com_map[IMU_ENABLE]=0; - g_com_map[COM_INTERVAL]=1000; +// g_com_map[IMU_ENABLE]=0; +// g_com_map[COM_INTERVAL]=1000; active_flag = g_com_map[ACTIVE_INDEX]; if(active_flag==0) { g_com_map[COM_INTERVAL]=1000; @@ -306,9 +315,9 @@ Error_Handler(); } //g_com_map[NOMOVESLEEP_TIME]=5; - printf("标签ID: %d .\r\n",dev_id); - printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]); - printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]); +// printf("标签ID: %d .\r\n",dev_id); +// printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]); +// printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]); // printf("DEVICE PAIRID: %d .\r\n",g_com_map[PAIR_ID]); @@ -437,7 +446,7 @@ { waitusart_timer--; } - if(m_bEUARTTxEn==0&&waitusart_timer==0) + if(m_bEUARTTxEn==0&&waitusart_timer==0&&(motor_state==0||motor_state==3)) { #ifndef DEBUG_MODE if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) @@ -671,16 +680,16 @@ Error_Handler(); } /* USER CODE BEGIN USART1_Init 2 */ - GPIO_InitStruct.Pin = GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF4_USART1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - if(HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer, 1) != HAL_OK) - { - Error_Handler(); - } +// GPIO_InitStruct.Pin = GPIO_PIN_9; +// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; +// GPIO_InitStruct.Pull = GPIO_PULLUP; +// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; +// GPIO_InitStruct.Alternate = GPIO_AF4_USART1; +// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); +// if(HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer, 1) != HAL_OK) +// { +// Error_Handler(); +// } Usart1InitVariables(); /* USER CODE END USART1_Init 2 */ @@ -839,6 +848,10 @@ current_slotnum++; SetNextPollTime(tagslotpos); nomove_count+=(float)g_com_map[COM_INTERVAL]/1000; + if(motor_keeptime>0) + { + motor_keeptime-=(float)g_com_map[COM_INTERVAL]/1000; + } if(active_flag==0) { if(!GET_USERKEY) @@ -873,13 +886,7 @@ } } - 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