Commit a9444dc6 authored by 王佳伟's avatar 王佳伟

Merge branch 'wjw_dev' into 'dev'

Wjw dev

See merge request !34
parents 2e05216e 0007ebf4
......@@ -63,88 +63,98 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
uint8_t i, j;
uint32_t temp32;
static uint16_t timeCount = 0;
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 += 5;
LightRes = 32000;
}
/*由小到大插入数据*/
for (i = 0; i < NtcDataCount; i++)
{
if (LightRes < NtcData[i])
{
break;
}
}
for (j = NtcDataCount; j > i; j--)
{
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 ;
}
}
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 ;
}
LightR_Status_Count = 0;
LightR_Status = !LightR_Status;
}
}
if(LightR_Status_Count>=150)
{
LightR_Status_Count = 0;
LightR_Status = !LightR_Status;
}
}
else
{
BackLight_Process();
}
}
......
......@@ -4065,4 +4065,9 @@ void AMT630H_GUI_ReadPosittion_Display(void)
default:
break;
}
}
uint8_t GET_Backlight(void)
{
return g_u8Backlight;
}
\ No newline at end of file
......@@ -52,7 +52,7 @@ typedef enum
extern void AMT630H_GUI_DisplayProc(void);
extern void AMT630H_GUI_Background(void);
extern uint8_t GET_Backlight(void);
......
......@@ -84,7 +84,7 @@ void Sys_100ms_Tasks(void)
//Data_Mileage_Clear();
RTE_GPIO_Config(RTE_GPIO_PORT05_PIN04, GpioOut_High);
BackLight_Process();
//BackLight_Process();
//TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 100);
// aaa = Menu_Item_Select_Get(MENU_ITEM_SELECT_AUTO);
......
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