' SERLCD_1.BS2

' Illustrates various features of the PIC-n-LCD

' copyright, Peter H. Anderson, Feb, ‘98

	N_9600 CON $4000+84	' 9600 baud inverted

	T VAR BYTE	' variables
	P VAR BYTE
	N VAR BYTE

	DIRS = $0001	' make P0 an output
TOP:
	T = 74		' dummy up some variables for later display
	P = 30

	SEROUT 0, N_9600, [$0C]	' clear the LCD and locate cursor to upper
left
	PAUSE 1000		

	SEROUT 0, N_9600, [$19, $02]
				' define cursor as blinking block
				' $00 is no cursor, $01 is blinking block
				' $02 is underline, $03 is blinking block
				' and under line
		
	PAUSE 1000

	SEROUT 0, N_9600, ["Hello", $0A, $0D]
				' $0D - move cursor to extreme left
				' $0A - move cursor to next line
	SEROUT 0, N_9600, ["World", $0A, $0D]


	SEROUT 0, N_9600, ["T=", DEC T, $09, "P=", DEC P, $05, $0A, $0D]
				' display some variables, $09 is tab
				' $05 is save cursor

	SEROUT 0, N_9600, ["Rochanda", $06]
				' print some more text on line 4
				' restore cursor to the end of line 3

	PAUSE 4000
		
	
	SEROUT 0, N_9600, [$0C]		' clear the LCD
	SEROUT 0, N_9600, [$19, $00]	' disable cursor

	FOR N = 1 TO 20		' twirl a wheel
	    SEROUT 0, N_9600, 50, ["|", $03, "/", $03, "-", $03, "\", $03]
	NEXT			' $03 is non destructive back space
 
	PAUSE 4000

	SEROUT 0, N_9600, [$0D, $0A] ' new line	
	
	T=$81		' dummy in a value	
	SEROUT 0, N_9600, 1000, [$17, T, $09, $16, T]

	' prints T as unsigned quantity (129) and as signed (-127)

	PAUSE 4000

	FOR N=1 TO 5
	   SEROUT 0, N_9600, 300, [$0F]	' $0F is shift right
	NEXT 	' pull the whole display to the right 5 places

	FOR N=1 TO 5
	   SEROUT 0, N_9600, 300, [$0E]	' $0E is shift left
	NEXT 	' pull the whole display back to the left

	PAUSE 4000

	SEROUT 0, N_9600, 100, [$0B, $0B]	' two vertical tabs

	PAUSE 4000

	FOR N=1 TO 5			' beep the speaker 5 times
	  SEROUT 0, N_9600,  [$07]
	  PAUSE 100
	NEXT


	FOR N=0 TO 15			' output to the GP Outputs
	   SEROUT 0, N_9600, [$15, N]	
	   PAUSE 1000			
        	NEXT

	SEROUT 0, N_9600, [$15, $00]	' turn GP Outs off

	PAUSE 4000

	SEROUT 0, N_9600, [$0C, "BEST WISHES", $0A, $0D]	
					' clear LCD and output message
	SEROUT 0, N_9600, ["73", $0A, $0D]
			
DONE:	
	GOTO DONE