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.

Revision:
16:c2b0f3ca63dd
Parent:
15:1d643b831a03
Child:
18:b046bba4ffa7
--- a/TRP105F_Spline.cpp	Wed Jun 08 10:45:19 2016 +0000
+++ b/TRP105F_Spline.cpp	Wed Jun 08 11:32:29 2016 +0000
@@ -148,16 +148,6 @@
         return 0xFFFF;
 }
 
-unsigned short TRP105FS::getDistance(unsigned short arg_y)
-{
-    return getX(arg_y);
-}
-
-unsigned short TRP105FS::getDistance()
-{
-    return getX(_ai.read_u16());
-}
-
 /*
     Function to find a set whose y member is nearest a ytage from the sensor, recursively.
 
@@ -568,31 +558,6 @@
     }
 }
 
-void TRP105FS::saveSetting()
-{
-    FILE *fp;
-
-    fp = fopen("/local/savedata.log", "wb");
-
-    for(int i = 0; i < _ENUM; i++) {
-        fwrite(&_Set[i].x,    sizeof(unsigned short), 1, fp);
-        fputc(0x2c, fp);
-        fwrite(&_Set[i].y,    sizeof(unsigned short), 1, fp);
-        fputc(0x2c, fp);
-        fwrite(&_Threshold[i],  sizeof(unsigned short), 1, fp);
-        fputc(0x3b, fp);
-    }
-    fwrite(&_Sample_Num, sizeof(unsigned short), 1, fp);
-    fputc(0x3b, fp);
-    for(int i = 0; i < _Sample_Num; i++) {
-        fwrite(&_Sample_Set[i].x,    sizeof(unsigned short), 1, fp);
-        fputc(0x2c, fp);
-        fwrite(&_Sample_Set[i].y,    sizeof(unsigned short), 1, fp);
-        fputc(0x3b, fp);
-    }
-    fclose(fp);
-
-}
 
 #ifdef HAS_COM_TO_CONSOLE
 void TRP105FS::printThresholds()
@@ -631,6 +596,32 @@
 
 }
 
+void TRP105FS::saveSetting()
+{
+    FILE *fp;
+
+    fp = fopen("/local/savedata.log", "wb");
+
+    for(int i = 0; i < _ENUM; i++) {
+        fwrite(&_Set[i].x,    sizeof(unsigned short), 1, fp);
+        fputc(0x2c, fp);
+        fwrite(&_Set[i].y,    sizeof(unsigned short), 1, fp);
+        fputc(0x2c, fp);
+        fwrite(&_Threshold[i],  sizeof(unsigned short), 1, fp);
+        fputc(0x3b, fp);
+    }
+    fwrite(&_Sample_Num, sizeof(unsigned short), 1, fp);
+    fputc(0x3b, fp);
+    for(int i = 0; i < _Sample_Num; i++) {
+        fwrite(&_Sample_Set[i].x,    sizeof(unsigned short), 1, fp);
+        fputc(0x2c, fp);
+        fwrite(&_Sample_Set[i].y,    sizeof(unsigned short), 1, fp);
+        fputc(0x3b, fp);
+    }
+    fclose(fp);
+
+}
+
 void TRP105FS::loadSetting()
 {
     FILE *fp;