BackLight_APP.c 4.99 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10
#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"
hu's avatar
hu committed
11
#include "RTE_ADC.h"
hu's avatar
hu committed
12 13
#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

33 34 35 36 37 38 39
uint16_t BackLightVLv = 10u;
uint16_t testBG = 500;
uint16_t BackLightOFF_TIME = 0u;
uint16_t BackLightOFFFlag = 0;
uint8_t BackLightTestIG = 1u;
uint8_t BackLightWakeFlag = 0u;
uint8_t BackLightTPostLight = 0u;
hu's avatar
hu committed
40
uint8_t WARNING_DOOR_STATUS;
hu's avatar
hu committed
41 42 43

uint32_t Left_Right_Delay;

hu's avatar
hu committed
44 45
void SEG_LCD_Window_Switch(uint8_t Sw);
void BL_Init(void)
hu's avatar
hu committed
46 47 48
{
    SEG_LCD_Init();
}
49

hu's avatar
hu committed
50 51 52 53 54 55 56 57
/*-------------------------------------------------------------------------
 * Function Name  : BL_Management_service
 * Description    : 100ms任务
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
58
void BL_Management_service(void)
hu's avatar
hu committed
59
{
hu's avatar
hu committed
60
    uint8_t Msg;
hu's avatar
hu committed
61
    uint8_t LED_Pos = 0u;
hu's avatar
hu committed
62 63 64
    uint8_t LED_Left;
    uint8_t LED_Right;
    uint8_t LED_Plus;
hu's avatar
hu committed
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;
69
    uint32_t Get_Menu_Off_Time = 0u;
hu's avatar
hu committed
70
    uint32_t DNC_NumValue = 0u;
hu's avatar
hu committed
71

hu's avatar
hu committed
72
    if (Line_In_Get_Status(LINE_IN_ILLUMINATION))
hu's avatar
hu committed
73
    {
74 75 76 77 78 79 80 81 82 83
        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
84 85 86
    }
    else
    {
87 88 89 90 91 92 93 94 95 96
        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
97 98
    }

hu's avatar
hu committed
99
    if (Common_Get_IG_Sts() == COMMON_POWER_OFF)
hu's avatar
hu committed
100
    {
101 102 103 104 105
        BackLightOFFFlag = 0;

        Get_Menu_Off_Time = Coom_Get_Menu_Off_Time();

        //if (BackLightOFF_TIME < 3000)
106
        if ((State_Flag.Menu_Key_Static == 1u) && (Coom_Get_Menu_Off_MenuTime() < 7500))
hu's avatar
hu committed
107 108 109 110 111 112 113 114
        {
            BackLightOFF_TIME++;

            BackLightWakeFlag = 1u;
            SEG_LCD_Window_Switch(1);
        }
        else
        {
115
            State_Flag.Menu_Key_Static = 0;
hu's avatar
hu committed
116 117 118
            BackLightWakeFlag = 0u;
            SEG_LCD_Window_Switch(0);
        }
hu's avatar
hu committed
119 120 121
    }
    else
    {
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
        State_Flag.Menu_Key_Static = 0;

        if (BackLightOFFFlag <= 50)
        {
            BackLightOFFFlag++;
        }
        if (BackLightOFFFlag >= 5)
        {
            SEG_LCD_Window_Switch(1);
        }
        else
        {
            SEG_LCD_Window_Switch(0);
        }

hu's avatar
hu committed
137
        BackLightOFF_TIME = 0u;
hu's avatar
hu committed
138
        BackLightWakeFlag = 0u;
hu's avatar
hu committed
139
    }
hu's avatar
hu committed
140

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

hu's avatar
hu committed
144
    /*得到工作模式 白天 傍晚 夜晚 在枚举中已定义*/
hu's avatar
hu committed
145
    GetBGLType(ILL);
hu's avatar
hu committed
146 147
    // GetBGLType(0);

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

hu's avatar
hu committed
151
    /*得到热敏电阻电压参数为100倍电压值*/
hu's avatar
hu committed
152 153
    DNC_NumValue = RTE_Read_NTC_R_Valid();
    GetBGLNTCVol((uint16_t)DNC_NumValue);
154

hu's avatar
hu committed
155
    /*主函数中调用第一个参数电源状态 1是 ON档 2 off 第二个参数 唤醒条件 1是TTF唤醒 2 是表盘唤醒 3 是表盘和屏都有唤醒,0无唤醒*/
156

hu's avatar
hu committed
157 158 159
    BackLightSchedu(Common_Get_IG_Sts(), BackLightWakeFlag);
}

hu's avatar
hu committed
160
void BL_PWM_Duty_Cycle_Capture_ISR(void)
hu's avatar
hu committed
161 162
{
}
hu's avatar
hu committed
163 164

void SEG_LCD_Init(void)
hu's avatar
hu committed
165 166
{
    SEGLCDBackup.Brightness = 0xFF;
hu's avatar
hu committed
167
    SEGLCDBackup.Window = 0x00;
hu's avatar
hu committed
168 169
    SEG0_MCU_OUT = 0;
    COMM_MCU_OUT = 0;
hu's avatar
hu committed
170
    BackLightOFF_TIME = 0u;
hu's avatar
hu committed
171 172
}

hu's avatar
hu committed
173
void SEG_LCD_Window_Switch(uint8_t Sw)
hu's avatar
hu committed
174
{
hu's avatar
hu committed
175
    if (Sw == SEGLCDBackup.Window)
hu's avatar
hu committed
176 177 178 179
        return;

    SEGLCDBackup.Window = Sw;

hu's avatar
hu committed
180
    if (Sw)
hu's avatar
hu committed
181 182 183 184 185 186 187 188 189 190 191
    {
        SEG0_MCU_OUT = 1;
        COMM_MCU_OUT = 0;
    }
    else
    {
        SEG0_MCU_OUT = 0;
        COMM_MCU_OUT = 0;
    }
}

hu's avatar
hu committed
192 193 194 195 196 197 198 199
/*-------------------------------------------------------------------------
 * Function Name  : SEG_LCD_Window_Control_Service
 * Description    : 10ms任务 窗口翻转
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
200
void SEG_LCD_Window_Control_Service(void)
hu's avatar
hu committed
201
{
hu's avatar
hu committed
202
    if (SEGLCDBackup.Window)
hu's avatar
hu committed
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
    {
        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
220
}