Commit dc80ae3d authored by 张金硕's avatar 张金硕

🐞 fix:修改背光和NTC的逻辑

parent 628ee544
......@@ -206,23 +206,41 @@ void BackLight_Get_curDuty(void)
NTCresistance = ADC_Read_Signal(ADC_CH_NTC_TEMP);
/* 计算温度值 */
NTCDegrees = NTC_Get_Degrees(NTCResBoard ,NTCDegreesBoard, sizeof(NTCResBoard)/sizeof(uint16_t), NTCresistance);
if ( NTCDegrees < 650 )
if ( NTCDegrees < 600 )
{
g_stBL.destFactor = 100;
}
else if ( NTCDegrees <= 850 )
{
wtemp = (850 - NTCDegrees);
wtemp *= 3;
wtemp += 400;
wtemp *= 1;
wtemp += 700;
wtemp /= 10;
g_stBL.destFactor = wtemp;
/* 85°为40%占空比,65°为100%占空比, 1°大概为3% */
/* 85°为70%占空比,60°为95%占空比, 1°大概为1% */
}
else
else if(NTCDegrees <= 880 )
{
g_stBL.destFactor = 40;
wtemp = (880 - NTCDegrees);
wtemp *= 16;
wtemp += 200;
wtemp /= 10;
g_stBL.destFactor = wtemp;
/* 88°为20%占空比,85°为70%占空比, 1°大概为16.6% */
}
else if(NTCDegrees <= 900 )
{
wtemp = (900 - NTCDegrees);
wtemp *= 5;
wtemp += 100;
wtemp /= 10;
g_stBL.destFactor = wtemp;
/* 90°为10%占空比,88°为20%占空比, 1°大概为5% */
}
else
{
g_stBL.destFactor = 10;
}
if ( (g_stBL.curFactor < g_stBL.destFactor) && (NTCDegrees < 750) )
{
......@@ -309,17 +327,17 @@ void BackLight_Get_curDuty(void)
g_stBL.u16TftdestDuty = 100;
}
/* 如果当前占空比小于100,那还是按照上次结果显示 */
if(g_stBL.u16TftcurDuty < 100)
{
// /* 如果当前占空比小于100,那还是按照上次结果显示 */
// if(g_stBL.u16TftcurDuty < 100)
// {
// g_stBL.u16TftcurDuty = g_stBL.u16TftdestDuty;
// }
// /* 逐步逼近目标占空比 */
// else
// {
// U16_Data_Gradient((uint16_t *)&g_stBL.u16TftcurDuty, g_stBL.u16TftdestDuty, 1u, (uint16_t *)&g_stBL.u16DialDampingTimer, 1u);
// }
g_stBL.u16TftcurDuty = g_stBL.u16TftdestDuty;
}
/* 逐步逼近目标占空比 */
else
{
U16_Data_Gradient((uint16_t *)&g_stBL.u16TftcurDuty, g_stBL.u16TftdestDuty, 1u, (uint16_t *)&g_stBL.u16DialDampingTimer, 1u);
}
}
#if 0
......@@ -482,6 +500,7 @@ void BackLight_Process(void)
{
LightR_Status_Count = 0;
LightR_Status = 0;
g_u8Display_Mode = ModeNIGHT;
}
}
else if(LightR > 200)
......@@ -491,29 +510,30 @@ void BackLight_Process(void)
{
LightR_Status_Count = 0;
LightR_Status = 1;
g_u8Display_Mode = ModeDAY;
}
}
/* 系统的意思是要当前背光等级基础上的80%和20%,不是直接设置背光 */
/*if(LightR_Status == 0)
{
BackLight_Set_Lvl(Light_Lvl_1);
BackLight_Set_Lvl(Light_Lvl_1);
}
else
{
BackLight_Set_Lvl(Light_Lvl_4);
BackLight_Set_Lvl(Light_Lvl_4);
}*/
if(LightR_Status == 0)
{
g_u8Display_Mode = ModeNIGHT;
}
else if(LightR_Status == 1)
{
g_u8Display_Mode = ModeDAY;
}
// if(LightR_Status == 0)
// {
// g_u8Display_Mode = ModeNIGHT;
// }
// else if(LightR_Status == 1)
// {
// g_u8Display_Mode = ModeDAY;
// }
}
}
/* 根据感光判断当前应该设置什么背光等级 */
else if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_AUTO))
if(Menu_Item_Select_Get(MENU_ITEM_BACKLIGHT_AUTO))
{
if(Backlight_GetPwmLevel() == 1U)
{
......@@ -566,26 +586,26 @@ void BackLight_Process(void)
}
/* 数据处理,包括NTC功能 */
BackLight_Get_curDuty();
if(Menu_Item_Select_Get(MENU_ITEM_SELECT_AUTO))
{
uint16_t u16TftPwmBackShow = g_stBL.u16TftcurDuty ;
if(LightR_Status == 0)
{
u16TftPwmBackShow *= 20U;
u16TftPwmBackShow /= 100U;
}
else
{
u16TftPwmBackShow *= 80U;
u16TftPwmBackShow /= 100U;
}
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, u16TftPwmBackShow);
}
else
{
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, g_stBL.u16TftcurDuty);
}
TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, g_stBL.u16TftcurDuty);
// if(Menu_Item_Select_Get(MENU_ITEM_SELECT_AUTO))
// {
// uint16_t u16TftPwmBackShow = g_stBL.u16TftcurDuty ;
// if(LightR_Status == 0)
// {
// u16TftPwmBackShow *= 20U;
// u16TftPwmBackShow /= 100U;
// }
// else
// {
// u16TftPwmBackShow *= 80U;
// u16TftPwmBackShow /= 100U;
// }
// TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, u16TftPwmBackShow);
// }
// else
// {
// TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, g_stBL.u16TftcurDuty);
// }
}
else
{
......
......@@ -264,6 +264,7 @@ void Key_Event_Short_Press_Left(void)//选择
(Menu_Get_Current_Cursor_Information() == MENU_ITEM_LANGUAGE_ENGLISH)) && (Get_ActualVechileSpeed() == 0))
{
Menu_Service(MENU_KEY_DOWN_SHORT);
Key_Event_BackLight_Press_Left();
}
}
......@@ -339,6 +340,64 @@ void Key_Event_SHORT_PRESS_2_Right(void)
}
void Key_Event_BackLight_Press_Left(void)
{
if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_5)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
else if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_4)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
else if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_3)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
else if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_2)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
else if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_1)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
else if(Menu_Get_Current_Cursor_Information() == MENU_ITEM_BACKLIGHT_AUTO)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 1);
}
}
uint8_t OTA_Update_Flag = 0;
void Get_Into_OTA_Update_Mode(void)
{
......
......@@ -63,6 +63,7 @@ Key_Status_en_t Key_Status_Read_Right(void);
void Key_Event_Short_Press_Left(void);
void Key_Event_Short_Press_Right(void);
void Key_Event_SHORT_PRESS_2_Right(void);
void Key_Event_BackLight_Press_Left(void);
void Get_Into_OTA_Update_Mode(void);
void KEY_RIGHT_EVENT_NONE_Service(void);
void KEY_LEFT_EVENT_NONE_Service(void);
......
......@@ -65,11 +65,11 @@ void Menu_User_Init(void)
Menu_Init_st.enMenuItemLen = MENU_ITEM_MAX;
Menu_Init_st.uintMenuConfig = 0x0001;
Menu_Init_st.uintMenuCursorMemoryDepth = 0;
Menu_Init((uint8_t *)u8MenuRamData, (Menu_Item_Attribute_st_t *)stMenuItemAttribute, (Menu_Init_st_t *)&Menu_Init_st);
Menu_Item_Select_Set(MENU_ITEM_SELECT_DAYTIME, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
Menu_Item_Select_Set(MENU_ITEM_UNIT_KM, 1);
Menu_Item_Select_Set(MENU_ITEM_LANGUAGE_CHINESE, 1);
Menu_Init((uint8_t *)u8MenuRamData, (Menu_Item_Attribute_st_t *)stMenuItemAttribute, (Menu_Init_st_t *)&Menu_Init_st);
}
void Menu_User_WAKEUP(void)
......@@ -80,11 +80,11 @@ void Menu_User_WAKEUP(void)
Menu_Init_st.enMenuItemLen = MENU_ITEM_MAX;
Menu_Init_st.uintMenuConfig = 0x0001;
Menu_Init_st.uintMenuCursorMemoryDepth = 0;
Menu_Wake_Up_Init((uint8_t *)u8MenuRamData, (Menu_Item_Attribute_st_t *)stMenuItemAttribute, (Menu_Init_st_t *)&Menu_Init_st);
Menu_Item_Select_Set(MENU_ITEM_SELECT_DAYTIME, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
Menu_Item_Select_Set(MENU_ITEM_UNIT_KM, 1);
Menu_Item_Select_Set(MENU_ITEM_LANGUAGE_CHINESE, 1);
Menu_Wake_Up_Init((uint8_t *)u8MenuRamData, (Menu_Item_Attribute_st_t *)stMenuItemAttribute, (Menu_Init_st_t *)&Menu_Init_st);
}
/*---------------------------------------------------------------------------------------*/
......@@ -232,80 +232,80 @@ void Menu_Logic_Operation_Select_Auto(Menu_Key_en_t enKeyType)
void Menu_Logic_Operation_Backlight_5(Menu_Key_en_t enKeyType)
{
if(enKeyType == MENU_KEY_CONFIRM_SHORT)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
// if(enKeyType == MENU_KEY_CONFIRM_SHORT)
// {
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 1);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
// }
}
void Menu_Logic_Operation_Backlight_4(Menu_Key_en_t enKeyType)
{
if(enKeyType == MENU_KEY_CONFIRM_SHORT)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
// if(enKeyType == MENU_KEY_CONFIRM_SHORT)
// {
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 1);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
// }
}
void Menu_Logic_Operation_Backlight_3(Menu_Key_en_t enKeyType)
{
if(enKeyType == MENU_KEY_CONFIRM_SHORT)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
// if(enKeyType == MENU_KEY_CONFIRM_SHORT)
// {
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 1);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
// }
}
void Menu_Logic_Operation_Backlight_2(Menu_Key_en_t enKeyType)
{
if(enKeyType == MENU_KEY_CONFIRM_SHORT)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
// if(enKeyType == MENU_KEY_CONFIRM_SHORT)
// {
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 1);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
// }
}
void Menu_Logic_Operation_Backlight_1(Menu_Key_en_t enKeyType)
{
if(enKeyType == MENU_KEY_CONFIRM_SHORT)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 1);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
}
// if(enKeyType == MENU_KEY_CONFIRM_SHORT)
// {
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 1);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 0);
// }
}
void Menu_Logic_Operation_Backlight_Auto(Menu_Key_en_t enKeyType)
{
if(enKeyType == MENU_KEY_CONFIRM_SHORT)
{
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 1);
}
// if(enKeyType == MENU_KEY_CONFIRM_SHORT)
// {
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_5, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_4, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_3, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_2, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_1, 0);
// Menu_Item_Select_Set(MENU_ITEM_BACKLIGHT_AUTO, 1);
// }
}
void Menu_Logic_Operation_Bluetooth_Open_Close(Menu_Key_en_t enKeyType)
......
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