危機處理作業-密碼鎖
1. Ascii_Table.C 新增
2.LCD_Driver.C 新增函式
3.主程式
/*black_block*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
,
/*white_block*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
,
/*key(K)*/
0x1C,0xF4,0x84,0xF4,0x14,0x74,0x44,0x74
,
/*key(L)*/
0x14,0x34,0x42,0x99,0xA5,0x99,0x42,0x3C
,
/*fish(F)*/
0x38,0x44,0x82,0x81,0x89,0x81,0x81,0x81
,
/*fish(G)*/
0x81,0x81,0x42,0x24,0x18,0x24,0x42,0xFF
,
/*bigX(E)*/
0x81,0x42,0x24,0x18,0x18,0x24,0x42,0x81
,
2.LCD_Driver.C 新增函式
void Show_graph(unsigned char x, unsigned char y,unsigned char ascii_word){
int i=0,k=0;
unsigned char temp;
//k=(ascii_word-32)*16;
if(ascii_word==70){ //ascii_word49==>F "fish"
k=1552;
}
else if(ascii_word==71){ //ascii_word49==>G
k=1560;
}
else if(ascii_word==75){ //ascii_word49==>K "KEY"
k=1536;
}
else if(ascii_word==76){ //ascii_word49==>L
k=1544;
}
else if(ascii_word==69){ //ascii_word69==>E "X"
k=1568;
}
else{
k=1528;
}
for(i=0;i<8;i++){
SetPACA(x,(129-(y*8)-i));
temp=Ascii[k+i];
WriteData(temp);
}
}
void print_graph(unsigned char line, char *str)
{
int i=0;
do{
Show_graph(line,i,*str++);
i++;
if(i>15)
break;
}
while(*str!='\0');
}
3.主程式
case 6:
print_lcd(1,"8247"); //line1
print_graph(0, key); //line0
print_lcd(2, input); //line2
//Control the number shows on LCD using keypad
while(1) {
i=Scankey();
DrvSYS_Delay(180000);
if(i!=0)break;
}
//record the value of "i"
if(i!=0){
d=c; c=b; b=a; a=i;
}
//change the "*" to the input vlaue
if(i!=0){
if(tmp==1){
sprintf(input,"%d***", a);
print_lcd(2, input);
tmp++;
break;
}
if(tmp==2){
sprintf(input,"%d%d**", b, a);
print_lcd(2, input);
tmp++;
break;
}
if(tmp==3){
sprintf(input,"%d%d%d*", c, b, a);
print_lcd(2, input);
tmp++;
break;
}
if(tmp==4){
sprintf(input,"%d%d%d%d", d, c, b, a);
print_lcd(2, input);
tmp++;
//change image of the key
if(d==8&&c==2&&b==4&&a==7){
sprintf(key,"FG");
}
else{
sprintf(key,"E ");
}
break;
留言
張貼留言