IDD Fall 2015
/
idd_fall15_hw2_inezraharjo_braille
Based on braile system for blind people.
main.cpp@3:e61ba28a98aa, 2015-09-13 (annotated)
- Committer:
- inezraharjo
- Date:
- Sun Sep 13 07:23:57 2015 +0000
- Revision:
- 3:e61ba28a98aa
- Parent:
- 2:ce1a6c9ed015
- Child:
- 4:4803c429f2f0
braille text entry v3.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
inezraharjo | 0:c31de740c873 | 1 | #include "mbed.h" |
inezraharjo | 0:c31de740c873 | 2 | #include <math.h> |
inezraharjo | 0:c31de740c873 | 3 | #include "USBKeyboard.h" |
inezraharjo | 0:c31de740c873 | 4 | |
inezraharjo | 0:c31de740c873 | 5 | //USBKeyboard |
inezraharjo | 0:c31de740c873 | 6 | USBKeyboard keyboard; |
inezraharjo | 0:c31de740c873 | 7 | |
inezraharjo | 0:c31de740c873 | 8 | //DigitalOut myled(LED1); |
inezraharjo | 0:c31de740c873 | 9 | //DigitalOut led2(LED2); |
inezraharjo | 0:c31de740c873 | 10 | //DigitalOut led3(LED3); |
inezraharjo | 0:c31de740c873 | 11 | DigitalIn pb(D2); |
inezraharjo | 0:c31de740c873 | 12 | DigitalIn pb2(D4); |
inezraharjo | 0:c31de740c873 | 13 | DigitalIn pb3(D8); |
inezraharjo | 0:c31de740c873 | 14 | DigitalIn pb4(D11); |
inezraharjo | 0:c31de740c873 | 15 | DigitalIn pb5(D14); |
inezraharjo | 0:c31de740c873 | 16 | DigitalIn pb6(D15); |
inezraharjo | 2:ce1a6c9ed015 | 17 | int one, two, three, four, five, six, capital; |
inezraharjo | 0:c31de740c873 | 18 | // SPST Pushbutton demo using internal PullUp function |
inezraharjo | 0:c31de740c873 | 19 | // no external PullUp resistor needed |
inezraharjo | 0:c31de740c873 | 20 | // Pushbutton from P8 to GND. |
inezraharjo | 0:c31de740c873 | 21 | int main() { |
inezraharjo | 0:c31de740c873 | 22 | pb.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 23 | pb2.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 24 | pb3.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 25 | pb4.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 26 | pb5.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 27 | pb6.mode(PullUp); |
inezraharjo | 0:c31de740c873 | 28 | while(1) { |
inezraharjo | 0:c31de740c873 | 29 | while (pb && pb2 && pb3 && pb4 && pb5 && pb6){ |
inezraharjo | 0:c31de740c873 | 30 | if (!one && two && three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 31 | keyboard.keyCode('a'); |
inezraharjo | 0:c31de740c873 | 32 | } |
inezraharjo | 0:c31de740c873 | 33 | if (!one && !two && three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 34 | keyboard.keyCode('b'); |
inezraharjo | 0:c31de740c873 | 35 | } |
inezraharjo | 0:c31de740c873 | 36 | if (!one && two && three && four && five && !six) { |
inezraharjo | 0:c31de740c873 | 37 | keyboard.keyCode('c'); |
inezraharjo | 0:c31de740c873 | 38 | } |
inezraharjo | 0:c31de740c873 | 39 | if (!one && two && three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 40 | keyboard.keyCode('d'); |
inezraharjo | 0:c31de740c873 | 41 | } |
inezraharjo | 0:c31de740c873 | 42 | if (!one && two && three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 43 | keyboard.keyCode('e'); |
inezraharjo | 0:c31de740c873 | 44 | } |
inezraharjo | 0:c31de740c873 | 45 | if (!one && !two && three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 46 | keyboard.keyCode('f'); |
inezraharjo | 0:c31de740c873 | 47 | } |
inezraharjo | 0:c31de740c873 | 48 | if (!one && !two && three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 49 | keyboard.keyCode('g'); |
inezraharjo | 0:c31de740c873 | 50 | } |
inezraharjo | 0:c31de740c873 | 51 | if (!one && !two && three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 52 | keyboard.keyCode('h'); |
inezraharjo | 0:c31de740c873 | 53 | } |
inezraharjo | 0:c31de740c873 | 54 | if (one && !two && three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 55 | keyboard.keyCode('i'); |
inezraharjo | 0:c31de740c873 | 56 | } |
inezraharjo | 0:c31de740c873 | 57 | if (one && !two && three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 58 | keyboard.keyCode('j'); |
inezraharjo | 0:c31de740c873 | 59 | } |
inezraharjo | 0:c31de740c873 | 60 | if (!one && two && !three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 61 | keyboard.keyCode('k'); |
inezraharjo | 0:c31de740c873 | 62 | } |
inezraharjo | 0:c31de740c873 | 63 | if (!one && !two && !three && four && five && six){ |
inezraharjo | 0:c31de740c873 | 64 | keyboard.keyCode('l'); |
inezraharjo | 0:c31de740c873 | 65 | } |
inezraharjo | 0:c31de740c873 | 66 | if (!one && two && !three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 67 | keyboard.keyCode('m'); |
inezraharjo | 0:c31de740c873 | 68 | } |
inezraharjo | 0:c31de740c873 | 69 | if (!one && two && !three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 70 | keyboard.keyCode('n'); |
inezraharjo | 0:c31de740c873 | 71 | } |
inezraharjo | 0:c31de740c873 | 72 | if (!one && two && !three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 73 | keyboard.keyCode('o'); |
inezraharjo | 0:c31de740c873 | 74 | } |
inezraharjo | 0:c31de740c873 | 75 | if (!one && !two && !three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 76 | keyboard.keyCode('p'); |
inezraharjo | 0:c31de740c873 | 77 | } |
inezraharjo | 0:c31de740c873 | 78 | if (!one && !two && !three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 79 | keyboard.keyCode('q'); |
inezraharjo | 0:c31de740c873 | 80 | } |
inezraharjo | 0:c31de740c873 | 81 | if (!one && !two && !three && four && !five && six){ |
inezraharjo | 0:c31de740c873 | 82 | keyboard.keyCode('r'); |
inezraharjo | 0:c31de740c873 | 83 | } |
inezraharjo | 0:c31de740c873 | 84 | if (one && !two && !three && four && five && !six){ |
inezraharjo | 0:c31de740c873 | 85 | keyboard.keyCode('s'); |
inezraharjo | 0:c31de740c873 | 86 | } |
inezraharjo | 0:c31de740c873 | 87 | if (one && !two && !three && four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 88 | keyboard.keyCode('t'); |
inezraharjo | 0:c31de740c873 | 89 | } |
inezraharjo | 0:c31de740c873 | 90 | if (!one && two && !three && !four && five && six){ |
inezraharjo | 0:c31de740c873 | 91 | keyboard.keyCode('u'); |
inezraharjo | 0:c31de740c873 | 92 | } |
inezraharjo | 0:c31de740c873 | 93 | if (!one && !two && !three && !four && five && six){ |
inezraharjo | 0:c31de740c873 | 94 | keyboard.keyCode('v'); |
inezraharjo | 0:c31de740c873 | 95 | } |
inezraharjo | 0:c31de740c873 | 96 | if (one && !two && three && !four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 97 | keyboard.keyCode('w'); |
inezraharjo | 0:c31de740c873 | 98 | } |
inezraharjo | 0:c31de740c873 | 99 | if (!one && two && !three && !four && five && !six){ |
inezraharjo | 0:c31de740c873 | 100 | keyboard.keyCode('x'); |
inezraharjo | 0:c31de740c873 | 101 | } |
inezraharjo | 0:c31de740c873 | 102 | if (!one && two && !three && !four && !five && !six){ |
inezraharjo | 0:c31de740c873 | 103 | keyboard.keyCode('y'); |
inezraharjo | 0:c31de740c873 | 104 | } |
inezraharjo | 0:c31de740c873 | 105 | if (!one && two && !three && !four && !five && six){ |
inezraharjo | 0:c31de740c873 | 106 | keyboard.keyCode('z'); |
inezraharjo | 0:c31de740c873 | 107 | } |
inezraharjo | 0:c31de740c873 | 108 | if (one && two && !three && !four && five && six){ |
inezraharjo | 0:c31de740c873 | 109 | keyboard.keyCode(' '); |
inezraharjo | 0:c31de740c873 | 110 | } |
inezraharjo | 1:7c1f8a60c3d4 | 111 | if (one && !two && !three && !four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 112 | keyboard.keyCode('?'); |
inezraharjo | 1:7c1f8a60c3d4 | 113 | } |
inezraharjo | 1:7c1f8a60c3d4 | 114 | if (one && !two && !three && four && !five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 115 | keyboard.keyCode('!'); |
inezraharjo | 1:7c1f8a60c3d4 | 116 | } |
inezraharjo | 1:7c1f8a60c3d4 | 117 | if (one && two && !three && four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 118 | keyboard.keyCode('\''); |
inezraharjo | 1:7c1f8a60c3d4 | 119 | } |
inezraharjo | 3:e61ba28a98aa | 120 | if (one && !two && three && four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 121 | keyboard.keyCode(','); |
inezraharjo | 1:7c1f8a60c3d4 | 122 | } |
inezraharjo | 1:7c1f8a60c3d4 | 123 | if (one && !two && three && !four && !five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 124 | keyboard.keyCode('.'); |
inezraharjo | 1:7c1f8a60c3d4 | 125 | } |
inezraharjo | 1:7c1f8a60c3d4 | 126 | if (one && two && !three && !four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 127 | keyboard.keyCode('#'); |
inezraharjo | 1:7c1f8a60c3d4 | 128 | } |
inezraharjo | 1:7c1f8a60c3d4 | 129 | if (one && !two && three && four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 130 | keyboard.keyCode('0'); |
inezraharjo | 1:7c1f8a60c3d4 | 131 | } |
inezraharjo | 1:7c1f8a60c3d4 | 132 | if (!one && two && three && four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 133 | keyboard.keyCode('1'); |
inezraharjo | 1:7c1f8a60c3d4 | 134 | } |
inezraharjo | 1:7c1f8a60c3d4 | 135 | if (!one && !two && three && four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 136 | keyboard.keyCode('2'); |
inezraharjo | 1:7c1f8a60c3d4 | 137 | } |
inezraharjo | 1:7c1f8a60c3d4 | 138 | if (!one && two && three && four && five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 139 | keyboard.keyCode('3'); |
inezraharjo | 1:7c1f8a60c3d4 | 140 | } |
inezraharjo | 1:7c1f8a60c3d4 | 141 | if (!one && two && three && four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 142 | keyboard.keyCode('4'); |
inezraharjo | 1:7c1f8a60c3d4 | 143 | } |
inezraharjo | 1:7c1f8a60c3d4 | 144 | if (!one && two && three && four && !five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 145 | keyboard.keyCode('5'); |
inezraharjo | 1:7c1f8a60c3d4 | 146 | } |
inezraharjo | 1:7c1f8a60c3d4 | 147 | if (!one && !two && three && four && five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 148 | keyboard.keyCode('6'); |
inezraharjo | 1:7c1f8a60c3d4 | 149 | } |
inezraharjo | 1:7c1f8a60c3d4 | 150 | if (!one && !two && three && four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 151 | keyboard.keyCode('7'); |
inezraharjo | 1:7c1f8a60c3d4 | 152 | } |
inezraharjo | 1:7c1f8a60c3d4 | 153 | if (!one && !two && three && four && !five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 154 | keyboard.keyCode('8'); |
inezraharjo | 1:7c1f8a60c3d4 | 155 | } |
inezraharjo | 1:7c1f8a60c3d4 | 156 | if (one && !two && three && four && five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 157 | keyboard.keyCode('9'); |
inezraharjo | 1:7c1f8a60c3d4 | 158 | } |
inezraharjo | 2:ce1a6c9ed015 | 159 | if (one && two && three && four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 160 | capital = 1; |
inezraharjo | 2:ce1a6c9ed015 | 161 | } |
inezraharjo | 2:ce1a6c9ed015 | 162 | if (capital){ |
inezraharjo | 2:ce1a6c9ed015 | 163 | capital = 0; |
inezraharjo | 2:ce1a6c9ed015 | 164 | if (!one && two && three && four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 165 | keyboard.keyCode('A'); |
inezraharjo | 2:ce1a6c9ed015 | 166 | } |
inezraharjo | 2:ce1a6c9ed015 | 167 | if (!one && !two && three && four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 168 | keyboard.keyCode('B'); |
inezraharjo | 2:ce1a6c9ed015 | 169 | } |
inezraharjo | 2:ce1a6c9ed015 | 170 | if (!one && two && three && four && five && !six) { |
inezraharjo | 2:ce1a6c9ed015 | 171 | keyboard.keyCode('C'); |
inezraharjo | 2:ce1a6c9ed015 | 172 | } |
inezraharjo | 2:ce1a6c9ed015 | 173 | if (!one && two && three && four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 174 | keyboard.keyCode('D'); |
inezraharjo | 2:ce1a6c9ed015 | 175 | } |
inezraharjo | 2:ce1a6c9ed015 | 176 | if (!one && two && three && four && !five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 177 | keyboard.keyCode('E'); |
inezraharjo | 2:ce1a6c9ed015 | 178 | } |
inezraharjo | 2:ce1a6c9ed015 | 179 | if (!one && !two && three && four && five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 180 | keyboard.keyCode('F'); |
inezraharjo | 2:ce1a6c9ed015 | 181 | } |
inezraharjo | 2:ce1a6c9ed015 | 182 | if (!one && !two && three && four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 183 | keyboard.keyCode('G'); |
inezraharjo | 2:ce1a6c9ed015 | 184 | } |
inezraharjo | 2:ce1a6c9ed015 | 185 | if (!one && !two && three && four && !five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 186 | keyboard.keyCode('H'); |
inezraharjo | 2:ce1a6c9ed015 | 187 | } |
inezraharjo | 2:ce1a6c9ed015 | 188 | if (one && !two && three && four && five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 189 | keyboard.keyCode('I'); |
inezraharjo | 2:ce1a6c9ed015 | 190 | } |
inezraharjo | 2:ce1a6c9ed015 | 191 | if (one && !two && three && four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 192 | keyboard.keyCode('J'); |
inezraharjo | 2:ce1a6c9ed015 | 193 | } |
inezraharjo | 2:ce1a6c9ed015 | 194 | if (!one && two && !three && four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 195 | keyboard.keyCode('K'); |
inezraharjo | 2:ce1a6c9ed015 | 196 | } |
inezraharjo | 2:ce1a6c9ed015 | 197 | if (!one && !two && !three && four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 198 | keyboard.keyCode('L'); |
inezraharjo | 2:ce1a6c9ed015 | 199 | } |
inezraharjo | 2:ce1a6c9ed015 | 200 | if (!one && two && !three && four && five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 201 | keyboard.keyCode('M'); |
inezraharjo | 2:ce1a6c9ed015 | 202 | } |
inezraharjo | 2:ce1a6c9ed015 | 203 | if (!one && two && !three && four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 204 | keyboard.keyCode('N'); |
inezraharjo | 2:ce1a6c9ed015 | 205 | } |
inezraharjo | 2:ce1a6c9ed015 | 206 | if (!one && two && !three && four && !five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 207 | keyboard.keyCode('O'); |
inezraharjo | 2:ce1a6c9ed015 | 208 | } |
inezraharjo | 2:ce1a6c9ed015 | 209 | if (!one && !two && !three && four && five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 210 | keyboard.keyCode('P'); |
inezraharjo | 2:ce1a6c9ed015 | 211 | } |
inezraharjo | 2:ce1a6c9ed015 | 212 | if (!one && !two && !three && four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 213 | keyboard.keyCode('Q'); |
inezraharjo | 2:ce1a6c9ed015 | 214 | } |
inezraharjo | 2:ce1a6c9ed015 | 215 | if (!one && !two && !three && four && !five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 216 | keyboard.keyCode('R'); |
inezraharjo | 2:ce1a6c9ed015 | 217 | } |
inezraharjo | 2:ce1a6c9ed015 | 218 | if (one && !two && !three && four && five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 219 | keyboard.keyCode('S'); |
inezraharjo | 2:ce1a6c9ed015 | 220 | } |
inezraharjo | 2:ce1a6c9ed015 | 221 | if (one && !two && !three && four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 222 | keyboard.keyCode('T'); |
inezraharjo | 2:ce1a6c9ed015 | 223 | } |
inezraharjo | 2:ce1a6c9ed015 | 224 | if (!one && two && !three && !four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 225 | keyboard.keyCode('U'); |
inezraharjo | 2:ce1a6c9ed015 | 226 | } |
inezraharjo | 2:ce1a6c9ed015 | 227 | if (!one && !two && !three && !four && five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 228 | keyboard.keyCode('V'); |
inezraharjo | 2:ce1a6c9ed015 | 229 | } |
inezraharjo | 2:ce1a6c9ed015 | 230 | if (one && !two && three && !four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 231 | keyboard.keyCode('W'); |
inezraharjo | 2:ce1a6c9ed015 | 232 | } |
inezraharjo | 2:ce1a6c9ed015 | 233 | if (!one && two && !three && !four && five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 234 | keyboard.keyCode('X'); |
inezraharjo | 2:ce1a6c9ed015 | 235 | } |
inezraharjo | 2:ce1a6c9ed015 | 236 | if (!one && two && !three && !four && !five && !six){ |
inezraharjo | 2:ce1a6c9ed015 | 237 | keyboard.keyCode('Y'); |
inezraharjo | 2:ce1a6c9ed015 | 238 | } |
inezraharjo | 2:ce1a6c9ed015 | 239 | if (!one && two && !three && !four && !five && six){ |
inezraharjo | 2:ce1a6c9ed015 | 240 | keyboard.keyCode('Z'); |
inezraharjo | 2:ce1a6c9ed015 | 241 | } |
inezraharjo | 2:ce1a6c9ed015 | 242 | } |
inezraharjo | 0:c31de740c873 | 243 | one = 1; |
inezraharjo | 0:c31de740c873 | 244 | two = 1; |
inezraharjo | 0:c31de740c873 | 245 | three = 1; |
inezraharjo | 0:c31de740c873 | 246 | four = 1; |
inezraharjo | 0:c31de740c873 | 247 | five = 1; |
inezraharjo | 0:c31de740c873 | 248 | six = 1; |
inezraharjo | 0:c31de740c873 | 249 | } |
inezraharjo | 0:c31de740c873 | 250 | wait(0.1); |
inezraharjo | 0:c31de740c873 | 251 | |
inezraharjo | 0:c31de740c873 | 252 | while (!pb || !pb2 || !pb3 || !pb4 || !pb5 || !pb6){ |
inezraharjo | 0:c31de740c873 | 253 | if (!pb){ |
inezraharjo | 0:c31de740c873 | 254 | one=0; |
inezraharjo | 0:c31de740c873 | 255 | } |
inezraharjo | 0:c31de740c873 | 256 | if (!pb2){ |
inezraharjo | 0:c31de740c873 | 257 | two=0; |
inezraharjo | 0:c31de740c873 | 258 | } |
inezraharjo | 0:c31de740c873 | 259 | if (!pb3){ |
inezraharjo | 0:c31de740c873 | 260 | three=0; |
inezraharjo | 0:c31de740c873 | 261 | } |
inezraharjo | 0:c31de740c873 | 262 | if (!pb4){ |
inezraharjo | 0:c31de740c873 | 263 | four=0; |
inezraharjo | 0:c31de740c873 | 264 | } |
inezraharjo | 0:c31de740c873 | 265 | if (!pb5){ |
inezraharjo | 0:c31de740c873 | 266 | five=0; |
inezraharjo | 0:c31de740c873 | 267 | } |
inezraharjo | 0:c31de740c873 | 268 | if (!pb6){ |
inezraharjo | 0:c31de740c873 | 269 | six=0; |
inezraharjo | 0:c31de740c873 | 270 | } |
inezraharjo | 0:c31de740c873 | 271 | |
inezraharjo | 0:c31de740c873 | 272 | } |
inezraharjo | 0:c31de740c873 | 273 | |
inezraharjo | 0:c31de740c873 | 274 | wait(0.1); |
inezraharjo | 0:c31de740c873 | 275 | |
inezraharjo | 0:c31de740c873 | 276 | } |
inezraharjo | 0:c31de740c873 | 277 | } |