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:
9:dc8f155b71c8
Parent:
8:e1da2ae62885
Child:
10:16ba52f8e025
--- a/globals.cpp	Mon Nov 16 22:20:11 2015 +0000
+++ b/globals.cpp	Mon Nov 16 23:44:44 2015 +0000
@@ -1,4 +1,6 @@
 #include "globals.h"
+#include "Block.h"
+#include "fpga.h"
 
 int kDefaultBaudRate = 19200;
 //SerialBase gParity = SerialBase::None;
@@ -21,8 +23,30 @@
 void hazBlock(CommandTypeRaw typeRaw){
 	if (typeRaw == Set) {
 		pc.printf("setting new haz block.\n");
+		pc.printf("Send 'y' when block is inserted.\n");
+		int lowerBeam = 0;
+		char readyChar = '\0';
+		do{
+			readyChar = pc.getc();
+			lowerBeam = fpga->checkForBlock();
+			if (readyChar == 'y' && lowerBeam == 0){
+				pc.printf("No block detected by beam\nTry again.");
+			}
+		} while (readyChar != 'y' || lowerBeam != 0);
+		
+		int higherBeam = 0;
+		higherBeam = fpga->checkForSize();
+		
+			_HazBlock = Block();
+			if (higherBeam == 1)
+				_HazBlock.size = Block::Big;
+			else if (higherBeam == 0)
+				_HazBlock.size = Block::Small;
+				
+			
+			
 	}else if (typeRaw == Query){
-		pc.printf("priting current haz block settings.\n");
+		pc.printf(	"HazBlock:\n \t Size:%i\n \t Min Colour:%i,%i,%i,%i\n \t Max Colour:TBA\n ", _HazBlock.size, _HazBlock.minColour.components[Colour::Red], _HazBlock.minColour.components[Colour::Blue], _HazBlock.minColour.components[Colour::Green], _HazBlock.minColour.components[Colour::Alpha]);
 	}
 }