Plamen Totev
/
keypad_test
keypad
keypad.cpp@0:208c883dc5fa, 2014-03-06 (annotated)
- Committer:
- redplam
- Date:
- Thu Mar 06 02:56:45 2014 +0000
- Revision:
- 0:208c883dc5fa
keypad
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
redplam | 0:208c883dc5fa | 1 | #include "mbed.h" |
redplam | 0:208c883dc5fa | 2 | #define BAUDRATE0 1200 |
redplam | 0:208c883dc5fa | 3 | Serial pc(PTE20,PTE21); |
redplam | 0:208c883dc5fa | 4 | //#include "TextLCD.h" |
redplam | 0:208c883dc5fa | 5 | |
redplam | 0:208c883dc5fa | 6 | BusIn colonne(PTC6,PTC5,PTC4,PTC3,PTC0,PTC7); |
redplam | 0:208c883dc5fa | 7 | BusOut righe(PTA1,PTA2,PTA12,PTA4,PTA5); |
redplam | 0:208c883dc5fa | 8 | //TextLCD lcd(PTE5,PTE4,PTE3,PTE2,PTB11,PTB10); |
redplam | 0:208c883dc5fa | 9 | |
redplam | 0:208c883dc5fa | 10 | char Keypad(void) |
redplam | 0:208c883dc5fa | 11 | { |
redplam | 0:208c883dc5fa | 12 | char key = 100; |
redplam | 0:208c883dc5fa | 13 | // righe.write(31);//11111 |
redplam | 0:208c883dc5fa | 14 | // switch(colonne) { |
redplam | 0:208c883dc5fa | 15 | // case 31: |
redplam | 0:208c883dc5fa | 16 | // key = 1; |
redplam | 0:208c883dc5fa | 17 | // break;//011111 |
redplam | 0:208c883dc5fa | 18 | // case 47: |
redplam | 0:208c883dc5fa | 19 | // key = 2; |
redplam | 0:208c883dc5fa | 20 | // break;//101111 |
redplam | 0:208c883dc5fa | 21 | // case 55: |
redplam | 0:208c883dc5fa | 22 | // key = 3; |
redplam | 0:208c883dc5fa | 23 | // break;//110111 |
redplam | 0:208c883dc5fa | 24 | // case 59: |
redplam | 0:208c883dc5fa | 25 | // key = 4; |
redplam | 0:208c883dc5fa | 26 | // break;//111011 |
redplam | 0:208c883dc5fa | 27 | // case 61: |
redplam | 0:208c883dc5fa | 28 | // key = 5; |
redplam | 0:208c883dc5fa | 29 | // break;//111101 |
redplam | 0:208c883dc5fa | 30 | // case 62: |
redplam | 0:208c883dc5fa | 31 | // key = 6; |
redplam | 0:208c883dc5fa | 32 | // break;//111110 |
redplam | 0:208c883dc5fa | 33 | // } |
redplam | 0:208c883dc5fa | 34 | righe.write(30);//11110 |
redplam | 0:208c883dc5fa | 35 | switch(colonne) { |
redplam | 0:208c883dc5fa | 36 | case 31: |
redplam | 0:208c883dc5fa | 37 | key = 7; |
redplam | 0:208c883dc5fa | 38 | break;//011111 |
redplam | 0:208c883dc5fa | 39 | case 47: |
redplam | 0:208c883dc5fa | 40 | key = 8; |
redplam | 0:208c883dc5fa | 41 | break;//101111 |
redplam | 0:208c883dc5fa | 42 | case 55: |
redplam | 0:208c883dc5fa | 43 | key = 9; |
redplam | 0:208c883dc5fa | 44 | break;//110111 |
redplam | 0:208c883dc5fa | 45 | case 59: |
redplam | 0:208c883dc5fa | 46 | key = 10; |
redplam | 0:208c883dc5fa | 47 | break;//111011 |
redplam | 0:208c883dc5fa | 48 | case 61: |
redplam | 0:208c883dc5fa | 49 | key = 11; |
redplam | 0:208c883dc5fa | 50 | break;//111101 |
redplam | 0:208c883dc5fa | 51 | case 62: |
redplam | 0:208c883dc5fa | 52 | key = 12; |
redplam | 0:208c883dc5fa | 53 | break;//111110 |
redplam | 0:208c883dc5fa | 54 | } |
redplam | 0:208c883dc5fa | 55 | righe.write(29); |
redplam | 0:208c883dc5fa | 56 | switch(colonne) { |
redplam | 0:208c883dc5fa | 57 | case 31: |
redplam | 0:208c883dc5fa | 58 | key = 13; |
redplam | 0:208c883dc5fa | 59 | break;//011111 |
redplam | 0:208c883dc5fa | 60 | case 47: |
redplam | 0:208c883dc5fa | 61 | key = 14; |
redplam | 0:208c883dc5fa | 62 | break;//101111 |
redplam | 0:208c883dc5fa | 63 | case 55: |
redplam | 0:208c883dc5fa | 64 | key = 15; |
redplam | 0:208c883dc5fa | 65 | break;//110111 |
redplam | 0:208c883dc5fa | 66 | case 59: |
redplam | 0:208c883dc5fa | 67 | key = 16; |
redplam | 0:208c883dc5fa | 68 | break;//111011 |
redplam | 0:208c883dc5fa | 69 | case 61: |
redplam | 0:208c883dc5fa | 70 | key = 17; |
redplam | 0:208c883dc5fa | 71 | break;//111101 |
redplam | 0:208c883dc5fa | 72 | case 62: |
redplam | 0:208c883dc5fa | 73 | key = 18; |
redplam | 0:208c883dc5fa | 74 | break;//111110 |
redplam | 0:208c883dc5fa | 75 | } |
redplam | 0:208c883dc5fa | 76 | righe.write(27);//11011 |
redplam | 0:208c883dc5fa | 77 | switch(colonne) { |
redplam | 0:208c883dc5fa | 78 | case 31: |
redplam | 0:208c883dc5fa | 79 | key = 19; |
redplam | 0:208c883dc5fa | 80 | break;//011111 |
redplam | 0:208c883dc5fa | 81 | case 47: |
redplam | 0:208c883dc5fa | 82 | key = 20; |
redplam | 0:208c883dc5fa | 83 | break;//101111 |
redplam | 0:208c883dc5fa | 84 | case 55: |
redplam | 0:208c883dc5fa | 85 | key = 21; |
redplam | 0:208c883dc5fa | 86 | break;//110111 |
redplam | 0:208c883dc5fa | 87 | case 59: |
redplam | 0:208c883dc5fa | 88 | key = 22; |
redplam | 0:208c883dc5fa | 89 | break;//111011 |
redplam | 0:208c883dc5fa | 90 | case 61: |
redplam | 0:208c883dc5fa | 91 | key = 23; |
redplam | 0:208c883dc5fa | 92 | break;//111101 |
redplam | 0:208c883dc5fa | 93 | case 62: |
redplam | 0:208c883dc5fa | 94 | key = 24; |
redplam | 0:208c883dc5fa | 95 | break;//111110 |
redplam | 0:208c883dc5fa | 96 | } |
redplam | 0:208c883dc5fa | 97 | righe.write(23);//10111 |
redplam | 0:208c883dc5fa | 98 | switch(colonne) { |
redplam | 0:208c883dc5fa | 99 | case 31: |
redplam | 0:208c883dc5fa | 100 | key = 25; |
redplam | 0:208c883dc5fa | 101 | break;//011111 |
redplam | 0:208c883dc5fa | 102 | case 47: |
redplam | 0:208c883dc5fa | 103 | key = 26; |
redplam | 0:208c883dc5fa | 104 | break;//101111 |
redplam | 0:208c883dc5fa | 105 | case 55: |
redplam | 0:208c883dc5fa | 106 | key = 27; |
redplam | 0:208c883dc5fa | 107 | break;//110111 |
redplam | 0:208c883dc5fa | 108 | case 59: |
redplam | 0:208c883dc5fa | 109 | key = 28; |
redplam | 0:208c883dc5fa | 110 | break;//111011 |
redplam | 0:208c883dc5fa | 111 | case 61: |
redplam | 0:208c883dc5fa | 112 | key = 29; |
redplam | 0:208c883dc5fa | 113 | break;//111101 |
redplam | 0:208c883dc5fa | 114 | case 62: |
redplam | 0:208c883dc5fa | 115 | key = 30; |
redplam | 0:208c883dc5fa | 116 | break;//111110 |
redplam | 0:208c883dc5fa | 117 | } |
redplam | 0:208c883dc5fa | 118 | righe.write(15);//01111 |
redplam | 0:208c883dc5fa | 119 | switch(colonne) { |
redplam | 0:208c883dc5fa | 120 | case 31: |
redplam | 0:208c883dc5fa | 121 | key = 31; |
redplam | 0:208c883dc5fa | 122 | break;//011111 |
redplam | 0:208c883dc5fa | 123 | case 47: |
redplam | 0:208c883dc5fa | 124 | key = 32; |
redplam | 0:208c883dc5fa | 125 | break;//101111 |
redplam | 0:208c883dc5fa | 126 | case 55: |
redplam | 0:208c883dc5fa | 127 | key = 33; |
redplam | 0:208c883dc5fa | 128 | break;//110111 |
redplam | 0:208c883dc5fa | 129 | case 59: |
redplam | 0:208c883dc5fa | 130 | key = 34; |
redplam | 0:208c883dc5fa | 131 | break;//111011 |
redplam | 0:208c883dc5fa | 132 | case 61: |
redplam | 0:208c883dc5fa | 133 | key = 35; |
redplam | 0:208c883dc5fa | 134 | break;//111101 |
redplam | 0:208c883dc5fa | 135 | case 62: |
redplam | 0:208c883dc5fa | 136 | key = 36; |
redplam | 0:208c883dc5fa | 137 | break;//111110 |
redplam | 0:208c883dc5fa | 138 | } |
redplam | 0:208c883dc5fa | 139 | return key; |
redplam | 0:208c883dc5fa | 140 | } |
redplam | 0:208c883dc5fa | 141 | |
redplam | 0:208c883dc5fa | 142 | int main(void) |
redplam | 0:208c883dc5fa | 143 | { |
redplam | 0:208c883dc5fa | 144 | pc.baud( BAUDRATE0 ); |
redplam | 0:208c883dc5fa | 145 | char key; |
redplam | 0:208c883dc5fa | 146 | // lcd.cls(); |
redplam | 0:208c883dc5fa | 147 | while(1) { |
redplam | 0:208c883dc5fa | 148 | // lcd.cls(); |
redplam | 0:208c883dc5fa | 149 | // key = Keypad(); |
redplam | 0:208c883dc5fa | 150 | pc.printf("k\n"); |
redplam | 0:208c883dc5fa | 151 | // if(key != 100) { |
redplam | 0:208c883dc5fa | 152 | // pc.printf("keypad = %f\n", key); |
redplam | 0:208c883dc5fa | 153 | // |
redplam | 0:208c883dc5fa | 154 | } |
redplam | 0:208c883dc5fa | 155 | // lcd.printf("%c\n\r",&key); |
redplam | 0:208c883dc5fa | 156 | wait(0.2); |
redplam | 0:208c883dc5fa | 157 | } |
redplam | 0:208c883dc5fa | 158 | } |