📄 display_led.c
字号:
/*
********************************************************************************************************************
*描述: DP-51中LED显示程序文件
*文件名: DISPLAY_LED.C
*应用语言: KEIL C51
*应用系统: RTX51 FULL 5.10
*版本 : V1.0
*作者: 刘养海
*广州周立功单片机发展有限公司 保留所有的版权
********************************************************************************************************************
*/
/*
********************************************************************************************************************
*应用定义
********************************************************************************************************************
*/
#define _GLOBAL_DISPLAY_LED_
/*
********************************************************************************************************************
*引用头文件
********************************************************************************************************************
*/
#include <P8xC5x2.h>
#include <string.h>
#include <intrins.h>
#include "DISPLAY_LED.H"
/*
********************************************************************************************************************
*本文件中使用常量定义
********************************************************************************************************************
*/
#define DispLightFre 200
#define LEDBITCTRL P1
sbit EBIT0 = P1^7; /* LED显示位选:LED0 */
sbit EBIT1 = P1^6; /* LED显示位选:LED1 */
sbit EBIT2 = P1^5; /* LED显示位选:LED2 */
sbit EBIT3 = P1^4; /* LED显示位选:LED3 */
sbit EBIT4 = P1^3; /* LED显示位选:LED4 */
sbit LEDSDA = P1^0; //串行显示数据线
sbit LEDSCL = P1^1; //串行显示时钟线
bit SyncFlight; //同步闪烁控制
unsigned char GlintCounter; //闪烁计数器
/*
********************************************************************************************************************
*本文件中子函数定义
********************************************************************************************************************
*/
void SendDataToShow(unsigned char value)
{
unsigned char i=8;
LEDBITCTRL |= 0x03; //使能显示控制时钟、数据线
while(i--){
value <<=1;
LEDSDA = CY;
LEDSCL =0;
LEDSCL =1;
}
}
/*
********************************************************************************************************************
函数原型: void Show_LED(void)
参数说明: 无
返回值: 无
说明: 该函数用于LED显示处理
********************************************************************************************************************
*/
void Show_LED(void){
if((structDisplayLedApp.DisplayPoint++)>4)
structDisplayLedApp.DisplayPoint=0; //位选
GlintCounter++; //闪烁计数
if(GlintCounter>DispLightFre ){
GlintCounter = 0;
SyncFlight = ~SyncFlight;
}
if(structDisplayLedApp.LedGlintAtbBit0){
structDisplayLedApp.LedImmergeAtbBit0 = SyncFlight;
}
if(structDisplayLedApp.LedGlintAtbBit1){
structDisplayLedApp.LedImmergeAtbBit1 = SyncFlight;
}
if(structDisplayLedApp.LedGlintAtbBit2){
structDisplayLedApp.LedImmergeAtbBit2 = SyncFlight;
}
if(structDisplayLedApp.LedGlintAtbBit3){
structDisplayLedApp.LedImmergeAtbBit3 = SyncFlight;
}
if(structDisplayLedApp.LedGlintAtbBit4){
structDisplayLedApp.LedImmergeAtbBit4 = SyncFlight;
}
SendDataToShow(0xff); //送0xff以消除电影效果
LEDBITCTRL |= 0xF8; //关显示
SendDataToShow(LedSegCode[structDisplayLedApp.DisplayBuf[structDisplayLedApp.DisplayPoint]]);
switch(structDisplayLedApp.DisplayPoint){
case 0:if(!structDisplayLedApp.LedImmergeAtbBit0)
EBIT0=0; //位选0
break;
case 1: //位选1
if(!structDisplayLedApp.LedImmergeAtbBit1)EBIT1=0;
break;
case 2:
if(!structDisplayLedApp.LedImmergeAtbBit2)EBIT2=0; //位选2
break;
case 3:
if(!structDisplayLedApp.LedImmergeAtbBit3)EBIT3=0; //位选3
break;
case 4:
if(!structDisplayLedApp.LedImmergeAtbBit4)EBIT4=0; //位选4
break;
default:structDisplayLedApp.DisplayPoint=0;
structDisplayLedApp.LedImmergeAtbBit0 =0;
structDisplayLedApp.LedImmergeAtbBit1 =0;
structDisplayLedApp.LedImmergeAtbBit2 =0;
structDisplayLedApp.LedImmergeAtbBit3 =0;
structDisplayLedApp.LedImmergeAtbBit4 =0;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -