Commit 5cc101bc authored by hu's avatar hu

调整NTC功能

parent f3107d95
...@@ -192,65 +192,53 @@ void BackLightDamp(uint8_t TimeX) ...@@ -192,65 +192,53 @@ void BackLightDamp(uint8_t TimeX)
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function Name : App_SwapShort * Function Name : calculate_Thermistor
* Description : ½»»»Êý¾Ý * Description :
* Input : None * Input : None
* Output : None * Output : None
* Return : None * Return : None
* onther : qitiancun 2018-9-10 * onther : qitiancun 2018-9-10
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
void AD_SwapShort(uint16_t *pData1, uint16_t *pData2) uint32_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara)
{ {
uint16_t psw; uint32_t resistance = 0;
if ((*pData1) > (*pData2)) uint32_t ThermistorADValue = 0;
uint8_t i = 0;
uint16_t AdValue = 0;
AdValue = BLFunStatePara.BL_User_NTC_AD;
if (ThermistorIndex == 0)
{ {
psw = (*pData2); ThermistorList[ThermistorIndex++] = AdValue;
(*pData2) = (*pData1);
(*pData1) = psw;
} }
} else
{
/*------------------------------------------------------------------------- for (i = 0; i < ThermistorIndex; i++)
* Function Name : App_SortShort
* Description :
* Input : None
* Output : None
* Return : None
* onther : qitiancun 2018-9-10
--------------------------------------------------------------------------*/
void AD_SortShort(uint16_t SortData[], uint8_t len)
{
uint8_t n = 0u, m;
for (; n < len - 1u; n++)
{ {
for (m = n + 1u; m < len; m++) if (AdValue < ThermistorList[i])
{ {
AD_SwapShort(&SortData[n], &SortData[m]); memmove((uint8_t*)&ThermistorList[i + 1], (uint8_t*)&ThermistorList[i], (ThermistorIndex - i) * sizeof (ThermistorList[i]));
ThermistorList[i] = AdValue;
ThermistorIndex++;
break;
}
}
if (i == ThermistorIndex)
{
ThermistorList[ThermistorIndex++] = AdValue;
} }
} }
}
/*-------------------------------------------------------------------------
* Function Name : calculate_Thermistor
* Description :
* Input : None
* Output : None
* Return : None
* onther : qitiancun 2018-9-10
--------------------------------------------------------------------------*/
uint16_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara)
{
uint32_t resistance = 0u;
uint32_t TmpNTCADMax = 0u;
ThermistorList[ThermistorIndex] = BLFunStatePara.BL_User_NTC_AD;
TmpNTCADMax = BLFunStatePara.BL_User_NTC_AD_MAX * 10u;
ThermistorIndex++;
ThermistorIndex = (ThermistorIndex + 1u) % 5u;
AD_SortShort(ThermistorList, 5u);
if ((ThermistorCurValue > (ThermistorList[2u] + 3u)) || ((ThermistorCurValue + 3u) < ThermistorList[2])) if (ThermistorIndex > THERMISTLISTCN)
{
ThermistorIndex = 0;
ThermistorADValue = (ThermistorList[0] + ThermistorList[1] + ThermistorList[2] \
+ ThermistorList[3] + ThermistorList[4] + ThermistorList[5]) / 6;
if ((ThermistorCurValue > (ThermistorADValue + 3)) || ((ThermistorCurValue + 3) < ThermistorADValue))
{ {
ThermistorCurValue = ThermistorList[2]; ThermistorCurValue = ThermistorADValue;
}
} }
/* /*
ad 10K ad 10K
...@@ -264,23 +252,24 @@ uint16_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara) ...@@ -264,23 +252,24 @@ uint16_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara)
*/ */
if (ThermistorCurValue) if (ThermistorCurValue)
{ {
resistance = ((TmpNTCADMax - (10u * ThermistorCurValue)) * 100u) / ThermistorCurValue; resistance = ((40960 - (10u * ThermistorCurValue)) * 100u) / ThermistorCurValue;
} }
else else
{ {
resistance = 7851u; resistance = 7851u;
} }
return (uint16_t)resistance; return resistance;
} }
void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara) void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara)
{ {
uint16_t tmpval; uint16_t tmpval;
uint16_t NTCresistance; uint32_t NTCresistance;
uint16_t BacklightTftDestVal; uint16_t BacklightTftDestVal;
uint32_t tmpDestVal; uint32_t tmpDestVal;
NTCresistance = Calculate_Thermistor(BLFunStatePara); NTCresistance = Calculate_Thermistor(BLFunStatePara);
/* high temprature TFT decrease brightness*/ /* high temprature TFT decrease brightness*/
if ((NTCresistance >= 1607u) && (NTCresistance <= 1712u)) if ((NTCresistance >= 1507) && (NTCresistance <= 1712u))
{ {
CurBacklightLv = BACKLIGHT_LV80; CurBacklightLv = BACKLIGHT_LV80;
BackLightDerating = 1u; BackLightDerating = 1u;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "Data_Fuel_User.h" #include "Data_Fuel_User.h"
#include "Menu.h" #include "Menu.h"
#include "GUI.h" #include "GUI.h"
#include "Analog_Signals.h"
typedef struct typedef struct
{ {
...@@ -148,8 +149,8 @@ void BL_Management_service(void) ...@@ -148,8 +149,8 @@ void BL_Management_service(void)
/*得到背光等级 可自己在枚举中定义 在BackGroundLight.c里填表*/ /*得到背光等级 可自己在枚举中定义 在BackGroundLight.c里填表*/
GetBGLLvl((BackLightVLv - 1), LED_Pos); GetBGLLvl((BackLightVLv - 1), LED_Pos);
/*得到热敏电阻电压参数为100倍电压值*/ /*得到热敏电阻电压参数为AD数值*/
//DNC_NumValue = RTE_Read_NTC_R_Valid(); DNC_NumValue = Common_Get_NTCAD();
GetBGLNTCVol((uint16_t)DNC_NumValue); GetBGLNTCVol((uint16_t)DNC_NumValue);
/*主函数中调用第一个参数电源状态 1是 ON档 2 off 第二个参数 唤醒条件 1是TTF唤醒 2 是表盘唤醒 3 是表盘和屏都有唤醒,0无唤醒*/ /*主函数中调用第一个参数电源状态 1是 ON档 2 off 第二个参数 唤醒条件 1是TTF唤醒 2 是表盘唤醒 3 是表盘和屏都有唤醒,0无唤醒*/
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#define BACKLIGHT_LV100 0u #define BACKLIGHT_LV100 0u
#define BACKLIGHT_LV80 1u #define BACKLIGHT_LV80 1u
#define BACKLIGHT_LV40 2u #define BACKLIGHT_LV40 2u
#define THERMISTLISTCN 120
extern void SetBackLightOutput(uint8_t n, uint16_t val); extern void SetBackLightOutput(uint8_t n, uint16_t val);
extern void SetBacklightDestVal(uint8_t n, const uint16_t val); extern void SetBacklightDestVal(uint8_t n, const uint16_t val);
extern void SetBacklightCurVal(uint8_t n, uint16_t val); extern void SetBacklightCurVal(uint8_t n, uint16_t val);
...@@ -20,7 +22,5 @@ extern void BackLightDeal(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara ...@@ -20,7 +22,5 @@ extern void BackLightDeal(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara
extern void SetBacklightMinVal(uint8_t n, uint16_t val); extern void SetBacklightMinVal(uint8_t n, uint16_t val);
/*TFT高温处理函数*/ /*TFT高温处理函数*/
extern void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara); extern void BackLightDeal_NTC(BL_USER_PARA BL_FunPara, BL_STATE_PARA BLFunStatePara);
extern void AD_SwapShort(uint16_t *pData1, uint16_t *pData2); extern uint32_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara);
extern void AD_SortShort(uint16_t SortData[], uint8_t len);
extern uint16_t Calculate_Thermistor(BL_STATE_PARA BLFunStatePara);
#endif #endif
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "r_typedefs.h" #include "r_typedefs.h"
#define ADC_RESOLUTION (4096U) /* 12bit ADC */ #define ADC_RESOLUTION (4095U) /* 12bit ADC */
......
...@@ -400,3 +400,8 @@ uint16_t ADC_Conv_Single_Channel(uint8_t u8ADCCh) ...@@ -400,3 +400,8 @@ uint16_t ADC_Conv_Single_Channel(uint8_t u8ADCCh)
return u16Result; return u16Result;
} }
uint16_t Common_Get_NTCAD(void)
{
return u16ADCSample[ADC_CH_NTC_R];
}
\ No newline at end of file
...@@ -54,7 +54,7 @@ extern void Analog_Signal_Conv_Service(void); ...@@ -54,7 +54,7 @@ extern void Analog_Signal_Conv_Service(void);
extern uint16_t ADC_Read_Signal(uint8_t u8ADCCh); extern uint16_t ADC_Read_Signal(uint8_t u8ADCCh);
extern uint8_t ADC_Read_Signal_Valid(uint8_t u8ADCCh); extern uint8_t ADC_Read_Signal_Valid(uint8_t u8ADCCh);
extern uint16_t ADC_Conv_Single_Channel(uint8_t u8ADCCh); extern uint16_t ADC_Conv_Single_Channel(uint8_t u8ADCCh);
uint16_t Common_Get_NTCAD(void);
/*! @} */ /*! @} */
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -238,6 +238,7 @@ void Sys_Run_Mode_50ms_Tasks(void) ...@@ -238,6 +238,7 @@ void Sys_Run_Mode_50ms_Tasks(void)
Speed_PPK_Processing(); Speed_PPK_Processing();
Sound_Scheduling_Service(); Sound_Scheduling_Service();
// BGTask(); // BGTask();
BL_Management_service();
LED_Driver_Scan_Refresh(); LED_Driver_Scan_Refresh();
Drive_Info_IC1_STATUS_Rx(); Drive_Info_IC1_STATUS_Rx();
...@@ -252,7 +253,6 @@ void Sys_Run_Mode_50ms_Tasks(void) ...@@ -252,7 +253,6 @@ void Sys_Run_Mode_50ms_Tasks(void)
//uint32_t YZHD_Count = 0; //uint32_t YZHD_Count = 0;
void Sys_Run_Mode_100ms_Tasks(void) void Sys_Run_Mode_100ms_Tasks(void)
{ {
BL_Management_service();
RTE_RTC_Services_100Ms_Cbk(); RTE_RTC_Services_100Ms_Cbk();
Data_ODO_Processing(); Data_ODO_Processing();
Data_Trip_Processing(); Data_Trip_Processing();
......
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