WXK
6 天以前 6e2aa19146fd20603a9e811fddd0e0dd76871efb
keil/include/main/main.c
@@ -183,31 +183,31 @@
//        LOG_INFO(TRACE_MODULE_APP, "The voltage measured %d mv\r\n",
//        ADC_INTERNAL_VREF_MV + adc_code_to_mv((int16_t)*result, ADC_INTERNAL_VREF_MV));
        fVoltage_mv=ADC_INTERNAL_VREF_MV + adc_code_to_mv((int16_t)*result, ADC_INTERNAL_VREF_MV);
        fVoltage_mv=fVoltage_mv*2;
        if(fVoltage_mv < 3300)
        fVoltage_mv=fVoltage_mv*2+1100;
        if(fVoltage_mv < 2800)
        {
            bat_percent = 0;
        }
        else if(fVoltage_mv > 4100)
        else if(fVoltage_mv > 3100)
        {
            bat_percent = 100;
        }
        else
        {
            bat_percent = ((fVoltage_mv - 3300) /8);
            bat_percent = ((fVoltage_mv - 2800) /3);
        }
    }
            if(fVoltage_mv<3300)
            {
               power_low_flag=1;
               gps_air780_power_change(gps_power_state,0);//gps原样,关闭4G
               //LOG_INFO(TRACE_MODULE_APP, "电池电压低于3.3V,4G,GPS停止工作\r\n");
            }else{
               power_low_flag=0;
               gps_air780_power_change(gps_power_state,1);//gps原样,开启4G
               //LOG_INFO(TRACE_MODULE_APP, "电池电压正常,4G,GPS,正常工作\r\n");
            }
      PCA9555_Set_One_Value_Output(ADC_MINIUS,1);//拉高
//            if(fVoltage_mv<3300)
//            {
//               power_low_flag=1;
//               gps_air780_power_change(gps_power_state,0);//gps原样,关闭4G
//               //LOG_INFO(TRACE_MODULE_APP, "电池电压低于3.3V,4G,GPS停止工作\r\n");
//            }else{
//               power_low_flag=0;
//               gps_air780_power_change(gps_power_state,1);//gps原样,开启4G
//               //LOG_INFO(TRACE_MODULE_APP, "电池电压正常,4G,GPS,正常工作\r\n");
//            }
//      PCA9555_Set_One_Value_Output(ADC_MINIUS,1);//拉高
  //  LOG_INFO(TRACE_MODULE_APP, "The voltage is %%%d \r\n",bat_percent);
}
extern uint8_t gps_uwb_flag,gps_need_data_flag;
@@ -266,16 +266,18 @@
}
void MinuteTask(void)
{      
      PCA9555_Set_One_Value_Output(ADC_MINIUS,0);//拉低
//      PCA9555_Set_One_Value_Output(ADC_MINIUS,0);//拉低
    adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样
}
//uint16_t adc_count;
//uint8_t adc_start_flag;
void SecondTask(void)
{static uint8_t second_count;
    if(second_count++>60)
    {
        second_count = 0;
        MinuteTask();
    }
//    if(adc_count++>3600&&adc_start_flag)
//    {
//        adc_count = 0;
//        MinuteTask();
//    }
      
//      if(!power_low_flag)
//      Gps_change();
@@ -420,7 +422,7 @@
    ip2 = (g_com_map[TCP_IP_2]>>12&0xf)*1000+(g_com_map[TCP_IP_2]>>8&0xf)*100+(g_com_map[TCP_IP_2]>>4&0xf)*10+(g_com_map[TCP_IP_2]&0xf);
    ip3 = (g_com_map[TCP_IP_3]>>12&0xf)*1000+(g_com_map[TCP_IP_3]>>8&0xf)*100+(g_com_map[TCP_IP_3]>>4&0xf)*10+(g_com_map[TCP_IP_3]&0xf);
    port = g_com_map[TCP_PORT];
    g_com_map[VERSION] = (1<<8)|6;
    g_com_map[VERSION] = (1<<8)|7;
    LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id);
    LOG_INFO(TRACE_MODULE_APP,"固件版本:4G-GPS定位手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
    LOG_INFO(TRACE_MODULE_APP,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port);
@@ -670,10 +672,11 @@
    sleep_timer_start(__MS_TO_32K_CNT(5000));//测试
    #endif
    board_5V_input_init(voltage_input_handler);
    adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样
//    adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样
    board_acceleration_detection_init(move_handler);
    Uwb_init();
    Dw1000_App_Init();
//    adc_get(&sample[0], NUM_SAMPLES, adc_callback);//adc采样
    while (1)
    { 
        if(flag_secondtask)