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:
10:8c0696b99692
Parent:
6:e64796f1f384
Child:
12:814a8fdbb6f7
--- a/mbedStorage.h	Mon Nov 10 19:01:43 2014 +0000
+++ b/mbedStorage.h	Wed Nov 12 20:14:45 2014 +0000
@@ -1,19 +1,34 @@
 #include "mbed.h"
+bool logEnable = false;
 LocalFileSystem local("local");
 void writeFile(int r, int g, int b){
-    FILE* File1 = fopen("/local/datafile.txt","w"); // open file
-    fputc(r, File1); // put char (data value) into file
-    fputc(g, File1); // put char (data value) into file
-    fputc(b, File1); // put char (data value) into file
-    fclose(File1); // close file 
-    }
+    FILE* file = fopen("/local/datafile.txt","w"); // open file
+    fputc(r, file); // put char (data value) into file
+    fputc(g, file); // put char (data value) into file
+    fputc(b, file); // put char (data value) into file
+    fclose(file); // close file 
+}
     
 int readFile(int index){
-    FILE* File2 = fopen ("/local/datafile.txt","r"); // open file for reading
+    FILE* file = fopen ("/local/datafile.txt","r"); // open file for reading
     int read_var;
     for(int i = 0; i <= index; i++){
-        read_var = fgetc(File2); // read data value
+        read_var = fgetc(file); // read data value
     }
-    fclose(File2); // close file
+    fclose(file); // close file
     return read_var;   
-    }
\ No newline at end of file
+}
+
+void log(char* text){
+    if(logEnable){
+        FILE* file = fopen ("/local/log.txt", "a");    
+        fputs(text, file);
+        fputs("\r\n", file);
+        fclose(file);
+        }
+}
+
+void clearLog(){
+    FILE* file = fopen ("/local/log.txt", "w");
+    fclose(file);    
+}
\ No newline at end of file