?? display_led.c
字號:
/*
********************************************************************************************************************
*描述: DP-51中LED顯示程序文件
*文件名: DISPLAY_LED.C
*應(yīng)用語言: KEIL C51
*應(yīng)用系統(tǒng): RTX51 FULL 5.10
*版本 : V1.0
*作者: 劉養(yǎng)海
*廣州周立功單片機發(fā)展有限公司 保留所有的版權(quán)
********************************************************************************************************************
*/
/*
********************************************************************************************************************
*應(yīng)用定義
********************************************************************************************************************
*/
#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; //串行顯示數(shù)據(jù)線
sbit LEDSCL = P1^1; //串行顯示時鐘線
bit SyncFlight; //同步閃爍控制
unsigned char GlintCounter; //閃爍計數(shù)器
/*
********************************************************************************************************************
*本文件中子函數(shù)定義
********************************************************************************************************************
*/
void SendDataToShow(unsigned char value)
{
unsigned char i=8;
LEDBITCTRL |= 0x03; //使能顯示控制時鐘、數(shù)據(jù)線
while(i--){
value <<=1;
LEDSDA = CY;
LEDSCL =0;
LEDSCL =1;
}
}
/*
********************************************************************************************************************
函數(shù)原型: void Show_LED(void)
參數(shù)說明: 無
返回值: 無
說明: 該函數(shù)用于LED顯示處理
********************************************************************************************************************
*/
void Show_LED(void){
if((structDisplayLedApp.DisplayPoint++)>4)
structDisplayLedApp.DisplayPoint=0; //位選
GlintCounter++; //閃爍計數(shù)
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; //關(guān)顯示
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;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -