/* ****************************************************************************** * * @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" #ifdef LED_DISPLAY /******************************************************************************\ Macro definitions \******************************************************************************/ /******************************************************************************\ Variables definitions \******************************************************************************/ static idata TS_LED_INFO LED; /******************************************************************************\ Functions definitions \******************************************************************************/ /* * 函数名称 : LED_Init * 功能描述 : LED初始化 * 参 数 : NONE * 返回值 : NONE */ /******************************************************************************/ void LED_Init(void) /******************************************************************************/ { SFRADDR = P0_OE; SFRDATA = 0x1C; SFRADDR = P0_DRV; SFRDATA = 0x3F; P0 &= ~0x1C; } /* * 函数名称 : LED_On * 功能描述 : 点亮LED * 参 数 : LED的ID * 返回值 : NONE */ /******************************************************************************/ static void LED_On(uint8_t LedId) /******************************************************************************/ { switch(LedId) { case LED_R: LEDR_ON(); break; case LED_G: LEDG_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_G: LEDG_OFF(); break; case LED_B: LEDB_OFF(); break; default: break; } } /* * 函数名称 : LED_Clr * 功能描述 : 熄灭全部LED * 参 数 : NONE * 返回值 : NONE */ /******************************************************************************/ void LED_Clr(void) /******************************************************************************/ { uint8_t i = 0; for(i=0;i= LED.Flash_Period[i])//LED.Timer[i]表示累加的时间 { LED.Timer[i] = 0; if(LED.Flash_Times[i] > 0) { LED.Flash_Times[i]--; } if(LED.Flash_Times[i] == 0) { LED.State[i] = LED_OFF; } } break; case LED_KEEP_FLASHING: if(LED.Timer[i] <= LED.Flash_Duty[i]) { LED_On(i); } else { LED_Off(i); } if(LED.Timer[i] >= LED.Flash_Period[i]) { LED.Timer[i] = 0; } break; default: LED_Off(i); break; } } for(i=0;i 188) { Num = 188; } Num_Hundred = Num / 100; //百位 Num_Decade = (Num % 100) / 10; //十位 Num_Uint = (Num % 100) % 10; //个位 Set_AllLed_Down(); //消影 nDisplay_Sram = 0; nDisplay_Sram = Segment[0][Num_Hundred] | Segment[1][Num_Decade] | Segment[2][Num_Uint]; //显示百位,十位,个位。 switch(Case_Cnt) { case 0: Display_Scan(0,nDisplay_Sram); Case_Cnt++; break; case 1: Display_Scan(1,nDisplay_Sram); Case_Cnt++; break; case 2: Display_Scan(2,nDisplay_Sram); Case_Cnt++; break; case 3: Display_Scan(3,nDisplay_Sram); Case_Cnt = 0; break; default: Case_Cnt = 0; break; } } #endif