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

Revision:
27:47a7bc902587
Parent:
24:8868101d01d0
--- a/mbedStorage.h	Thu Dec 04 12:31:23 2014 +0000
+++ b/mbedStorage.h	Thu Dec 04 22:05:18 2014 +0000
@@ -1,9 +1,19 @@
 #include "mbed.h"
-bool logEnable = false;
+/*  Allows easy enable and disable of log file.
+ *  WARNING: Every time a file is changed on the MBED, it reconnects to the PC,
+ *  resulting in hundrets of Autoplay notices appearing on your desktop window.
+ *  Unplug the MBED from the PC for best results.
+ *  Logging is extremely useful for debugging but should be disabled when not debugging.
+ */
+bool logEnable = false; 
 LocalFileSystem local("local");
+
+/*  void writeFile(int r, int g, int b, int re)
+ *  Write the values of each storage tube to the datafile.
+ *  Ensures no negative values are written to the file.
+ */
 void writeFile(int r, int g, int b, int re)
 {
-
     FILE* file = fopen("/local/df.txt","w"); // open file
     if(r >= 0) {
         fputc(r, file); // put char (data value) into file
@@ -11,24 +21,25 @@
         fputc(0, file);
     }
     if(g >= 0) {
-        fputc(g, file); // put char (data value) into file
+        fputc(g, file); 
     } else {
         fputc(0, file);
     }
     if(b >= 0) {
-        fputc(b, file); // put char (data value) into file
+        fputc(b, file); 
     } else {
         fputc(0, file);
     }
     if(re >= 0) {
-        fputc(re, file); // put char (data value) into file
+        fputc(re, file); 
     } else {
         fputc(0, file);
     }
     fclose(file); // close file
-
 }
-
+/*  int readFile(int index)
+ *  Read a character from the datafile and return as an integer.
+ */
 int readFile(int index)
 {
     FILE* file = fopen ("/local/df.txt","r"); // open file for reading
@@ -40,6 +51,9 @@
     return read_var;
 }
 
+/*  void log(char* text)
+ *  Append a charcater array on a new line in the log file.
+ */
 void log(char* text)
 {
     if(logEnable) {
@@ -49,7 +63,9 @@
         fclose(file);
     }
 }
-
+/*  void clearLog()
+ *  Clear the log file.
+ */
 void clearLog()
 {
     FILE* file = fopen ("/local/log.txt", "w");