Commit d759f4a3 authored by hu's avatar hu

调整背光NTC逻辑

parent d19aa359
......@@ -132,10 +132,10 @@ void BackLightSchedu(uint8_t BGLPowerSt, uint8_t WakeFlag)
BLStatePara.BL_User_Lvl_Total = BL_LV_TOTAL;
BLStatePara.BL_User_NTC_AD_MAX = NTC_AD_MAX;
BLStatePara.BL_User_effect = testBL;
if (BLStatePara.BL_User_Lvl < BL_LV_TOTAL)
if (BLStatePara.BL_User_TFTLvl < BL_LV_TOTAL && BLStatePara.BL_User_DIALLvl < BL_LV_TOTAL && BLStatePara.BL_User_RGBLvl < BL_LV_TOTAL )
{
BL_Tmp_PARA.BL_User_TFTDuty = BackLightValue_TFT_Default[BLStatePara.BL_User_Type][BLStatePara.BL_User_Lvl];
BL_Tmp_PARA.BL_User_GaugesDuty = BackLightValue_DIAL_Default[BLStatePara.BL_User_Type][BLStatePara.BL_User_Lvl];
BL_Tmp_PARA.BL_User_TFTDuty = BackLightValue_TFT_Default[BLStatePara.BL_User_Type][BLStatePara.BL_User_TFTLvl];
BL_Tmp_PARA.BL_User_GaugesDuty = BackLightValue_DIAL_Default[BLStatePara.BL_User_Type][BLStatePara.BL_User_TFTLvl];
// BL_Tmp_PARA.BL_User_RDuty = BackLightValue_R_Default[BLStatePara.BL_User_Theme][BLStatePara.BL_User_Type][BLStatePara.BL_User_Lvl];
// BL_Tmp_PARA.BL_User_GDuty = BackLightValue_G_Default[BLStatePara.BL_User_Theme][BLStatePara.BL_User_Type][BLStatePara.BL_User_Lvl];
// BL_Tmp_PARA.BL_User_BDuty = BackLightValue_B_Default[BLStatePara.BL_User_Theme][BLStatePara.BL_User_Type][BLStatePara.BL_User_Lvl];
......@@ -194,7 +194,7 @@ void GetBGLLvl(uint8_t BGLLvl, uint8_t FunPositionLight)
{
tmpLvl = BGLLvl;
}
BLStatePara.BL_User_Lvl = tmpLvl;
BLStatePara.BL_User_TFTLvl = tmpLvl;
}
/**@brief Get Ground Light Little Light function
* @author TYW
......@@ -291,3 +291,26 @@ void SetGDebugPara(uint16_t TestBDuty)
DebugBDuty = TestBDuty;
}
#endif
/**@brief Ground Light Task function
* @author TYW
* @param[in]
* @since 1.0.0.0
*/
uint8_t BackLightTestWakeFlag = 3;
uint8_t BLlv = 10;
uint8_t BGLType = 0;
void BGTask(void)
{
uint8_t TmpPopupMsg;
uint8_t positionLight;
uint8_t realLight;
GetBGLTheme(0u);
GetBGLType(BGLType);
GetBGLLvl(BLlv, 0);
GetBGLNTCVol(0u);
BackLightSchedu(1, BackLightTestWakeFlag);
}
......@@ -11,15 +11,7 @@
#define NTC_AD_MAX 4096u
/*有小灯背光降到当前显示等级的百分比*/
#define POSITION_LIGHT_PERCENT 50u
enum {
BGL_IGN_OFF,
BGL_IGN_ON,
};
enum {
BGL_GRADUAL,
BGL_DIRECT,
};
enum {
BL_TYPE_DAY,
BL_TYPE_EVENING,
......@@ -52,44 +44,8 @@ enum {
BL_LV_MAX,
BL_LV_TOTAL,
};
enum {
BL_TFT,
BL_DIAL,
LED_FUEL,
LED_TEMP,
LED_TEMPBL,
BACKLIGHT_TOTAL,
};
typedef struct {
uint16_t DestBackLightDuty;
uint16_t CurBackLightDuty;
uint16_t BackLightDutyMin;
}BACKLIGHT_PARA;
typedef struct {
uint8_t BL_User_PowerSt;
uint8_t BL_User_WakeFlag;
uint16_t BL_User_TFTDuty;
uint16_t BL_User_GaugesDuty;
uint16_t BL_User_RDuty;
uint16_t BL_User_GDuty;
uint16_t BL_User_BDuty;
uint16_t BL_User_TFTDuty_MIN;
uint16_t BL_User_GaugesDuty_MIN;
uint16_t BL_User_RDuty_MIN;
uint16_t BL_User_GDuty_MIN;
uint16_t BL_User_BDuty_MIN;
}BL_USER_PARA;
typedef struct {
uint8_t BL_User_Theme;
uint8_t BL_User_Type;
uint8_t BL_User_Lvl;
uint8_t BL_User_Lvl_Total;
uint16_t BL_User_NTC_AD;
uint16_t BL_User_NTC_AD_MAX;
uint8_t BL_User_effect;
}BL_STATE_PARA;
extern void BGLPwm_Config(uint8_t BGLType, uint16_t DutyVal);
extern void BackLightDeal(BL_USER_PARA BL_FunPara,BL_STATE_PARA BLFunStatePara);
extern void BGLPwm_Stop(uint8_t BGLType);
extern void BGLPwm_Start(uint8_t BGLType);
/*以下主函数调用*/
......@@ -116,4 +72,7 @@ extern void SetRDebugPara(uint16_t TestRDuty);
extern void SetGDebugPara(uint16_t TestGDuty);
extern void SetBDebugPara(uint16_t TestBDuty);
#endif
extern void BGTask(void);
extern uint8_t BackLightTestWakeFlag;
#endif
......@@ -7,6 +7,8 @@
#include "Telltales.h"
#include "Menu.h"
#define THERMISTLISTCN 10
uint16_t IgnOffKeepMs;
uint16_t IgnOnKeepMs;
uint8_t BGLCurIgnSt = BGL_IGN_OFF;
......@@ -51,6 +53,7 @@ void SetBacklightMinVal(uint8_t n, uint16_t val)
* @since 1.0.0.0
*/
uint16_t NTCUpdateTime = 0u;
uint16_t Thermistoimes = 0;
void BackLightDamp(uint8_t TimeX)
{
uint16_t tmpval = 0u;
......@@ -60,16 +63,16 @@ void BackLightDamp(uint8_t TimeX)
TmpStep = 1u;
if (BGLCurIgnSt == BGL_IGN_ON)
{
LcdDownDelay = 400u;
TmpStep = 5u;
LcdDownDelay = 1000u;
TmpStep = 10u;
}
else
{
LcdDownDelay = 2u;
TmpStep = 5u;
TmpStep = 10u;
}
if (NTCUpdateTime < 1000u)
if (NTCUpdateTime < 100u)
{
NTCUpdateTime += TimeX;
}
......@@ -78,6 +81,7 @@ void BackLightDamp(uint8_t TimeX)
CurBackLightAdjustValid = 1u;
NTCUpdateTime = 0u;
}
Thermistoimes += TimeX;
if ((BGLCurIgnSt == BGL_IGN_ON) || (BGLWakeupSt))
{
if (IgnOnKeepMs < 60000u)
......@@ -187,7 +191,12 @@ void BackLightDamp(uint8_t TimeX)
}
else
{
;
for ( i = 0u; i < BACKLIGHT_TOTAL; i++)
{
BackLightPara[i].CurBackLightDuty = 0;
}
}
}
......@@ -201,38 +210,48 @@ void BackLightDamp(uint8_t TimeX)
--------------------------------------------------------------------------*/
uint32_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara)
{
uint32_t resistance = 0;
uint32_t ThermistorADValue = 0;
uint8_t i = 0;
uint16_t AdValue = 0;
AdValue = BLFunStatePara.BL_User_NTC_AD;
uint32_t resistance = 0u;
uint32_t TmpNTCADMax = 0u;
uint32_t ThermistorADValue = 0u;
uint8_t i = 0u;
TmpNTCADMax = BLFunStatePara.BL_User_NTC_AD_MAX;
TmpNTCADMax = TmpNTCADMax * 10u;
if (Thermistoimes > 50u)
{
Thermistoimes = 0u;
if (ThermistorIndex == 0)
{
ThermistorList[ThermistorIndex++] = AdValue;
ThermistorList[ThermistorIndex++] = BLFunStatePara.BL_User_NTC_AD;
}
else
{
for (i = 0; i < ThermistorIndex; i++)
{
if (AdValue < ThermistorList[i])
if (BLFunStatePara.BL_User_NTC_AD < ThermistorList[i])
{
memmove((uint8_t*)&ThermistorList[i + 1], (uint8_t*)&ThermistorList[i], (ThermistorIndex - i) * sizeof (ThermistorList[i]));
ThermistorList[i] = AdValue;
ThermistorList[i] = BLFunStatePara.BL_User_NTC_AD;
ThermistorIndex++;
break;
}
}
if (i == ThermistorIndex)
{
ThermistorList[ThermistorIndex++] = AdValue;
ThermistorList[ThermistorIndex++] = BLFunStatePara.BL_User_NTC_AD;
}
}
}
else
{
;
}
if (ThermistorIndex > THERMISTLISTCN)
{
ThermistorIndex = 0;
// App_SortShort(ThermistorList, THERMISTLISTCN);
ThermistorADValue = (ThermistorList[0] + ThermistorList[1] + ThermistorList[2] \
+ ThermistorList[3] + ThermistorList[4] + ThermistorList[5]) / 6;
if ((ThermistorCurValue > (ThermistorADValue + 3)) || ((ThermistorCurValue + 3) < ThermistorADValue))
......@@ -252,7 +271,7 @@ uint32_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara)
*/
if (ThermistorCurValue)
{
resistance = ((40960 - (10u * ThermistorCurValue)) * 100u) / ThermistorCurValue;
resistance = ((TmpNTCADMax - (10u * ThermistorCurValue)) * 100u) / ThermistorCurValue;
}
else
{
......@@ -260,16 +279,16 @@ uint32_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara)
}
return resistance;
}
uint32_t NTCresistance;
void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
{
uint16_t tmpval;
uint32_t NTCresistance;
uint16_t BacklightTftDestVal;
uint32_t tmpDestVal;
NTCresistance = Calculate_Thermistor(BLFunStatePara);
/* high temprature TFT decrease brightness*/
if ((NTCresistance >= 1507) && (NTCresistance <= 1712u))
if ((NTCresistance >= 1607u) && (NTCresistance <= 1712u))
{
CurBacklightLv = BACKLIGHT_LV80;
BackLightDerating = 1u;
......@@ -283,9 +302,9 @@ void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
{
CurBacklightLv = BACKLIGHT_LV100;
BackLightDerating = 0u;
tmpval = BLFunStatePara.BL_User_Lvl;
tmpval = BLFunStatePara.BL_User_TFTLvl;
CurBackLightAdjustNum = (uint8_t)((tmpval * 100u) / BLFunStatePara.BL_User_Lvl_Total);
CurBackLightAdjustNum = 100;
}
else
{
......@@ -323,8 +342,13 @@ void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
tmpDestVal = BL_FunPara.BL_User_TFTDuty;
BacklightTftDestVal = (uint16_t)(tmpDestVal * CurBackLightAdjustNum / 100u);
SetBacklightDestVal(BL_TFT, BacklightTftDestVal);
SetBacklightDestVal(BL_DIAL, BacklightTftDestVal);
}
}
uint32_t Get_NTCresistance(void)
{
return NTCresistance;
}
/*------------------------------------------------------------------------------
Description: The main function of backlight deal.
Function :
......@@ -341,7 +365,7 @@ void BackLightDeal(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
if ((BL_FunPara.BL_User_PowerSt == BGL_IGN_ON) && (IgnOnKeepMs <= IGN_ON_BACK_LIGHT_DELAY_MS))
{
SetBacklightDestVal(BL_TFT, BL_FunPara.BL_User_TFTDuty);
SetBacklightCurVal(BL_TFT, BL_FunPara.BL_User_TFTDuty - 5u);
SetBacklightCurVal(BL_TFT, BL_FunPara.BL_User_TFTDuty - 50u);
SetBacklightDestVal(BL_DIAL, BL_FunPara.BL_User_GaugesDuty);
SetBacklightMinVal(BL_TFT, BL_FunPara.BL_User_TFTDuty_MIN);
......@@ -442,7 +466,7 @@ void BackLightDeal(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
if ((BL_FunPara.BL_User_WakeFlag & 0x01u) == 1u)
{
SetBacklightDestVal(BL_TFT, BL_FunPara.BL_User_TFTDuty);
SetBacklightCurVal(BL_TFT, BL_FunPara.BL_User_TFTDuty - 5u);
SetBacklightCurVal(BL_TFT, BL_FunPara.BL_User_TFTDuty - 50u);
}
else
{
......@@ -453,7 +477,7 @@ void BackLightDeal(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
if ((BL_FunPara.BL_User_WakeFlag & 0x02u) == 2u)
{
SetBacklightDestVal(BL_DIAL, BL_FunPara.BL_User_GaugesDuty);
SetBacklightCurVal(BL_DIAL, BL_FunPara.BL_User_GaugesDuty - 5u);
SetBacklightCurVal(BL_DIAL, BL_FunPara.BL_User_GaugesDuty - 50u);
}
else
{
......
......@@ -6,12 +6,73 @@
/*#define uint16_t unsigned int*/ /*Freesecale */
/*#define uint32_t unsigned long*//*Freesecale */
/*#define uint32_t unsigned int*/
typedef struct
{
uint16_t DestBackLightDuty;
uint16_t CurBackLightDuty;
uint16_t BackLightDutyMin;
} BACKLIGHT_PARA;
typedef struct
{
uint8_t BL_User_PowerSt;
uint8_t BL_User_WakeFlag;
uint16_t BL_User_TFTDuty;
uint16_t BL_User_GaugesDuty;
uint16_t BL_User_TFTDuty_MIN;
uint16_t BL_User_GaugesDuty_MIN;
#if (RGB_FUCTION ==1)
uint16_t BL_User_RDuty;
uint16_t BL_User_GDuty;
uint16_t BL_User_BDuty;
uint16_t BL_User_RDuty_MIN;
uint16_t BL_User_GDuty_MIN;
uint16_t BL_User_BDuty_MIN;
#endif
} BL_USER_PARA;
typedef struct
{
uint8_t BL_User_Theme;
uint8_t BL_User_Type;
uint8_t BL_User_TFTLvl;
uint8_t BL_User_DIALLvl;
uint8_t BL_User_RGBLvl;
uint8_t BL_User_Lvl_Total;
uint16_t BL_User_NTC_AD;
uint16_t BL_User_NTC_AD_MAX;
uint8_t BL_User_effect;
} BL_STATE_PARA;
enum
{
BGL_IGN_OFF,
BGL_IGN_ON,
};
enum
{
BL_TFT,
BL_DIAL,
LED_FUEL,
LED_TEMP,
LED_TEMPBL,
#if (RGB_FUCTION ==1)
BL_R,
BL_G,
BL_B,
#endif
BACKLIGHT_TOTAL,
};
enum
{
BGL_GRADUAL,
BGL_DIRECT,
};
extern uint16_t IgnOffKeepMs;
#define IGN_ON_BACK_LIGHT_DELAY_MS 400u
#define IGN_OFF_BACK_LIGHT_DELAY_MS 10u
#define BACKLIGHT_LV100 0u
#define BACKLIGHT_LV80 1u
#define BACKLIGHT_LV40 2u
#define THERMISTLISTCN 120
extern void SetBackLightOutput(uint8_t n, uint16_t val);
extern void SetBacklightDestVal(uint8_t n, const uint16_t val);
......@@ -20,7 +81,14 @@ extern void SetBacklightMinVal(uint8_t n, uint16_t val);
extern void BackLightDamp(uint8_t TimeX);
extern void BackLightDeal(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara);
extern void SetBacklightMinVal(uint8_t n, uint16_t val);
/*TFT高温处理函数*/
extern void BGLPwm_Config(uint8_t BGLType, uint16_t DutyVal);
extern void BGLPwm_Start(uint8_t BGLType);
extern void BGLPwm_Stop(uint8_t BGLType);
/**/
extern void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara);
extern void AD_SwapShort(uint16_t *pData1, uint16_t *pData2);
extern void AD_SortShort(uint16_t SortData[], uint8_t len);
extern uint32_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara);
extern uint32_t Get_NTCresistance(void);
#endif
\ No newline at end of file
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