Working reset, flipped logic

Dependencies:   SDFileSystem emic2 mbed-rtos mbed

Fork of BAT_senior_design_Nhi by BAT

Revision:
6:1aa86ad19af9
Parent:
4:cc181f8f2bd1
Child:
9:418a4437a693
--- a/main.cpp	Wed Oct 11 14:54:30 2017 +0000
+++ b/main.cpp	Fri Oct 13 15:01:03 2017 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
-#include "wave_player.h"
-#include "SDFileSystem.h"
+#include "functions.cpp"
+#include "rtos.h"
 
 PwmOut myservo(p21);
 DigitalIn pb1 (p20);
@@ -11,61 +11,80 @@
 AnalogOut DACout(p26);
 wave_player waver(&DACout);
 
-void moveServoIn()
+// add start, mode, reset buttons
+
+
+
+
+// THREADS
+
+
+void button_thread()
 {
-    while(pb1 == 1)
-        //myled = 1;
-        // rotate 90 degrees one way
-        for(int i=3; i<=7; i++) {
-            myservo = i/100.0;
-            wait(0.01);
-        }
+
 }
 
-void moveServoOut()
+void submit_thread()
 {
-    while(pb1 == 1)
-        //myled = 0;
-        for(int i=7; i>3; i--) {
-            myservo = i/100.0;
-            wait(0.01);
-        }
+
 }
 
-void playSound()
+void start_thread()
 {
-    FILE *wave_file;
-    wave_file=fopen("/sd/police_siren.wav","r");
-    waver.play(wave_file);
-    fclose(wave_file);
+    // read pb_start
+    // if 1
+    start == 1;
+    // else 0
 }
 
 int main()
 {
-    pc.printf("begin\n");
-
+    // SETUP
     // button up: state = 0, button halfway: state = 1; button down: state = 2
     int state = 2;
-
     // pull up the pushbutton to prevent bouncing
     pb1.mode(PullUp);
     wait(.001);
-
     // servo begins at 30 degrees
     for(int i=0; i<=3; i++) {
         myservo = i/100.0;
         wait(0.01);
     }
 
-    while(1) {
+    // MAIN THREAD
+    while(true) {
+
+        // start threads for reset, mode, start
+        Thread t1(start_thread);
+
+        // setup SDcard and Speaker
+
+
+        // when started
+        while (start == 0) {}
+        Thread t2(button_thread);
+        Thread t3(submit_thread);
+
+        // when submitted
+        while (submit == 0) {}
+                
+
+        // start button threads and submit thread
+        // if submit close button threads and submit thread
+        // check result, speaker result
+        // save results
+
+
+
+
         // Servo code
         if (pb1 == 1 && state == 2) {
-            moveServoIn();
+            moveServoIn(myservo, pb1);
             state = 1;
         }
         // rotate 90 degrees other way
         if (pb1 == 1 && state == 1) {
-            moveServoOut();
+            moveServoOut(myservo, pb1);
             state = 2;
         }