comparison projects/loggingSensors/render.cpp @ 157:f36313cbb55d

Added capability to WriteFile to save binary files, added example project
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 13 Oct 2015 02:01:05 +0100
parents
children 048b7a4dc841
comparison
equal deleted inserted replaced
156:89f28a867a09 157:f36313cbb55d
1 #include <BeagleRT.h>
2 #include <Scope.h>
3 #include <cmath>
4 #include <WriteFile.h>
5
6 WriteFile file1;
7 WriteFile file2;
8
9 bool setup(BeagleRTContext *context, void *userData)
10 {
11 file1.init("out.bin"); //set the file name to write to
12 file1.setEchoInterval(1000);
13 file1.setFileType(kBinary);
14 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
15 file2.init("out.m"); //set the file name to write to
16 file2.setHeader("myvar=[\n"); //set one or more lines to be printed at the beginning of the file
17 file2.setFooter("];\n"); //set one or more lines to be printed at the end of the file
18 file2.setFormat("%.4f\n"); // set the format that you want to use for your output. Please use %f only (with modifiers)
19 file2.setFileType(kText);
20 file2.setEchoInterval(10000); // only print to the console 1 line every other 10000
21 return true;
22 }
23
24 void render(BeagleRTContext *context, void *userData)
25 {
26 for(unsigned int n = 0; n < context->analogFrames; n++) {
27 file1.log(&(context->analogIn[n*context->analogFrames]), 2); // log an array of values
28 file2.log(context->analogIn[n*context->analogFrames]); // log a single value
29 }
30 }
31
32 // cleanup_render() is called once at the end, after the audio has stopped.
33 // Release any resources that were allocated in initialise_render().
34
35 void cleanup(BeagleRTContext *context, void *userData)
36 {
37
38 }