Mosaic
Well-Known Member
I searched the forum and couldn't quite find a utility i needed...so I built this 16F code.
It allows easy character conversion on the fly from a look up table.
Input is ASCII in wreg...returns a com cathode 7 segment bit pattern.
Special handling for spaces, underscores, dashes & @ sign.
Handles 0-9 Numeric and alphabet @-z (lower case)
Note that some letters k,m,v,w,x, don't display well.
Hope it's useful to others.
It allows easy character conversion on the fly from a look up table.
Input is ASCII in wreg...returns a com cathode 7 segment bit pattern.
Special handling for spaces, underscores, dashes & @ sign.
Handles 0-9 Numeric and alphabet @-z (lower case)
Note that some letters k,m,v,w,x, don't display well.
Hope it's useful to others.
Code:
ASCIIto7seg;
movwf Tmp
sublw 0x2d
skpnz
goto Dash
movf Tmp,w
sublw 0x20
skpnz
goto Spc
movf Tmp,w
sublw 0x5f
skpnz
goto Underscore
movf Tmp,w
btfsc Tmp,6 ; skip next if numerals, else
goto alphabet
andlw b'00001111' ; as numerals 30h - 39h ascii
addwf PCL,f ; offset prog counter to lookup which # to be displayed
retlw 0x3f ; code for 0, bit 7 is the dot. Common cathode. Invert values then clr bit 7 (dot) for common anode.
retlw 0x06; 1
retlw 0x5b; 2
retlw 0x4f ;3
retlw 0x66 ;4
retlw 0x6d ;5
retlw 0x7d ;6
retlw 0x07 ;7
retlw 0x7f ;8
retlw 0x67 ;9
alphabet;
andlw b'00011111'; as alphabet >= 60h ascii
addwf PCL,f
retlw 0x80; return a decimal rather than @ sign.
retlw 0x77 ;A
retlw 0x7c ;b
retlw 0x58 ;c
retlw 0x5e ;d
retlw 0x79 ;E
retlw 0x71 ;F
retlw 0x3D ;G
retlw 0x74 ;h
retlw 0x10 ;i
retlw 0x0e;j
retlw 0x70;k - avoid
retlw 0x38; L
retlw 0x37;m - avoid
retlw 0x54 ;n
retlw 0x5c;o
retlw 0x73 ;P
retlw 0x67;q =>like 9
retlw 0x50 ;r
retlw 0x6d;S =>like 5
retlw 0x78;t
retlw 0x3e ;U
retlw 0x62;v => like a superscript u.
retlw 0x7e; w - avoid
retlw 0x76;x => avoid, like H
retlw 0x6e; y
retlw 0x5b; z => like 2
Underscore;
retlw 0x08; underscore
Dash;
retlw .64; -
Spc;
retlw 0x00;