SY883x_For_Client_JLAB_JS07/UsrSrc/led/led.c

158 lines
3.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
******************************************************************************
*
* @file led.c
* @brief led module
* @ic TP3102
*
* @version 1.0
* @date 2022/08/04 15:00:40
* @author Alex Xu
*
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
* All Rights Reserved
*
* History:
* Revision Date Author Desc
* 1.0.0 2022/08/04 Alex build this file
******************************************************************************/
/*_____ I N C L U D E S ____________________________________________________*/
#include "led.h"
#if LED_DISPLAY
/******************************************************************************\
Macro definitions
\******************************************************************************/
/******************************************************************************\
Variables definitions
\******************************************************************************/
/******************************************************************************\
Functions definitions
\******************************************************************************/
#if 0
/*
* 函数名称 : LED_On
* 功能描述 : 点亮LED
* 参 数 : LED的ID
* 返回值 : NONE
*/
/******************************************************************************/
static void LED_On(uint8_t LedId)
/******************************************************************************/
{
switch(LedId)
{
case LED_R:
LEDR_ON();
break;
case LED_B:
LEDB_ON();
break;
default:
break;
}
}
/*
* 函数名称 : LED_Off
* 功能描述 : 熄灭LED
* 参 数 : LED的ID
* 返回值 : NONE
*/
/******************************************************************************/
static void LED_Off(uint8_t LedId)
/******************************************************************************/
{
switch(LedId)
{
case LED_R:
LEDR_OFF();
break;
case LED_B:
LEDB_OFF();
break;
default:
break;
}
}
#endif
#ifdef BREATHING_LIGHT
idata BRTH_LED_INFO BL_LED;
/*
* 函数名称 : LED_Breathing_Light
* 功能描述 : LED呼吸灯驱动需放在100us时间片中每20ms改变一次占空比。
模拟人体呼吸吸气和呼气各占1.5s人眼的图像滞留时间0.04s1/24帧画面
按最快0.04s40ms。亮20ms灭20ms人眼看到的应该是一直亮。
呼吸灯就是改变这40ms中亮和灭所占用的百分百。
1500/20=75个周期40ms/75=266us。75个变化周期中每个周期增长1个单位266us
75个周期刚好是40ms这样就能达到全亮反之全灭。
* 参 数 : NONE
* 返回值 : NONE
*/
/******************************************************************************/
void LED_Breathing_Light(void)
/******************************************************************************/
{
if ( BL_LED.Breathing_Light_On )
{
if( BL_LED.BL_Timer <= BL_LED.BL_Flash_Duty )
{
LEDB_ON();
}
else
{
LEDB_OFF();
}
if( BL_LED.BL_Timer >= BL_DUTY_MAX )
{
BL_LED.BL_Timer = 0;
if(BL_LED.Flash_Duty_Declining)
{
BL_LED.BL_Flash_Duty -= BL_STEP;
}
else
if(BL_LED.Flash_Duty_Rising)
{
BL_LED.BL_Flash_Duty += BL_STEP;
}
}
if( BL_DUTY_MAX <= BL_LED.BL_Flash_Duty )
{
BL_LED.Flash_Duty_Declining = 1;
BL_LED.Flash_Duty_Rising = 0;
}
else
if( BL_LED.BL_Flash_Duty <= 1 )
{
BL_LED.Flash_Duty_Rising = 1;
BL_LED.Flash_Duty_Declining = 0;
}
}
BL_LED.BL_Timer += LED_PLUS_TIME;
}
#endif
#endif