Log system based on external FRAM storage. Allow to collect float values in FRAM, and then store whole collection into file on flash.

Sample code

#include "mbed.h"
#include "FRAMLog.h"

SPI spi(p5,p6,p7);
FRAMLog flog(spi, p8, 4, 2048);
Serial pc(USBTX, USBRX);

int main() {
    for( int i=0; i<2048; i++){
        flog.log(i/4096.0);
        flog.log(i/(4096.0+1));
        flog.log(i/(4096.0+2));
        flog.log(i/(4096.0+3));
    }
    flog.save();
}
Revision:
0:f211f4870371
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FileLog.cpp	Mon Oct 15 17:04:49 2012 +0000
@@ -0,0 +1,50 @@
+/* mbed File Log Library
+ * Copyright (c) 2012 Oleg Evsegneev
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+ 
+#include "mbed.h"
+#include "FileLog.h"
+
+FileLog::FileLog( short cols, short rows ): _local("local") {
+    _cols = cols;
+    _rows = rows;
+    _data_idx = 0;
+    _data = new float[cols*rows];
+}
+
+void FileLog::log( float value ) {
+    _data[_data_idx++] = value;
+}
+
+void FileLog::save() {
+    FILE *fp = fopen("/local/log.txt", "w");
+    for( short i=0; i<_data_idx; i++){
+        if( i && (i % _cols == 0))
+            fprintf( fp, "\r\n");
+        else if( i && i != _data_idx-1 )
+            fprintf( fp, "\t");
+        fprintf( fp, "%.4f", _data[i]);
+    }
+    fclose(fp);
+    
+    delete [] _data;
+    _data = NULL;
+}