Commit 59b1636b authored by 张金硕's avatar 张金硕

feat:增加背光自动调节功能

parent 5c35c886
...@@ -63,8 +63,6 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并 ...@@ -63,8 +63,6 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
uint8_t i, j; uint8_t i, j;
uint32_t temp32; uint32_t temp32;
static uint16_t timeCount = 0; static uint16_t timeCount = 0;
if(GET_Backlight() == Backlight_ATUO)
{
if (timeCount >= LIGHT_DATA_TIME) if (timeCount >= LIGHT_DATA_TIME)
{ {
timeCount = 0; timeCount = 0;
...@@ -72,7 +70,6 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并 ...@@ -72,7 +70,6 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
{ {
/*获取光敏电阻*/ /*获取光敏电阻*/
LightRes = ADC_Read_Signal(ADC_CH_LIGHT_SENSITIVE); // ADC_Read_Signal(ADC_CH_FUEL1); LightRes = ADC_Read_Signal(ADC_CH_LIGHT_SENSITIVE); // ADC_Read_Signal(ADC_CH_FUEL1);
/*四舍五入*/ /*四舍五入*/
if (LightRes < 32000) if (LightRes < 32000)
{ {
...@@ -114,6 +111,8 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并 ...@@ -114,6 +111,8 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
} }
} }
timeCount += deltaTime; timeCount += deltaTime;
if(GET_Backlight() == Backlight_ATUO)
{
if(LightADCompleteFlg) if(LightADCompleteFlg)
{ {
if(LightR <= 800) if(LightR <= 800)
...@@ -145,6 +144,29 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并 ...@@ -145,6 +144,29 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
} }
} }
else if(Menu_Item_Select_Get(MENU_ITEM_SELECT_AUTO))
{
if(Backlight_SetPwmLevel() == 1U)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 100);
}
else if(Backlight_SetPwmLevel() == 2U)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 200);
}
else if(Backlight_SetPwmLevel() == 3U)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 400);
}
else if(Backlight_SetPwmLevel() == 4U)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 600);
}
else if(Backlight_SetPwmLevel() == 5U)
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 800);
}
}
else else
{ {
BackLight_Process(); BackLight_Process();
...@@ -209,8 +231,29 @@ Light_uint8_t Backlight_SetPwmEn(void) ...@@ -209,8 +231,29 @@ Light_uint8_t Backlight_SetPwmEn(void)
/* 背光等级回调函数 */ /* 背光等级回调函数 */
Light_uint8_t Backlight_SetPwmLevel(void) Light_uint8_t Backlight_SetPwmLevel(void)
{ {
Light_uint8_t Backlight_PwmLevel;
return 1; if(LightR > 0 && LightR <= 400)
{
Backlight_PwmLevel = 1U;
}
else if(LightR > 400 && LightR <= 800)
{
Backlight_PwmLevel = 2U;
}
else if(LightR > 800 && LightR <= 1400)
{
Backlight_PwmLevel = 3U;
}
else if(LightR > 1400 && LightR <= 2000)
{
Backlight_PwmLevel = 4U;
}
else if(LightR > 2000 && LightR <= 2600)
{
Backlight_PwmLevel = 5U;
}
return Backlight_PwmLevel;
} }
/* 获取电阻值回调函数 */ /* 获取电阻值回调函数 */
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
void Backlight_KL30_Wakeup_Init(void); void Backlight_KL30_Wakeup_Init(void);
void BackLight_Process(void); void BackLight_Process(void);
Light_uint8_t Backlight_SetPwmLevel(void);
......
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