Index: trunk/code/projects/test/test_rangefinders.c
===================================================================
--- trunk/code/projects/test/test_rangefinders.c	(revision 1380)
+++ trunk/code/projects/test/test_rangefinders.c	(nonexistent)
@@ -1,77 +0,0 @@
-#include <dragonfly_lib.h>
-
-
-/**
- * RangeFinder Rules
- * - analog_init() is needed
- * - value 100 - under 5cm is not detected
- * - value 800 - over ~30cm is not detected
- * - at ~20cm values become increasingly erroneous
- *
- */
- 
-int to_mm(int rangeFinder) 
-{
-
-	if(rangeFinder != -1)
-		return (int)(rangeFinder/15.112*10);
-	else
-		return -1;
-
-}
-
-int testrangefinders(void) {
-  usb_init();
-	usb_puts("usb turned on\r\n");
-  range_init();
-  usb_puts("rangefinders turned on\r\n");
-  int d1,d2,d3,d4,d5;
-  delay_ms(1000);
-  
-  //int sum = 0;
-  //int count = 0;
-  //int average = 0;
-  
-  // start testing rangefinders
-  while(1) {
-	//if(count == 10000)
-	//{
-	//	average = sum/count;
-	//	count = 0;
-	//}
-	
-    // get ranges
-    //d1 = range_read_distance(IR1);
-    d2 = range_read_distance(IR2);
-    //d3 = range_read_distance(IR3);
-    //d4 = range_read_distance(IR4);
-    //d5 = range_read_distance(IR5);
-    //usb_puts("d1=");
-    //usb_puti(d1);
-	
-	//sum += d2;
-	
-    //usb_puts("\taverage of 10000=");
-    //usb_puti(d2);
-	
-    //usb_puts("\td3=");
-    //usb_puti(d3);
-    //usb_puts("\td4=");
-    //usb_puti(d4);
-    //usb_puts("\td5=");
-    //usb_puti(d5);
-	
-	usb_puts("\tIn mm=");
-	usb_puti(to_mm(d2));
-    usb_puts("\r\n");   
-	
-	//count++;
-	
-    delay_ms(100);
-  }
-  
-  // end testing rangefinders
-	return 0;
-}
-
-

Property changes on: trunk/code/projects/test/test_rangefinders.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_rangefinder.c
===================================================================
--- trunk/code/projects/test/test_rangefinder.c	(nonexistent)
+++ trunk/code/projects/test/test_rangefinder.c	(revision 1381)
@@ -0,0 +1,54 @@
+/**
+ * @file test_rangefinder.c
+ * @brief Contains unit test for rangefinder.c module of libdragonfly
+ *
+ * Contains a function allowing the user to test whether the rangefinder module
+ * works correctly.
+ *
+ * @author Colony Project, CMU Robotics Club
+ **/
+
+/* Testing Procedure
+ * - Position robot facing you
+ * - Wait for initial BLUE flashes
+ * - Position hand at ~12cm from leftmost, rearmost rangefinder (IR4)
+ * - Sweep hand around front of robot, maintaining distance from rangefinders
+ * - Observe orbs
+ *
+ * Expected Behavior:
+ * - Orbs flash BLUE 3 times to signal start of test
+ * - Orbs turn RED when IR4 gets a useable reading
+ * - Orbs turn ORANGE when IR1 gets a useable reading
+ * - Orbs turn YELLOW when IR2 gets a useable reading
+ * - Orbs turn GREEN when IR3 gets a useable reading
+ * - Orbs turn BLUE when IR5 gets a useable reading
+ */
+
+#include <dragonfly_lib.h>
+
+#define delay 750   // delay between sensors (in ms)
+
+int test_rangefinder() {
+    uint8_t i, ir, color;   // plain old index, rangefinder index, color index
+    int detectors[5] = {IR4, IR1, IR2, IR3, IR5};   // rangefinders L to R
+    int colors[5] = {RED, ORANGE, YELLOW, GREEN, BLUE};	// colors of rainbow
+
+    // flash orbs BLUE 3 times
+    for (i = 0; i < 3; i++) {
+	orb_set_color(BLUE);
+	delay_ms(500);
+	orb_set_color(ORB_OFF);
+	delay_ms(250);
+    }
+
+    // show appropriate color when sensor gets a good read, then wait a second
+    // do this for each sensor in left-to-right order
+    for (ir = 1, color = 0; ir <= 5; ir++, color++) {
+	while (range_read_distance(ir) == -1);
+	orb_set_color(color);
+	delay_ms(DELAY);
+    }
+
+    return 0;
+}
+

Property changes on: trunk/code/projects/test/test_rangefinder.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/main.c
===================================================================
--- trunk/code/projects/test/main.c	(revision 1380)
+++ trunk/code/projects/test/main.c	(revision 1381)
@@ -15,7 +15,7 @@
     //    RUN_TEST(testlcd);
     RUN_TEST(testlights);
     RUN_TEST(testmotors);
-    RUN_TEST(testrangefinders);
+    RUN_TEST(testrangefinder);
     RUN_TEST(testtokenring);
 
   }
