Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
The problem with these is that the programmers have optimized (or tried to optimize) the code to such a point that it can be a bit difficult to follow what is happening.Piclist is always a good start for code.
I found this there:-
http://www.piclist.org/techref/microchip/qenc.htm
; Check for an input change of state
movf gpio,w ; read inputs
xorwf LastEnc,w ; compare to previously saved encoder status
andlw 030h ; mask off all except bits 4 and 5
btfsc status,z ; zero flag is clear if encoder status has changed
goto EncEnd ; Skip around next section if no status change
;
; Encoder inputs have changed, so determine direction and update Counter
bcf STATUS,RP0 ; Sel Bank 0
rrf LastEnc,w ; get previous bit 5 value as bit 4
xorwf gpio,w ; and xor it with current bit 4
andlw 010h ; clear all but bit 4
btfss status,z ; increment (+1)
movlw 0feh ; decrement (-1)
addlw 1
addwf counter,f ; add to counter
movf gpio,w ; get current encoder status again
movwf LastEnc ; and save value for next time
EncEnd
; End of Encoder service section