;      --------- rutina  display.inc  ------------- v1.20 ------------


; podrogram obsluhy displeje pouzitelny pouze pro FOX2-urceno propojenim vyvodu mezi 
; M5451B7 a displejem. Po zapsani ciselnych hodnot do registru DIG1 az DIG4 [v rozsahu 0 az 17]
; zavolat PRINT_D a hodnoty se zobrazi v jednotlivych digitech 
; nastaveny BIT DP reg. DISPLAY_FL,0 rozsviti deset. tecky 
; obsahuje reset pos. registru display IC / provadi se pri kazdem volani PRINT_D / 


		LOCAL		PRINT, JEDN


;-----------------------------------------------------------------
;||||||||||  OBSLUHA DISPLEJE  |||||||||||||||
;-----------------------------------------------------------------
;---------------ROUTINES-------------

H_PULS		NOP			; vyslani jednoho hodinoveho
		NOP			; pulsu definovane delky
		BSF	PORTA,2 
		BTFSS	SCL
		GOTO	$-2
		NOP
		BCF	SCL
		BTFSC	SCL
		GOTO	$-2
		BCF	SDA
		RETURN
;===================================================		
;ZACATEK OBSLUHY DISPLEJE

PRINT_D		MOVLW 	H'20'
		MOVWF	FSR
		MOVFW	DIG1		;prevod ciselneho vyjadreni
		CALL	TAB_ZNAK	;v DIGX na graficke
		MOVWF	T_DIG1
		MOVFW	DIG2
		CALL	TAB_ZNAK
		MOVWF	T_DIG2
		MOVFW	DIG3
		CALL	TAB_ZNAK
		MOVWF	T_DIG3
		MOVFW	DIG4
		CALL	TAB_ZNAK
		MOVWF	T_DIG4
;-------------------------------------------------------
		MOVLW	38		;reset posuvneho registru IC-M5451B7
		MOVWF	CYKL1		;
		BSF	SDA		;start puls
		CALL	H_PULS		;
		DECFSZ	CYKL1,F		;
		GOTO	$-2		;
;-------------------------------------------------------
D_SEND		BSF	SDA		;start puls
		CALL	H_PULS
		MOVLW	4
		MOVWF	CYKL1
		MOVLW	T_DIG1
		MOVWF	FSR
FIRST_HALF	BTFSC	DP		;test priznakoveho bitu DISPLAY_FL,0 - desetinna tecka 
		BSF	SDA
		CALL	H_PULS
		BTFSC	INDF,2
		BSF	SDA
		CALL	H_PULS
		BTFSC	INDF,3
		BSF	SDA
		CALL	H_PULS
		BTFSC	INDF,4
		BSF	SDA
		CALL	H_PULS
		MOVFW	CYKL1		;podchyceni nepouziteho
		XORLW	2		;BITu a vyslani prazdneho
		BTFSC	STATUS,Z	;SCL hod. pulsu	
		CALL	H_PULS		;
		INCF	FSR,F
		DECFSZ	CYKL1,F
		GOTO	FIRST_HALF
		DECF	FSR,F
		MOVLW	4
		MOVWF	CYKL1
SEC_HALF	BTFSC	INDF,6
		BSF	SDA
		CALL	H_PULS
		BTFSC	INDF,5
		BSF	SDA
		CALL	H_PULS
		BTFSC	INDF,0
		BSF	SDA
		CALL	H_PULS
		BTFSC	INDF,1
		BSF	SDA
		CALL	H_PULS
		MOVFW	CYKL1		;podchyceni nepouziteho
		XORLW	4		;BITu a vyslani prazdneho
		BTFSC	STATUS,Z	;SCL hod. pulsu	
		CALL	H_PULS		;
		DECF	FSR,F
		DECFSZ	CYKL1,F
		GOTO	SEC_HALF
		CALL	H_PULS
		CALL	H_PULS
		BCF	SDA
		BTFSC	SDA
		GOTO	$-2
		MOVLW 	H'20'
		MOVWF	FSR	
		RETURN	
;----------------------------------------------------------------------------------------	
TAB_ZNAK	ADDWF 	PCL,F
		RETLW	63		;graficke vyjadreni znaku 0
		RETLW	6		;1
		RETLW	91		;2
		RETLW	79		;3
		RETLW	102		;4
		RETLW	109		;5
		RETLW	125		;6
		RETLW	39		;7	
		RETLW	127		;8	
		RETLW	111		;9
		RETLW	0		;BL
		RETLW	119		;A	
		RETLW	121		;E
		RETLW	113		;F	
		RETLW	116		;h	
		RETLW	115		;P
		RETLW	80		;r
		RETLW	120		;t
		NOP		
;-------------------------------------------------------------------------------------------				
						
