#include"type.h"BETY_BIT status;//code P_scanf_data_led_7[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};code N_scanf_data_led_7[16] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};unsigned char scanf_data[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d};//顯存void Delay_ms(unsigned char z)//延時程序1ms{unsigned char x;while(--z){x= 10;while(--x);}}void Scanf_Display(unsigned char *dat){unsigned char x;for(x=0;x<6;x++) {PORT_DATA=dat[x];PORT_SCANF=~(0x01<矩陣鍵盤掃描部分**************************************************/char proces_data(unsigned char num){switch(num){case 1:num=1; break;case 2:num=2; break;case 4:num=3; break;case 8:num=4; break;default:num=0; break;}return num;}unsigned char Scanf_Key(void){unsigned char H=0,L=0,port_temp,key_value;KEY_COM=0xf0;KEY_DOWN = 0;key_value = 0xff;if(KEY_COM!=0xf0){Delay_ms(100);if(KEY_COM!=0xf0){KEY_DOWN = 1;port_temp = KEY_COM;H=(~port_temp)>>4;KEY_COM=0x0f;Delay_ms(10);port_temp = KEY_COM;L=(~port_temp)&0x0f; key_value=((proces_data(H)-1)<<2)+proces_data(L);}}return (key_value-1);}main(){unsigned char temp;while(1){temp=Scanf_Key();if(KEY_DOWN){scanf_data[0]=N_scanf_data_led_7[temp];scanf_data[1]=N_scanf_data_led_7[temp];scanf_data[2]=N_scanf_data_led_7[temp];scanf_data[3]=N_scanf_data_led_7[temp];scanf_data[4]=N_scanf_data_led_7[temp];scanf_data[5]=N_scanf_data_led_7[temp];}Scanf_Display(scanf_data);}}
評論