|
@@ -16,9 +16,9 @@ const static char *TAG = "Decection";
|
|
static int adc_raw[2][10];
|
|
static int adc_raw[2][10];
|
|
static int voltage[2][10];
|
|
static int voltage[2][10];
|
|
// 0度的电池电量映射
|
|
// 0度的电池电量映射
|
|
-batt_map batt_map_0Du[] = {
|
|
|
|
|
|
+batt_map batt_map_0Du[100] = {
|
|
//
|
|
//
|
|
- {2225, 100},
|
|
|
|
|
|
+ {2200, 100},
|
|
{2162, 99},
|
|
{2162, 99},
|
|
{2156, 98},
|
|
{2156, 98},
|
|
{2151, 97},
|
|
{2151, 97},
|
|
@@ -134,7 +134,7 @@ adc_cali_handle_t adc2_cali_handle = NULL;
|
|
// }
|
|
// }
|
|
static int get_batt_pre(int vol)
|
|
static int get_batt_pre(int vol)
|
|
{
|
|
{
|
|
- for (int i = 0; i <= 100; i++)
|
|
|
|
|
|
+ for (int i = 0; i < 100; i++)
|
|
{
|
|
{
|
|
if (vol >= batt_map_0Du[i].vol)
|
|
if (vol >= batt_map_0Du[i].vol)
|
|
{
|
|
{
|
|
@@ -169,7 +169,7 @@ int adc_read_power_pin(adc_oneshot_unit_handle_t adc_handle)
|
|
ESP_LOGD(TAG, "ADC%d Channel[%d] Cali Voltage: %d mV", USER_ADC_UNIT + 1, USER_ADC_CHANNEL, voltage[0][0]);
|
|
ESP_LOGD(TAG, "ADC%d Channel[%d] Cali Voltage: %d mV", USER_ADC_UNIT + 1, USER_ADC_CHANNEL, voltage[0][0]);
|
|
adc_calibration_deinit(adc2_cali_handle);
|
|
adc_calibration_deinit(adc2_cali_handle);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return get_batt_pre(voltage[0][0]);
|
|
return get_batt_pre(voltage[0][0]);
|
|
}
|
|
}
|
|
|
|
|