Skip to content

Commit

Permalink
added Andreas Lekas as a contributor and merged some of his changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
medecau committed Feb 3, 2013
2 parents ccd4053 + e6cefd3 commit 48aee81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion QuadEncoder.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
/** /**
* QuadEncoder.cpp - Library for reading moves from a quadrature rotary encoder * QuadEncoder.cpp - Library for reading moves from a quadrature rotary encoder
* Created by Pedro Rodrigues (medecau@gmail.com) 9, January of 2010 * Created by Pedro Rodrigues (medecau@gmail.com) 9, January of 2010
* Modified by Andreas Lekas (spadusa@gmail.com) 31, January, 2010
* Released into the public domain. * Released into the public domain.
* Updated by Scottapotamas scott@26oclock.com for arduino 1.0 ice * Updated by Scottapotamas scott@26oclock.com for arduino 1.0 ice
*/ */
Expand All @@ -24,11 +25,11 @@ QuadEncoder::QuadEncoder(int pin1, int pin2)
_oldPos=0; _oldPos=0;
_turn=0; _turn=0;
_turnCount=0; _turnCount=0;

} }


char QuadEncoder::tick() char QuadEncoder::tick()
{ {
_moved = false;
_val1 = digitalRead(_inputPin1); _val1 = digitalRead(_inputPin1);
_val2 = digitalRead(_inputPin2); _val2 = digitalRead(_inputPin2);
// Detect changes // Detect changes
Expand Down Expand Up @@ -61,11 +62,14 @@ char QuadEncoder::tick()
if (_pos==0){ if (_pos==0){
if (_turnCount>0){ if (_turnCount>0){
_turnCount=0; _turnCount=0;
_moved = true;
return '>'; return '>';
} else if (_turnCount<0){ } else if (_turnCount<0){
_moved = true;
_turnCount=0; _turnCount=0;
return '<'; return '<';
} else { } else {
_moved = false;
_turnCount=0; _turnCount=0;
return '-'; return '-';
} }
Expand Down
1 change: 1 addition & 0 deletions QuadEncoder.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class QuadEncoder
QuadEncoder(int pin1, int pin2); QuadEncoder(int pin1, int pin2);
char tick(); char tick();
private: private:
bool _moved;
int _inputPin1; int _inputPin1;
int _inputPin2; int _inputPin2;
int _val1; int _val1;
Expand Down

0 comments on commit 48aee81

Please sign in to comment.