BackLight_APP.c 4.33 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "BackLight_APP.h"
#include "RTE_PWM_OUT.h"
#include "Common_Interface.h"
#include "Popup_List.h"
#include "Popup_Scheduler.h"
#include "GPIO.h"
#include "dr7f701441.dvf.h"
#include "CAN_Communication_Matrix.h"
#include "BGLInterface.h"
#include "Line_in.h"

#include "TimerB.h"
#include "Data_Fuel_User.h"
14 15
#include "Menu.h"
#include "GUI.h"
hu's avatar
hu committed
16 17 18

typedef struct
{
hu's avatar
hu committed
19 20
    uint8_t Brightness;
    uint8_t Window;
hu's avatar
hu committed
21 22 23 24
} SEGLCDBackupStruct;

typedef struct
{
hu's avatar
hu committed
25 26 27
    uint8_t DoorStatusBackup;
    uint16_t Timer;
    uint16_t BackupPwm;
hu's avatar
hu committed
28 29
} BlOFFCtrlStruct;

hu's avatar
hu committed
30 31
BlOFFCtrlStruct BlOFFCtrl;
SEGLCDBackupStruct SEGLCDBackup;
hu's avatar
hu committed
32

hu's avatar
hu committed
33
uint8_t WARNING_DOOR_STATUS;
hu's avatar
hu committed
34 35 36

uint32_t Left_Right_Delay;

hu's avatar
hu committed
37 38
void SEG_LCD_Window_Switch(uint8_t Sw);
void BL_Init(void)
hu's avatar
hu committed
39 40 41 42 43 44 45
{
    SEG_LCD_Init();
}
uint16_t BackLightVLv = 10u;
uint8_t BackLightTestIG = 1u;
uint8_t BackLightWakeFlag = 0u;
uint8_t BackLightTPostLight = 0u;
hu's avatar
hu committed
46
uint16_t testBG = 500;
hu's avatar
hu committed
47 48 49 50 51 52 53 54 55
uint16_t BackLightOFF_TIME = 0u;
/*-------------------------------------------------------------------------
 * Function Name  : BL_Management_service
 * Description    : 100ms任务
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
56
void BL_Management_service(void)
hu's avatar
hu committed
57
{
hu's avatar
hu committed
58 59 60 61 62
    uint8_t Msg;
    uint8_t LED_Pos;
    uint8_t LED_Left;
    uint8_t LED_Right;
    uint8_t LED_Plus;
hu's avatar
hu committed
63 64 65 66 67
    uint8_t WARNING_PARKING_BRAKE_TEL = 0u;
    uint8_t BCM_PositionLight = 0;

    uint8_t DutyCycle;

hu's avatar
hu committed
68
    uint8_t ILL = 0;
hu's avatar
hu committed
69

hu's avatar
hu committed
70
    if (Line_In_Get_Status(LINE_IN_ILLUMINATION))
hu's avatar
hu committed
71
    {
72 73 74 75 76 77 78 79 80 81
        if (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_1)
        {
            ILL = 0;
            BackLightVLv = User_set_Num.User_Light1;
        }
        else
        {
            ILL = 2;
            BackLightVLv = User_set_Num.User_Light2;
        }
hu's avatar
hu committed
82 83 84
    }
    else
    {
85 86 87 88 89 90 91 92 93 94
        if (bCurMenuIDX == _MN_DSP_LEVEL3_7_MENU_2)
        {
            ILL = 2;
            BackLightVLv = User_set_Num.User_Light2;
        }
        else
        {
            ILL = 0;
            BackLightVLv = User_set_Num.User_Light1;
        }
hu's avatar
hu committed
95 96
    }

hu's avatar
hu committed
97
    if (Common_Get_IG_Sts() == COMMON_POWER_OFF)
hu's avatar
hu committed
98
    {
hu's avatar
hu committed
99 100 101 102 103 104 105 106 107 108 109 110
        if (BackLightOFF_TIME < 150u)
        {
            BackLightOFF_TIME++;

            BackLightWakeFlag = 1u;
            SEG_LCD_Window_Switch(1);
        }
        else
        {
            BackLightWakeFlag = 0u;
            SEG_LCD_Window_Switch(0);
        }
hu's avatar
hu committed
111 112 113
    }
    else
    {
hu's avatar
hu committed
114
        BackLightOFF_TIME = 0u;
hu's avatar
hu committed
115 116
        BackLightWakeFlag = 0u;
        SEG_LCD_Window_Switch(1);
hu's avatar
hu committed
117
    }
hu's avatar
hu committed
118

hu's avatar
hu committed
119 120
    /*得到主题模式可自己在枚举中定义 在BackGroundLight.c里填表*/
    GetBGLTheme(0);
hu's avatar
hu committed
121

hu's avatar
hu committed
122
    /*得到工作模式 白天 傍晚 夜晚 在枚举中已定义*/
hu's avatar
hu committed
123
    GetBGLType(ILL);
hu's avatar
hu committed
124 125
    // GetBGLType(0);

hu's avatar
hu committed
126
    /*得到背光等级 可自己在枚举中定义 在BackGroundLight.c里填表*/
127
    GetBGLLvl((BackLightVLv - 1), LED_Pos);
hu's avatar
hu committed
128

hu's avatar
hu committed
129
    /*得到热敏电阻电压参数为100倍电压值*/
hu's avatar
hu committed
130
    GetBGLNTCVol(0);
131

hu's avatar
hu committed
132
    /*主函数中调用第一个参数电源状态 1是 ON档 2 off 第二个参数 唤醒条件 1是TTF唤醒 2 是表盘唤醒 3 是表盘和屏都有唤醒,0无唤醒*/
hu's avatar
hu committed
133 134 135
    BackLightSchedu(Common_Get_IG_Sts(), BackLightWakeFlag);
}

hu's avatar
hu committed
136
void BL_PWM_Duty_Cycle_Capture_ISR(void)
hu's avatar
hu committed
137 138
{
}
hu's avatar
hu committed
139 140

void SEG_LCD_Init(void)
hu's avatar
hu committed
141 142
{
    SEGLCDBackup.Brightness = 0xFF;
hu's avatar
hu committed
143
    SEGLCDBackup.Window = 0x00;
hu's avatar
hu committed
144 145
    SEG0_MCU_OUT = 0;
    COMM_MCU_OUT = 0;
hu's avatar
hu committed
146
    BackLightOFF_TIME = 0u;
hu's avatar
hu committed
147 148
}

hu's avatar
hu committed
149
void SEG_LCD_Window_Switch(uint8_t Sw)
hu's avatar
hu committed
150
{
hu's avatar
hu committed
151
    if (Sw == SEGLCDBackup.Window)
hu's avatar
hu committed
152 153 154 155
        return;

    SEGLCDBackup.Window = Sw;

hu's avatar
hu committed
156
    if (Sw)
hu's avatar
hu committed
157 158 159 160 161 162 163 164 165 166 167
    {
        SEG0_MCU_OUT = 1;
        COMM_MCU_OUT = 0;
    }
    else
    {
        SEG0_MCU_OUT = 0;
        COMM_MCU_OUT = 0;
    }
}

hu's avatar
hu committed
168 169 170 171 172 173 174 175
/*-------------------------------------------------------------------------
 * Function Name  : SEG_LCD_Window_Control_Service
 * Description    : 10ms任务 窗口翻转
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
176
void SEG_LCD_Window_Control_Service(void)
hu's avatar
hu committed
177
{
hu's avatar
hu committed
178
    if (SEGLCDBackup.Window)
hu's avatar
hu committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    {
        if (SEG0_MCU_OUT == 1)
        {
            SEG0_MCU_OUT = 0;
            COMM_MCU_OUT = 1;
        }
        else
        {
            SEG0_MCU_OUT = 1;
            COMM_MCU_OUT = 0;
        }
    }
    else
    {
        SEG0_MCU_OUT = 0;
        COMM_MCU_OUT = 0;
    }
hu's avatar
hu committed
196
}