Fixed wait time
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_senior_design_Nhi by
Revision 27:b2e53ce54b3e, committed 2017-11-10
- Comitter:
- aismail1997
- Date:
- Fri Nov 10 16:22:04 2017 +0000
- Parent:
- 23:23970cf718ee
- Child:
- 28:3c4ebc4fde0f
- Commit message:
- added iterators for the arrays
Changed in this revision
--- a/button.cpp Fri Nov 10 15:59:21 2017 +0000
+++ b/button.cpp Fri Nov 10 16:22:04 2017 +0000
@@ -122,3 +122,9 @@
return state;
}
+void button::setup() {
+ for(int i=0; i<=3; i++) {
+ servo = i/100.0;
+ wait(0.01);
+ }
+}
--- a/button.h Fri Nov 10 15:59:21 2017 +0000
+++ b/button.h Fri Nov 10 16:22:04 2017 +0000
@@ -36,6 +36,7 @@
int getState();
int getPress();
int getLp();
+ void setup();
};
#endif
\ No newline at end of file
--- a/buttonArray.cpp Fri Nov 10 15:59:21 2017 +0000
+++ b/buttonArray.cpp Fri Nov 10 16:22:04 2017 +0000
@@ -66,13 +66,15 @@
{
int* pinsup;
char* braille = getBraille(val);
- int j = 0;
+ int j = 1;
for (int i = 0; i < 6; i++) {
if (braille[i] == '0') {
+ j++;
pinsup[j] = i+1;
- j++;
}
}
+ // record size of array in the first element
+ pinsup[0] = j;
return pinsup;
}
@@ -87,10 +89,12 @@
int j = 0;
for (int i = 0; i < 6; i++) {
if(inarr[i] != actarr[i]) {
+ j++;
wrong[j] = i+1;
- j++;
}
}
+ // record size of array in the first element
+ wrong[0] = j;
return wrong;
}
@@ -102,4 +106,41 @@
button1.setState(3);
button1.setPress(0);
}
+ if (button2.getPress()) {
+ button2.moveServoOut();
+ button2.setState(3);
+ button2.setPress(0);
+ }
+ if (button3.getPress()) {
+ button3.moveServoOut();
+ button3.setState(3);
+ button3.setPress(0);
+ }
+ if (button4.getPress()) {
+ button4.moveServoOut();
+ button4.setState(3);
+ button4.setPress(0);
+ }
+ if (button5.getPress()) {
+ button5.moveServoOut();
+ button5.setState(3);
+ button5.setPress(0);
+ }
+ if (button6.getPress()) {
+ button6.moveServoOut();
+ button6.setState(3);
+ button6.setPress(0);
+ }
}
+
+void buttonArray::setup()
+{
+ // servos begin at 30 degrees
+ // replace with a button setup function
+ button1.setup();
+ button2.setup();
+ button3.setup();
+ button4.setup();
+ button5.setup();
+ button6.setup();
+}
\ No newline at end of file
--- a/buttonArray.h Fri Nov 10 15:59:21 2017 +0000
+++ b/buttonArray.h Fri Nov 10 16:22:04 2017 +0000
@@ -25,4 +25,5 @@
void releaseButtons();// release all buttons;
int* pinsUp(char val);
char* getBraille(char val);
+ void setup();
};
\ No newline at end of file
--- a/main.cpp Fri Nov 10 15:59:21 2017 +0000
+++ b/main.cpp Fri Nov 10 16:22:04 2017 +0000
@@ -128,6 +128,7 @@
int main()
{
+
/*
// SETUP
// pull up the pushbutton to prevent bouncing
@@ -137,38 +138,11 @@
pb4.mode(PullUp);
pb5.mode(PullUp);
pb6.mode(PullUp);
- wait(.001);
+ wait(.001); */
// servos begin at 30 degrees
// replace with a button setup function
- for(int i=0; i<=3; i++) {
- myservo = i/100.0;
- wait(0.01);
- }
- for(int i=0; i<=3; i++) {
- myservo2 = i/100.0;
- wait(0.01);
- }
-
- for(int i=0; i<=3; i++) {
- myservo3 = i/100.0;
- wait(0.01);
- }
-
- for(int i=0; i<=3; i++) {
- myservo4 = i/100.0;
- wait(0.01);
- }
-
- for(int i=0; i<=3; i++) {
- myservo5 = i/100.0;
- wait(0.01);
- }
-
- for(int i=0; i<=3; i++) {
- myservo6 = i/100.0;
- wait(0.01);
- }*/
+ buttonarr.setup();
//led1 = 1;
//led2 = 1;
@@ -246,6 +220,7 @@
// check result
// play results on speaker
// save results
+
char currletter;
int lettersize = sizeof(letter)/sizeof(letter[0]);
for (int i = 0; i < lettersize; i++) {
@@ -253,13 +228,23 @@
pc.printf("currletter %c \n", currletter);
pc.printf("braille %s \n", buttonarr.getBraille(currletter));
}
+
int* pinsup = buttonarr.pinsUp('M');
- pc.printf("pins up M: %d \n", pinsup[0]);
- pc.printf("pins up M: %d \n", pinsup[1]);
- pc.printf("pins up M: %d \n", pinsup[2]);
+ int currpress;
+ // get what pins to press
+ for (int i = 1; i <= pinsup[0]; i++) {
+ // speaker stuff
+ currpress = pinsup[i];
+ }
+
int* wrongpins = buttonarr.wrongPins('M', 'O');
- pc.printf("wrong pins M & O %d \n", wrongpins[0]);
- pc.printf("wrong pins M & O %d \n", wrongpins[1]);
+ int currwrong;
+ // get what pins are wrong
+ for (int i = 1; i <= wrongpins[0]; i++) {
+ // speaker stuff
+ currwrong = wrongpins[i];
+ }
+
//pc.printf("current braille %c \n", buttonarr.checkVal());
//pc.printf("%c\n", buttonarr.releaseButtons());
