From df5669303bd54d7bfd553c7cfad279231d7ece17 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期五, 25 四月 2025 09:33:37 +0800 Subject: [PATCH] 3.6,加入蜂鸣器等逻辑 --- APL/App.c | 90 +++++++++++++++++++++++++++++--------------- 1 files changed, 59 insertions(+), 31 deletions(-) diff --git a/APL/App.c b/APL/App.c index d6567af..6827944 100644 --- a/APL/App.c +++ b/APL/App.c @@ -195,7 +195,7 @@ //deca_sleep(1000); g_com_map[GROUP_ID]=3; - g_com_map[VERSION] = (3<<8)|1; + g_com_map[VERSION] = (3<<8)|6; if (g_com_map[COM_INTERVAL] <50) { @@ -290,7 +290,7 @@ uwbled=WHITE; loraled=WHITE; powerled=WHITE; - + Set4LEDColor(uwbled,gpsled,loraled,powerled); if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_12)==0) { powercount = 0; @@ -298,7 +298,7 @@ while(1) { - if((HIDO_TimerGetTick() - l_u32QXpowerTick) >=100) +// if((HIDO_TimerGetTick() - l_u32QXpowerTick) >=100) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); @@ -379,6 +379,8 @@ loraled = 1; HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET); } +extern uint8_t ledonflag; +extern uint32_t ledontime; void PowerLedTask(void) { static u8 powerled_state=0; @@ -447,36 +449,27 @@ chargedbg_flag = 0; } - if(HIDO_TimerGetTick()%1000<50 ) + if(HIDO_TimerGetTick()-ledontime>100&&ledonflag==1) { -// if(powerled_state==0) + ledonflag=0; + Set4LEDColor_Off(); + } +// else // { -////// if(bat_percent>15) -////// { -////// powerled = BLUE; -////// }else{ -////// powerled = RED; -////// } -// powerled_state = 1; -//// // bat_percent = Battery_GetPercentage(); -////// Set4LEDColor(uwbled,gpsled,loraled,powerled); -// } - }else - { -// if(powerled_state) - { - powerled_state = 0; -// powerled = LEDOFF; -// uwbled = LEDOFF; -// gpsled = LEDOFF; -// loraled = LEDOFF; -// Set4LEDColor(uwbled,gpsled,loraled,powerled); - Set4LEDColor_Off(); - } - - } +//// if(powerled_state) +// { +// powerled_state = 0; +//// powerled = LEDOFF; +//// uwbled = LEDOFF; +//// gpsled = LEDOFF; +//// loraled = LEDOFF; +//// Set4LEDColor(uwbled,gpsled,loraled,powerled); +// Set4LEDColor_Off(); +// } +// +// } - + if(HIDO_TimerGetTick()-adctick>6000) //10分钟采样一次 电量 { adctick = HIDO_TimerGetTick(); @@ -505,6 +498,12 @@ } } } + if(bat_percent<=1) + { + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8, GPIO_PIN_RESET); + } } extern uint32_t main_time; @@ -513,6 +512,33 @@ char str[17]= {"AT+IPR=9600;&W\r\n"}; extern UART_HandleTypeDef huart5; extern uint8_t stop_flag; +extern uint16_t beepontime; +u32 keystarttime,keystarttime2; +extern uint8_t userkey_state4g; +void UserKeyTask(void) +{ + if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_1)) + { + if(HIDO_TimerGetTick() - keystarttime>1000) + { + beepontime = 2; + userkey_state4g = 1; +// userkey_state = 1; +// heartbeasend_flag = 1; + keystarttime = HIDO_TimerGetTick(); + } + }else + { + keystarttime = HIDO_TimerGetTick(); + keystarttime2 = HIDO_TimerGetTick(); + } + if(beepontime>0) + {Beep_On();} + else + {Beep_Off();} + Sleep_Panduan_Poll(); + +} void Main_Poll() { // if(main_time>10&&only_one_flag==0) @@ -538,8 +564,10 @@ HIDO_ATLitePoll(); UDPClient_Poll(); HAL_IWDG_Refresh(&hiwdg); - PowerDownDetect(); + PowerDownDetect(); + UserKeyTask(); Sleep_Panduan_Poll(); + } // if(AIR780E_IsIPIdle() && Socket_IsSendQueueEmpty(0)) // { -- Gitblit v1.9.3