GroupA / Mbed 2 deprecated WaG_final

Dependencies:   mbed

Fork of Lab_6_WaG by GroupA

Revision:
66:70efa618c378
Parent:
65:b8f3339b9268
Child:
67:6dffd5c82eb6
--- a/wag.cpp	Thu Apr 19 00:14:15 2018 +0000
+++ b/wag.cpp	Thu Apr 19 15:26:19 2018 +0000
@@ -27,7 +27,7 @@
 int led_values[8] = {1, 2, 4, 8, 16, 32, 64, 128};
 
 
-void gnoll(int sensor_no, float sensor_values[]) {
+void gnoll(int sensor_no, float * sensor_values) {
     int hit, miss = 0;
     int a_num;
     int led_command;
@@ -37,7 +37,6 @@
     if (sensor_no == 0)
         whacker_no = 8;
 
-    int sensor_no = 0; //change to match station
 
     for (int i = 0; i < 15; i++) {
         pc.printf("Round %d\n", i + 1);
@@ -48,7 +47,7 @@
         
         ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // scan all sensors
         
-        if (sensor_values[sensor_no + a_num] > PTHRESH) { // confirm that the sensor is high
+        if (sensor_values[sensor_no + a_num] > PTTHRESH) { // confirm that the sensor is high
             led_command = 0x0500 + led_values[a_num]; // create SPI command for LED
             spi_send(as1107, led_command); // light up LED
         }
@@ -64,22 +63,22 @@
         do {
             finish = clock(); // update timer
             ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // scan all sensors
-        } while (finish - start < VOLLEY_DELAY or sensor_values[whacker_no + a_num] < PTHRESH); // check if timer expired or if sensor hit
+        } while (finish - start < VOLLEY_DELAY or sensor_values[whacker_no + a_num] < PTTHRESH); // check if timer expired or if sensor hit
         
-        if (sensor_values[whacker_no + a_num] > PTHRESH) {
+        if (sensor_values[whacker_no + a_num] > PTTHRESH) {
             hit++; // increment hit count
             pc.printf("Hit\n");
-            while(sensor_values[whacker_no + a_num] > PTHRESH)
+            while(sensor_values[whacker_no + a_num] > PTTHRESH)
                 ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // waits for whacker laser to turn off
         }
         
         else {
             for (int j = 0 + whacker_no; j < 8 + whacker_no; j++) { // go through all whacker sensors
-                if (sensor_values[i + whacker_no] > PTHRESH and j != a_num) { // check if wrong sensor hit
+                if (sensor_values[i + whacker_no] > PTTHRESH and j != a_num) { // check if wrong sensor hit
                     pc.printf("Wrong sensor hit.\n");
                     i = 15; // ends volley
                     ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // scan all sensors 
-                    while(sensor_values[i + whacker_no] > PTHRESH)
+                    while(sensor_values[i + whacker_no] > PTTHRESH)
                         ana_scan_mux(sensor_values, TGT_SENSOR_QUAN * 2); // waits for whacker laser to turn off
                 }
             }