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();
}

FileLog.h

Committer:
Decimus
Date:
2012-10-15
Revision:
0:f211f4870371

File content as of revision 0:f211f4870371:

/* 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.
 */

#ifndef MBED_FILELOG_H
#define MBED_FILELOG_H
  
#include "mbed.h"

class FileLog {

public:
    FileLog( short cols, short rows );

    /** Set new value to log
     *
     * @param value Value of log entry.
     */
    void log( float value );

    /**  Save log to file
     *
     */
    void save();
        
protected:
    short _data_idx;
    short _cols;
    short _rows;
    float* _data;
    LocalFileSystem _local;
};

#endif