Words in Typing mode
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_Type_word by
Revision 43:fa8d0db68228, committed 2017-12-05
- Comitter:
- nnguyen45
- Date:
- Tue Dec 05 03:34:17 2017 +0000
- Parent:
- 42:aa46c2be7dbb
- Commit message:
- working type word with mode button but with inconsistent submit button
Changed in this revision
buttonArray.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r aa46c2be7dbb -r fa8d0db68228 buttonArray.cpp --- a/buttonArray.cpp Mon Dec 04 19:40:28 2017 +0000 +++ b/buttonArray.cpp Tue Dec 05 03:34:17 2017 +0000 @@ -18,31 +18,31 @@ char val = 'K'; if (strcmp(braille, "000000") == 0) val = 'X'; if (strcmp(braille, "011111") == 0) val = 'A'; - //if (strcmp(braille, "001111") == 0) val = 'B'; - //if (strcmp(braille, "011011") == 0) val = 'C'; + if (strcmp(braille, "001111") == 0) val = 'B'; + if (strcmp(braille, "011011") == 0) val = 'C'; if (strcmp(braille, "011001") == 0) val = 'D'; - //if (strcmp(braille, "011101") == 0) val = 'E'; - //if (strcmp(braille, "001011") == 0) val = 'F'; - //if (strcmp(braille, "001001") == 0) val = 'G'; - //if (strcmp(braille, "001101") == 0) val = 'H'; - //if (strcmp(braille, "101101") == 0) val = 'I'; - //if (strcmp(braille, "101001") == 0) val = 'J'; - if (strcmp(braille, "010011") == 0) val = 'M'; - if (strcmp(braille, "010101") == 0) val = 'O'; + /*if (strcmp(braille, "011101") == 0) val = 'E'; + if (strcmp(braille, "001011") == 0) val = 'F'; + if (strcmp(braille, "001001") == 0) val = 'G'; + 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, "011111") == 0) val = 'L'; - if (strcmp(braille, "011111") == 0) val = 'N'; - if (strcmp(braille, "011111") == 0) val = 'P'; - if (strcmp(braille, "011111") == 0) val = 'Q'; - if (strcmp(braille, "011111") == 0) val = 'R'; - if (strcmp(braille, "011111") == 0) val = 'S'; - if (strcmp(braille, "011111") == 0) val = 'T'; - if (strcmp(braille, "011111") == 0) val = 'U'; - if (strcmp(braille, "011111") == 0) val = 'V'; - if (strcmp(braille, "011111") == 0) val = 'W'; - if (strcmp(braille, "011111") == 0) val = 'X'; - if (strcmp(braille, "011111") == 0) val = 'Y'; - if (strcmp(braille, "011111") == 0) val = 'Z';*/ + 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, "000001") == 0) val = 'Q'; + if (strcmp(braille, "000101") == 0) val = 'R'; + if (strcmp(braille, "100011") == 0) val = 'S'; + if (strcmp(braille, "100001") == 0) val = 'T'; + 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, "010000") == 0) val = 'Y'; + if (strcmp(braille, "010100") == 0) val = 'Z';*/ // check if reset if (strcmp(braille, "111111") == 0) val = 'Z'; //pc.printf(" %c \n", val); @@ -53,13 +53,32 @@ char* buttonArray::getBraille(char val) { char* braille; - if (val == 'A') braille = "100000"; - if (val == 'D') braille = "100110"; - if (val == 'X') braille = "000000"; - if (val == 'Z') braille = "111111"; + if (val == 'A') braille = "011111"; + if (val == 'B') braille = "001111"; + if (val == 'C') braille = "011011"; + if (val == 'D') braille = "011001"; + if (val == 'E') braille = "011101"; + if (val == 'F') braille = "001011"; + if (val == 'G') braille = "001001"; + if (val == 'H') braille = "001101"; + if (val == 'I') braille = "101011"; + if (val == 'J') braille = "101001"; + 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 == 'K') braille = "100000"; + /*if (val == 'P') braille = "000011"; + if (val == 'Q') braille = "000001"; + if (val == 'R') braille = "000101"; + if (val == 'S') braille = "100011"; + if (val == 'T') braille = "100001"; + if (val == 'U') braille = "010110"; + if (val == 'V') braille = "000110"; + if (val == 'W') braille = "101000"; + if (val == 'X') braille = "010010"; + if (val == 'Y') braille = "010000"; + if (val == 'Z') braille = "010100";*/ // check if reset if (val == ' ') braille = "111111"; return braille;
diff -r aa46c2be7dbb -r fa8d0db68228 main.cpp --- a/main.cpp Mon Dec 04 19:40:28 2017 +0000 +++ b/main.cpp Tue Dec 05 03:34:17 2017 +0000 @@ -22,6 +22,9 @@ DigitalIn pb5 (p16); PwmOut myservo6(p26); DigitalIn pb6 (p15); +DigitalIn read (p29); +DigitalIn submit (p30); + //DigitalOut led1(LED1); //DigitalOut led3(LED3); @@ -44,8 +47,6 @@ // INITIALIZE VARIABLES // add mode, reset buttons -int start = 0; -int submit = 0; // Buttons begins in up state int state = 0; int state2 = 0; @@ -116,6 +117,8 @@ pb4.mode(PullUp); pb5.mode(PullUp); pb6.mode(PullUp); + read.mode(PullUp); + submit.mode(PullUp); wait(.001); // PARSE INPUT FILE FOR LETTERS AND WORDS @@ -173,7 +176,7 @@ //int type = 0; //TEXT-TO-SPEECH LOGIC - myTTS.volume(3); //max volume is 18 + myTTS.volume(18); //max volume is 18 myTTS.voice(2); @@ -201,13 +204,15 @@ string currword; int wordsize = sizeof(word)/sizeof(word[0]); - + //myTTS.speakf("SLet us now put these letters together to form words. Please reset buttons after each letter. Press down the submit button when done.\r"); // Send the desired string to convert to speech - myTTS.speakf("SPlease switch the device into typing mode. Press down the submit button when done.\r"); // Send the desired string to convert to speech + myTTS.speakf("SPlease switch the device into typing mode. After each word, press the submit button.\r"); // Send the desired string to convert to speech myTTS.ready(); //ready waits for speech to finish from last command with a ":" response + while(read==1) {} // loop through each of the words for(int i = 0; i < wordsize; i++) { //iterate through the word array + //int i = 0; currword = word[i]; char currword1[3]; @@ -232,24 +237,33 @@ char wordinput[3]; // replace for loop with submit // while (!submit) { - - for (int j = 0; j < 3; j++) { + int j = 0; + int mysubmit = 0; + while(submit==0) { + //for (int j = 0; j <= 3; j++) { // check if all buttons were pressed char* braille; char* oldbraille; - wait(1); + wait(0.5); sprintf(braille, "%d%d%d%d%d%d", !button1.getPress(), !button2.getPress(), !button3.getPress(), !button4.getPress(), !button5.getPress(), !button6.getPress()); //pc.printf("test %s ", braille); // wait for input - while (strcmp(braille, "111111") == 0) { + while ((strcmp(braille, "111111") == 0) && (submit==0)) { sprintf(braille, "%d%d%d%d%d%d", !button1.getPress(), !button2.getPress(), !button3.getPress(), !button4.getPress(), !button5.getPress(), !button6.getPress()); } + if(submit==1) { + pc.printf("submit\n"); + break; + //mysubmit = 1; + } /*else { + pc.printf("submit button not pressed\n"); + }*/ // while buttons have not been released int oldsum = 0; @@ -265,10 +279,17 @@ // at the end of this, oldbraille contains the letter representation //pc.printf("%s ", oldbraille); + //if(mysubmit==0) { userinput = buttonarr.checkVal(oldbraille); - //pc.printf("%c ", userinput); + pc.printf("%c ", userinput); + //wordinput[j] = userinput; + //if(j <= 2) { wordinput[j] = userinput; + //} + j++; + //} } + //pc.printf("submit button pressed\n"); // check result of words incorrect = 0; @@ -291,7 +312,9 @@ } } } - + myTTS.speakf("SThis is the end of the module.\r"); // Send the desired string to convert to speech + myTTS.ready(); //ready waits for speech to finish from last command with a ":" response + // MAIN THREAD while(true) {