Words in Typing mode
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Revision 40:85be3490d3a7, committed 2017-12-03
- Comitter:
- aismail1997
- Date:
- Sun Dec 03 23:10:29 2017 +0000
- Parent:
- 39:8cc80f0b4398
- Child:
- 41:560ee7866781
- Commit message:
- Word works!
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Dec 02 23:53:06 2017 +0000
+++ b/main.cpp Sun Dec 03 23:10:29 2017 +0000
@@ -72,6 +72,7 @@
{
while(true) {
state2 = button2.updateState();
+ //state5 = button5.updateState();
Thread::wait(200); // wait till thread is done
}
}
@@ -81,6 +82,7 @@
{
while(true) {
state3 = button3.updateState();
+ //state5 = button4.updateState();
Thread::wait(200); // wait till thread is done
}
}
@@ -103,30 +105,6 @@
}
}
-// thread for the custom button
-void button6_thread()
-{
- while(true) {
- state6 = button6.updateState();
- Thread::wait(200); // wait till thread is done
- }
-}
-
-void submit_thread()
-{
- Thread::wait(500); // wait till thread is done
-}
-
-void start_thread()
-{
- // read pb_start
- // if 1
- start = 1;
- //pc.printf("start %d ", start);
- // else 0
- Thread::wait(500); // wait till thread is done
-}
-
int main()
{
@@ -140,15 +118,6 @@
pb6.mode(PullUp);
wait(.001);
- // servos begin at 30 degrees
- // replace with a button setup function
- //buttonarr.setup();
- //buttonarr.setMode();
-
- //led1 = 1;
- //led2 = 1;
-
-
// PARSE INPUT FILE FOR LETTERS AND WORDS
char delimiter = ',';
// TODO: fix the letters
@@ -166,7 +135,6 @@
while(check != '\n') { //while not at the end of line for letters
if((check == delimiter) && (temp.length() == 1)) { //at a comma and have a letter stored
letter[counter] = temp; //write letter
- //pc.printf("Letter: %s \n", letter[counter]);
counter = counter + 1; //increment counter
} else {
temp = check; //store letter
@@ -178,7 +146,6 @@
while(!feof(fp)) { //while not at the end of line for words
if(check == delimiter) { //when at the comma at the end of a word
word[counter] = tempword; //write word
- //pc.printf("Word: %s \n", word[counter]);
tempword = "";
counter = counter + 1; //increment counter
} else {
@@ -233,6 +200,9 @@
string currword;
int wordsize = sizeof(word)/sizeof(word[0]);
+ //int wordlength;
+ //char* braille;
+ //char* oldbraille;
//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
@@ -241,11 +211,14 @@
// loop through each of the words
for(int i = 0; i < wordsize; i++) { //iterate through the word array
currword = word[i];
+ char currword1[3];
+
string presspin = "To type the word ";
presspin = presspin + word[i];
presspin = presspin + ", type letters ";
for (int j = 0; j < currword.length(); j++) {
presspin = presspin + ", "+ currword[j];
+ currword1[j] = currword[j];
}
myTTS.speakf("S%s\r", presspin);
@@ -257,16 +230,12 @@
// while(!submit)
while (incorrect == 1) {
- //myTTS.speakf("S%s\r", presspin);
- //myTTS.ready();
- char wordinput[currword.length()];
+ char wordinput[3];
// replace for loop with submit
// while (!submit) {
- for (int j = 0; j < currword.length(); j++) {
-
- //currletter = currword[j];
+ for (int j = 0; j < 3; j++) {
// check if all buttons were pressed
char* braille;
@@ -300,14 +269,15 @@
// at the end of this, oldbraille contains the letter representation
//pc.printf("%s ", oldbraille);
userinput = buttonarr.checkVal(oldbraille);
- pc.printf("%c ", userinput);
+ //pc.printf("%c ", userinput);
wordinput[j] = userinput;
}
// check result of words
incorrect = 0;
- for (int k = 0; k < currword.length(); k++) {
- if (currword[k] != wordinput[k]) { // if any letter doesn't match
+ for (int k = 0; k < 3; k++) {
+ //pc.printf("%c %c\n", currword[k], wordinput[k]);
+ if (currword1[k] != wordinput[k]) { // if any letter doesn't match
incorrect = 1; // spelling is wrong
}
}