Working read code with mode button
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_senior_design_Testnew by
Diff: buttonArray.cpp
- Revision:
- 43:82d67fb53e61
- Parent:
- 42:44a898adef26
--- a/buttonArray.cpp Mon Dec 04 23:25:38 2017 +0000 +++ b/buttonArray.cpp Tue Dec 05 03:31:58 2017 +0000 @@ -1,17 +1,27 @@ #include "mbed.h" #include "buttonArray.h" +// type mode + // buttonArray constructor buttonArray::buttonArray(button b1, button b2, button b3, button b4, button b5, button b6) : button1(b1), button2(b2), button3(b3), button4(b4), button5(b5), button6(b6) {} +//Serial pc(USBTX, USBRX); + // FUNCTIONS // map input braille to ascii // braille respresentation here - https://en.wikipedia.org/wiki/Braille_ASCII char buttonArray::checkVal(char* braille) { + //pc.printf(" checkVal \n"); + //char* braille; char val = 'K'; + /*int test = button1.getPress(); + sprintf(braille, "%d%d%d%d%d%d", test, button2.getPress(), + button3.getPress(), button4.getPress(), button5.getPress(), button6.getPress());*/ + //pc.printf(" %s \n", braille); if (strcmp(braille, "000000") == 0) val = 'X'; if (strcmp(braille, "011111") == 0) val = 'A'; if (strcmp(braille, "001111") == 0) val = 'B'; @@ -23,12 +33,12 @@ if (strcmp(braille, "001101") == 0) val = 'H'; if (strcmp(braille, "101011") == 0) val = 'I'; if (strcmp(braille, "101001") == 0) val = 'J'; - //if (strcmp(braille, "011111") == 0) val = 'K'; - if (strcmp(braille, "000111") == 0) val = 'L'; + /*if (strcmp(braille, "011111") == 0) val = 'K'; + if (strcmp(braille, "000111") == 0) val = 'L';*/ if (strcmp(braille, "010011") == 0) val = 'M'; if (strcmp(braille, "010001") == 0) val = 'N'; if (strcmp(braille, "010101") == 0) val = 'O'; - if (strcmp(braille, "000011") == 0) val = 'P'; + /*if (strcmp(braille, "000011") == 0) val = 'P'; if (strcmp(braille, "000001") == 0) val = 'Q'; if (strcmp(braille, "000101") == 0) val = 'R'; if (strcmp(braille, "100011") == 0) val = 'S'; @@ -36,11 +46,12 @@ if (strcmp(braille, "010110") == 0) val = 'U'; if (strcmp(braille, "000110") == 0) val = 'V'; if (strcmp(braille, "101000") == 0) val = 'W'; - //if (strcmp(braille, "010010") == 0) val = 'X'; + if (strcmp(braille, "010010") == 0) val = 'X'; if (strcmp(braille, "010000") == 0) val = 'Y'; - //if (strcmp(braille, "010100") == 0) val = 'Z'; + if (strcmp(braille, "010100") == 0) val = 'Z';*/ // check if reset if (strcmp(braille, "111111") == 0) val = 'Z'; + //pc.printf(" %c \n", val); return val; } @@ -58,12 +69,12 @@ if (val == 'H') braille = "001101"; if (val == 'I') braille = "101011"; if (val == 'J') braille = "101001"; - //if (val == 'K') braille = "010111"; - if (val == 'L') braille = "000111"; + /*if (val == 'K') braille = "011111"; + if (val == 'L') braille = "000111";*/ if (val == 'M') braille = "010011"; if (val == 'N') braille = "010001"; if (val == 'O') braille = "010101"; - if (val == 'P') braille = "000011"; + /*if (val == 'P') braille = "000011"; if (val == 'Q') braille = "000001"; if (val == 'R') braille = "000101"; if (val == 'S') braille = "100011"; @@ -71,9 +82,9 @@ if (val == 'U') braille = "010110"; if (val == 'V') braille = "000110"; if (val == 'W') braille = "101000"; - //if (val == 'X') braille = "010010"; + if (val == 'X') braille = "010010"; if (val == 'Y') braille = "010000"; - //if (val == 'Z') braille = "010100"; + if (val == 'Z') braille = "010100";*/ // check if reset if (val == ' ') braille = "111111"; return braille; @@ -83,6 +94,7 @@ int* buttonArray::pinsUp(char val) { int* pinsup; + //pinsup = new int[7]; char* braille = getBraille(val); int j = 1; for (int i = 0; i < 6; i++) { @@ -100,13 +112,16 @@ // takes in current and actual char as input and returns status of each char int* buttonArray::wrongPins(char* inarr, char actual) { + // TODO check initial value of wrong int* wrong; wrong = new int[7]; char* actarr = getBraille(actual); + //pc.printf("wrong pins"); int j = 1; for (int i = 0; i < 6; i++) { if(inarr[i] != actarr[i]) { wrong[j] = i+1; + //pc.printf("%d ", wrong[j]); j++; } } @@ -152,7 +167,8 @@ void buttonArray::setup() { - // servo setup function; servos begin at 30 degrees + // servos begin at 30 degrees + // replace with a button setup function button1.setup(); button2.setup(); button3.setup();