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
59b1636b
Commit
59b1636b
authored
Aug 16, 2024
by
张金硕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:增加背光自动调节功能
parent
5c35c886
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
40 deletions
+84
-40
BackLight.c
Firmware/Source/Application/BackLight.c
+83
-40
BackLight.h
Firmware/Source/Application/BackLight.h
+1
-0
No files found.
Firmware/Source/Application/BackLight.c
View file @
59b1636b
...
...
@@ -63,8 +63,6 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
uint8_t
i
,
j
;
uint32_t
temp32
;
static
uint16_t
timeCount
=
0
;
if
(
GET_Backlight
()
==
Backlight_ATUO
)
{
if
(
timeCount
>=
LIGHT_DATA_TIME
)
{
timeCount
=
0
;
...
...
@@ -72,7 +70,6 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
{
/*获取光敏电阻*/
LightRes
=
ADC_Read_Signal
(
ADC_CH_LIGHT_SENSITIVE
);
// ADC_Read_Signal(ADC_CH_FUEL1);
/*四舍五入*/
if
(
LightRes
<
32000
)
{
...
...
@@ -114,6 +111,8 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
}
}
timeCount
+=
deltaTime
;
if
(
GET_Backlight
()
==
Backlight_ATUO
)
{
if
(
LightADCompleteFlg
)
{
if
(
LightR
<=
800
)
...
...
@@ -145,6 +144,29 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
}
}
else
if
(
Menu_Item_Select_Get
(
MENU_ITEM_SELECT_AUTO
))
{
if
(
Backlight_SetPwmLevel
()
==
1U
)
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
100
);
}
else
if
(
Backlight_SetPwmLevel
()
==
2U
)
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
200
);
}
else
if
(
Backlight_SetPwmLevel
()
==
3U
)
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
400
);
}
else
if
(
Backlight_SetPwmLevel
()
==
4U
)
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
600
);
}
else
if
(
Backlight_SetPwmLevel
()
==
5U
)
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
800
);
}
}
else
{
BackLight_Process
();
...
...
@@ -209,8 +231,29 @@ Light_uint8_t Backlight_SetPwmEn(void)
/* 背光等级回调函数 */
Light_uint8_t
Backlight_SetPwmLevel
(
void
)
{
Light_uint8_t
Backlight_PwmLevel
;
return
1
;
if
(
LightR
>
0
&&
LightR
<=
400
)
{
Backlight_PwmLevel
=
1U
;
}
else
if
(
LightR
>
400
&&
LightR
<=
800
)
{
Backlight_PwmLevel
=
2U
;
}
else
if
(
LightR
>
800
&&
LightR
<=
1400
)
{
Backlight_PwmLevel
=
3U
;
}
else
if
(
LightR
>
1400
&&
LightR
<=
2000
)
{
Backlight_PwmLevel
=
4U
;
}
else
if
(
LightR
>
2000
&&
LightR
<=
2600
)
{
Backlight_PwmLevel
=
5U
;
}
return
Backlight_PwmLevel
;
}
/* 获取电阻值回调函数 */
...
...
Firmware/Source/Application/BackLight.h
View file @
59b1636b
...
...
@@ -23,6 +23,7 @@
void
Backlight_KL30_Wakeup_Init
(
void
);
void
BackLight_Process
(
void
);
Light_uint8_t
Backlight_SetPwmLevel
(
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