欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
STC11F02E單鍵控制模式之折騰二
[打印本頁]
作者:
liuda
時間:
2015-1-23 00:54
標題:
STC11F02E單鍵控制模式之折騰二
OMG!這樣操作是不可行的!用長短按太讓人惱火,采用選擇狀態后計時4秒自動切入;
本人一下子進不了狀態,在網上下了個PADS9.3瘋狂安裝,結果還是DEMO版本,又看了會兒片,洗完澡出來看代碼了;
呵呵呵,一下子明白過來了, 洗完衣服,來寫日志,把原先寫的程序又啃了遍,又對了下真值表,把原先打算不要的那部份又修改正確了!呵呵!明天再繼續。。。。。。
其實我也是在論壇上看了很多貼子,有的也是在別人的空間里看到的;相對來說,我就是個流浪漢。。。。。
//#pragma src(signle.a51)
#include <reg52.h>
#include <display.c>
#define uchar unsigned char
#define uint unsigned int
//sfr PCON = 0x87h;
sbit Key1 = P3^2;
sbit BUZ = P3^1;
sbit Signle = P3^0;
sbit Led0 = P1^0;
sbit JDQ = P1^2;
sbit Dp = P1^5;
sbit SMG1 = P3^7;
sbit SMG2 = P3^5;
sbit SMG3 = P3^4;
sbit SMG4 = P3^3;
uint Key_count,Time_value,Time_Count,BTime_Count;
uchar Beep_time,Key_flag,BTime_Flag,JDQ_flag,BP_Count,LM_Count,LM_GroupCNT;
uchar BT_Sec,Sec,Min,Hour,Key_Select,Key_long_flag,Key_long_count;
uchar Led_Scan,Led_Loop,Sec_1,Min_1,Hour_1,BT_Sec_1;
uchar Key_Select_Flag;
//uchar Display_number[]={0xd7,0x14,0xcd,0x5d,0x1e,0x5b,0xdb,0x15,0xdf,0x5f,0x00};
uchar code Display_number[]={0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0,0xff,0xf7}; //0123456789 -
uchar code Display_string[]={0xff,0xff,0xff,0xf7,0xeb,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-1HZ-
uchar code Display_string2[]={0xff,0xff,0xff,0xf7,0x32,0x61,0x32,0xf7,0xff,0xff,0xff,0xff,0xff,0xff};//-2HZ-
uchar Clock[]={0xff,0xff,0xff,0xeb,0x32,0xf7,0xeb,0x32,0xf7,0xeb,0x32,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
//---------------------------------------------------
//---------------------------------------------------
//4COM 共陽數碼管 1234 SR410361K
//---------------------------------------------------
//P1.0 A; |---|
//P1.2 B; | |
//P1.4 C; |---|
//P1.6 D; | |
//P1.7 E; |---|
//P1.1 F;
//P1.3 G;
//P1.5 Dp;
//SMG1=P3.7,SMG2=P3.5,SMG3=P3.4,SMG4=P3.3;
//---------------------------------------------------
//---------------------------------------------------
void display_Scan(void);
void Delay_ms();
void Delay_ms(uint Tms)
{
uint i,j;
for(i=Tms;i>0;i--)
for(j=1220;j>0;j--)
{;}
}
void Delay_us(uint Tus)
{
while(--Tus);
}
void Buz(void)
{
uint i;
for(i=0;i<200;i++)
{
BUZ=~BUZ;
Delay_us(300);
}
BUZ=0;
}
void Beep_Bi(void)
{
if(Beep_time!=0)
{
Beep_time--;
BUZ=~BUZ;
}
else
{
BUZ=0;
}
}
void T0_ini()
{
TMOD=0x12;
TH1=(65536-1000)/256;
TL1=(65536-1000)%256;
TR1=1;
ET1=1;
TH0=6;
TL0=6;
TR0=0;
ET0=1;
EA=1;
}
void TM0(void)interrupt 1
{
//uint Time_Count,BTime_Count;
TF0=0;
Time_Count++;BTime_Count++;BP_Count++;
if(BTime_Count==2000)
{
BTime_Count=0;BT_Sec++;BTime_Flag=~BTime_Flag;
}
if(BP_Count==2) //1ms DiDa Batime;
{
BP_Count=0;
Beep_Bi();
}
if(Key_Select_Flag==1) //1Hz
{
if(Time_Count==2000)
{
Time_Count=0;Dp=~Dp;Signle=~Signle;
}
}
if(Key_Select_Flag==2) //2Hz
{
if(Time_Count==1000)
{
Time_Count=0;Dp=~Dp;Signle=~Signle;
}
}
//if(Time_Count==2000) // ext atxl 12MHz;500ms
//if(Time_Count==1333) // ext atxl 8MHz 500ms;
//if(Time_Count==998) // built in atxl; 500ms
if(BT_Sec==2)
{
BT_Sec=0;
Sec++;
if(Sec==60)
{
Sec=0;Min++;
}
if(Min==60)
{
Min=0;Hour++;
}
if(Hour==24)
{
Hour=0;
}
}
}
void TM1(void)interrupt 3
{
TH1=(65536-1000)/256;
TL1=(65536-1000)%256;
Led_Scan=1;Led_Loop++;Led_Loop=Led_Loop&0x03;
Key1=1;
if(Key1==0)
{
Key_count++;
if(Key_count==20)
{
Beep_time=100;
Key_flag=1;
TR0=1;
Key_Select++;
if(Key_Select==3)
{
Key_Select=0;Key_flag=0;TR0=1;
}
if(Key_Select==1)
{
Key_Select_Flag=1;
}
if(Key_Select==2)
{
Key_Select_Flag=2;
}
}
}
else
{Key_count=0;Key_long_flag=0;Key_Select_Flag=0;}
}
void SmgDisp(uchar ch,uchar num)
{
uchar number;
number=num;
//P3=0x03;
P1=0xff;
SMG1=0;SMG2=0;SMG3=0;SMG4=0;
switch(ch)
{
case 1:SMG4=1;LM_Count=0;break; //SMG排列 1 2 3 4 第四個數碼管
case 2:SMG3=1;LM_Count++;break; //SMG排列 1 2 3 4 第三個數碼管
case 3:SMG2=1;LM_Count++;break; //SMG排列 1 2 3 4 第二個數碼管
case 4:SMG1=1;LM_Count++;break; //SMG排列 1 2 3 4 第一個數碼管
default:break;
}
if((Key_Select==0)&(Key_Select_Flag==1))
{
P1=Display_string[number];
}
if((Key_Select==0)&(Key_Select_Flag==2))
{
P1=Display_string2[number];
}
else
P1=Display_number[number];
}
void CheckTime()
{
if(Led_Scan)
{
switch(Led_Loop)
{
case 0:SmgDisp(4,LM_Count+LM_GroupCNT);break; //第一個數碼管
case 1:SmgDisp(3,LM_Count+LM_GroupCNT);break; //第二個數碼管
case 2:SmgDisp(2,LM_Count+LM_GroupCNT);break; //第三個數碼管
case 3:SmgDisp(1,LM_Count+LM_GroupCNT);break; //第四個數碼管
}
Led_Scan=0;
}
}
void Display(void)
{
if((BTime_Flag)&(Key_Select==2))
{
P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0;
//P3=0x00;
}
else
{
if(BTime_Flag)
{
Dp=0;SMG1=1; //P3=0x80;
Delay_ms(1);SMG1=0; //P3=0x00;
Dp=0;SMG2=1; //P3=0x20;
Delay_ms(1);SMG2=0; //P3=0x00;
}
P1=Display_string[4];
SMG1=1; //P3=0x80;
Delay_ms(1);
SMG1=0; //P3=0x00;
P1=0xff;
P1=Display_string[5];
SMG2=1; //P3=0x20;
Delay_ms(1);
SMG2=0; //P3=0x00;
P1=0xff;
}
if((BTime_Flag)&(Key_Select==1))
{
P1=0xff;SMG1=0;SMG2=0;SMG3=0;SMG4=0; //P3=0x00;
}
else
{
if(BTime_Flag)
{
Dp=0;SMG3=1; //P3=0x10;
Delay_ms(1);SMG3=0; //P3=0x00;
Dp=0;SMG4=1; //P3=0x08;
Delay_ms(1);SMG4=0; //P3=0x00;
}
P1=Display_string2[4];
SMG3=1; //P3=0x10;
Delay_ms(1);
SMG3=0; //P3=0x00;
P1=0xff;
P1=Display_string2[5];
SMG4=1; //P3=0x08;
Delay_ms(1);
SMG4=0; //P3=0x00;
P1=0xff;
}
}
void exint0(void)interrupt 0
{
Buz();T0_ini();EX0=0;EA=1;
}
void Display_Scan(void)
{
P1=0x00;
P3=0x00;
//---------"A"--------------p1.0
//P1=0x01;
P1=0xfe;
P3=0x80; //smg1
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfe;
P3=0x20; //smg2
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfe;
P3=0x10; //smg3
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfe;
P3=0x08; //smg4
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfe;
P3=0x40;
Delay_ms(250);
//---------"B"--------------p1.2
P1=0xfb;
P3=0x80;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfb;
P3=0x20;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfb;
P3=0x10;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfb;
P3=0x08;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfb;
P3=0x40;
Delay_ms(250);
//---------"C"--------------p1.4
//P1=0x10;
P1=0xef;
P3=0x80;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xef;
P3=0x20;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xef;
P3=0x10;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xef;
P3=0x08;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xef;
P3=0x40;
Delay_ms(250);
//---------"D"--------------p1.6
//-----p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0---//
//-------1011 1111-------------------------------//
P1=0xbf;
P3=0x80;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xbf;
P3=0x20;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xbf;
P3=0x10;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xbf;
P3=0x08;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xbf;
P3=0x40;
Delay_ms(250);
//---------"E"--------------p1.7
P1=0x7f;
P3=0x80;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0x7f;
P3=0x20;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0x7f;
P3=0x10;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0x7f;
P3=0x08;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0x7f;
P3=0x40;
Delay_ms(250);
//---------"F"--------------p1.1
P1=0xfd;
P3=0x80;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfd;
P3=0x20;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfd;
P3=0x10;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfd;
P3=0x08;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xfd;
P3=0x40;
Delay_ms(250);
//---------"G"--------------p1.3
P1=0xf7;
P3=0x80;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xf7;
P3=0x20;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xf7;
P3=0x10;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xf7;
P3=0x08;
Delay_ms(5);
P1=0xff;
P3=0x00;
P1=0xf7;
P3=0x40;
//------------------------------
P1=0x00;
P3=0xfc;
Delay_ms(500);
//------------------------------
P1=0x00;
P3=0x80;
Delay_ms(100); //smg1
P1=0x00;
P3=0x20;
Delay_ms(100); //smg2
P1=0x00;
P3=0x10;
Delay_ms(100); //smg3
P1=0x00;
P3=0x08; //smg4
Delay_ms(100);
P1=0x00;
P3=0xfc;
Delay_ms(250);
P1=0xff;
P3=0x00;
Delay_ms(250);
P1=0x00;
P3=0xfc;
Delay_ms(250);
}
void main(void)
{
uint k;
Buz();Display_Scan();
T0_ini();
while(1)
{
///*/-------------按鍵小于2次有分鐘睡眠模式-----------------
if(Hour==4)
{
EX0=1;
EA=1;
Key_flag=0;
Min_1=0;
Hour_1=0;
Signle=1;
TR0=1;
P1=0xff;
PCON=0x02;
}
////--------------------------------------------------------- */
if(Key_Select==0)
{
//for(LM_GroupCNT=0;LM_GroupCNT<13;LM_GroupCNT++)//拉幕時鐘時分秒顯示
for(LM_GroupCNT=0;LM_GroupCNT<10;LM_GroupCNT++)
{
for(k=65500;k>0;k--)
{
CheckTime();
}
}
}
else
Display();
}
}
復制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1