BackLight.c 1.7 KB
Newer Older
时昊's avatar
时昊 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 64

#include "BackLight.h"
#include "Components.h"

#define BACK_LIGHT_DAY 600
#define BACK_LIGHT_NIGHT 200
#define BACK_LIGHT_Val_1 100
#define BACK_LIGHT_Val_2 200
#define BACK_LIGHT_Val_3 400
#define BACK_LIGHT_Val_4 600
#define BACK_LIGHT_Val_5 800

_Light g_Light;

void BackLight_Init(void)
{
    MenuInfor.BackLight_Val = BackLight_Val_2;
    g_Light.Light_Auto = 0XFFFF;
}

void BackLight_Process(void)
{
    if (SYS_OPR_STAT_IGN_ON)
    {
        if(MenuInfor.BackLight_Val == BackLight_Val_A)
        {
            //g_Light.Light_Auto = ALS_Get_Data1();
            if (g_Light.Light_Auto >= 1000)
            {
                g_Light.Light_Auto = 1000;
            }
            TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, g_Light.Light_Auto);
        }
        else if(MenuInfor.BackLight_Val == BackLight_Val_1)
        {
            TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_1);
        }
        else if(MenuInfor.BackLight_Val == BackLight_Val_2)
        {
            TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_2);
        }
        else if(MenuInfor.BackLight_Val == BackLight_Val_3)
        {
            TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_3);
        }
        else if(MenuInfor.BackLight_Val == BackLight_Val_4)
        {
            TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_4);
        }
        else if(MenuInfor.BackLight_Val == BackLight_Val_5)
        {
            TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, BACK_LIGHT_Val_5);
        }
        else
        {
            ;
        }
    }
    else
    {
        g_Light.Light_Auto = 0;
        TimerM_PWM_set_duty(TIMERM_COUNTER1, TIMERM_CHB, 0);
    }
}