BackLight_APP.c 5.01 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
#include "Analog_Signals.h"
hu's avatar
hu committed
17 18 19

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

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

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

34 35 36 37 38 39 40
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
41
uint8_t WARNING_DOOR_STATUS;
hu's avatar
hu committed
42 43 44

uint32_t Left_Right_Delay;

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

hu's avatar
hu committed
51 52 53 54 55 56 57 58
/*-------------------------------------------------------------------------
 * Function Name  : BL_Management_service
 * Description    : 100ms任务
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
59
void BL_Management_service(void)
hu's avatar
hu committed
60
{
hu's avatar
hu committed
61
    uint8_t Msg;
hu's avatar
hu committed
62
    uint8_t LED_Pos = 0u;
hu's avatar
hu committed
63 64 65
    uint8_t LED_Left;
    uint8_t LED_Right;
    uint8_t LED_Plus;
hu's avatar
hu committed
66 67 68
    uint8_t WARNING_PARKING_BRAKE_TEL = 0u;
    uint8_t BCM_PositionLight = 0;
    uint8_t DutyCycle;
hu's avatar
hu committed
69
    uint8_t ILL = 0;
70
    uint32_t Get_Menu_Off_Time = 0u;
hu's avatar
hu committed
71
    uint32_t DNC_NumValue = 0u;
hu's avatar
hu committed
72

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

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

        Get_Menu_Off_Time = Coom_Get_Menu_Off_Time();

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

            BackLightWakeFlag = 1u;
            SEG_LCD_Window_Switch(1);
        }
        else
        {
116
            State_Flag.Menu_Key_Static = 0;
hu's avatar
hu committed
117 118 119
            BackLightWakeFlag = 0u;
            SEG_LCD_Window_Switch(0);
        }
hu's avatar
hu committed
120 121 122
    }
    else
    {
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
        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
138
        BackLightOFF_TIME = 0u;
hu's avatar
hu committed
139
        BackLightWakeFlag = 0u;
hu's avatar
hu committed
140
    }
hu's avatar
hu committed
141

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

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

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

hu's avatar
hu committed
152 153
    /*得到热敏电阻电压参数为AD数值*/
    DNC_NumValue = Common_Get_NTCAD();
hu's avatar
hu committed
154

hu's avatar
hu committed
155
    GetBGLNTCVol((uint16_t)DNC_NumValue);
156

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

hu's avatar
hu committed
159 160 161
    BackLightSchedu(Common_Get_IG_Sts(), BackLightWakeFlag);
}

hu's avatar
hu committed
162
void BL_PWM_Duty_Cycle_Capture_ISR(void)
hu's avatar
hu committed
163 164
{
}
hu's avatar
hu committed
165 166

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

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

    SEGLCDBackup.Window = Sw;

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

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