4x20 LCD Big Numbers

Jamster

Senior Member
Can you supply the code in [noparse]
Code:
[/noparse] tags so we can copy and paste to the PE please :)
 

shakespeare

New Member
Yeah, sorry about that, publishing in pieces here.

I'll post the circuit diagram shortly (Still got to scan it in). In the meantime, the program is here:
Code:
symbol e=5
symbol rs=4
symbol bbit=3
symbol lbit=2
symbol twoline=8
symbol scroncron=14
symbol clr=3
symbol redled=7
symbol redpb=pin0
symbol whtpb=pin7
symbol yelpb=pin2
symbol tbout=6
symbol serpin=6
symbol char=b2
symbol index=b3
symbol Line1=0
symbol Line2=64
symbol Line3=20
symbol Line4=84
symbol SetDDRam=128
symbol ShiftLeft=24
symbol ShiftRight=30
symbol bnum=b4
symbol defidx=b5
symbol numadr=b6
symbol bchr=b7
symbol tnumadr=b8
symbol cpos=b9
symbol coff=b10
symbol idx2=b11
symbol total=b12
symbol wtotal=b13

'Initialise IO
	dirsb=%11111111
	dirsc=%00001000


'Initialise display unit

init:
	let pins = 0		   'Clear all output lines
	pause 200 			'Wait 200 ms for LCD to reset.
	let pins = bbit		'Set to 8-bit operation
	pulsout e,1
	pause 10 			 'Wait 10 ms
	pulsout e,1 		   'Send data again
	pulsout e,1
	let pins = lbit		'Set to 4-bit operation.
	pulsout e,1
	pulsout e,1 		   'Send data again.
	let pins = twoline	  'Set to two line operation
	pulsout e,1
	let char = scroncron	'Screen on, cursor on instruction
	gosub wrins 
	char=clr
	gosub wrins
	
start:	'set cursor flag to line 1 col 1
	cpos=146
	
	'Define CG0 to 7:
	eeprom (31,31,0,0,0,0,0,0)
	eeprom (0,0,0,0,0,0,31,31)
	eeprom (24,24,24,24,24,24,24,24)
	eeprom (3,3,3,3,3,3,3,3)
	eeprom (3,7,14,28,24,24,24,24)
	eeprom (24,28,14,7,3,3,3,3)
	eeprom (24,24,24,24,28,14,7,3)
	eeprom (3,3,3,3,7,14,28,24)

	char=64
	gosub wrins
	
	for index=0 to 63
		read index,char
		gosub wrchr
	next
	
	'Go back to DDRam
	
	char=cpos
	gosub wrins
	
	'Define bignum data 0 to 9
	eeprom (86,52,52,120)	'0
	eeprom (3,3,3,3)		'1
	eeprom (86,8,80,114)	 '2
	eeprom (86,8,6,120)	  '3
	eeprom (52,120,4,4)	  '4
	eeprom (81,112,6,120)	'5
	eeprom (86,48,86,120)	'6
	eeprom (22,4,4,4)	    '7
	eeprom (86,120,86,120)    '8
	eeprom (86,120,4,120)	'9
	
	'display title
	
	char=128
	gosub wrins
	
	eeprom 200,("BIG COUNT   ")
	
	for index=200 to 211
		read index, char
		gosub wrchr
	next
	
	'Display a count from 000 to 255
main:
	for index=0 to 255
		total=index
		for idx2=1 to 3
			wtotal=total % 10
			total=total/10
			bnum=wtotal
			gosub wrbig
		next
		pause 200
		cpos=146
		char=cpos
		gosub wrins
	next

	goto main 	'loop



wrchr:
	if char<255 then skipconvspc
	char=32

skipconvspc:
	gosub wrbyte		'Send High nibble and set up low nibble
	high rs			'Make sure RS is high
	pulsout e,1 		'Pulse enable pin to send data.
	return

wrins:
	gosub wrbyte		'Send High nibble and set up low nibble
	pulsout e,1 		'Pulse enable pin to send data.
	return

wrbyte:
	let pins = char/16    'High nibble of char to outputs 0 to 3
	pulsout e,1 		'Pulse the enable pin to send data.
	let pins = char & 15  'Low nibble of char to outputs 0 to 3
	return

wrbig:	'find start of definintion for 'bnum'

	numadr=bnum*4+64
	
	'write char out
	for defidx=0 to 3
		tnumadr=numadr+defidx
		read tnumadr,bchr	'read byte with next two halves of the line
		char=bchr/16-1	   'write high nibble as CG
		gosub wrchr
		char=bchr & 15-1	 'write low nibble as CG
		gosub wrchr
		lookup defidx,(64,20,84,0),coff
		char=cpos+coff
		gosub wrins
	next
	
	'restore to next position in line 1
	cpos=cpos-3
	char=cpos
	gosub wrins
	return
 
Top