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 | 29 ++++++++++++++--------------- 1 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Src/main.c b/Src/main.c index 1c24fc3..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; @@ -255,7 +263,7 @@ Usart1ParseDataCallback = UsartParseDataHandler; parameter_init(); //deca_sleep(1000); - g_com_map[VERSION] = 0x0212; + g_com_map[VERSION] = 0x0213; // g_com_map[DEV_ID]=0x11; #ifdef DEBUG_MODE // g_com_map[DEV_ROLE]=1; @@ -438,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)) @@ -830,7 +838,7 @@ } extern u16 tagslotpos; extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag; -float key_keeptime,motor_keeptime; +float key_keeptime; extern float motor_ontime; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { @@ -841,11 +849,8 @@ SetNextPollTime(tagslotpos); nomove_count+=(float)g_com_map[COM_INTERVAL]/1000; if(motor_keeptime>0) - { - motor_state = 2; + { motor_keeptime-=(float)g_com_map[COM_INTERVAL]/1000; - }else{ - motor_state = 0; } if(active_flag==0) { @@ -881,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