明石高専ロボ研 mbedライブラリ

Dependencies:   mbed

Revision:
3:28c77df7c0b6
Parent:
0:ca84ed7518f5
diff -r 141358d84ff4 -r 28c77df7c0b6 rotary_inc.cpp
--- a/rotary_inc.cpp	Fri Jan 03 02:37:48 2020 +0000
+++ b/rotary_inc.cpp	Mon Jan 06 11:06:26 2020 +0000
@@ -1,28 +1,28 @@
 #include "rotary_inc.hpp"
 
-RotaryInc::RotaryInc(PinName pinA, PinName pinB,int mode):mode_(mode){
+RotaryInc::RotaryInc(PinName pin_a, PinName pin_b,int mode):mode_(mode){
     measur_ = false;
-    init(pinA,pinB);
+    init(pin_a,pin_b);
 }
 
-RotaryInc::RotaryInc(PinName pinA,PinName pinB,double circumference,int resolution,int mode)
+RotaryInc::RotaryInc(PinName pin_a,PinName pin_b,double circumference,int resolution,int mode)
     :mode_(mode),resolution_(resolution),circumference_(circumference){
     measur_ = true;
-    init(pinA,pinB);
+    init(pin_a,pin_b);
 }
 
 void RotaryInc::init(PinName pinA,PinName pinB){
     reset();
-    A_ = new InterruptIn(pinA,PullUp);
-    B_ = new InterruptIn(pinB,PullUp);
-    A_->rise(callback(this,&RotaryInc::riseA));
+    pin_a_ = new InterruptIn(pinA,PullUp);
+    pin_b_ = new InterruptIn(pinB,PullUp);
+    pin_a_->rise(callback(this,&RotaryInc::riseA));
         
     if(mode_ == 2){
-        A_->fall(callback(this,&RotaryInc::fallA));
+        pin_a_->fall(callback(this,&RotaryInc::fallA));
     }else if(mode_ == 4){
-        A_->fall(callback(this,&RotaryInc::fallA));
-        B_->rise(callback(this,&RotaryInc::riseB));
-        B_->fall(callback(this,&RotaryInc::fallB));
+        pin_a_->fall(callback(this,&RotaryInc::fallA));
+        pin_b_->rise(callback(this,&RotaryInc::riseB));
+        pin_b_->fall(callback(this,&RotaryInc::fallB));
     }else{
         mode_ = 1;
     }
@@ -76,28 +76,28 @@
 }
 
 void RotaryInc::riseA(){
-    B_->read() ? pulse_-- : pulse_++;
+    pin_b_->read() ? pulse_-- : pulse_++;
     if(measur_){
         calcu();
     }
 }
 
 void RotaryInc::fallA(){
-    B_->read() ? pulse_++ : pulse_--;
+    pin_b_->read() ? pulse_++ : pulse_--;
     if(measur_){
         calcu();
     }
 }
 
 void RotaryInc::riseB(){
-    A_->read() ? pulse_++ : pulse_--;
+    pin_a_->read() ? pulse_++ : pulse_--;
     if(measur_){
         calcu();
     }
 }
 
 void RotaryInc::fallB(){
-    A_->read() ? pulse_-- : pulse_++;
+    pin_a_->read() ? pulse_-- : pulse_++;
     if(measur_){
         calcu();
     }
@@ -132,8 +132,8 @@
 }
 
 RotaryInc::~RotaryInc(){
-    A_->disable_irq();
-    B_->disable_irq();
-    delete A_;
-    delete B_;
+    pin_a_->disable_irq();
+    pin_b_->disable_irq();
+    delete pin_a_;
+    delete pin_b_;
 }
\ No newline at end of file