Commit ab240894 authored by 王金亮's avatar 王金亮

feat:增加新的电源管理代码,在下电后,关闭背光

parent 7a111b47
......@@ -1008,6 +1008,11 @@
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor_User.h</FilePath>
</File>
<File>
<FileName>System_Monitor.lib</FileName>
<FileType>4</FileType>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor.lib</FilePath>
</File>
</Files>
</Group>
<Group>
......
......@@ -63,98 +63,104 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
uint8_t i, j;
uint32_t temp32;
static uint16_t timeCount = 0;
if(GET_Backlight() == Backlight_ATUO)
if(SYS_OPR_STAT_IGN_ON)
{
if (timeCount >= LIGHT_DATA_TIME)
if(GET_Backlight() == Backlight_ATUO)
{
timeCount = 0;
if (NtcDataCount < LIGHT_DATA_NUM)
if (timeCount >= LIGHT_DATA_TIME)
{
/*获取光敏电阻*/
LightRes = ADC_Read_Signal(ADC_CH_LIGHT_SENSITIVE); // ADC_Read_Signal(ADC_CH_FUEL1);
/*四舍五入*/
if (LightRes < 32000)
timeCount = 0;
if (NtcDataCount < LIGHT_DATA_NUM)
{
if (LightRes % 10 >= 5)
/*获取光敏电阻*/
LightRes = ADC_Read_Signal(ADC_CH_LIGHT_SENSITIVE); // ADC_Read_Signal(ADC_CH_FUEL1);
/*四舍五入*/
if (LightRes < 32000)
{
if (LightRes % 10 >= 5)
{
LightRes += 5;
}
}
else
{
LightRes = 32000;
}
/*由小到大插入数据*/
for (i = 0; i < NtcDataCount; i++)
{
if (LightRes < NtcData[i])
{
break;
}
}
for (j = NtcDataCount; j > i; j--)
{
LightRes += 5;
NtcData[j] = NtcData[j - 1];
}
NtcData[i] = LightRes;
NtcDataCount++;
}
else
{
LightRes = 32000;
}
/*由小到大插入数据*/
for (i = 0; i < NtcDataCount; i++)
{
if (LightRes < NtcData[i])
/*一组数据采集完毕,取中间部分计算平均值*/
temp32 = 0;
for (i = LIGHT_CAL_START; i < LIGHT_CAL_END; i++)
{
break;
temp32 += NtcData[i];
}
LightR = (uint16_t) (temp32 / (LIGHT_CAL_END - LIGHT_CAL_START));
NtcDataCount = 0;
LightADCompleteFlg = 1;
}
for (j = NtcDataCount; j > i; j--)
{
NtcData[j] = NtcData[j - 1];
}
NtcData[i] = LightRes;
NtcDataCount++;
}
else
timeCount += deltaTime;
if(LightADCompleteFlg)
{
/*一组数据采集完毕,取中间部分计算平均值*/
temp32 = 0;
for (i = LIGHT_CAL_START; i < LIGHT_CAL_END; i++)
if(LightR_Status == 0)
{
temp32 += NtcData[i];
}
LightR = (uint16_t) (temp32 / (LIGHT_CAL_END - LIGHT_CAL_START));
NtcDataCount = 0;
LightADCompleteFlg = 1;
}
}
timeCount += deltaTime;
if(LightADCompleteFlg)
{
if(LightR_Status == 0)
{
if(LightR >20)
{
LightR_Status_Count++;
if(LightR >20)
{
LightR_Status_Count++;
}
else
{
LightR_Status_Count = 0 ;
}
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 200);
}
else
{
LightR_Status_Count = 0 ;
}
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 200);
}
else
{
if(LightR <20)
{
LightR_Status_Count++;
if(LightR <20)
{
LightR_Status_Count++;
}
else
{
LightR_Status_Count = 0 ;
}
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 800);
}
else
if(LightR_Status_Count>=150)
{
LightR_Status_Count = 0 ;
}
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 800);
LightR_Status_Count = 0;
LightR_Status = !LightR_Status;
}
}
if(LightR_Status_Count>=150)
{
LightR_Status_Count = 0;
LightR_Status = !LightR_Status;
}
}
else
{
BackLight_Process();
}
}
else
{
BackLight_Process();
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 0);
}
}
......@@ -219,10 +225,10 @@ Light_uint8_t Backlight_SetPwmLevel(void)
}
/* 获取电阻值回调函数 */
Light_uint8_t Backlight_NtcRes(void)
Light_uint16_t Backlight_NtcRes(void)
{
return 1;
Light_uint16_t u8NtcRes = ADC_Read_Signal(ADC_CH_NTC_TEMP);
return u8NtcRes;
}
void Backlight_Init(BackLightExtPara *backlightInit)
......@@ -497,28 +503,35 @@ void BackLight_Service(void)
void BackLight_Process(void)
{
if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_5) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_5);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_4) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_4);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_3) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_3);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_2) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_2);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_1) == 1)
if(SYS_OPR_STAT_IGN_ON)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_1);
if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_5) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_5);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_4) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_4);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_3) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_3);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_2) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_2);
}
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_1) == 1)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_1);
}
else
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_4);
}
}
else
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_4);
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 0);
}
}
......@@ -23,6 +23,7 @@
void Backlight_KL30_Wakeup_Init(void);
void BackLight_Process(void);
extern void BackLight_Service(void);
......
......@@ -54,6 +54,7 @@ static void Power_KL30_Init(void)
Key_KL30_Init_EXample();
Data_User_Mileage_KL30Init();
Fuel_KL30_Init();
Backlight_KL30_Wakeup_Init();
Amt630hInit();
Telltales_Init();
TimerM_PWM_counter_Output_Init(TIMERM_COUNTER1, 20000, 64000000);
......@@ -87,6 +88,7 @@ static void Power_Wakeup_Init(void)
Key_Wakeup_Init_EXample();
Line_In_KL15_ON_Init();
Fuel_KL30_Init();
Backlight_KL30_Wakeup_Init();
Amt630hInit();
TimerM_PWM_counter_Output_Init(TIMERM_COUNTER1, 20000, 64000000);
TimerM_PWM_CH_Output_init(TIMERM_COUNTER1, TIMERM_CHB, ActiveLevel_High);
......@@ -122,6 +124,8 @@ static void Power_IG_ON_Init(void)
Fuel_KL15_Init();
//RTE_GPIO_Set_Level(Blacklight_PWM, 1);
FaultCode_Init();
Amt630hInit();
ResetInitedState();
}
static void Power_Sleep_Init(void)
......@@ -173,6 +177,10 @@ static Power_Status_em Power_Stay_OFF(void)
{
u8PowerSts = EM_IGN_OFF;
}
else
{
u8PowerSts = EM_IGN_Sleep_Init;
}
}
return u8PowerSts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment