|
樓主 |
發表於 2011-11-8 01:37:32
|
顯示全部樓層
unsigned char code DspBNKU[8][10]={
{0x3b,0x12,0x35,0x36,0x1e,0x2e,0x2f,0x32,0x3f,0x3e},//dig1
{0x3b,0x12,0x35,0x36,0x1e,0x2e,0x2f,0x32,0x3f,0x3e},//dig2
{0x0e,0x04,0x0d,0x0d,0x07,0x0b,0x0b,0x0c,0x0f,0x0f},//dig3
{0x0e,0x04,0x0d,0x0d,0x07,0x0b,0x0b,0x0c,0x0f,0x0f},//dig4
{0x03,0x01,0x03,0x03,0x01,0x02,0x02,0x03,0x03,0x03},//dig5
{0x03,0x01,0x03,0x03,0x01,0x02,0x02,0x03,0x03,0x03},//dig6
{0xdc,0x48,0xac,0xb4,0x70,0x74,0x7c,0x90,0xfc,0xf4},//dig7
{0xdc,0x48,0xac,0xb4,0x70,0x74,0x7c,0x90,0xfc,0xf4}//dig8
};//要改成8字10變化(0~9)
unsigned char code DspBNKD[8][10]={
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//dig1-2-19560602 n0.1byt
{0xc0,0x00,0x80,0x80,0x00,0x80,0x80,0x00,0x80,0x80},//dig2-0-19560602 no.0byt
{0xc0,0x80,0x40,0x50,0x00,0x50,0xc0,0x80,0xc0,0xc0},//dig3-6-19560602 n0.4byt
{0xc0,0x80,0x40,0x50,0x00,0x50,0xc0,0x80,0xc0,0xc0},//dig4-0-19560602 no.3byt
{0x70,0x40,0x30,0x50,0xc0,0xd0,0xf0,0x40,0xf0,0xd0},//dig5-6-19560602 no.6byt
{0x70,0x40,0x30,0x50,0xc0,0xd0,0xf0,0x40,0xf0,0xd0},//dig6-5-19560602 no.5byt
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},//dig7-9-19560602 no.8byt
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}//dig8-1- 19560602 no.7byt
};
void Display_Data_Operation(void)// write data to display buffer需要上下兩部分;
{
disbuf[7]=time_buf1[2]/10; //月
disbuf[6]=time_buf1[2]%10;
disbuf[5]=time_buf1[3]/10;//日
disbuf[4]=time_buf1[3]%10;
disbuf[3]=time_buf1[4]/10;//时
disbuf[2]=time_buf1[4]%10;
disbuf[1]=time_buf1[5]/10; //分
disbuf[0]=time_buf1[5]%10;
Disaddr[1]=DspBNKU[0][disbuf[0]];//dig0-
Disaddr[0]=DspBNKD[1][disbuf[1]];//dig0D
Disaddr[0]|=DspBNKU[1][disbuf[1]];//dig1-
//Disaddr[0]=DspBNKU[1][disbuf[1]];//
Disaddr[3]=DspBNKU[2][disbuf[2]];//dig2-
Disaddr[2]=DspBNKD[2][disbuf[2]];//dig2D
Disaddr[2]|=DspBNKU[3][disbuf[3]];//dig3-
Disaddr[1]|=DspBNKD[3][disbuf[3]];//dig3D
Disaddr[5]=DspBNKU[4][disbuf[4]];//dig4-
Disaddr[4]=DspBNKD[4][disbuf[4]];//dig4D
Disaddr[4]|=DspBNKU[5][disbuf[5]];//dig5-
Disaddr[3]|=DspBNKD[5][disbuf[5]];//dig5D
Disaddr[6]=DspBNKU[6][disbuf[6]];//dig6 byte5--
// Disaddr[5]=DspBNKU[5][disbuf[5]];
Disaddr[5]|=DspBNKU[7][disbuf[7]];//dig7 byte6-
....
void main (void)
{
unsigned char num;
Init_Timer0();
Ds1302_Init();
PT6312_Init();
cmd1=0x01;// 指令1 5 dig 16 segment
cmd2=0x40 ;//指令 2 資料設定參數,續增位址
Dat_flag=1;//增加資料時不會把STB變回HI 脈沖
cmd3=0xc0 ;//指令 3 位址內資料寫入start addr 00h
cmd4=0x89 ;//指令 4 顯示輸出以及亮度調整
//Ds1302_Write_Time();//不能加否則每次斷電時間就須重設
while (1) //主循环
{
num=KeyPro();
switch(num)
{
case 7:time_buf1[4]++;if(time_buf1[4]==24)time_buf1[4]=0;
Ds1302_Write_Time();break; //正常时间 小时 加1
case 14:time_buf1[4]--;if(time_buf1[4]==255)time_buf1[4]=23;
Ds1302_Write_Time();break; //正常时间 小时减1
case 4:time_buf1[5]++;if(time_buf1[5]==60)time_buf1[5]=0;
Ds1302_Write_Time();break;//分加1
case 1:time_buf1[5]--;if(time_buf1[5]==255)time_buf1[5]=59;
Ds1302_Write_Time();break; //分减1
default:break;
}
if(ReadTimeFlag==1)//每隔200ms時間要讀出 & 顯示
{
q++;
Disaddr[7]=q;
Disaddr[8]=q;
ReadTimeFlag=0;
Ds1302_Read_Time();
Display_Data_Operation();//---Display(VFD)
//数据的转换,因我们采用数码管0~9的显示,将数据分开
}
Disupdate();
}
}
|
|