From 76c6f753fae3cc84ebb0f129d10aff2fb5c9720f Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期五, 08 八月 2025 16:56:23 +0800 Subject: [PATCH] 免布线基站V1.13,修改电量百分比算法,使能显示到100% --- keil/include/main/main.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/keil/include/main/main.c b/keil/include/main/main.c index 9de8816..535653b 100644 --- a/keil/include/main/main.c +++ b/keil/include/main/main.c @@ -61,7 +61,7 @@ #define TEST_UART_MODE TEST_UART_DMA_MODE #define NUM_SAMPLES 1 -#define SLEEP_START_TIME 1 +#define SLEEP_START_TIME 10 #define FREQ_LOST_TIME 5 #define NOTAG_FREQ 1 #define BATTERY_GET_TIME 3600 @@ -118,7 +118,7 @@ .callback = app_wdt_callback, }; -uint8_t state5v = 1; +uint8_t state5v = 0; uint8_t bat_percent=0,g_start_send_flag=1; int16_t fVoltage_mv; uint8_t bat_percent; @@ -133,6 +133,7 @@ void boot_deinit(void); void Get_batterty_Voltage(void); void Calculate_battery_percent(void); +uint8_t sleep_limit_time=1; static void uart_receive_callback(void *dev, uint32_t err_code) { uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); @@ -162,13 +163,13 @@ { bat_percent = 0; } - else if(fVoltage_mv > 3500) + else if(fVoltage_mv > 3260) { bat_percent = 100; } else { - bat_percent = ((fVoltage_mv - 3000) /8); + bat_percent = ((fVoltage_mv - 3000) /3); } //LOG_INFO(TRACE_MODULE_APP, "The voltage is %d ,percent is %%%d \r\n",fVoltage_mv,bat_percent); } @@ -180,8 +181,8 @@ if(reboot_num>=3600) NVIC_SystemReset(); //软复位回到bootloader enable_sleep_count++; - if(enable_sleep_count==SLEEP_START_TIME){ - + + if(enable_sleep_count==sleep_limit_time){ enable_sleep_count=0; sleep_flag=1; } @@ -239,21 +240,24 @@ group_id=g_com_map[GROUP_ID]; memcpy(&dev_id ,&g_com_map[DEV_ID],2); tag_frequency=1000/g_com_map[COM_INTERVAL]; -g_com_map[VERSION] = (1<<8)|11; +g_com_map[VERSION] = (1<<8)|13; LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id); LOG_INFO(TRACE_MODULE_APP,"固件版本:UWB-免布线信标 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); } +uint8_t test1; void IdleTask(void) { UART0_CheckReceive(); + test1=gpio_pin_get_val(INPUT_5V_Pin); if(gpio_pin_get_val(INPUT_5V_Pin)) { - - //UART_CheckSend(); // bat_percent=Get_Battary(); if(state5v==0) { state5v=1; + sleep_flag=0; + sleep_limit_time=30;//新增插入串口后30s不休眠 + enable_sleep_count=0;//重新插拔可以重置时间 } }else{ if(state5v==1) @@ -338,11 +342,11 @@ #endif //Serial0_PutString("进入app测试\r\n"); while (1) - { wdt_ping(WDT_ID0);//喂狗 + { if(g_start_send_flag) { //LOG_INFO(TRACE_MODULE_APP, "测距ing"); - + wdt_ping(WDT_ID0);//喂狗 g_start_send_flag = 0; gpio_pin_set(LED_PIN);//亮 TagRange(); -- Gitblit v1.9.3