From 768ce43ddc4bd349f7dba772cf478915d550420c Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期五, 26 一月 2024 10:25:27 +0800 Subject: [PATCH] 版本v1.4 修复不上传电量 --- Src/main.c | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Src/main.c b/Src/main.c index 6f4507c..b9a1a2d 100644 --- a/Src/main.c +++ b/Src/main.c @@ -33,7 +33,7 @@ #define NSH1 0x0001 #define GP 0x0002 #define FLASH_HARDWARE_VERSION_MAP (uint32_t)0x08004F00 //硬件版本号和批次信息位置 -//#define DEBUG_MODE +#define DEBUG_MODE /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -276,9 +276,9 @@ break; } } -uint16_t bigslot_num; +uint16_t bigslot_num,nomovesleeptime; int16_t g_commap_antdelay; -u8 active_flag,nomovesleeptime; +u8 active_flag; void Program_Init(void) { float temp; uint16_t temp2; @@ -289,7 +289,7 @@ hardware_pici = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2); hardware_type = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4); //deca_sleep(1000); - g_com_map[VERSION] = (1<<8)|34; + g_com_map[VERSION] = (1<<8)|4; active_flag = g_com_map[ACTIVE_INDEX]; module_power = g_com_map[POWER]; imu_enable=g_com_map[IMU_ENABLE]; @@ -303,7 +303,7 @@ slot_startcount=tyncpoll_time*1000/LPTIMER_LSB; lastpoll_time=tyncpoll_time; tag_frequency = 1000/g_com_map[COM_INTERVAL]; - bigslot_num = TOTAL_SLOTNUM/tag_frequency; +// bigslot_num = TOTAL_SLOTNUM/tag_frequency; total_slotnum = 1000/g_com_map[COM_INTERVAL]; nomovesleeptime = g_com_map[NOMOVESLEEP_TIME]; if(active_flag==0) @@ -455,15 +455,7 @@ // LED_TR_BLINK;s bat_percent=Get_Battary(); - if(bat_percent>15) - { LED_TB_ON; - Tag_App(); - LED_TB_OFF; - } else { - LED_TR_ON; - Tag_App(); - LED_TR_OFF; - } + Tag_App(); //LED0_BLINK; IdleTask(); if(waitusart_timer>0) @@ -917,6 +909,8 @@ } extern uint8_t tx_near_msg[80],stationary_flag; float key_keeptime; +uint16_t current_count1; +uint16_t lpcount1; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { static uint8_t i=0; @@ -924,6 +918,16 @@ g_start_send_flag=1; current_slotnum++; // SetNextPollTime(tyncpoll_time); + + current_count1=HAL_LPTIM_ReadCounter(&hlptim1); + lpcount1 = current_count1+32.768*g_com_map[COM_INTERVAL];; + if(lpcount1>=32768) + { + lpcount1 -=32768; + } + __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount1); + + nomove_count+=(float)g_com_map[COM_INTERVAL]/1000; if(motor_keeptime>0) { @@ -951,7 +955,7 @@ } if(nomove_count>=nomovesleeptime-1&&imu_enable) { - tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT; +// tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT; } if(nomove_count>nomovesleeptime&&imu_enable) { -- Gitblit v1.9.3