![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Diff: main.cpp
- Revision:
- 14:cf2f255b5560
- Parent:
- 11:0fe833f8a1ab
- Child:
- 15:777390eb5afd
diff -r 4f24da6e2f8e -r cf2f255b5560 main.cpp --- a/main.cpp Sat Nov 21 20:24:08 2015 +0000 +++ b/main.cpp Sun Nov 22 17:53:36 2015 +0000 @@ -99,21 +99,21 @@ bool abortOperation = false; for(;;) { displayWaitingLine(); + lcd->locate(1, 0); + lcd->printf("for block."); i2cport->write_bit(1, 15); - - int blockInserted = 0; // Wait until a block is breaking the beam, or button 4 is pressed to abort. do { - blockInserted = fpga->checkForBlock(); + blockInserted = fpga->getBeamValue(Top); myLED4 = blockInserted; if (i2cport->read_bit(11)) { abortOperation = displayAbortDialog(); // Cancel the Abort if (abortOperation == false) { displayWaitingLine(); - lcd->printf("for Block"); + lcd->printf("for block"); i2cport->write_bit(1, 15); } } @@ -129,11 +129,17 @@ // Detach rx interrupt until block processed. NVIC_DisableIRQ(UART1_IRQn); + int canCheckForSize = fpga->checkForBlock(); int blockSize = 0; + + while (canCheckForSize == 0) { + canCheckForSize = fpga->checkForBlock(); + } + blockSize = fpga->checkForSize(); myLED3 = blockSize; - if (blockSize == 0) { + if (blockSize == Block::Small) { // detectColour() int colourValues[4]; // displayWaitingLine(); @@ -173,15 +179,10 @@ while (connectedToPC == false && abortOperation == false) { abortOperation = readSwitches() == 4; } + if (abortOperation == true) { D_LEDS_OFF(); break; - } else if (connectedToPC == true) { - lcd->cls(); - LCDFL(); - lcd->printf("Connected to PC"); - LCDSL(); - lcd->printf("4: Disconnect."); } while (abortOperation == false && connectedToPC == true) {