Skip to content

Commit 1c3ee01

Browse files
committed
Fix _irq_handler
I'm working on a project that has 3 rotary encoders. When I used this libary, I couldn't get the 3 switches to properly increment / decrement the steps when I called readAbs(). Looking back at the code, I see there was a change in 351cd82 which seemed to have caused the issue. If I look previous to 351cd82, the _irq_handler was using digitalRead. I think switching to bitRead caused a mix up between the physical pin number vs. the port pin? I'm not entirely sure. I reimplemented the pre 351cd82 code and used the new ada_callback. Seems to be working great now!
1 parent bf50479 commit 1c3ee01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libraries/RotaryEncoder/SwRotaryEncoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ void SwRotaryEncoder::clearAbs(void)
120120

121121
void SwRotaryEncoder::_irq_handler(void)
122122
{
123-
uint32_t val = NRF_GPIO->IN;
124-
uint8_t bita = bitRead(val, _pina);
123+
uint8_t bita = digitalRead(_pina);
124+
uint8_t bitb = digitalRead(_pinb);
125125

126126
if ( bita != _a_last)
127127
{
128128
int32_t step;
129129

130-
if ( bita != bitRead(val, _pinb) )
130+
if ( bita != bitb )
131131
{
132132
step = 1;
133133
}else

0 commit comments

Comments
 (0)