Fixed wait time
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_senior_design_Nhi by
Revision 24:4b2940eec275, committed 2017-11-10
- Comitter:
- nnguyen45
- Date:
- Fri Nov 10 16:48:26 2017 +0000
- Parent:
- 23:23970cf718ee
- Child:
- 25:0ed2a9cad0e1
- Commit message:
- text to speech logic with errors
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 10 15:59:21 2017 +0000
+++ b/main.cpp Fri Nov 10 16:48:26 2017 +0000
@@ -6,6 +6,7 @@
#include "buttonArray.h"
#include <string>
#include <iostream>
+#include "emic2.h"
using namespace std;
@@ -30,6 +31,8 @@
DigitalIn linpot(p9);
Serial pc(USBTX, USBRX);
SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+emic2 myTTS(p28, p27); //serial RX,TX pins to emic
+
//AnalogOut DACout(p26);
//wave_player waver(&DACout);
//button button1(myservo, pb1, linpot);
@@ -263,12 +266,67 @@
//pc.printf("current braille %c \n", buttonarr.checkVal());
//pc.printf("%c\n", buttonarr.releaseButtons());
- // MAIN THREAD
- while(true) {
+
+ //TEXT-TO-SPEECH LOGIC
+ myTTS.volume(18); //max volume
+ string repeat = "Please try again.";
+
+ myTTS.speakf("SWelcome to Bat, the Blind Assistive Teacher. This device will help you learn how to write and type braille.\r"); // Send the desired string to convert to speech
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+ for(int i = 0; i < letter.length(); i++) { //iterate through the letter array
+ int* pinsup = buttonarr.pinsUp('M');
+ int currpress;
+ int numpinsups = pinsup[0];
+ string presspin = "STo write the letter %s, press pins ";
+ sprintf(presspin, letter[i]):
+
+ for (int i = 1; i <= numpinsups; i++) { // get what pins to press
+ currpress = pinsup[i];
+ presspin = presspin + to_string(currpress) + " ";
+
+ }
+ myTTS.speakf("S%s\r",presspin);
+
+ }
+ myTTS.speakf("STo write the letter %s, press pins %D\r",letter[i]);
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
- // read linear potentiometer
- //led4 = linpot;
+ //check pins pressed
+ if(incorrect) {
+ myTTS.speakf("SPin %D is incoorect.\r",ID);
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+ myTTS.speakf("S%s.\r", repeat);
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+ }
+}
+for(int i = 0; i < word.length(); i++) //iterate through the word array
+{
+ myTTS.speakf("SWrite the word %s, press pins %D\r",word[i], ID);
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+ //check pins pressed
+ if(incorrect) {
+ myTTS.speakf("SPin %D is incoorect.\r",ID);
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+ myTTS.speakf("S%s.\r", repeat);
+ myTTS.ready(); //ready waits for speech to finish from last command with a ":" response
+ }
+}
- Thread::wait(500); // wait till thread is done
- }
+
+
+
+
+
+
+
+
+// MAIN THREAD
+while(true)
+{
+
+ // read linear potentiometer
+ //led4 = linpot;
+
+ Thread::wait(500); // wait till thread is done
+}
}
\ No newline at end of file
