Henrik, inspired by your code. I got down to 6.4 - 8.6us:
Goes in initialization section:
Code:
Enc1_previous = %11111111
Enc1_Current = %00000000
Enc1_counter = 0
MainLoop:
Code:
MyLogic:
Enc1_Current = (Enc1_WiperA << 1) + Enc1_WiperB
IF Enc1_Current != Enc1_Previous THEN
IF Enc1_Current = %00000011 THEN
IF Enc1_Previous = %00000010 THEN
Enc1_counter = Enc1_counter + 1
ELSE
IF Enc1_Previous = %00000001 THEN
Enc1_counter = Enc1_counter - 1
ENDIF
ENDIF
ELSE
IF Enc1_Current = %00000000 THEN
IF Enc1_Previous = %00000001 THEN
Enc1_counter = Enc1_counter + 1
ELSE
IF Enc1_Previous = %00000010 THEN
Enc1_counter = Enc1_counter - 1
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
Enc1_Previous = Enc1_Current
BlinkLED1 = 0 ' Bottom of IFs on Logic 2 probe
GOSUB LCDoutput
goto mainloop
Since my encoder doesn't stop on 01 or 10, I only need to check 11 and 00. Already 3 times faster than my original.
EDIT: Updated times
Bookmarks