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();
}
Committer:
Decimus
Date:
Mon Oct 15 17:04:49 2012 +0000
Revision:
0:f211f4870371
Logging on internal Flash

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Decimus 0:f211f4870371 1 /* mbed File Log Library
Decimus 0:f211f4870371 2 * Copyright (c) 2012 Oleg Evsegneev
Decimus 0:f211f4870371 3 *
Decimus 0:f211f4870371 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
Decimus 0:f211f4870371 5 * of this software and associated documentation files (the "Software"), to deal
Decimus 0:f211f4870371 6 * in the Software without restriction, including without limitation the rights
Decimus 0:f211f4870371 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Decimus 0:f211f4870371 8 * copies of the Software, and to permit persons to whom the Software is
Decimus 0:f211f4870371 9 * furnished to do so, subject to the following conditions:
Decimus 0:f211f4870371 10 *
Decimus 0:f211f4870371 11 * The above copyright notice and this permission notice shall be included in
Decimus 0:f211f4870371 12 * all copies or substantial portions of the Software.
Decimus 0:f211f4870371 13 *
Decimus 0:f211f4870371 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Decimus 0:f211f4870371 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Decimus 0:f211f4870371 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Decimus 0:f211f4870371 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Decimus 0:f211f4870371 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Decimus 0:f211f4870371 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Decimus 0:f211f4870371 20 * THE SOFTWARE.
Decimus 0:f211f4870371 21 */
Decimus 0:f211f4870371 22
Decimus 0:f211f4870371 23 #ifndef MBED_FILELOG_H
Decimus 0:f211f4870371 24 #define MBED_FILELOG_H
Decimus 0:f211f4870371 25
Decimus 0:f211f4870371 26 #include "mbed.h"
Decimus 0:f211f4870371 27
Decimus 0:f211f4870371 28 class FileLog {
Decimus 0:f211f4870371 29
Decimus 0:f211f4870371 30 public:
Decimus 0:f211f4870371 31 FileLog( short cols, short rows );
Decimus 0:f211f4870371 32
Decimus 0:f211f4870371 33 /** Set new value to log
Decimus 0:f211f4870371 34 *
Decimus 0:f211f4870371 35 * @param value Value of log entry.
Decimus 0:f211f4870371 36 */
Decimus 0:f211f4870371 37 void log( float value );
Decimus 0:f211f4870371 38
Decimus 0:f211f4870371 39 /** Save log to file
Decimus 0:f211f4870371 40 *
Decimus 0:f211f4870371 41 */
Decimus 0:f211f4870371 42 void save();
Decimus 0:f211f4870371 43
Decimus 0:f211f4870371 44 protected:
Decimus 0:f211f4870371 45 short _data_idx;
Decimus 0:f211f4870371 46 short _cols;
Decimus 0:f211f4870371 47 short _rows;
Decimus 0:f211f4870371 48 float* _data;
Decimus 0:f211f4870371 49 LocalFileSystem _local;
Decimus 0:f211f4870371 50 };
Decimus 0:f211f4870371 51
Decimus 0:f211f4870371 52 #endif