53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
#include <stdio.h>
|
|
#include "FluxPower.h"
|
|
|
|
static const char *TAG = "POWER_IO";
|
|
|
|
extern lv_obj_t * ui_Batinfo_valueVoltage;
|
|
extern lv_obj_t * ui_Batinfo_valueVolume;
|
|
extern lv_obj_t * ui_Batinfo_SpinboxBAT;
|
|
extern lv_obj_t * ui_Batinfo_BarBAT;
|
|
extern lv_obj_t * ui_Home_LabelHeaderBatValue;
|
|
|
|
|
|
/*没有返回值的电源管理任务*/
|
|
int Bat_Adc_Value = 0;
|
|
adc_oneshot_unit_handle_t adc1_handle;
|
|
|
|
|
|
void powerTask(void)
|
|
{
|
|
while (1)
|
|
{
|
|
ESP_ERROR_CHECK(adc_oneshot_read(adc1_handle, EXAMPLE_ADC1_CHAN8, &Bat_Adc_Value));
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
|
|
lv_bar_set_value(ui_Batinfo_BarBAT,Bat_Adc_Value*2,LV_ANIM_ON);
|
|
lv_spinbox_set_value(ui_Batinfo_SpinboxBAT,Bat_Adc_Value*2);
|
|
|
|
ESP_LOGI("dd","%d",Bat_Adc_Value);
|
|
}
|
|
|
|
}
|
|
|
|
void powerInit(void)
|
|
{
|
|
/*电源接口初始化*/
|
|
//-------------ADC1 Init---------------//
|
|
adc_oneshot_unit_init_cfg_t init_config1 = {
|
|
.unit_id = ADC_UNIT_1,
|
|
};
|
|
ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config1, &adc1_handle));
|
|
|
|
//-------------ADC1 Config---------------//
|
|
adc_oneshot_chan_cfg_t config = {
|
|
.bitwidth = ADC_BITWIDTH_DEFAULT,
|
|
.atten = ADC_ATTEN_DB_11,
|
|
};
|
|
ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN8, &config));
|
|
|
|
xTaskCreate(powerTask,"powerTask",2*1024, NULL, 2, NULL);
|
|
|
|
}
|