9/10
Revision 5:b78f031b66f7, committed 2021-09-10
- Comitter:
- oshin1030
- Date:
- Fri Sep 10 08:55:09 2021 +0000
- Parent:
- 4:1ee3f6183111
- Commit message:
- 9/10;
Changed in this revision
AMT21.cpp | Show annotated file Show diff for this revision Revisions of this file |
AMT21.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/AMT21.cpp Wed Apr 14 12:18:56 2021 +0000 +++ b/AMT21.cpp Fri Sep 10 08:55:09 2021 +0000 @@ -56,25 +56,34 @@ receive_mode=RECEIVE_TURN; sendMessage(); wait_us(190); - int turn,receive_; + int turn_,receive_; receive_=((high_turn&0b00111111)<<8)+low_turn; if(receive_>th_max&&receive_old<th_min) {//ターン数がアンダーフローしたとき flow_count--; } else if(receive_<th_min&&receive_old>th_max) { //ターン数がオーバーフローした場合 flow_count++; } - turn=receive_+flow_count*RESOLUTION_AMT21; + turn_=receive_+flow_count*RESOLUTION_AMT21; receive_old=receive_; - return turn; + return turn_; } -void Amt21::rewriteCount() +void Amt21::rewriteCount_1() { - int count,turn; + int count,turn_; count=getAbCount(); wait_us(200); - turn=getTurn(); - count_=count+RESOLUTION_AMT21*turn; + turn_=getTurn(); + count_=-(count+RESOLUTION_AMT21*turn_); } +void Amt21::rewriteCount_2() +{ + int count,turn_; + count=getAbCount(); + wait_us(200); + turn_=getTurn(); + count_=count+RESOLUTION_AMT21*turn_; +} + int Amt21::getCount() { return count_;
--- a/AMT21.h Wed Apr 14 12:18:56 2021 +0000 +++ b/AMT21.h Fri Sep 10 08:55:09 2021 +0000 @@ -50,7 +50,8 @@ Timer timer_; - void rewriteCount();//1周期に1度呼び出す。 + void rewriteCount_1();//1周期に1度呼び出す。 + void rewriteCount_2();//1周期に1度呼び出す。 int getCount();//インクリメント型のカウントと同じように使えて、-のカウントや16383以上のカウントを返す。 double getDeg();//角度[°]を返す double getRad();//角度[rad]を返す