3rd year group project. Electronic and Electrical Engineering. Heriot-Watt University. This is the code for the mbed for the Automatic Little Object Organiser (ALOO).

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed

Revision:
24:02c61793f90b
Parent:
23:db91aaa43a9e
Child:
25:792540d69c49
diff -r db91aaa43a9e -r 02c61793f90b main.cpp
--- a/main.cpp	Sat Nov 28 23:28:22 2015 +0000
+++ b/main.cpp	Sun Nov 29 01:05:42 2015 +0000
@@ -81,6 +81,9 @@
 
 		fpga->moveStoppingServo(Stop);
 		fpga->moveSortingServo(NonHaz);
+		
+		pc.printf(":<pc>connect;");
+//		wait(0.03);
 
 		int selection = 0;
 		do {
@@ -134,10 +137,13 @@
 
 				while (abortOperation == false && connectedToPC == true) {
 					if (currentMode == Maintanence) {
+						displayPCStatus();
+						while (currentMode == Maintanence){
 						if (runServoTest == true)
 							runInServoTestMode();
 						else if (runBreakBeamTest == true)
 							runInBreakBeamTestMode();
+						}
 					} else if (currentMode == Normal) {
 						displayPCStatus();
 						while (currentMode == Normal) {
@@ -367,7 +373,6 @@
 	pc.format(8, SerialBase::None, gStopBits);
 	myLED4 = 1;
 	wait (0.1);
-	pc.printf(":<pc>connect;");
 	return;
 }
 
@@ -445,15 +450,15 @@
 	lcd->cls();
 	lcd->locate(0,0);
 	if (fpga->stoppingServoPosition == Stop)
-		lcd->printf("1: Stopping servo: Stop");
+		lcd->printf("1: Top: Stop");
 	else if (fpga->stoppingServoPosition == Go)
-		lcd->printf("1: Stopping servo: Go");
+		lcd->printf("1: Top: Go");
 
 	lcd->locate(1,0);
 	if (fpga->sortingServoPosition == NonHaz)
-		lcd->printf("2: Sorting servo: NonHaz");
+		lcd->printf("2: Bottom: NonHaz");
 	else if (fpga->sortingServoPosition == Haz)
-		lcd->printf("2: Sorting serov: Haz");
+		lcd->printf("2: Bottom: Haz");
 }
 
 void printServoInfoOnPC() {
@@ -536,6 +541,12 @@
 		button = readSwitches();
 		int currentTopBeamValue = fpga->getBeamValue(1);
 		int currentBottomBeamValue = fpga->getBeamValue(2);
+		
+		// For debugging, hold down both 1 and 3 or 2 and 3
+		if (i2cport->read_bit(10) == 1){
+			currentTopBeamValue = i2cport->read_bit(8) && i2cport->read_bit(10);
+			currentBottomBeamValue = i2cport->read_bit(9) && i2cport->read_bit(10);
+		}
 		myLED1 = currentTopBeamValue;
 		myLED2 = currentBottomBeamValue;