tested software encoder
This commit is contained in:
1 parent
97114cb54d
commit
2e61dab738
6 files changed
+68
-10
No files matched your search
@@ -65,12 +65,15 @@ static voidFuncPtr _pina_irq_ptr[SW_ROTARY_ENCODER_MAX_INSTANCE] =
|
||||
_pina_irqn_4, _pina_irqn_5, _pina_irqn_6, _pina_irqn_7
|
||||
};
|
||||
|
||||
bool SwRotaryEncoder::begin(void)
|
||||
bool SwRotaryEncoder::begin(uint8_t pina, uint8_t pinb)
|
||||
{
|
||||
// Add to pointer array
|
||||
VERIFY ( _encoder_count < SW_ROTARY_ENCODER_MAX_INSTANCE);
|
||||
_encoder_ptr[_encoder_count] = this;
|
||||
|
||||
_pina = pina;
|
||||
_pinb = pinb;
|
||||
|
||||
pinMode(_pina, INPUT);
|
||||
pinMode(_pinb, INPUT);
|
||||
|
||||
@@ -81,6 +84,11 @@ bool SwRotaryEncoder::begin(void)
|
||||
_encoder_count++;
|
||||
}
|
||||
|
||||
void SwRotaryEncoder::stop(void)
|
||||
{
|
||||
detachInterrupt(_pina);
|
||||
}
|
||||
|
||||
int32_t SwRotaryEncoder::read(void)
|
||||
{
|
||||
int32_t ret = _abs - _last_read;
|
||||
@@ -116,6 +124,8 @@ void SwRotaryEncoder::_irq_handler(void)
|
||||
{
|
||||
_abs--;
|
||||
}
|
||||
|
||||
_a_last = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user