GP2Y0A21YK0F IRsensor 用ライブラリ

Dependents:   IRsensor_sample 2019NHK_A_sensor 200_yotsuba_21

Files at this revision

API Documentation at this revision

Comitter:
skouki
Date:
Thu Aug 29 02:20:25 2019 +0000
Parent:
3:26e2cfa5a983
Commit message:
updata_Doxygen

Changed in this revision

IRsensor.cpp Show annotated file Show diff for this revision Revisions of this file
IRsensor.h Show annotated file Show diff for this revision Revisions of this file
--- a/IRsensor.cpp	Thu Aug 22 06:14:12 2019 +0000
+++ b/IRsensor.cpp	Thu Aug 29 02:20:25 2019 +0000
@@ -86,3 +86,8 @@
 {
     return distance_average;    
 }
+
+float IRsensor::getVoltage()
+{
+    return voltage;    
+}
\ No newline at end of file
--- a/IRsensor.h	Thu Aug 22 06:14:12 2019 +0000
+++ b/IRsensor.h	Thu Aug 29 02:20:25 2019 +0000
@@ -1,14 +1,68 @@
-#ifndef IRSENSOR_H
-#define IRSENSOR_H
+/**
+* @file IRsensor.h
+* @brief SHARP 2Y0A21を使ったIR距離測定
+*
+* Example :
+* @code
+* #include"mbed.h"
+* #include"IRsensor.h"
+* 
+* IRsensor ir1(PC_1);
+*
+* Serial pc(USBTX,USBRX,115200);
+*
+* int main()
+* {
+*    ir1.startAveraging(255);
+*    while(1){
+*        float dis = ir1.getDistance();
+*        float ave_dis = ir1.get_Averagingdistance();
+*        pc.printf("dis:%4.4f[cm]||ave_dis:%4.4f[cm]\n\r",dis,ave_dis);
+*        
+*    }   
+* }
+* @endcode
+*/
 
-#include "mbed.h"
+#ifndef IRSENSOR_H
+#define IRSENSOE_H
 
+#include"mbed.h"
+
+/**
+* @brief SHARP 2Y0A21を使ったIR距離測定のクラス
+*/
 class IRsensor{
  public:
+    /**
+     * @brief コンストラクタ
+     * @param pin Pint that can do analogin
+     */
     IRsensor(PinName pin);
+    
+    /**
+    * @brief センサの値を取得
+    * @return voltage
+    */
+    float getVoltage();
+    
+    /**
+    * @brief センサの値を距離変換し取得
+    * @return originaldistance
+    */
     float getDistance();
+    
+    /**
+    * @brief 距離の平均化設定
+    * @param averaging_range averaging range 1~255
+    */
+    void startAveraging(uint8_t averaging_range);
+    
+    /**
+    * @brief 平均化した距離を取得
+    * @return distance_average
+    */
     float get_Averagingdistance();
-    void startAveraging(uint8_t averaging_range);
 
 private:
     void threadloop_get_distance();