This lib is supposed to be used as a sensor's calibration or control program. This makes Cubic Spline Model from some sample plots(sets of (value, voltage)), and then discretize the model (dividing the range of voltage into some steps) in order to use the calibrated model data without getting the INVERSE function.
Diff: TRP105F_Spline.cpp
- Revision:
- 6:d2363b50aeaf
- Parent:
- 4:701f958d137a
- Child:
- 9:ec1ee4a6b6a4
--- a/TRP105F_Spline.cpp Mon Jun 06 10:28:37 2016 +0000 +++ b/TRP105F_Spline.cpp Mon Jun 06 13:09:41 2016 +0000 @@ -697,15 +697,14 @@ { FILE *fp; char *filepath; - char tmp; int fnnum = 0; while (filename[fnnum] != 0) fnnum++; filepath = (char *)malloc((fnnum + 8) * sizeof(char)); // "/local/" are 7 char and \0 is 1 char. sprintf(filepath, "/local/%s", filename); - fp = fopen(filepath, "rb"); - - fp = fopen("/local/log.txt", "w"); // open file in writing mode + fp = fopen(filepath, "w"); + //fp = fopen("/local/log.txt", "w"); // open file in writing mode + fprintf(fp, "x, y,(threshold)\n"); for(int i = 0; i < _ENUM; i++) { fprintf(fp, "%d,%d,(%d)\n", _Set[i].x, _Set[i].y, _Threshold[i]); @@ -714,6 +713,7 @@ for(int i = 0; i < _Sample_Num; i++) { fprintf(fp, "%d,%d\n", _Sample_Set[i].x, _Sample_Set[i].y); } + free(filepath); fclose(fp);