comparison examples/loggingSensors/render.cpp @ 300:dbeed520b014 prerelease

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