Yeah, that's kinda what I need it for, highlighting. I guess I'll meddle around with it a bit to see what I can find, but in the end there's the ability to create custom characters if I've read it correctly.
1234567890123456 (character counts, does not print)
MAJOR MENU TITLE L1
ITEM ONE L2
> ITEM TWO L3
ITEM THREE L4
1234567890123456
UPDATE ITEM: L1
L2
12:12:12 L3
^ L4
The Yen symbol instead of a \ is a nuisance but you can use other spinners.One thing I didn't like is when doing a spinning line animation using the characters: | \ - / - seems the \ character isn't there, you have to make it custom.
/* C18 spinner defines , characters are repeated for simple fast/slow timing adjustment */
#define MAX_SHAPES 6
const rom char spin[MAX_SHAPES][20] = {
"||//--", // classic LCD version with no \ character
"||//--\\\\", // classic
"OOOOOO--__-", // eye blink
"vv<<^^>>", // point spinner
"**x#x#XX||--", // warp portal
"..ooOOoo" // ball bouncer
};
I've seen this method before and my analysis was similar;Wether you do the encoder in an interrupt or polled in the main loop depends on how fast the encoder changes and how fast your loop can poll the inputs.
Presumably you are interrupting on change. In the example below I was polling.
I did this on a PIC a few years ago and so I dug up some of my notes. I started by drawing a state diagram of the encoder sequence (see attached). To guard against spurious miss-counting I identified some "no-change" and error transitions. I then used a computed GOTO in the code to increment or decrement a counter depending on the state of 4 inputs (A,/A,B,/B). Hope this helps (and makes sense!).
Rich (BB code):;Computed GOTO for encoder state diagram. ;Arrive here with offset in W. LookUp ANDLW H'0F' ;Mask out high bits ADDWF PCL,F ;Add W to the program counter GOTO NoCh ;0000 No change GOTO Dec ;0001 Link 5 (decrement) GOTO Inc ;0010 Link 1 (increment) GOTO NoCh ;0011 ERROR GOTO Inc ;0100 Link 4 (increment) GOTO NoCh ;0101 No change GOTO NoCh ;0110 ERROR GOTO Dec ;0111 Link 6 (decrement) GOTO Dec ;1000 Link 8 (decrement) GOTO NoCh ;1001 ERROR GOTO NoCh ;1010 No change GOTO Inc ;1011 Link 2 (increment) GOTO NoCh ;1100 ERROR GOTO Inc ;1101 Link 3 (increment) GOTO Dec ;1110 Link 7 (decrement) GOTO NoCh ;1111 No change
;
; XOR 'old' and 'new' AB values and exclude readings with
; a '00' (same) or '11' (skip) result. XOR 'new' A or B
; bit with opposite 'old' bit for direction (0 or 1).
;
; old new <-- dec inc -->
; AB AB --- -------
; 00^00 = 00 (same) A | |
; 00^01 = 01 ( -1) -------
; 00^10 = 10 ( +1) ------- ---
; 00^11 = 11 (skip) B | |
; 01^00 = 01 ( +1) -------
; 01^01 = 00 (same) ^ ^ ^ ^ ^
; 01^10 = 11 (skip) 0 1 2 3 0
; 01^11 = 10 ( -1)
; 10^00 = 10 ( -1)
; 10^01 = 11 (skip)
; 10^10 = 00 (same)
; 10^11 = 01 ( +1)
; 11^00 = 11 (skip)
; 11^01 = 10 ( +1)
; 11^10 = 01 ( -1)
; 11^11 = 00 (same)
;
;******** Port B Change Interrupt **********
;
; (A) 11 words shorter
; (B) uses one less variable
; (C) isochronous at 19 cycles
; (D) eliminates non-boundary-tolerant table
;
k8lh
movf PORTB,W ; get new AB, clear mismatch
bcf INTCON,RBIF ; clear IOC interrupt flag
andlw 0xC0 ; only RB7 and RB6 bits
xorwf encold,W ; no change?
skpz ; yes, skip, else
xorlw 0xC0 ; both changed?
skpnz ; no, skip, else
goto isrexit ; exit (invalid step)
xorlw 0xC0 ; restore new AB bits
xorwf encold,W ; restore new AB bits
rlf encold,F ; encold.7 = old B bit
xorwf encold,F ; encold.7 = new A ^ old B
rlf encold,F ; put bit 7 (dir) into C
movwf encold ; update encoder latch
movlw 1 ;
skpnc ;
movlw -1 ;
addwf _encinc,F ;
bsf rawrdy ;
isrexit
by Aaron Carman
by Jake Hertz
by Jake Hertz
by Jeff Child