Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MCP23017 TCS3472_I2C WattBob_TextLCD mbed-rtos mbed
main.cpp
- Committer:
- IonSystems
- Date:
- 2014-11-10
- Revision:
- 9:8d78eb55ad5e
- Parent:
- 8:b7771391adc9
- Child:
- 10:8c0696b99692
File content as of revision 9:8d78eb55ad5e:
#include "mbed.h"
#include <sstream>
#include "lcdCommands.h"
#include "mbedStorage.h"
#include "rgbLED.h"
#include "mbedLCD.h"
#include "stateMachine.h"
#include "FPGAcomms.h"
Serial pc(USBTX, USBRX);
StateMachine stateMachine;
//Boolean values to easily enable and disable certain features for individual testing
bool colourSensor = true;
bool cardReader = true;
bool sorter = true;
bool dispensor = true;
bool cardDataAcquired = false;
bool colourDataAcquired = false;
bool chipDetected = false;
bool operationMode = true; //the MBED starts in operation mode.
void processState(StateMachine stateMachine){
switch(stateMachine){
case INITIALISING:
setupLCD();
printLCD("Welcome to the Chipin Sorter");
wait(1);
break;
case READING_RGB_VALUES:
readChipNumbers();
break;
case DISPENSE_RED:
printLCD("DISPENSING A RED CHIP");
select = 0; //Setting to operation mode just in case it has not been set.
dispenseBit1 = true;
dispenseBit2 = true;
dispenseBit2 = false;
dispenseBit1 = false;
wait(0.01);
startDispense = true; //set the startDispense line high.
//wait(1); //temporary delay
while(!complete){
wait(0.1);
printLCD("Waiting to complete");
}
dispenseBit1 = true; //reset the dispense select to do nothing
dispenseBit2 = true; //reset the dispense select to do nothing
//startDispense = false;
printLCD("RED DISPENSE COMPLETE");
break;
}
}
int main() {
stateMachine = INITIALISING;
processState(stateMachine);
writeFile(2,6,22);
stateMachine = READING_RGB_VALUES;
processState(stateMachine);
while(true){
if(par_port->read_bit(9)){
stateMachine = DISPENSE_RED;
processState(stateMachine);
}
}
//printStoredChipValues();
/*
while(1){
if(par_port->read_bit(11)) resetForNextCustomer();
if(cardDetect & !cardDataAcquired) cardAcquisition();
setLEDs();
readButtons();
if(chipDetected & !colourDataAcquired){
Colour colour = readColourSensor();
sendColourSignal(colour);
}
writeFile(redQueue, greenQueue, blueQueue);
readFile();
wait(2);
}
*/
/* setLEDcolour(255,0,0);
wait(0.1);
setLEDcolour(0,255,0);
wait(0.1);
setLEDcolour(0,0,255);
wait(0.1);
displayOperationMode(); */
}
