Fork of original senior design repo
Dependencies: SDFileSystem mbed-rtos mbed wave_player emic2
Fork of BAT_senior_design by
Revision 12:b80dde24e9bc, committed 2017-10-18
- Comitter:
- aismail1997
- Date:
- Wed Oct 18 14:41:04 2017 +0000
- Parent:
- 11:b302c71e300f
- Child:
- 13:581a3b02f4c3
- Commit message:
- added comments
Changed in this revision
--- a/button.cpp Wed Oct 18 14:06:19 2017 +0000
+++ b/button.cpp Wed Oct 18 14:41:04 2017 +0000
@@ -1,20 +1,25 @@
#include "mbed.h"
#include "button.h"
+// button constructor
button::button(PwmOut servo, DigitalIn pb)
: servo(servo), pb(pb) {}
// FUNCTIONS
+
+// get servo pin
PwmOut button::getServoPin()
{
return servo;
}
-int button::getState()
+// get current state of the button
+/*int button::getState()
{
return state;
-}
+}*/
+// move servo into the slot
void button::moveServoIn()
{
//myled = 1;
@@ -25,6 +30,7 @@
}
}
+// move servo out of the slot
void button::moveServoOut()
{
//myled = 0;
--- a/button.h Wed Oct 18 14:06:19 2017 +0000
+++ b/button.h Wed Oct 18 14:41:04 2017 +0000
@@ -1,19 +1,23 @@
#include "mbed.h"
+// This is a button class for our custom button
class button {
+// pins connected to the button
private:
PwmOut servo;
DigitalIn pb;
- int state;
-
+ //int state; // is the button up or down
+ // int mode; // is the system in reading or typing mode
+ //AnalogIn linpot;
+
public:
// constructors
button();
button(PwmOut servo, DigitalIn pb);
// functions
- PwmOut getServoPin();
- int getState();
- void moveServoIn();
- void moveServoOut();
+ PwmOut getServoPin(); // get the servo pin
+ //int getState(); // determine what state the button is in - up or down
+ void moveServoIn(); // move servo into the slot
+ void moveServoOut(); // move servo out of the slot
};
\ No newline at end of file
--- a/main.cpp Wed Oct 18 14:06:19 2017 +0000
+++ b/main.cpp Wed Oct 18 14:41:04 2017 +0000
@@ -4,8 +4,7 @@
#include "SDFileSystem.h"
#include "button.h"
-// Azra
-
+// DEFINE I/O
PwmOut myservo(p21);
DigitalIn pb1 (p20);
//AnalogIn linpot(p20);
@@ -16,22 +15,26 @@
wave_player waver(&DACout);
button button1(myservo, pb1);
-// add start, mode, reset buttons
+// INITIALIZE VARIABLES
+// add mode, reset buttons
int start = 0;
int submit = 0;
// FIX THIS: button up: state = 2, button halfway: state = 0; button down: state = 1
int state = 2;
// FUNCTIONS
+// play a file on the speaker
void playSound(wave_player waver)
{
FILE *wave_file;
- wave_file=fopen("/sd/police_siren.wav","r");
+ wave_file=fopen("/sd/lesson.wav","r");
waver.play(wave_file);
fclose(wave_file);
}
// THREADS
+
+// thread for the custom button
void button_thread()
{
// button was up and is moving down, move servo in
@@ -44,11 +47,12 @@
button1.moveServoOut();
state = 2;
}
+ Thread::wait(200); // wait till thread is done
}
void submit_thread()
{
-
+ Thread::wait(500); // wait till thread is done
}
void start_thread()
@@ -57,6 +61,7 @@
// if 1
start == 1;
// else 0
+ Thread::wait(500); // wait till thread is done
}
int main()
@@ -88,19 +93,17 @@
// when submitted
//while (submit == 0) {}
-
// start button threads and submit thread
// if submit close button threads and submit thread
- // check result, speaker result
+ // check result
+ // play results on speaker
// save results
- // SD card code
-
- // speaker code
-
// read linear potentiometer
//if (linpot < 0.5) {
//float potval = linpot;
//pc.printf("linear pot: %f\n", potval);
+
+ Thread::wait(200); // wait till thread is done
}
}
\ No newline at end of file
