|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/*
|
|
|
|
|
MD_REncoder - Library for Rotary Encoders |
|
|
|
|
MD_REncoderPlus - Library for Rotary Encoders |
|
|
|
|
|
|
|
|
|
See header file for comments |
|
|
|
|
|
|
|
|
@ -25,9 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file |
|
|
|
|
* \brief Implements core MD_REncoder class methods |
|
|
|
|
* \brief Implements core MD_REncoderPlus class methods |
|
|
|
|
*/ |
|
|
|
|
#include <MD_REncoder.h> |
|
|
|
|
#include <MD_REncoderPlus.h> |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The below state table has, for each state (row), the new state |
|
|
|
@ -77,7 +77,7 @@ const unsigned char ttable[][4] = |
|
|
|
|
}; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
MD_REncoder::MD_REncoder(uint8_t pinA, uint8_t pinB): |
|
|
|
|
MD_REncoderPlus::MD_REncoderPlus(uint8_t pinA, uint8_t pinB): |
|
|
|
|
_pinA (pinA), _pinB (pinB), _state(R_START) |
|
|
|
|
#if ENABLE_SPEED |
|
|
|
|
, _period(DEFAULT_PERIOD), _count(0), _spd(0), _timeLast(0) |
|
|
|
@ -85,7 +85,7 @@ _pinA (pinA), _pinB (pinB), _state(R_START) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MD_REncoder::begin(void) |
|
|
|
|
void MD_REncoderPlus::begin(void) |
|
|
|
|
{ |
|
|
|
|
pinMode(_pinA, (ENABLE_PULLUPS ? INPUT_PULLUP : INPUT)); |
|
|
|
|
pinMode(_pinB, (ENABLE_PULLUPS ? INPUT_PULLUP : INPUT)); |
|
|
|
@ -93,7 +93,7 @@ void MD_REncoder::begin(void) |
|
|
|
|
last_dir=DIR_NONE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void MD_REncoder::update(void)
|
|
|
|
|
void MD_REncoderPlus::update(void)
|
|
|
|
|
// Grab state of input pins, determine new state from the pins
|
|
|
|
|
// and state table, and return the emit bits (ie the generated event).
|
|
|
|
|
{ |
|
|
|
@ -125,12 +125,12 @@ void MD_REncoder::update(void) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t MD_REncoder::read_value(void) |
|
|
|
|
int32_t MD_REncoderPlus::read_value(void) |
|
|
|
|
{ |
|
|
|
|
return (value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int8_t MD_REncoder::read(void) |
|
|
|
|
int8_t MD_REncoderPlus::read(void) |
|
|
|
|
{ |
|
|
|
|
switch(last_dir) |
|
|
|
|
{ |
|
|
|
@ -145,7 +145,7 @@ int8_t MD_REncoder::read(void) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MD_REncoder::write(int32_t v)
|
|
|
|
|
void MD_REncoderPlus::write(int32_t v)
|
|
|
|
|
{ |
|
|
|
|
value=v; |
|
|
|
|
} |