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
758193f5
Commit
758193f5
authored
Aug 21, 2024
by
王金亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat:增加背光NTC部分代码,功能已应用
parent
f9b0a8f2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
50 deletions
+56
-50
BackLight.c
Firmware/Source/Application/BackLight.c
+54
-49
BackLight.h
Firmware/Source/Application/BackLight.h
+1
-1
Sys_Task_List.c
Firmware/Source/System/Sys_Task_List.c
+1
-0
No files found.
Firmware/Source/Application/BackLight.c
View file @
758193f5
#include "Backlight.h"
#include "Backlight.h"
#include "Components.h"
#include "Components.h"
#define BACK_LIGHT_Val_1 100
typedef
void
(
*
SetPwm
)(
Light_uint16_t
Pwm
);
#define BACK_LIGHT_Val_2 300
typedef
Light_uint8_t
(
*
SetPwmEnable
)(
void
);
#define BACK_LIGHT_Val_3 500
typedef
Light_uint8_t
(
*
SetPwmLevel
)(
void
);
#define BACK_LIGHT_Val_4 700
typedef
Light_uint16_t
(
*
NtcRes
)(
void
);
#define BACK_LIGHT_Val_5 900
typedef
struct
{
SetPwm
SetPwmCbk
;
/* 设置PWM回调函数 */
SetPwmEnable
SetPwmEnCbk
;
/* 设置PWM使能回调函数 */
SetPwmLevel
SetPwmLevelCbk
;
/* 背光等级回调函数 */
NtcRes
NtcResCbk
;
/* 获取电阻值回调函数 */
}
BackLightExtPara
;
typedef
struct
{
SetPwm
SetPwmCbk
;
/* 设置PWM回调函数 */
SetPwmEnable
SetPwmEnCbk
;
/* 设置PWM使能回调函数 */
SetPwmLevel
SetPwmLevelCbk
;
/* 背光等级回调函数 */
NtcRes
NtcResCbk
;
Light_uint8_t
BacklightEn
;
/* 背光使能 */
Light_uint16_t
BacklightPwm
;
/* 背光PWM */
Light_uint16_t
BacklightLevel
;
/* 背光等级 */
}
_Backlight_Op
;
_Backlight_Op
Backlight_Operate
;
#define BACK_LIGHT_Val_1 (( 100 * Backlight_Operate.BacklightPwm ) / 100 )
#define BACK_LIGHT_Val_2 (( 200 * Backlight_Operate.BacklightPwm ) / 100 )
#define BACK_LIGHT_Val_3 (( 400 * Backlight_Operate.BacklightPwm ) / 100 )
#define BACK_LIGHT_Val_4 (( 600 * Backlight_Operate.BacklightPwm ) / 100 )
#define BACK_LIGHT_Val_5 (( 800 * Backlight_Operate.BacklightPwm ) / 100 )
#define LIGHT_DATA_TIME 10u
/*这里填写多长时间采集一个数据,单位ms*/
#define LIGHT_DATA_TIME 10u
/*这里填写多长时间采集一个数据,单位ms*/
#define LIGHT_DATA_NUM 20u
/*燃油电阻采集数据总数 最大255*/
#define LIGHT_DATA_NUM 20u
/*燃油电阻采集数据总数 最大255*/
...
@@ -136,11 +162,11 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
...
@@ -136,11 +162,11 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
}
}
if
(
LightR_Status
==
0
)
if
(
LightR_Status
==
0
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
200
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_2
);
}
}
else
else
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
800
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_5
);
}
}
}
}
}
}
...
@@ -148,23 +174,23 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
...
@@ -148,23 +174,23 @@ void Data_Light_Res_service(Light_uint8_t deltaTime)//获取光感阻值,并
{
{
if
(
Backlight_SetPwmLevel
()
==
1U
)
if
(
Backlight_SetPwmLevel
()
==
1U
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
100
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_1
);
}
}
else
if
(
Backlight_SetPwmLevel
()
==
2U
)
else
if
(
Backlight_SetPwmLevel
()
==
2U
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
200
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_2
);
}
}
else
if
(
Backlight_SetPwmLevel
()
==
3U
)
else
if
(
Backlight_SetPwmLevel
()
==
3U
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
400
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_3
);
}
}
else
if
(
Backlight_SetPwmLevel
()
==
4U
)
else
if
(
Backlight_SetPwmLevel
()
==
4U
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
600
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_4
);
}
}
else
if
(
Backlight_SetPwmLevel
()
==
5U
)
else
if
(
Backlight_SetPwmLevel
()
==
5U
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
800
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_5
);
}
}
}
}
else
else
...
@@ -187,31 +213,8 @@ Light_uint16_t GetBacklightDutyByLevel(Light_uint16_t level)
...
@@ -187,31 +213,8 @@ Light_uint16_t GetBacklightDutyByLevel(Light_uint16_t level)
return
0
;
return
0
;
}
}
typedef
void
(
*
SetPwm
)(
Light_uint16_t
Pwm
);
typedef
Light_uint8_t
(
*
SetPwmEnable
)(
void
);
typedef
Light_uint8_t
(
*
SetPwmLevel
)(
void
);
typedef
Light_uint16_t
(
*
NtcRes
)(
void
);
typedef
struct
{
SetPwm
SetPwmCbk
;
/* 设置PWM回调函数 */
SetPwmEnable
SetPwmEnCbk
;
/* 设置PWM使能回调函数 */
SetPwmLevel
SetPwmLevelCbk
;
/* 背光等级回调函数 */
NtcRes
NtcResCbk
;
/* 获取电阻值回调函数 */
}
BackLightExtPara
;
typedef
struct
{
SetPwm
SetPwmCbk
;
/* 设置PWM回调函数 */
SetPwmEnable
SetPwmEnCbk
;
/* 设置PWM使能回调函数 */
SetPwmLevel
SetPwmLevelCbk
;
/* 背光等级回调函数 */
NtcRes
NtcResCbk
;
Light_uint8_t
BacklightEn
;
/* 背光使能 */
Light_uint16_t
BacklightPwm
;
/* 背光PWM */
Light_uint16_t
BacklightLevel
;
/* 背光等级 */
}
_Backlight_Op
;
_Backlight_Op
Backlight_Operate
;
/* 设置PWM回调函数 */
/* 设置PWM回调函数 */
...
@@ -494,7 +497,7 @@ void BackLight_Service(void)
...
@@ -494,7 +497,7 @@ void BackLight_Service(void)
BacklightFactorCtrl
.
curFactor
=
BacklightFactorCtrl
.
destFactor
;
BacklightFactorCtrl
.
curFactor
=
BacklightFactorCtrl
.
destFactor
;
}
}
BacklightFactorCtrl
.
u16DialdestDuty
=
Backlight
FactorCtrl
.
curFactor
*
BacklightFactorCtrl
.
curFactor
/
100
;
BacklightFactorCtrl
.
u16DialdestDuty
=
Backlight
_Operate
.
BacklightPwm
*
BacklightFactorCtrl
.
curFactor
/
100
;
if
(
BacklightFactorCtrl
.
u16DialdestDuty
<
50
)
if
(
BacklightFactorCtrl
.
u16DialdestDuty
<
50
)
{
{
...
@@ -518,17 +521,19 @@ void BackLight_Service(void)
...
@@ -518,17 +521,19 @@ void BackLight_Service(void)
}
}
Backlight_Operate
.
BacklightPwm
=
BacklightFactorCtrl
.
u16DialcurDuty
;
Backlight_Operate
.
BacklightPwm
=
BacklightFactorCtrl
.
u16DialcurDuty
;
Backlight_Operate
.
SetPwmCbk
(
Backlight_Operate
.
BacklightPwm
);
//
Backlight_Operate.SetPwmCbk(Backlight_Operate.BacklightPwm);
}
}
else
else
{
{
/* 无NTC策略 直接根据当前背光等级调整PWM */
/* 无NTC策略 直接根据当前背光等级调整PWM */
Backlight_Operate
.
SetPwmCbk
(
Backlight_Operate
.
BacklightPwm
);
Backlight_Operate
.
BacklightPwm
=
100U
;
// Backlight_Operate.SetPwmCbk(Backlight_Operate.BacklightPwm);
}
}
}
}
else
else
{
{
Backlight_Operate
.
SetPwmCbk
(
0
);
Backlight_Operate
.
BacklightPwm
=
100U
;
// Backlight_Operate.SetPwmCbk(0);
}
}
}
}
...
@@ -538,7 +543,7 @@ void BackLight_Process(void)
...
@@ -538,7 +543,7 @@ void BackLight_Process(void)
{
{
if
(
Menu_Item_Select_Get
(
MENU_ITEM_BACKLIGHT_5
)
==
1
)
if
(
Menu_Item_Select_Get
(
MENU_ITEM_BACKLIGHT_5
)
==
1
)
{
{
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
BACK_LIGHT_Val_5
);
TimerM_PWM_set_duty
(
TIMERM_COUNTER1
,
TIMERM_CHB
,
(
BACK_LIGHT_Val_5
)
);
}
}
else
if
(
Menu_Item_Select_Get
(
MENU_ITEM_BACKLIGHT_4
)
==
1
)
else
if
(
Menu_Item_Select_Get
(
MENU_ITEM_BACKLIGHT_4
)
==
1
)
{
{
...
...
Firmware/Source/Application/BackLight.h
View file @
758193f5
...
@@ -25,7 +25,7 @@ extern Light_uint16_t LightR_Status ;
...
@@ -25,7 +25,7 @@ extern Light_uint16_t LightR_Status ;
void
Backlight_KL30_Wakeup_Init
(
void
);
void
Backlight_KL30_Wakeup_Init
(
void
);
void
BackLight_Process
(
void
);
void
BackLight_Process
(
void
);
Light_uint8_t
Backlight_SetPwmLevel
(
void
);
Light_uint8_t
Backlight_SetPwmLevel
(
void
);
extern
void
BackLight_Service
(
void
);
...
...
Firmware/Source/System/Sys_Task_List.c
View file @
758193f5
...
@@ -53,6 +53,7 @@ void Sys_20ms_Tasks(void)
...
@@ -53,6 +53,7 @@ void Sys_20ms_Tasks(void)
void
Sys_50ms_Tasks
(
void
)
void
Sys_50ms_Tasks
(
void
)
{
{
// BlueToothService();
// BlueToothService();
BackLight_Service
();
Telltales_Management
();
Telltales_Management
();
g_u8Cursor_Posittion
=
Menu_Get_Current_Cursor_Information
();
g_u8Cursor_Posittion
=
Menu_Get_Current_Cursor_Information
();
...
...
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