Test fork nhi
Dependencies: SDFileSystem mbed-rtos mbed emic2
Fork of BAT_senior_design by
Revision 33:3090ec93b4aa, committed 2017-11-29
- Comitter:
- nnguyen45
- Date:
- Wed Nov 29 00:40:16 2017 +0000
- Parent:
- 32:e87bb6e83072
- Child:
- 34:1248dfa0740b
- Commit message:
- read pin signal working
Changed in this revision
--- a/button.cpp Mon Nov 20 15:46:11 2017 +0000
+++ b/button.cpp Wed Nov 29 00:40:16 2017 +0000
@@ -13,6 +13,7 @@
/*button::button(PwmOut servo, DigitalIn pb, AnalogIn lp)
: servo(servo), pb(pb), linpot(lp), press(0), state(0) {}
*/
+//Serial pc(USBTX, USBRX);
// FUNCTIONS
@@ -53,6 +54,7 @@
int button::getPress()
{
+ //pc.printf("%d", press);
return press;
}
@@ -70,10 +72,11 @@
{
//myled = 1;
// rotate 90 degrees one way
- for(int i=3; i<=7; i++) {
+ for(int i=4; i<=7; i++) {
servo = i/100.0;
wait(0.01);
}
+ //press = 1;
switch (id) {
case 1:
led2 = 0;
@@ -112,7 +115,7 @@
void button::moveServoOut()
{
//myled = 0;
- for(int i=7; i>3; i--) {
+ for(int i=7; i>4; i--) {
servo = i/100.0;
wait(0.01);
}
@@ -160,7 +163,7 @@
}
void button::setup() {
- for(int i=0; i<=3; i++) {
+ for(int i=0; i<=4; i++) {
servo = i/100.0;
wait(0.01);
}
--- a/buttonArray.cpp Mon Nov 20 15:46:11 2017 +0000
+++ b/buttonArray.cpp Wed Nov 29 00:40:16 2017 +0000
@@ -7,7 +7,7 @@
buttonArray::buttonArray(button b1, button b2, button b3, button b4, button b5, button b6)
: button1(b1), button2(b2), button3(b3), button4(b4), button5(b5), button6(b6) {}
-Serial pc(USBTX, USBRX);
+//Serial pc(USBTX, USBRX);
// FUNCTIONS
@@ -15,10 +15,11 @@
// braille respresentation here - https://en.wikipedia.org/wiki/Braille_ASCII
char buttonArray::checkVal()
{
- pc.printf(" checkVal \n");
+ //pc.printf(" checkVal \n");
char* braille;
char val = NULL;
- sprintf(braille, "%d%d%d%d%d%d", button1.getPress(), button2.getPress(),
+ int test = button1.getPress();
+ sprintf(braille, "%d%d%d%d%d%d", test, button2.getPress(),
button3.getPress(), button4.getPress(), button5.getPress(), button6.getPress());
//pc.printf(" %s \n", braille);
if (strcmp(braille, "000000") == 0) val = 'X';
@@ -50,7 +51,7 @@
if (strcmp(braille, "011111") == 0) val = 'Z';*/
// check if reset
if (strcmp(braille, "111111") == 0) val = 'Z';
- pc.printf(" %c \n", val);
+ //pc.printf(" %c \n", val);
return val;
}
@@ -95,7 +96,7 @@
char* inarr = getBraille(input);
//pc.printf("input %s\n", inarr);
char* actarr = getBraille(actual);
- pc.printf("wrong pins");
+ //pc.printf("wrong pins");
int j = 1;
for (int i = 0; i < 6; i++) {
if(inarr[i] == actarr[i]) {
--- a/main.cpp Mon Nov 20 15:46:11 2017 +0000
+++ b/main.cpp Wed Nov 29 00:40:16 2017 +0000
@@ -28,7 +28,7 @@
//DigitalOut led4(LED4);
//DigitalIn linpot(p9);
-//Serial pc(USBTX, USBRX);
+Serial pc(USBTX, USBRX);
SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
//button button1(myservo, pb1, linpot);
button button1(myservo, pb1, 1);
@@ -61,6 +61,8 @@
{
while(true) {
state = button1.updateState();
+ state6 = button6.updateState();
+
//led4 = button1.getLp();
Thread::wait(100); // wait till thread is done
}
@@ -144,18 +146,7 @@
//led1 = 1;
//led2 = 1;
- Thread t1(button_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);
- t3.start(button3_thread);
- t4.start(button4_thread);
- t5.start(button5_thread);
- //t6.start(button6_thread);
+
// PARSE INPUT FILE FOR LETTERS AND WORDS
char delimiter = ',';
@@ -196,6 +187,19 @@
}
fclose(fp); //close file
+ Thread t1(button_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);
+ t3.start(button3_thread);
+ t4.start(button4_thread);
+ t5.start(button5_thread);
+ //t6.start(button6_thread);
+
// start threads for reset, mode, start
//Thread t1(start_thread);
//pc.printf("start thread");
@@ -222,11 +226,11 @@
char currletter;
int lettersize = sizeof(letter)/sizeof(letter[0]);
- for (int i = 0; i < lettersize; i++) {
+ /*for (int i = 0; i < lettersize; i++) {
currletter = letter[i][0];
//pc.printf("currletter %c \n", currletter);
//pc.printf("braille %s \n", buttonarr.getBraille(currletter));
- }
+ }*/
/*int* pinsup = buttonarr.pinsUp('M');
int currpress;
@@ -244,6 +248,7 @@
currwrong = wrongpins[i];
}*/
+
//TEXT-TO-SPEECH LOGIC
myTTS.volume(18); //max volume
myTTS.voice(2);
@@ -291,6 +296,8 @@
//WORKS UP TO HERE
char userinput = buttonarr.checkVal();
+ int test1 = button1.getPress();
+ pc.printf(" %d\n", test1);
//pc.printf("userinput: %c", userinput);
// get input
//pc.printf("Your input was: %c", userinput);
