IDD Fall 2015
/
idd_fall15_hw2_inezraharjo_braille
Based on braile system for blind people.
main.cpp@5:9c64dadda024, 2015-09-13 (annotated)
- Committer:
- inezraharjo
- Date:
- Sun Sep 13 16:21:25 2015 +0000
- Revision:
- 5:9c64dadda024
- Parent:
- 4:4803c429f2f0
braille text entry v4
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 | 5:9c64dadda024 | 28 | capital = 0; |
inezraharjo | 0:c31de740c873 | 29 | while(1) { |
inezraharjo | 0:c31de740c873 | 30 | while (pb && pb2 && pb3 && pb4 && pb5 && pb6){ |
inezraharjo | 5:9c64dadda024 | 31 | if (!one && two && three && four && five && six){ |
inezraharjo | 5:9c64dadda024 | 32 | keyboard.keyCode('a'); |
inezraharjo | 5:9c64dadda024 | 33 | } |
inezraharjo | 5:9c64dadda024 | 34 | if (!one && !two && three && four && five && six){ |
inezraharjo | 5:9c64dadda024 | 35 | keyboard.keyCode('b'); |
inezraharjo | 5:9c64dadda024 | 36 | } |
inezraharjo | 5:9c64dadda024 | 37 | if (!one && two && three && four && five && !six) { |
inezraharjo | 5:9c64dadda024 | 38 | keyboard.keyCode('c'); |
inezraharjo | 5:9c64dadda024 | 39 | } |
inezraharjo | 5:9c64dadda024 | 40 | if (!one && two && three && four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 41 | keyboard.keyCode('d'); |
inezraharjo | 5:9c64dadda024 | 42 | } |
inezraharjo | 5:9c64dadda024 | 43 | if (!one && two && three && four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 44 | keyboard.keyCode('e'); |
inezraharjo | 5:9c64dadda024 | 45 | } |
inezraharjo | 5:9c64dadda024 | 46 | if (!one && !two && three && four && five && !six){ |
inezraharjo | 5:9c64dadda024 | 47 | keyboard.keyCode('f'); |
inezraharjo | 5:9c64dadda024 | 48 | } |
inezraharjo | 5:9c64dadda024 | 49 | if (!one && !two && three && four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 50 | keyboard.keyCode('g'); |
inezraharjo | 5:9c64dadda024 | 51 | } |
inezraharjo | 5:9c64dadda024 | 52 | if (!one && !two && three && four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 53 | keyboard.keyCode('h'); |
inezraharjo | 5:9c64dadda024 | 54 | } |
inezraharjo | 5:9c64dadda024 | 55 | if (one && !two && three && four && five && !six){ |
inezraharjo | 5:9c64dadda024 | 56 | keyboard.keyCode('i'); |
inezraharjo | 5:9c64dadda024 | 57 | } |
inezraharjo | 5:9c64dadda024 | 58 | if (one && !two && three && four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 59 | keyboard.keyCode('j'); |
inezraharjo | 5:9c64dadda024 | 60 | } |
inezraharjo | 5:9c64dadda024 | 61 | if (!one && two && !three && four && five && six){ |
inezraharjo | 5:9c64dadda024 | 62 | keyboard.keyCode('k'); |
inezraharjo | 5:9c64dadda024 | 63 | } |
inezraharjo | 5:9c64dadda024 | 64 | if (!one && !two && !three && four && five && six){ |
inezraharjo | 5:9c64dadda024 | 65 | keyboard.keyCode('l'); |
inezraharjo | 5:9c64dadda024 | 66 | } |
inezraharjo | 5:9c64dadda024 | 67 | if (!one && two && !three && four && five && !six){ |
inezraharjo | 5:9c64dadda024 | 68 | keyboard.keyCode('m'); |
inezraharjo | 5:9c64dadda024 | 69 | } |
inezraharjo | 5:9c64dadda024 | 70 | if (!one && two && !three && four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 71 | keyboard.keyCode('n'); |
inezraharjo | 5:9c64dadda024 | 72 | } |
inezraharjo | 5:9c64dadda024 | 73 | if (!one && two && !three && four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 74 | keyboard.keyCode('o'); |
inezraharjo | 5:9c64dadda024 | 75 | } |
inezraharjo | 5:9c64dadda024 | 76 | if (!one && !two && !three && four && five && !six){ |
inezraharjo | 5:9c64dadda024 | 77 | keyboard.keyCode('p'); |
inezraharjo | 5:9c64dadda024 | 78 | } |
inezraharjo | 5:9c64dadda024 | 79 | if (!one && !two && !three && four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 80 | keyboard.keyCode('q'); |
inezraharjo | 5:9c64dadda024 | 81 | } |
inezraharjo | 5:9c64dadda024 | 82 | if (!one && !two && !three && four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 83 | keyboard.keyCode('r'); |
inezraharjo | 5:9c64dadda024 | 84 | } |
inezraharjo | 5:9c64dadda024 | 85 | if (one && !two && !three && four && five && !six){ |
inezraharjo | 5:9c64dadda024 | 86 | keyboard.keyCode('s'); |
inezraharjo | 5:9c64dadda024 | 87 | } |
inezraharjo | 5:9c64dadda024 | 88 | if (one && !two && !three && four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 89 | keyboard.keyCode('t'); |
inezraharjo | 5:9c64dadda024 | 90 | } |
inezraharjo | 5:9c64dadda024 | 91 | if (!one && two && !three && !four && five && six){ |
inezraharjo | 5:9c64dadda024 | 92 | keyboard.keyCode('u'); |
inezraharjo | 5:9c64dadda024 | 93 | } |
inezraharjo | 5:9c64dadda024 | 94 | if (!one && !two && !three && !four && five && six){ |
inezraharjo | 5:9c64dadda024 | 95 | keyboard.keyCode('v'); |
inezraharjo | 5:9c64dadda024 | 96 | } |
inezraharjo | 5:9c64dadda024 | 97 | if (one && !two && three && !four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 98 | keyboard.keyCode('w'); |
inezraharjo | 5:9c64dadda024 | 99 | } |
inezraharjo | 5:9c64dadda024 | 100 | if (!one && two && !three && !four && five && !six){ |
inezraharjo | 5:9c64dadda024 | 101 | keyboard.keyCode('x'); |
inezraharjo | 5:9c64dadda024 | 102 | } |
inezraharjo | 5:9c64dadda024 | 103 | if (!one && two && !three && !four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 104 | keyboard.keyCode('y'); |
inezraharjo | 5:9c64dadda024 | 105 | } |
inezraharjo | 5:9c64dadda024 | 106 | if (!one && two && !three && !four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 107 | keyboard.keyCode('z'); |
inezraharjo | 5:9c64dadda024 | 108 | } |
inezraharjo | 5:9c64dadda024 | 109 | if (one && !two && !three && !four && five && six){ |
inezraharjo | 5:9c64dadda024 | 110 | keyboard.keyCode('?', KEY_SHIFT); |
inezraharjo | 5:9c64dadda024 | 111 | } |
inezraharjo | 5:9c64dadda024 | 112 | if (one && !two && !three && four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 113 | keyboard.keyCode('!', KEY_SHIFT); |
inezraharjo | 5:9c64dadda024 | 114 | } |
inezraharjo | 5:9c64dadda024 | 115 | if (one && two && !three && !four && !five && !six){ |
inezraharjo | 5:9c64dadda024 | 116 | keyboard.keyCode('3', KEY_SHIFT); |
inezraharjo | 5:9c64dadda024 | 117 | } |
inezraharjo | 5:9c64dadda024 | 118 | if (one && two && !three && !four && five && six){ |
inezraharjo | 5:9c64dadda024 | 119 | keyboard.keyCode(' '); |
inezraharjo | 5:9c64dadda024 | 120 | } |
inezraharjo | 5:9c64dadda024 | 121 | if (one && two && !three && four && five && six){ |
inezraharjo | 5:9c64dadda024 | 122 | keyboard.keyCode('\''); |
inezraharjo | 5:9c64dadda024 | 123 | } |
inezraharjo | 5:9c64dadda024 | 124 | if (one && !two && three && four && five && six){ |
inezraharjo | 5:9c64dadda024 | 125 | keyboard.keyCode(','); |
inezraharjo | 5:9c64dadda024 | 126 | } |
inezraharjo | 5:9c64dadda024 | 127 | if (one && !two && three && !four && !five && six){ |
inezraharjo | 5:9c64dadda024 | 128 | keyboard.keyCode('.'); |
inezraharjo | 5:9c64dadda024 | 129 | } |
inezraharjo | 5:9c64dadda024 | 130 | |
inezraharjo | 5:9c64dadda024 | 131 | |
inezraharjo | 4:4803c429f2f0 | 132 | /* if (one && !two && three && four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 133 | keyboard.keyCode('0'); |
inezraharjo | 1:7c1f8a60c3d4 | 134 | } |
inezraharjo | 1:7c1f8a60c3d4 | 135 | if (!one && two && three && four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 136 | keyboard.keyCode('1'); |
inezraharjo | 1:7c1f8a60c3d4 | 137 | } |
inezraharjo | 1:7c1f8a60c3d4 | 138 | if (!one && !two && three && four && five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 139 | keyboard.keyCode('2'); |
inezraharjo | 1:7c1f8a60c3d4 | 140 | } |
inezraharjo | 1:7c1f8a60c3d4 | 141 | if (!one && two && three && four && five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 142 | keyboard.keyCode('3'); |
inezraharjo | 1:7c1f8a60c3d4 | 143 | } |
inezraharjo | 1:7c1f8a60c3d4 | 144 | if (!one && two && three && four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 145 | keyboard.keyCode('4'); |
inezraharjo | 1:7c1f8a60c3d4 | 146 | } |
inezraharjo | 1:7c1f8a60c3d4 | 147 | if (!one && two && three && four && !five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 148 | keyboard.keyCode('5'); |
inezraharjo | 1:7c1f8a60c3d4 | 149 | } |
inezraharjo | 1:7c1f8a60c3d4 | 150 | if (!one && !two && three && four && five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 151 | keyboard.keyCode('6'); |
inezraharjo | 1:7c1f8a60c3d4 | 152 | } |
inezraharjo | 1:7c1f8a60c3d4 | 153 | if (!one && !two && three && four && !five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 154 | keyboard.keyCode('7'); |
inezraharjo | 1:7c1f8a60c3d4 | 155 | } |
inezraharjo | 1:7c1f8a60c3d4 | 156 | if (!one && !two && three && four && !five && six){ |
inezraharjo | 1:7c1f8a60c3d4 | 157 | keyboard.keyCode('8'); |
inezraharjo | 1:7c1f8a60c3d4 | 158 | } |
inezraharjo | 1:7c1f8a60c3d4 | 159 | if (one && !two && three && four && five && !six){ |
inezraharjo | 1:7c1f8a60c3d4 | 160 | keyboard.keyCode('9'); |
inezraharjo | 4:4803c429f2f0 | 161 | } */ |
inezraharjo | 5:9c64dadda024 | 162 | |
inezraharjo | 0:c31de740c873 | 163 | one = 1; |
inezraharjo | 0:c31de740c873 | 164 | two = 1; |
inezraharjo | 0:c31de740c873 | 165 | three = 1; |
inezraharjo | 0:c31de740c873 | 166 | four = 1; |
inezraharjo | 0:c31de740c873 | 167 | five = 1; |
inezraharjo | 0:c31de740c873 | 168 | six = 1; |
inezraharjo | 0:c31de740c873 | 169 | } |
inezraharjo | 0:c31de740c873 | 170 | wait(0.1); |
inezraharjo | 0:c31de740c873 | 171 | |
inezraharjo | 0:c31de740c873 | 172 | while (!pb || !pb2 || !pb3 || !pb4 || !pb5 || !pb6){ |
inezraharjo | 0:c31de740c873 | 173 | if (!pb){ |
inezraharjo | 0:c31de740c873 | 174 | one=0; |
inezraharjo | 0:c31de740c873 | 175 | } |
inezraharjo | 0:c31de740c873 | 176 | if (!pb2){ |
inezraharjo | 0:c31de740c873 | 177 | two=0; |
inezraharjo | 0:c31de740c873 | 178 | } |
inezraharjo | 0:c31de740c873 | 179 | if (!pb3){ |
inezraharjo | 0:c31de740c873 | 180 | three=0; |
inezraharjo | 0:c31de740c873 | 181 | } |
inezraharjo | 0:c31de740c873 | 182 | if (!pb4){ |
inezraharjo | 0:c31de740c873 | 183 | four=0; |
inezraharjo | 0:c31de740c873 | 184 | } |
inezraharjo | 0:c31de740c873 | 185 | if (!pb5){ |
inezraharjo | 0:c31de740c873 | 186 | five=0; |
inezraharjo | 0:c31de740c873 | 187 | } |
inezraharjo | 0:c31de740c873 | 188 | if (!pb6){ |
inezraharjo | 0:c31de740c873 | 189 | six=0; |
inezraharjo | 0:c31de740c873 | 190 | } |
inezraharjo | 0:c31de740c873 | 191 | |
inezraharjo | 0:c31de740c873 | 192 | } |
inezraharjo | 0:c31de740c873 | 193 | |
inezraharjo | 0:c31de740c873 | 194 | wait(0.1); |
inezraharjo | 0:c31de740c873 | 195 | |
inezraharjo | 0:c31de740c873 | 196 | } |
inezraharjo | 0:c31de740c873 | 197 | } |