voor lennart

Dependencies:   mbed ADS1015 USBDevice

Files at this revision

API Documentation at this revision

Comitter:
lennartreij
Date:
Wed Jan 16 15:57:31 2019 +0000
Parent:
0:ce39f1aa5d6e
Commit message:
stable version 1

Changed in this revision

ADS1015.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADS1015.lib	Wed Jan 16 15:57:31 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/arve0/code/ADS1015/#aa277517f0ad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Wed Jan 16 15:57:31 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/USBDevice/#53949e6131f6
--- a/main.cpp	Wed Jan 16 10:31:23 2019 +0000
+++ b/main.cpp	Wed Jan 16 15:57:31 2019 +0000
@@ -2,7 +2,7 @@
 #include "mbed.h"
 #include "Adafruit_ADS1015.h"
 #include "USBSerial.h" 
-#include "windows.h"
+#include "stdio.h"
 
 //Not sure if we need those?
 #define SERIAL_BAUD_RATE    115200
@@ -21,65 +21,107 @@
 int baud_rate = 115200;
 
 //Declair var
-int ledPin = 1;
-int averageFSR[8];
-int averagePE[6];
-int i = 0;
-Timer t;
+int ledPin = 0;
+int listFSR[10] [10]; //column 0 t/m 7 - FSR data, column 8 - lap number, column 9 - posture lable
+int listPE[10] [8]; //column 0 t/m 5 - PE data, column 6 - lap number, column 7 - posture lable
 
 void setupLED(){
-    pinMode(ledPin, OUTPUT);
+    DigitalOut ledPin(LED1);
 }
 
-void piepLong(){
-    digitalWrite(ledPin, HIGH);
-    delay(1000);
-    digitalWrite(ledPin, LOW);
+void introTekst(){
+    int c;
+    pc.printf("\nTo start test press ENTER... \n \n");
+    pc.printf("When you have pressed enter, a 5 second countdown will begin. After this countdown, the test will begin. \n \n");
+    pc.printf("You have to follow the pattern listed below 10 times: \n");
+    pc.printf("1. Right side \n");
+    pc.printf("2. Back \n");
+    pc.printf("3. Left side \n");
+    pc.printf("4. Out of bed \n \n");
+    pc.printf("A long PIEEP indicates you to switch to the next position on the list, you have 5 seconds to switch. \n");
+    pc.printf("Two short PIEP's indicates you that the measurement has begun. Do not move during this period of 15 seconds. \n");
+    pc.printf("Three long PIEEEEP's will indicate you that the test has finished. \n \n");
+    pc.printf("Good luck!\n");
+    fflush(stdout);
+    do c = getchar(); while((c != '\n') && (c != EOF)); //Press enter to continue
+    pc.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); 
 }
-
-void piepShort(int x){
-     for(int i=1; i<=x; i++){ 
-        digitalWrite(ledPin, HIGH);
-        delay(500);
-        digitalWrite(ledPin, LOW);
-        delay(500);
-     }
-}   
-
-void delaySeconds(int x){
-    int timeMiliSeconds = x * 1000;
-    delay(timeMiliSeconds)
+  
+void piepLong(){ //create long piep sound one time
+    ledPin = 1;
+    pc.printf("PIEEEEEEEP");
+    wait_ms(1000);
+    ledPin = 0;
+    pc.printf("\n");
 }
 
+void piepShort(int x){ //create short piep sound for x times
+    for(int i=1; i<=x; i++){ 
+        ledPin = 1;
+        pc.printf("PIEP ");
+        wait_ms(200);
+        ledPin = 0;
+    }
+    pc.printf("\n");
+}   
+
+void countDown(){ //countdown from 5. makes short piep sound every second
+    for(int i=5; i>=1; i--){
+        ledPin = 1;
+        pc.printf("%d", i);
+        pc.printf("\n");
+        wait_ms(500);
+        ledPin = 0;
+        wait_ms(500);
+    }
+}    
+    
 int main() {
-    pc.usb.baud(baud_rate);
-    pc.printf(
-        “To start test press a key \n
-        \n
-        When you have pressed enter, a 5 second countdown will begin. After this countdown, the test will begin. \n
-        \n
-        You have to follow the pattern listed below 10 times: \r
-        1. Right side \n
-        2. Back \n
-        3. Left side \n
-        4. Out of bed \n
-        \n
-        A long PIEEP indicates you to switch to the next position on the list, you have 5 seconds to switch. \n
-        Two short PIEP’s indicates you to that the measurement has begun. Do not move during this period of 15 seconds. \n
-        Three long PIEEEEP’s will indicate you that the test has finished. \n
-        \n
-        Good luck!”);
+    pc.baud(baud_rate);
+    introTekst(); //explaination screen about the test  
+    countDown(); //5 seconds countdown
         
-    if getc{
-        piepShort(5); //5 seconds countdown
+    for(int i=1; i<=10; i++){ //10 times loop
+        pc.printf("Lap "); //print lap number
+        pc.printf("%d", i); //print lap number
+        pc.printf("\n"); //print lap number
+    
+        piepLong(); //right side signal
+        wait_ms(5000); //time for turning
+        piepShort(2); //create short piep sound two times
+        pc.printf("collect data right side\n"); //extra information for testing
+        //code collect data
+        wait_ms(5000); //time for collecting data  
+        // end of placeholder collect data code
+         
+        piepLong(); //back side signal
+        wait_ms(5000); //time for turning
+        piepShort(2); //creat short piep sound two times
+        pc.printf("collect data back side\n"); //extra information for testing
+        //code collect data
+        wait_ms(5000); //time for collecting data   
+        // end of placeholder collect data code
         
-        for(int i=1; i<=10; i++){ //10 times loop
-            piepLong(); //right side signal
-            delaySeconds(5); //time for turning
-            piepShort
-            //collect data
-            
-        }            
-    }
+        piepLong(); //left side signal
+        wait_ms(5000); //time for turning
+        piepShort(2); //creat short piep sound two times
+        pc.printf("collect data left side\n"); //extra information for testing
+        //code collect data
+        wait_ms(5000); //time for collecting data   
+        // end of placeholder collect data code
+        
+        piepLong(); //out of bed signal
+        wait_ms(5000); //time for turning
+        piepShort(2); //creat short piep sound two times
+        pc.printf("collect data out of bed\n"); //extra information for testing
+        //code collect data
+        wait_ms(5000); //time for collecting data  
+        // end of placeholder collect data code
+    }   
+    
+    piepLong(); //final piep sounds, signal that test has finished
+    piepLong(); //final piep sounds
+    piepLong(); //final piep sounds
+           
     return 0;
 }