Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NHK2019_mae_v6 NHK2019_main_v6 NHK2019_usiro_v6 NHK2019_mae_v6 ... more
Revision 4:004bdb88ab3e, committed 2019-08-29
- Comitter:
- skouki
- Date:
- Thu Aug 29 02:20:25 2019 +0000
- Parent:
- 3:26e2cfa5a983
- Child:
- 5:022e7ea6eea9
- 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();