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:
23:f9e7e64784be
Parent:
20:6de191ac7ff3
Child:
24:8868101d01d0
--- a/mbedStorage.h	Tue Nov 25 22:32:26 2014 +0000
+++ b/mbedStorage.h	Sat Nov 29 16:32:57 2014 +0000
@@ -1,46 +1,57 @@
 #include "mbed.h"
-bool logEnable = true;
+bool logEnable = false;
 LocalFileSystem local("local");
-void writeFile(int r, int g, int b){
-    
+void writeFile(int r, int g, int b, int re)
+{
+
     FILE* file = fopen("/local/datafile.txt","w"); // open file
-    if(r >= 0){
-    fputc(r, file); // put char (data value) into file
-    }else{
-        fputc(0, file);  
-    }if(g >00){
-    fputc(g, file); // put char (data value) into file
-    }else{
-        fputc(0, file);   
-    }if(b >= 0){
-    fputc(b, file); // put char (data value) into file
-    }else{
-        fputc(0, file);   
+    if(r >= 0) {
+        fputc(r, file); // put char (data value) into file
+    } else {
+        fputc(0, file);
+    }
+    if(g >= 0) {
+        fputc(g, file); // put char (data value) into file
+    } else {
+        fputc(0, file);
     }
-    fclose(file); // close file 
-    
+    if(b >= 0) {
+        fputc(b, file); // put char (data value) into file
+    } else {
+        fputc(0, file);
+    }
+    if(re >= 0) {
+        fputc(re, file); // put char (data value) into file
+    } else {
+        fputc(0, file);
+    }
+    fclose(file); // close file
+
 }
-    
-int readFile(int index){
+
+int readFile(int index)
+{
     FILE* file = fopen ("/local/datafile.txt","r"); // open file for reading
     int read_var = 0;
-    for(int i = 0; i <= index; i++){
+    for(int i = 0; i <= index; i++) {
         read_var = fgetc(file); // read data value
     }
     fclose(file); // close file
-    return read_var;   
+    return read_var;
 }
 
-void log(char* text){
-    /*if(logEnable){
-        FILE* file = fopen ("/local/log.txt", "a");    
+void log(char* text)
+{
+    if(logEnable) {
+        FILE* file = fopen ("/local/log.txt", "a");
         fputs(text, file);
         fputs("\r\n", file);
         fclose(file);
-        }*/
+    }
 }
 
-void clearLog(){
+void clearLog()
+{
     FILE* file = fopen ("/local/log.txt", "w");
-    fclose(file);    
+    fclose(file);
 }
\ No newline at end of file