Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
haoJin750TFT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
时昊
haoJin750TFT
Commits
68146ff4
Commit
68146ff4
authored
Aug 13, 2024
by
时昊
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wjw_dev' of
http://tyw-server.synology.me:12345/shihao/haojin750tft
into shihao
parents
08e48b36
8dec7321
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
4 deletions
+112
-4
BackLight.c
Firmware/Source/Application/BackLight.c
+100
-0
Analog_Signals.c
Firmware/Source/Component/Analog/Analog_Signals.c
+7
-2
Analog_Signals.h
Firmware/Source/Component/Analog/Analog_Signals.h
+4
-2
Sys_Task_List.c
Firmware/Source/System/Sys_Task_List.c
+1
-0
No files found.
Firmware/Source/Application/BackLight.c
View file @
68146ff4
...
...
@@ -7,6 +7,16 @@
#define BACK_LIGHT_Val_4 700
#define BACK_LIGHT_Val_5 900
#define LIGHT_DATA_TIME 10u
/*这里填写多长时间采集一个数据,单位ms*/
#define LIGHT_DATA_NUM 20u
/*燃油电阻采集数据总数 最大255*/
#define LIGHT_CAL_START 5u
/*数据排序后取中间部分计算平均:起始*/
#define LIGHT_CAL_END 15u
/*数据排序后取中间部分计算平均:结束*/
Light_uint8_t
LightADCompleteFlg
=
0u
;
Light_uint16_t
LightR
=
0u
;
Light_uint16_t
LightR_Status
=
0
;
Light_uint16_t
LightR_Status_Count
=
0u
;
Light_uint16_t
NtcDataCount
;
Light_uint16_t
NtcData
[
LIGHT_DATA_NUM
];
typedef
struct
{
Light_uint16_t
Temperature
;
/* 温度 */
...
...
@@ -47,6 +57,96 @@ _st_BacklightLevel BacklightLevelTable[BacklightLevel_Max] =
};
void
Data_Light_Res_service
(
Light_uint8_t
deltaTime
)
//获取光感阻值,并做平均
{
uint16_t
LightRes
=
0
;
uint8_t
i
,
j
;
uint32_t
temp32
;
static
uint16_t
timeCount
=
0
;
if
(
timeCount
>=
LIGHT_DATA_TIME
)
{
timeCount
=
0
;
if
(
NtcDataCount
<
LIGHT_DATA_NUM
)
{
/*获取光敏电阻*/
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
=
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
{
/*一组数据采集完毕,取中间部分计算平均值*/
temp32
=
0
;
for
(
i
=
LIGHT_CAL_START
;
i
<
LIGHT_CAL_END
;
i
++
)
{
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
++
;
}
else
{
LightR_Status_Count
=
0
;
}
}
else
{
if
(
LightR
<
20
)
{
LightR_Status_Count
++
;
}
else
{
LightR_Status_Count
=
0
;
}
}
if
(
LightR_Status_Count
>=
150
)
{
LightR_Status_Count
=
0
;
LightR_Status
=
!
LightR_Status
;
}
}
}
Light_uint16_t
GetBacklightDutyByLevel
(
Light_uint16_t
level
)
...
...
Firmware/Source/Component/Analog/Analog_Signals.c
View file @
68146ff4
...
...
@@ -74,7 +74,7 @@ ADC_Data_st_t stADCData[ADC_SIGNAL_CH_NUMBER];
const
uint8_t
__attribute__
((
aligned
(
4
)))
u8ADCChList
[
ADC_CONV_CH_NUMBER
]
=
{
2U
,
3U
,
7U
,
5U
,
6U
,
2U
,
3U
,
7U
,
5U
,
6U
,
4U
,
12U
,
};
const
__attribute__
((
aligned
(
4
)))
ADC_Ch_Cfg_st_t
stADCChCfg
[
ADC_SIGNAL_CH_NUMBER
]
=
...
...
@@ -84,6 +84,9 @@ const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBE
{
2U
,
0U
,
0U
,
0U
,
0U
,
1U
,
ADC_Voltage_Calc_Circuit101
,},
{
3U
,
2U
,
0U
,
2U
,
0U
,
1U
,
ADC_Res_Calc_Circuit101
,},
{
4U
,
2U
,
0U
,
2U
,
0U
,
1U
,
ADC_Res_Calc_Circuit101
,},
{
5U
,
3U
,
0U
,
5000U
,
0U
,
10U
,
ADC_Res_Calc_Circuit201
,},
{
6U
,
2U
,
0U
,
2U
,
0U
,
1U
,
ADC_Res_Calc_Circuit101
,},
};
const
__attribute__
((
aligned
(
4
)))
ADC_Res_List_st_t
stADCResList
[
ADC_SIGNAL_CH_NUMBER
]
=
...
...
@@ -93,6 +96,8 @@ const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_N
{
0U
,
0U
,
0U
,
0U
,},
{
0U
,
0U
,
500U
,
300U
,},
{
0U
,
0U
,
500U
,
0U
,},
{
47000U
,
0U
,
100000U
,
0U
,},
{
0U
,
0U
,
500U
,
0U
,},
};
/* Private function prototypes ----------------------------------------------*/
...
...
@@ -170,7 +175,7 @@ void Analog_Signal_Conv_Service(void)
if
(
stADCCtrl
.
u8DebounceCnt
==
0U
)
{
stADCCtrl
.
enStatus
=
ADC_STAT_CONV
;
stADCCtrl
.
enStatus
=
ADC_STAT_CONV
;
}
else
{
...
...
Firmware/Source/Component/Analog/Analog_Signals.h
View file @
68146ff4
...
...
@@ -33,11 +33,13 @@ enum ADCChName
ADC_CH_FUEL_VREF
,
ADC_CH_FUEL1
,
ADC_CH_COOLANT_TEMP1_R
,
ADC_CH_NTC_TEMP
,
ADC_CH_LIGHT_SENSITIVE
,
};
/* Exported macro ------------------------------------------------------------*/
#define ADC_TOTAL_CH_NUMBER (
5
U)
#define ADC_SIGNAL_CH_NUMBER (
5
U)
#define ADC_TOTAL_CH_NUMBER (
7
U)
#define ADC_SIGNAL_CH_NUMBER (
7
U)
#define ADC_REF_VOLTAGE u16ADCRefVoltage
/* Exported variables --------------------------------------------------------*/
...
...
Firmware/Source/System/Sys_Task_List.c
View file @
68146ff4
...
...
@@ -40,6 +40,7 @@ void Sys_10ms_Tasks(void)
Key_TimeOut_Service
();
Fuel_R_Cal
(
10u
);
Coolant_R_Cal
(
10u
);
Data_Light_Res_service
(
10
);
}
void
Sys_20ms_Tasks
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment