![](/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:
- 15:0c5f20e15b6a
- Parent:
- 14:31ba3e56c788
- Child:
- 16:498359d078dc
diff -r 31ba3e56c788 -r 0c5f20e15b6a main.cpp --- a/main.cpp Thu Nov 20 22:02:54 2014 +0000 +++ b/main.cpp Fri Nov 21 22:14:21 2014 +0000 @@ -1,7 +1,11 @@ bool operationMode = true; //the MBED starts in operation mode. #include "mbed.h" +#include "Language.h" +DigitalIn languageButton(p30); +Language currentLanguage = ENGLISH; #include <sstream> #include <string> + #include "lcdCommands.h" #include "mbedStorage.h" #include "rgbLED.h" @@ -10,6 +14,7 @@ #include "FPGAcomms.h" #ifndef serialComm #define serialComm + #include "serialCommunication.h" #endif #include "testFunctions.h" @@ -31,7 +36,7 @@ bool chipDetected = false; -int mode = 3; +int mode = 4; int maintenanceModePointer = 0; Colour lastColour = NONE; @@ -89,11 +94,16 @@ printLCD("Colour Sensor Mode"); //Colour Sensing Mode if(colourSensor){ Colour colour = readColourSensor(); - lastColour = colour; - if(lastColour == NONE || lastColour == BIN){ + + /* 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){ return; } - + lastColour = colour; if(sorter) sort(colour); //Put (sorter && colour != BIN) in if statement. } @@ -209,7 +219,14 @@ } } - +void changeLanguage(){ + currentLanguage = nextLanguage(currentLanguage); + //tell PC to change language + sendLanguageCharacter(); //Tell PC to change language + updateLCDLanguage(); + printLCD("setting language to english"); + wait(0.5); + } int main() { @@ -222,7 +239,11 @@ if(serialComms){ checkSerial(); }if(testFunctions) checkSortDispenseButtons(); - + if(languageButton) changeLanguage(); + + + + wait(0.05); }