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.
Revision 5:1458a8f024dc, committed 2019-09-26
- 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 */