![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
The MBED firmware used on the Chipin sorter, developed over 12 weeks for a 3rd year university systems project. Chipin is a token sorter, it sorts tokens by colours and dispenses them to order through an online booking system and card reader. This program interfaces with an FPGA, PC and LCD screen to control the sorter. The sorter has an operation mode where it can process orders when a card is entered into the machine. There is also a maintenance mode where the device responds to maintenance instructions such as 'dispense all'. More information at http://www.ionsystems.uk/
Dependencies: MCP23017 TCS3472_I2C WattBob_TextLCD mbed-rtos mbed
Diff: main.cpp
- Revision:
- 17:6a0bb0ad5bb4
- Parent:
- 16:498359d078dc
- Child:
- 18:12e2c82a5a6c
--- a/main.cpp Sun Nov 23 18:45:52 2014 +0000 +++ b/main.cpp Mon Nov 24 14:00:46 2014 +0000 @@ -6,7 +6,7 @@ #include <sstream> #include <string> -#include "lcdCommands.h" + #include "mbedStorage.h" #include "rgbLED.h" #include "mbedLCD.h" @@ -36,9 +36,10 @@ bool chipDetected = false; -int mode = 4; +int mode = 3; int maintenanceModePointer = 0; Colour lastColour = NONE; +Colour colourStore = NONE; void checkSortDispenseButtons(){ @@ -93,17 +94,21 @@ }else if(mode == 3){ printLCD("Colour Sensor Mode"); //Colour Sensing Mode if(colourSensor){ - Colour colour = readColourSensor(); - + + + Colour colour = readColourSensor(); + lastColour = colourStore; + colourStore = colour; /* Tries to prevent a colour mis-read. When a chip is read as BIN or NONE, the chip may be falling down the tube as the reading was taken. The chip may also be out of position on the slider. Ignoring the next reading is trying to prevent a mis-read being valid. */ - if(lastColour == NONE || lastColour == BIN){ + if(lastColour == NONE){ + return; } - lastColour = colour; + if(sorter) sort(colour); //Put (sorter && colour != BIN) in if statement. } @@ -137,8 +142,10 @@ printLCD("set values to 2"); } - }else if(mode == 6){ //Maintenance Mode - printLCD("Maintenace Mode"); + }else if(mode == 6){ + printLCD("Main. Mode: " + maintenanceModeSelect); + wait(0.1); //Maintenance Mode + //printLCD("Maintenance Mode"); if(par_port->read_bit(8)){ //Next maintenance function maintenanceModePointer++; if(maintenanceModePointer > 12) maintenanceModePointer = 0; @@ -221,12 +228,11 @@ } void changeLanguage(){ - currentLanguage = nextLanguage(currentLanguage); - //tell PC to change language - sendLanguageCharacter(); //Tell PC to change language - updateLCDLanguage(); + currentLanguage = nextLanguage(currentLanguage); //Change the language on teh MBED. + sendLanguageCharacter(); //Tell PC to change language + ////Change Language //Tell Arduino to change language. printLCD("setting language to english"); - wait(0.5); + wait(1); } int main() { @@ -240,7 +246,7 @@ if(serialComms){ checkSerial(); }if(testFunctions) checkSortDispenseButtons(); - if(languageButton) changeLanguage(); + //if(languageButton) changeLanguage(); @@ -258,41 +264,9 @@ - - - - - + - //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(); */ + \ No newline at end of file