ichinoseki_Bteam_2019 / SPI_Encoder

Dependents:   ArmNode

Files at this revision

API Documentation at this revision

Comitter:
Kirua
Date:
Thu Sep 26 15:21:39 2019 +0000
Parent:
4:2331b7fcfe8d
Commit message:
fix

Changed in this revision

SPI_Encoder.cpp Show annotated file Show diff for this revision Revisions of this file
SPI_Encoder.h Show annotated file Show diff for this revision Revisions of this file
--- a/SPI_Encoder.cpp	Thu Sep 26 13:49:51 2019 +0000
+++ b/SPI_Encoder.cpp	Thu Sep 26 15:21:39 2019 +0000
@@ -47,8 +47,8 @@
         EncoderByteData  += temp[1];
         
         if(!direction[num]) _angle = EncoderByteData / 4096.0f * 2.0f * PI;    //normal
-        else _angle = abs((EncoderByteData / 4096.0f * 2.0f * PI) - 2.0f*PI);  //inverse
-        if(_angle > PI) angle[num] = _angle - 2*PI;                            //0~2π → -π~π
+        else _angle = abs((EncoderByteData / 4096.0f * 2.0f * PI) - 2.0f * PI);  //inverse
+        if(_angle > PI) angle[num] = _angle - 2 * PI;                            //0~2π → -π~π
         else angle[num] = _angle;
         
         velocity[num] = (angle[num] - pre_angle) / delta_t;
--- a/SPI_Encoder.h	Thu Sep 26 13:49:51 2019 +0000
+++ b/SPI_Encoder.h	Thu Sep 26 15:21:39 2019 +0000
@@ -4,7 +4,7 @@
 #include "mbed.h"
 
 #define encoder_num 4
-#define PI 3.14159265359f
+#define PI 3.1415f
 
 
 /* cui amt203 */