Akifumi Takahashi / CubicSpline

Fork of TRP105F_Spline by Akifumi Takahashi

Revision:
1:2053662b1167
Parent:
0:e85788b14028
Child:
2:40ae18445079
diff -r e85788b14028 -r 2053662b1167 TRP105F_Spline.h
--- a/TRP105F_Spline.h	Fri Feb 12 11:02:15 2016 +0000
+++ b/TRP105F_Spline.h	Tue Feb 16 07:52:38 2016 +0000
@@ -17,7 +17,7 @@
  *      Distance data type has become unsigned short from int.
  *      Distance data range : [2:20] by 1 -> [0:1024] by 1.
  *  ver.2.1 2016/02.12 -
- *      Distance data range : [0:1024] -> [0:256].
+ *      Distance data range : [0:1024] -> [0:255].
  */
 #ifndef TRP105F_Spline_H
 #define TRP105F_Spline_H
@@ -31,7 +31,7 @@
     unsigned short dst; //  distance
 } VDset;
 
-//  Type of modality to input data   
+//  Type of modality to input data for calibration
 enum DataInType{
     KEYBORD,    //  set this if input data by 0-9 key
     SYSTEM      //  set this if any other input method, for instance, like GUI.
@@ -40,15 +40,16 @@
 //
 //  TRP105FS Class for get distance from voltage
 /////////////////////////////////////////////////////////////////////////////////
-////    At calibration, at sampling data, first the class send '>' via seral com, 
-////  after which You can send distancedata [2,20][mm]. Then the class measure
-////  the voltage data for 1 sec.
-////    Above procedure is looped for the number you input in the constructor.
+////    At calibration, at sampling data, first the class send '>' via serial com, 
+////  after which You can send distance data [0:255](in ver2.2). 
+////    Then the class measure the voltage data for 1 sec.
+////    Above procedure is looped for the number you input as 1st arg of the constructor.
 ////------------------------------------------
 ////    (when TRP105FS object is made)
 ////    >               (< you can input distance data after this signal('>' <=> 0x3e)
-////    >1              (< in this version, distance data is limited[2,20] integer.
-////    >14[CR or LF]   (< you can continue to input unless input ERNTER. But if you set [SYSTEM] on constructor you can input it only once. (use this in GUI)
+////    >1              (< distance data is limited in [0:255](in ver2.2) on integer.
+////    >14[CR or LF]   (< you can continue to input unless input ERNTER([CR or LF]). 
+////                    (   But if you set [SYSTEM] on constructor, you can input it only once. (use this in GUI)
 ////    >14             (< then voltage mesuring begins.
 ////                    (< after mesuring voltage, CR or LF signal is sent, which means tt is started a new line if console.
 ////    >               (< when you shoud input more data, ':'signal is sent again.
@@ -56,25 +57,34 @@
 class TRP105FS
 {
 public:
+    //  Constraction
     TRP105FS();
     TRP105FS(unsigned int);
     TRP105FS(unsigned int arg_num, DataInType arg_dit);
+    //  Destraction
     ~TRP105FS();
+    //  Functions
     unsigned short getDistance();  //  the fuction to get distance.
     void    calibrateSensor();
     void    saveSetting();
-    void    saveSetting(const char *filename);//not usable yet
+    void    saveSetting(const char *filename);
     void    loadSetting();
-    void    loadSetting(const char *filename);//not usable yet
+    void    loadSetting(const char *filename);
     void    printOutData();
     void    printThresholds();
 
 private:
+    //
+    //  Defining Constants
+    //
     enum _SetConstant {
         _LIDX = 0,
-        _RIDX = 1024,
+        _RIDX = 255,
         _ENUM = _RIDX - _LIDX + 1
     };
+    //
+    //  Variables
+    //
     int     _Sample_Num;    // the number of samples for derive spline
     VDset*  _Sample_Set;
     VDset   _Set[_ENUM];
@@ -92,7 +102,8 @@
     //
     int     _getNearest(int, int, unsigned short);
     //
-    //For debug
+    //  For debug
+    //
     void    _printOutData(unsigned short    *arg, int num, char* name);
     void    _printOutData(VDset             *arg, int num, char* name);
     void    _printOutData(double            *arg, int num, char* name);