Letters in typing mode
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_Type_letter by
buttonArray.cpp@21:c5df903f068a, 2017-11-01 (annotated)
- Committer:
- aismail1997
- Date:
- Wed Nov 01 15:22:13 2017 +0000
- Revision:
- 21:c5df903f068a
- Parent:
- 20:abbc12fca525
- Child:
- 22:6931917c70cd
Updated button and buttonarray classes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aismail1997 | 19:ceac47be2e64 | 1 | #include "mbed.h" |
aismail1997 | 19:ceac47be2e64 | 2 | #include "buttonArray.h" |
aismail1997 | 19:ceac47be2e64 | 3 | |
aismail1997 | 20:abbc12fca525 | 4 | // buttonArray constructor |
aismail1997 | 19:ceac47be2e64 | 5 | buttonArray::buttonArray(button b1, button b2, button b3, button b4, button b5, button b6) |
aismail1997 | 19:ceac47be2e64 | 6 | : button1(b1), button2(b2), button3(b3), button4(b4), button5(b5), button6(b6) {} |
aismail1997 | 21:c5df903f068a | 7 | |
aismail1997 | 20:abbc12fca525 | 8 | // FUNCTIONS |
aismail1997 | 19:ceac47be2e64 | 9 | |
aismail1997 | 20:abbc12fca525 | 10 | // map input braille to ascii |
aismail1997 | 21:c5df903f068a | 11 | // braille respresentation here - https://en.wikipedia.org/wiki/Braille_ASCII |
aismail1997 | 21:c5df903f068a | 12 | char buttonArray::checkVal() |
aismail1997 | 21:c5df903f068a | 13 | { |
aismail1997 | 21:c5df903f068a | 14 | char* input; |
aismail1997 | 21:c5df903f068a | 15 | char val = NULL; |
aismail1997 | 21:c5df903f068a | 16 | sprintf(input, "%d%d%d%d%d%d", button1.getPress(), button2.getPress(), |
aismail1997 | 21:c5df903f068a | 17 | button3.getPress(), button4.getPress(), button5.getPress(), button6.getPress()); |
aismail1997 | 21:c5df903f068a | 18 | if (strcmp(input, "000000") == 0) val = NULL; |
aismail1997 | 21:c5df903f068a | 19 | if (strcmp(input, "011111") == 0) val = 'A'; |
aismail1997 | 21:c5df903f068a | 20 | if (strcmp(input, "001101") == 0) val = 'M'; |
aismail1997 | 21:c5df903f068a | 21 | if (strcmp(input, "011001") == 0) val = 'O'; |
aismail1997 | 21:c5df903f068a | 22 | // check if reset |
aismail1997 | 21:c5df903f068a | 23 | if (strcmp(input, "111111") == 0) val = ' '; |
aismail1997 | 21:c5df903f068a | 24 | return val; |
aismail1997 | 21:c5df903f068a | 25 | } |
aismail1997 | 21:c5df903f068a | 26 | |
aismail1997 | 21:c5df903f068a | 27 | // return feedback on which pin to correct |
aismail1997 | 21:c5df903f068a | 28 | |
aismail1997 | 21:c5df903f068a | 29 | |
aismail1997 | 21:c5df903f068a | 30 | // release buttons |
aismail1997 | 21:c5df903f068a | 31 | void buttonArray::releaseButtons() |
aismail1997 | 21:c5df903f068a | 32 | { |
aismail1997 | 21:c5df903f068a | 33 | if (button1.getPress()) { |
aismail1997 | 21:c5df903f068a | 34 | button1.moveServoOut(); |
aismail1997 | 21:c5df903f068a | 35 | button1.setState(3); |
aismail1997 | 21:c5df903f068a | 36 | button1.setPress(0); |
aismail1997 | 21:c5df903f068a | 37 | } |
aismail1997 | 21:c5df903f068a | 38 | } |
aismail1997 | 21:c5df903f068a | 39 | // |
aismail1997 | 21:c5df903f068a | 40 |