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.
Fork of QEI by
Revision 1:bce581f398eb, committed 2018-08-13
- Comitter:
- CodyMarquardt
- Date:
- Mon Aug 13 18:49:19 2018 +0000
- Parent:
- 0:5c2ad81551aa
- Commit message:
- also mini glider
Changed in this revision
| QEI.cpp | Show annotated file Show diff for this revision Revisions of this file |
| QEI.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5c2ad81551aa -r bce581f398eb QEI.cpp
--- a/QEI.cpp Thu Sep 02 16:48:55 2010 +0000
+++ b/QEI.cpp Mon Aug 13 18:49:19 2018 +0000
@@ -127,6 +127,8 @@
* Includes
*/
#include "QEI.h"
+#include "PololuHBridge.hpp"
+#include "mbed.h"
QEI::QEI(PinName channelA,
PinName channelB,
@@ -170,16 +172,27 @@
pulses_ = 0;
revolutions_ = 0;
+}
+void QEI::check(float BE_array[], float _BE_mm){
+ BE_array[4] = BE_array[3];
+ BE_array[3] = BE_array[2];
+ BE_array[2] = BE_array[1];
+ BE_array[1] = BE_array[0];
+ BE_array[0] = _BE_mm;
+ if (BE_array[4] - BE_array[0] == 0){
+ BE_array[0] = 999;
+ }
}
+
int QEI::getCurrentState(void) {
return currState_;
}
-int QEI::getPulses(void) {
+float QEI::getPulses(void) {
return pulses_;
@@ -250,14 +263,14 @@
if ((prevState_ == 0x3 && currState_ == 0x0) ||
(prevState_ == 0x0 && currState_ == 0x3)) {
- pulses_++;
+ pulses_--;
}
//10->01->10->01 is clockwise rotation or "backward".
else if ((prevState_ == 0x2 && currState_ == 0x1) ||
(prevState_ == 0x1 && currState_ == 0x2)) {
- pulses_--;
+ pulses_++;
}
diff -r 5c2ad81551aa -r bce581f398eb QEI.h
--- a/QEI.h Thu Sep 02 16:48:55 2010 +0000
+++ b/QEI.h Mon Aug 13 18:49:19 2018 +0000
@@ -199,7 +199,7 @@
*
* @return Number of pulses which have occured.
*/
- int getPulses(void);
+ float getPulses(void);
/**
* Read the number of revolutions recorded by the encoder on the index channel.
@@ -207,6 +207,9 @@
* @return Number of revolutions which have occured on the index channel.
*/
int getRevolutions(void);
+ float BE_array;
+ char _input1;
+ void check(float BE_array[], float _BE_mm);
private:
