![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This drive is working well with "LPD3806-600BM-G5-24G", and have Simple program
Diff: Rotary_Encoder.cpp
- Revision:
- 3:6a91d523b146
- Parent:
- 0:b2ffb830539c
diff -r 7d34758c3cc4 -r 6a91d523b146 Rotary_Encoder.cpp --- a/Rotary_Encoder.cpp Fri Feb 08 07:11:22 2019 +0000 +++ b/Rotary_Encoder.cpp Tue Feb 19 05:31:32 2019 +0000 @@ -22,7 +22,27 @@ Encoder_Counter++; } -char *Rotary_Encoder::Calculate_Direction(void) +float Rotary_Encoder::Calculate_Direction(void) +{ + while(Encoder_Counter < -1200) + Encoder_Counter = Encoder_Counter + 1200; + while(Encoder_Counter > 1200) + Encoder_Counter = Encoder_Counter - 1200; + + if(Encoder_Counter <0 ) + { + Direction_Numb = ((Encoder_Counter / 1200.0) * 360.0f )+ 360.0f; + } + else + { + Direction_Numb = (Encoder_Counter / 1200.0) * 360.0f; + } + + return Direction_Numb; +} + + +char *Rotary_Encoder::Show_Direction_In_char(void) { // Data processing -2^32< "int" <2^32-1 while(Encoder_Counter < -1275) @@ -50,3 +70,6 @@ return Direction; } + + +