网上下载了一个温度传感器数码管显示的例程,但是有一段完全看不懂,求助(?ò?ó?)
时间:10-02
整理:3721RD
点击:
void dynamic_display(void)
{
static u8 DisPinOn = 0x01;
DisPinOn <<= 1;
if(DisPinOn == 0x10)
{
DisPosition = 0;
DisPinOn = 0x01;
}
P0 = 0xff;
P2 = DisPinOn;
P0 = DisCode[DisNum[DisPosition++]];
if(DisPinOn == 0x04) DIS_DAT &= 0x7f;
}
{
static u8 DisPinOn = 0x01;
DisPinOn <<= 1;
if(DisPinOn == 0x10)
{
DisPosition = 0;
DisPinOn = 0x01;
}
P0 = 0xff;
P2 = DisPinOn;
P0 = DisCode[DisNum[DisPosition++]];
if(DisPinOn == 0x04) DIS_DAT &= 0x7f;
}
void dynamic_display(void)
{
static u8 DisPinOn = 0x01;
DisPinOn <<= 1;
if(DisPinOn == 0x10)
{
DisPosition = 0;
DisPinOn = 0x01;
}
P0 = 0xff;
P2 = DisPinOn;
P0 = DisCode[DisNum[DisPosition++]];
if(DisPinOn == 0x04) DIS_DAT &= 0x7f;
}
P0是資料輸出,P2是掃描線,IO輸出1掃瞄線動作
"static u8 DisPinOn = 0x01;" DisPinOn 設成靜態變量,當成掃描線的臨時變量,所以一開機初始值為1,也就是從P2.0開始掃瞄一直到P2.7.
所以每次呼叫此掃描函式時會跳到下一個掃描線,所以DisPinOn 要左移一位,
DisCode[]就是每一條掃描線的資料