Words in Typing mode

Dependencies:   SDFileSystem emic2 mbed-rtos mbed

Fork of BAT_Type_word by Azra Ismail

Files at this revision

API Documentation at this revision

Comitter:
nnguyen45
Date:
Mon Nov 20 15:46:11 2017 +0000
Parent:
31:e5024aeca3a7
Child:
33:3090ec93b4aa
Commit message:
code demo to Dr. Howard

Changed in this revision

button.cpp Show annotated file Show diff for this revision Revisions of this file
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
plan.txt Show diff for this revision Revisions of this file
wave_player.lib Show diff for this revision Revisions of this file
--- a/button.cpp	Fri Nov 17 16:24:33 2017 +0000
+++ b/button.cpp	Mon Nov 20 15:46:11 2017 +0000
@@ -3,7 +3,9 @@
 #include "emic2.h"
 
 //emic2 myTTS(p28, p27); //serial RX,TX pins to emic
-//DigitalOut led4(LED4);
+DigitalOut led4(LED4);
+DigitalOut led3(LED3);
+DigitalOut led2(LED2);
 
 // button constructor
 button::button(PwmOut servo, DigitalIn pb, int id)
@@ -72,6 +74,38 @@
         servo = i/100.0;
         wait(0.01);
     }
+    switch (id) {
+        case 1:
+            led2 = 0;
+            led3 = 0;
+            led4 = 1;
+            break;
+        case 2:
+            led2 = 0;
+            led3 = 1;
+            led4 = 0;
+            break;
+        case 3:
+            led2 = 0;
+            led3 = 1;
+            led4 = 1;
+            break;
+        case 4:
+            led2 = 1;
+            led3 = 0;
+            led4 = 0;
+            break;
+        case 5:
+            led2 = 1;
+            led3 = 0;
+            led4 = 1;
+            break;
+        case 6:
+            led2 = 1;
+            led3 = 1;
+            led4 = 0;
+            break;
+    }
 }
 
 // move servo out of the slot
@@ -82,6 +116,9 @@
         servo = i/100.0;
         wait(0.01);
     }
+    led2 = 0;
+    led3 = 0;
+    led4 = 0;
 }
 
 int button::updateState()
--- a/buttonArray.cpp	Fri Nov 17 16:24:33 2017 +0000
+++ b/buttonArray.cpp	Mon Nov 20 15:46:11 2017 +0000
@@ -72,7 +72,7 @@
 int* buttonArray::pinsUp(char val)
 {
     int* pinsup;
-    pinsup = new int[7];
+    //pinsup = new int[7];
     char* braille = getBraille(val);
     int j = 1;
     for (int i = 0; i < 6; i++) {
--- a/main.cpp	Fri Nov 17 16:24:33 2017 +0000
+++ b/main.cpp	Mon Nov 20 15:46:11 2017 +0000
@@ -1,6 +1,5 @@
 #include "mbed.h"
 #include "rtos.h"
-#include "wave_player.h"
 #include "SDFileSystem.h"
 #include "button.h"
 #include "buttonArray.h"
@@ -28,11 +27,9 @@
 //DigitalOut led3(LED3);
 //DigitalOut led4(LED4);
 
-DigitalIn linpot(p9);
+//DigitalIn linpot(p9);
 //Serial pc(USBTX, USBRX);
 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
-//AnalogOut DACout(p26);
-//wave_player waver(&DACout);
 //button button1(myservo, pb1, linpot);
 button button1(myservo, pb1, 1);
 button button2(myservo2, pb2, 2);
@@ -73,7 +70,7 @@
 {
     while(true) {
         state2 = button2.updateState();
-        Thread::wait(100); // wait till thread is done
+        Thread::wait(200); // wait till thread is done
     }
 }
 
@@ -82,7 +79,7 @@
 {
     while(true) {
         state3 = button3.updateState();
-        Thread::wait(100); // wait till thread is done
+        Thread::wait(200); // wait till thread is done
     }
 }
 
@@ -91,7 +88,7 @@
 {
     while(true) {
         state4 = button4.updateState();
-        Thread::wait(100); // wait till thread is done
+        Thread::wait(200); // wait till thread is done
     }
 }
 
@@ -100,7 +97,7 @@
 {
     while(true) {
         state5 = button5.updateState();
-        Thread::wait(100); // wait till thread is done
+        Thread::wait(200); // wait till thread is done
     }
 }
 
@@ -109,7 +106,7 @@
 {
     while(true) {
         state6 = button6.updateState();
-        Thread::wait(100); // wait till thread is done
+        Thread::wait(200); // wait till thread is done
     }
 }
 
@@ -131,8 +128,6 @@
 
 int main()
 {
-
-
     // SETUP
     // pull up the pushbutton to prevent bouncing
     pb1.mode(PullUp);
@@ -145,18 +140,18 @@
 
     // servos begin at 30 degrees
     // replace with a button setup function
-    //buttonarr.setup();
+    buttonarr.setup();
 
     //led1 = 1;
     //led2 = 1;
     Thread t1(button_thread);
-    //Thread t2(button2_thread);
+    Thread t2(button2_thread);
     Thread t3(button3_thread);
     Thread t4(button4_thread);
     Thread t5(button5_thread);
     //Thread t6(button6_thread);
     t1.start(button_thread);
-    //t2.start(button2_thread);
+    t2.start(button2_thread);
     t3.start(button3_thread);
     t4.start(button4_thread);
     t5.start(button5_thread);
@@ -294,8 +289,6 @@
         wait(1);
         //pc.printf("hello");
 
-
-
         //WORKS UP TO HERE
         char userinput = buttonarr.checkVal();
         //pc.printf("userinput: %c", userinput);
@@ -370,7 +363,7 @@
     //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
 
-
+    //buttonarr.releaseButtons();
     //pc.printf("current braille %c \n", buttonarr.checkVal());
     //pc.printf("%c\n", buttonarr.releaseButtons());
 
--- a/plan.txt	Fri Nov 17 16:24:33 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-M,O,
-Mom,
\ No newline at end of file
--- a/wave_player.lib	Fri Nov 17 16:24:33 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/sravet/code/wave_player/#acc3e18e77ad