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

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

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

hu's avatar
hu committed
28 29
BlOFFCtrlStruct BlOFFCtrl;
SEGLCDBackupStruct SEGLCDBackup;
hu's avatar
hu committed
30

hu's avatar
hu committed
31
uint8_t WARNING_DOOR_STATUS;
hu's avatar
hu committed
32 33 34

uint32_t Left_Right_Delay;

hu's avatar
hu committed
35 36
void SEG_LCD_Window_Switch(uint8_t Sw);
void BL_Init(void)
hu's avatar
hu committed
37 38 39 40 41 42 43
{
    SEG_LCD_Init();
}
uint16_t BackLightVLv = 10u;
uint8_t BackLightTestIG = 1u;
uint8_t BackLightWakeFlag = 0u;
uint8_t BackLightTPostLight = 0u;
hu's avatar
hu committed
44
uint16_t testBG = 500;
hu's avatar
hu committed
45 46 47 48 49 50 51 52 53
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
54
void BL_Management_service(void)
hu's avatar
hu committed
55
{
hu's avatar
hu committed
56 57 58 59 60
    uint8_t Msg;
    uint8_t LED_Pos;
    uint8_t LED_Left;
    uint8_t LED_Right;
    uint8_t LED_Plus;
hu's avatar
hu committed
61 62 63 64 65
    uint8_t WARNING_PARKING_BRAKE_TEL = 0u;
    uint8_t BCM_PositionLight = 0;

    uint8_t DutyCycle;

hu's avatar
hu committed
66
    uint8_t ILL = 0;
hu's avatar
hu committed
67

hu's avatar
hu committed
68
    if (Line_In_Get_Status(LINE_IN_ILLUMINATION))
hu's avatar
hu committed
69
    {
hu's avatar
hu committed
70
        ILL = 2;
hu's avatar
hu committed
71 72 73
    }
    else
    {
hu's avatar
hu committed
74
        ILL = 0;
hu's avatar
hu committed
75 76
    }

hu's avatar
hu committed
77
    if (Common_Get_IG_Sts() == COMMON_POWER_OFF)
hu's avatar
hu committed
78
    {
hu's avatar
hu committed
79 80 81 82 83 84 85 86 87 88 89 90
        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
91 92 93
    }
    else
    {
hu's avatar
hu committed
94
        BackLightOFF_TIME = 0u;
hu's avatar
hu committed
95 96
        BackLightWakeFlag = 0u;
        SEG_LCD_Window_Switch(1);
hu's avatar
hu committed
97
    }
hu's avatar
hu committed
98

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

hu's avatar
hu committed
102
    /*得到工作模式 白天 傍晚 夜晚 在枚举中已定义*/
hu's avatar
hu committed
103
    GetBGLType(ILL);
hu's avatar
hu committed
104 105
    // GetBGLType(0);

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

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

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

hu's avatar
hu committed
116
void BL_PWM_Duty_Cycle_Capture_ISR(void)
hu's avatar
hu committed
117 118
{
}
hu's avatar
hu committed
119 120

void SEG_LCD_Init(void)
hu's avatar
hu committed
121 122
{
    SEGLCDBackup.Brightness = 0xFF;
hu's avatar
hu committed
123
    SEGLCDBackup.Window = 0x00;
hu's avatar
hu committed
124 125
    SEG0_MCU_OUT = 0;
    COMM_MCU_OUT = 0;
hu's avatar
hu committed
126
    BackLightOFF_TIME = 0u;
hu's avatar
hu committed
127 128
}

hu's avatar
hu committed
129
void SEG_LCD_Window_Switch(uint8_t Sw)
hu's avatar
hu committed
130
{
hu's avatar
hu committed
131
    if (Sw == SEGLCDBackup.Window)
hu's avatar
hu committed
132 133 134 135
        return;

    SEGLCDBackup.Window = Sw;

hu's avatar
hu committed
136
    if (Sw)
hu's avatar
hu committed
137 138 139 140 141 142 143 144 145 146 147
    {
        SEG0_MCU_OUT = 1;
        COMM_MCU_OUT = 0;
    }
    else
    {
        SEG0_MCU_OUT = 0;
        COMM_MCU_OUT = 0;
    }
}

hu's avatar
hu committed
148 149 150 151 152 153 154 155
/*-------------------------------------------------------------------------
 * Function Name  : SEG_LCD_Window_Control_Service
 * Description    : 10ms任务 窗口翻转
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
156
void SEG_LCD_Window_Control_Service(void)
hu's avatar
hu committed
157
{
hu's avatar
hu committed
158
    if (SEGLCDBackup.Window)
hu's avatar
hu committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    {
        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
176
}