Mercurial > hg > beaglert
annotate projects/loggingSensors/render.cpp @ 237:048b7a4dc841
Minor fixes
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 10 Apr 2016 12:23:36 +0200 |
parents | f36313cbb55d |
children |
rev | line source |
---|---|
giuliomoro@157 | 1 #include <BeagleRT.h> |
giuliomoro@157 | 2 #include <cmath> |
giuliomoro@157 | 3 #include <WriteFile.h> |
giuliomoro@157 | 4 |
giuliomoro@157 | 5 WriteFile file1; |
giuliomoro@157 | 6 WriteFile file2; |
giuliomoro@157 | 7 |
giuliomoro@157 | 8 bool setup(BeagleRTContext *context, void *userData) |
giuliomoro@157 | 9 { |
giuliomoro@157 | 10 file1.init("out.bin"); //set the file name to write to |
giuliomoro@157 | 11 file1.setEchoInterval(1000); |
giuliomoro@157 | 12 file1.setFileType(kBinary); |
giuliomoro@157 | 13 file1.setFormat("%.4f %.4f\n"); // set the format that you want to use for your output. Please use %f only (with modifiers). When in binary mode, this is used only for echoing to console |
giuliomoro@157 | 14 file2.init("out.m"); //set the file name to write to |
giuliomoro@157 | 15 file2.setHeader("myvar=[\n"); //set one or more lines to be printed at the beginning of the file |
giuliomoro@157 | 16 file2.setFooter("];\n"); //set one or more lines to be printed at the end of the file |
giuliomoro@157 | 17 file2.setFormat("%.4f\n"); // set the format that you want to use for your output. Please use %f only (with modifiers) |
giuliomoro@157 | 18 file2.setFileType(kText); |
giuliomoro@157 | 19 file2.setEchoInterval(10000); // only print to the console 1 line every other 10000 |
giuliomoro@157 | 20 return true; |
giuliomoro@157 | 21 } |
giuliomoro@157 | 22 |
giuliomoro@157 | 23 void render(BeagleRTContext *context, void *userData) |
giuliomoro@157 | 24 { |
giuliomoro@157 | 25 for(unsigned int n = 0; n < context->analogFrames; n++) { |
giuliomoro@157 | 26 file1.log(&(context->analogIn[n*context->analogFrames]), 2); // log an array of values |
giuliomoro@157 | 27 file2.log(context->analogIn[n*context->analogFrames]); // log a single value |
giuliomoro@157 | 28 } |
giuliomoro@157 | 29 } |
giuliomoro@157 | 30 |
giuliomoro@157 | 31 // cleanup_render() is called once at the end, after the audio has stopped. |
giuliomoro@157 | 32 // Release any resources that were allocated in initialise_render(). |
giuliomoro@157 | 33 |
giuliomoro@157 | 34 void cleanup(BeagleRTContext *context, void *userData) |
giuliomoro@157 | 35 { |
giuliomoro@157 | 36 |
giuliomoro@157 | 37 } |