| ??? 04/01/03 10:42 Read: times |
#42684 - small keypad algorithim require |
Take a look on this bulky code which returns the key which has been pressed on the key pad of 4*4 key matrix otherwise if no key is pressed then it returns 100. now it is taking a hell of space. can some body let me any algorithem which is small but does the same thing. give me a hint and i will program it my self or give me a program that will be best obviously. Shahzad int switchPressed(void) { for(temp=1;temp<=4;temp++) { sw1 = 1; sw2 = 1; sw3 = 1; //P3 = 28; P1 = P1 & 0xF0; if(temp == 1) { P1 = P1 | 0x0E; } else if(temp == 2) { P1 = P1 | 0x0D; } else if(temp == 3) { P1 = P1 | 0x0B; } else if(temp == 4) { P1 = P1 | 0x07; } if(sw1 == 0) { Simple_Delay_Fifty_Milliseconds(); if(sw1 == 0) { //while(sw1==0); if(temp == 1) return 1; else if(temp == 2) return 4; else if(temp == 3) return 7; else if(temp == 4) return 10; } } if(sw2 == 0) { Simple_Delay_Fifty_Milliseconds(); if(sw2 == 0) { //while(sw2==0); if(temp == 1) return 2; else if(temp == 2) return 5; else if(temp == 3) return 8; else if(temp == 4) return 0; } } if(sw3 == 0) { Simple_Delay_Fifty_Milliseconds(); if(sw3 == 0) { //while(sw3==0); if(temp == 1) return 3; else if(temp == 2) return 6; else if(temp == 3) return 9; else if(temp == 4) return 12; } } } return 100; } |
| Topic | Author | Date |
| small keypad algorithim require | 01/01/70 00:00 | |
| RE: small keypad algorithim require | 01/01/70 00:00 | |
RE: small keypad algorithim require | 01/01/70 00:00 |



