BackLight_APP.c 5.15 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#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
{
    uint8_t   Brightness;
    uint8_t   Window;
} SEGLCDBackupStruct;

typedef struct
{
    uint8_t   DoorStatusBackup;
    uint16_t  Timer;
    uint16_t  BackupPwm;
} BlOFFCtrlStruct;


BlOFFCtrlStruct     BlOFFCtrl;
SEGLCDBackupStruct   SEGLCDBackup;


uint8_t WARNING_DOOR_STATUS ;

uint32_t Left_Right_Delay;


void SEG_LCD_Window_Switch ( uint8_t Sw );
void BL_Init ( void )
{

    SEG_LCD_Init();
}
uint16_t BackLightVLv = 10u;
uint8_t BackLightTestIG = 1u;
uint8_t BackLightWakeFlag = 0u;
uint8_t BackLightTPostLight = 0u;
uint16_t testBG = 500 ;
void BL_Management_service ( void )
{

    uint8_t  Msg;
    uint8_t  LED_Pos;
    uint8_t  LED_Left;
    uint8_t  LED_Right;
    uint8_t  LED_Plus;
    uint8_t WARNING_PARKING_BRAKE_TEL = 0u;
    uint8_t BCM_PositionLight = 0;

    uint8_t DutyCycle;

    uint8_t ILL = 0 ;

hu's avatar
hu committed
64
    if (Line_In_Get_Status(LINE_IN_ILLUMINATION) )
hu's avatar
hu committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
    {
        ILL = 2 ;
    }
    else
    {
        ILL = 0 ;
    }

    if ( Common_Get_IG_Sts() == COMMON_POWER_OFF )
    {

#if 0

        LED_Pos = Get_ID_245_Sig_BCM_PosiLightSts();
        LED_Left = Get_ID_245_Sig_BCM_TurnLightSts_L();
        LED_Right = Get_ID_245_Sig_BCM_TurnLightSts_R();


        LED_Plus = LED_Left + LED_Right ;
        if (LED_Plus != 0u)
        {
            Left_Right_Delay = 0u;
            WARNING_PARKING_BRAKE_TEL =  LED_Left + LED_Right;
        }
        else
        {
            if (Left_Right_Delay <= 500ul)
            {
                Left_Right_Delay++;
            }
            if (Left_Right_Delay >= 15)
            {
                WARNING_PARKING_BRAKE_TEL =  LED_Left + LED_Right;
            }
            else
            {
                WARNING_PARKING_BRAKE_TEL =  1;
            }
        }


        if (( Get_Current_DispType() == Disp_Alarm ) || (WARNING_PARKING_BRAKE_TEL != 0) || (LED_Pos != 0))
        {

            Msg =  Popup_Get_Current_Message();

            //if (( Msg != POPUP_MSG_DOOR_OPEN_LOW_SPEED ) || (WARNING_PARKING_BRAKE_TEL != 0))
            //    BlOFFCtrl.Timer = 0;
            //else
            //{
            //    if ( ( WARNING_DOOR_STATUS != 0 ) && ( WARNING_DOOR_STATUS != BlOFFCtrl.DoorStatusBackup ) )
            //        BlOFFCtrl.Timer = 0;
            //    else
            //    {
            //        if ( BlOFFCtrl.Timer < 30 * 50 )
            //            BlOFFCtrl.Timer++;
            //    }

            //    BlOFFCtrl.DoorStatusBackup = WARNING_DOOR_STATUS;
            //}

            if ( BlOFFCtrl.Timer < 30 * 50 )
            {

                SEG_LCD_Window_Switch ( 1 );
                BackLightWakeFlag = 1u;
            }
            else
            {
                SEG_LCD_Window_Switch ( 0 );
                BackLightWakeFlag = 0u;
            }
        }
        else
        {
            BlOFFCtrl.Timer = 0;
            SEG_LCD_Window_Switch ( 0 );
            BackLightWakeFlag = 0u;
        }
#endif
    }
    else
    {
        //if ( BCM_PositionLight )
        //{
        //    RTE_PWM_Set_Panel ( 47, 42, 43 );
        //    RTE_PWM_Set_LCD ( DutyCycle );
        //    RTE_PWM_Set_Point ( DutyCycle );
        //}
        //else
        //{
        //    RTE_PWM_Set_Panel ( 95, 85, 86 );
        //    RTE_PWM_Set_LCD ( DutyCycle );           //LCD_BL   = 1;
        //    RTE_PWM_Set_Point ( DutyCycle );           //LCD_BL   = 1;
        //}
        SEG_LCD_Window_Switch ( 1 );
    }
    /*得到主题模式可自己在枚举中定义 在BackGroundLight.c里填表*/
    GetBGLTheme(0);
    /*得到工作模式 白天 傍晚 夜晚 在枚举中已定义*/
hu's avatar
hu committed
165

hu's avatar
hu committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
    GetBGLType(ILL);
    //GetBGLType(0);
    /*得到背光等级 可自己在枚举中定义 在BackGroundLight.c里填表*/
    GetBGLLvl(BackLightVLv, LED_Pos);
    /*得到热敏电阻电压参数为100倍电压值*/

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

void BL_PWM_Duty_Cycle_Capture_ISR ( void )
{



}
void SEG_LCD_Init ( void )
{
    SEGLCDBackup.Brightness = 0xFF;
    SEGLCDBackup.Window     = 0x00;
    SEG0_MCU_OUT = 0;
    COMM_MCU_OUT = 0;
}

void SEG_LCD_Window_Switch ( uint8_t Sw )
{
    if ( Sw == SEGLCDBackup.Window )
        return;

    SEGLCDBackup.Window = Sw;

    if ( Sw )
    {
        SEG0_MCU_OUT = 1;
        COMM_MCU_OUT = 0;
    }
    else
    {
        SEG0_MCU_OUT = 0;
        COMM_MCU_OUT = 0;
    }
}


//10ms

void SEG_LCD_Window_Control_Service ( void )
{
    if ( SEGLCDBackup.Window )
    {
        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
233
}