Working read code with mode button

Dependencies:   SDFileSystem emic2 mbed-rtos mbed

Fork of BAT_senior_design_Testnew by BAT

Revision:
30:3c4ebc4fde0f
Parent:
29:b2e53ce54b3e
Child:
31:b9bd85682db1
--- a/main.cpp	Fri Nov 10 16:22:04 2017 +0000
+++ b/main.cpp	Wed Nov 15 16:27:26 2017 +0000
@@ -6,6 +6,7 @@
 #include "buttonArray.h"
 #include <string>
 #include <iostream>
+#include "emic2.h"
 
 using namespace std;
 
@@ -42,6 +43,8 @@
 
 buttonArray buttonarr(button1, button2, button3, button4, button5, button6);
 
+emic2 myTTS(p28, p27); //serial RX,TX pins to emic
+
 // INITIALIZE VARIABLES
 // add mode, reset buttons
 int start = 0;
@@ -244,6 +247,54 @@
         // speaker stuff
         currwrong = wrongpins[i];
     }
+    
+    
+    //TEXT-TO-SPEECH LOGIC
+    myTTS.volume(18); //max volume
+    string repeat = "Please try again.";
+
+    myTTS.speakf("SWelcome to Bat, the Braille 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 < lettersize; i++) {  //iterate through the letter array
+        int* pinsup = buttonarr.pinsUp('M');
+        int currpress;
+        int numpinsups = pinsup[0];  // size of array is first element of pinsup
+        //string presspin;
+        string presspin = "STo write the letter ";
+        presspin = presspin + letter[i];
+        presspin = presspin + ", press pins";
+        pc.printf("numpinsups %d", numpinsups);
+
+        for (int j = 1; j < numpinsups; j++) {  // get what pins to press
+            currpress = pinsup[j];
+            switch (currpress) {
+                case 1:
+                    presspin = presspin + " 1,";
+                    break;
+                case 2:
+                    presspin = presspin + " 2,";
+                    break;
+                case 3:
+                    presspin = presspin + " 3,";
+                    break;
+                case 4:
+                    presspin = presspin + " 4,";
+                    break;
+                case 5:
+                    presspin = presspin + " 5,";
+                    break;
+                case 6:
+                    presspin = presspin + " 6,";
+                    break;
+            }
+
+        }
+        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
+
 
     //pc.printf("current braille %c \n", buttonarr.checkVal());
     //pc.printf("%c\n", buttonarr.releaseButtons());