diff code_part1/OSTC_code_asm_part1/pled_outputs.asm @ 516:b498245da3f1

imperial units patch from Vlad
author heinrichsweikamp
date Mon, 05 Dec 2011 20:40:10 +0100
parents 2ac77db9c150
children a73a452ca155
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Mon Dec 05 14:31:31 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Mon Dec 05 20:40:10 2011 +0100
@@ -463,19 +463,43 @@
 
 	ostc_debug	'y'		; Sends debug-information to screen if debugmode active
 	WIN_TOP		.80
-	WIN_LEFT	.94
 	WIN_FONT 	FT_MEDIUM
 	WIN_INVERT	.0                      ; Init new Wordprocessor
 	PLED_color_code		warn_ceiling    ; Color-code Output
 	lfsr	FSR2,letter
 	movff	char_O_first_deco_depth,lo  ; Ceiling in m
+	GETCUSTOM8  d'63'				; Check CF#63 Conversion to imperial units
+	btfss   WREG,0					; Enabled ?
+	bra		PLED_display_deko3		; NO
+	WIN_LEFT	.80
+	clrf	hi
+	call	convert_meters_to_feet2	; converts meters to feet, don't check CF#63
+	output_16_3
+	call word_processor
+
+	WIN_TOP		.91
+	WIN_LEFT	.115
+	WIN_FONT 	FT_SMALL
+	lfsr	FSR2,letter
+	STRCPY_PRINT TXT_FOOT2          ; Print 'ft' in small font
+
+	WIN_TOP		.80
+	WIN_LEFT	.130
+	WIN_FONT 	FT_MEDIUM
+	lfsr	FSR2,letter
+	bra		PLED_display_deko4
+
+PLED_display_deko3:
+	WIN_LEFT	.94
 	output_99
 	PUTC    TXT_METER_C
-	movff	char_O_first_deco_time,lo   ; length of first stop in m
+
+PLED_display_deko4:	
+	movff	char_O_first_deco_time,lo   ; length of first stop in min
 	output_99
 	STRCAT_PRINT "'"
 	WIN_FONT 	FT_SMALL
-	
+
 ;PLED_display_deko1:
 	ostc_debug	'x'		; Sends debug-information to screen if debugmode active
 	
@@ -561,6 +585,17 @@
 
 	movff	sim_btm_depth,lo
 	bsf		leftbind
+	GETCUSTOM8  d'63'				; Check CF#63 Conversion to imperial units
+	btfss   WREG,0					; Enabled ?
+	bra		PLED_simulator_data_3	; NO
+	clrf	hi
+	call	convert_meters_to_feet2	; converts meters to feet, don't check CF#63
+	output_16_3
+	STRCAT_PRINT  TXT_FOOT4
+	bcf		leftbind
+	return
+
+PLED_simulator_data_3:
 	output_8
 	STRCAT_PRINT  TXT_METER3
 
@@ -699,9 +734,21 @@
 	movlw	'+'
 	movwf	POSTINC2
 	movff	divA+0,lo
+	GETCUSTOM8  d'63'                               ; Check CF#63 Conversion to imperial units
+	btfss   WREG,0                                  ; Enabled ?
+	bra     PLED_display_velocity2  ; NO
+	clrf    hi
+	call    convert_meters_to_feet2 ; converts meters to feet, don't check CF#63
+	output_16_3
+	OUTPUTTEXTH     d'318'                  ; ft/min
+	bra     PLED_display_velocity3
+ 
+PLED_display_velocity2:
 	output_99
 	OUTPUTTEXT	d'83'			; m/min
-	call	word_processor
+
+PLED_display_velocity3:
+ 	call	word_processor
 	call	PLED_standard_color
 	bsf		pled_velocity_display
 	return
@@ -715,7 +762,7 @@
 	WIN_BOX_BLACK	 .20, .90, .65, .75		; Clear graphic display
 
 PLED_display_velocity_clear1:
-	movlw	d'8'
+	movlw	d'10'
 	movwf	temp1
 	WIN_TOP		.90
 	WIN_LEFT	.0
@@ -834,6 +881,17 @@
 	GETCUSTOM8	d'29'
 	movwf	lo
 	bsf		leftbind
+	GETCUSTOM8  d'63'					; Check CF#63 Conversion to imperial units
+	btfss   WREG,0						; Enabled ?
+	bra		PLED_show_cf11_cf12_cf29_3	; NO
+	clrf	hi
+	call	convert_meters_to_feet2
+	output_16
+	STRCAT_PRINT  TXT_FOOT2
+	bcf		leftbind
+	return
+
+PLED_show_cf11_cf12_cf29_3:
 	output_8
 	STRCAT_PRINT  TXT_METER1
 
@@ -997,6 +1055,7 @@
 	WIN_TOP		.177
 	STRCPY  "temp:"
     SAFE_2BYTE_COPY temperature, lo
+	call    convert_celsius_to_fahrenheit
 	call	PLED_convert_signed_temperature	; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
 	output_16
 	call	word_processor
@@ -1108,12 +1167,19 @@
 	movff	last_temperature+1,hi
 	movff	last_temperature+0,lo
 	lfsr	FSR2,letter
+	call    convert_celsius_to_fahrenheit
 	call	PLED_convert_signed_temperature	; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
 	movlw	d'3'
 	movwf	ignore_digits
 	bsf		leftbind			; left orientated output
 	output_16dp	d'2'
 	bcf		leftbind
+	GETCUSTOM8  d'63'                       ; Check CF#63 Conversion to imperial units
+	btfss   WREG,0                          ; Enabled ?
+	bra PLED_show_C                         ; NO
+	STRCAT_PRINT  "°F "
+	return
+PLED_show_C:
 	STRCAT_PRINT  "°C "
 	return
 
@@ -1133,6 +1199,7 @@
 	movff	last_temperature+0,lo
 
 	lfsr	FSR2,letter
+	call    convert_celsius_to_fahrenheit
 	call	PLED_convert_signed_temperature	; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
 	movlw	d'3'
 	movwf	ignore_digits
@@ -1696,15 +1763,16 @@
 PLED_depth:
 	ostc_debug	'r'		; Sends debug-information to screen if debugmode active
     SAFE_2BYTE_COPY rel_pressure, lo
-	call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
+	call	adjust_depth_with_salinity	; computes salinity setting into lo:hi [mbar]
+	call	convert_meters_to_feet		; converts meters to feet
 
 	movlw	.039
 	cpfslt	hi
-    bra		depth_greater_99_84mtr
-
-	btfsc	depth_greater_100m			; Was depth>100m during last call
+    bra		pled_depth_full_units_only
+
+	btfsc	depth_greater_100			; Was depth>100 during last call
 	call	PLED_clear_depth			; Yes, clear depth area
-	bcf		depth_greater_100m			; Do this once only...
+	bcf		depth_greater_100			; Do this once only...
 
 	lfsr	FSR2,letter
 
@@ -1718,8 +1786,8 @@
 	movlw	d'0'
 	addwfc	sub_b+1,F				; Add 1mbar offset
 	call	sub16					; sub_c = sub_a - sub_b
-	btfss	neg_flag				; Depth lower then 10m?
-	rcall	depth_less_10mtr		; Yes, add extra space
+	btfss	neg_flag				; Depth lower then 10?
+	rcall	depth_less_10   		; Yes, add extra space
 
 	WIN_TOP		.24
 	WIN_LEFT	.0
@@ -1734,7 +1802,7 @@
 	movff	hi,sub_b+1
 	movff	lo,sub_b+0
 	call	sub16					; sub_c = sub_a - sub_b
-	btfss	neg_flag				; Depth lower then 1m?
+	btfss	neg_flag				; Depth lower then 1?
 	bra		pled_depth2				; Yes, display manual Zero
 
 	bsf		leftbind
@@ -1750,6 +1818,10 @@
 	call	word_processor
 	bcf		ignore_digit4
 
+	GETCUSTOM8  d'63'               ; Check CF#63 Conversion to imperial units
+	btfsc   WREG,0                  ; Enabled ?
+	bra		pled_depth6             ; YES, don't print any fractions
+
 	WIN_FONT 	FT_MEDIUM
 	WIN_TOP		.50
 	WIN_LEFT	.40
@@ -1782,14 +1854,16 @@
 pled_depth5:
 	call	word_processor			; decimeters in medium font
 	bcf		ignore_digit5
+
+pled_depth6:
 	WIN_FONT 	FT_SMALL
 	return
 
-depth_greater_99_84mtr:			; Display only in full meters
-	btfss	depth_greater_100m			; Is depth>100m already?
+pled_depth_full_units_only:			; Display only in full meters or feet
+	btfss	depth_greater_100			; Is depth>100 already?
 	call	PLED_clear_depth			; No, clear depth area and set flag
 	; Depth is already in hi:lo
-	; Show depth in Full meters
+	; Show depth in Full units
 	; That means ignore figure 4 and 5
 	lfsr	FSR2,letter
 	WIN_TOP		.24
@@ -1807,13 +1881,13 @@
 	WIN_FONT 	FT_SMALL
 	return
 	
-depth_less_10mtr:
+depth_less_10:
 	PUTC    ' '
 	return
 
 PLED_clear_depth			; No, clear depth area and set flag
     WIN_BOX_BLACK   .24, .90, .0, .90		;top, bottom, left, right
-	bsf		depth_greater_100m			; Set Flag
+	bsf		depth_greater_100			; Set Flag
 	return
 
 PLED_desaturation_time:	
@@ -2177,10 +2251,15 @@
 	movff	max_pressure+0,lo
 	movff	max_pressure+1,hi
 	call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
+	call	convert_meters_to_feet			; converts meters to feet
+
+	GETCUSTOM8  d'63'                       ; Check CF#63 Conversion to imperial units
+	btfsc	WREG,0                          ; Enabled ?
+	bra		PLED_maxdepth_full_units_only   ; YES, don't print any feet fractions
 
 	movlw	.039
 	cpfslt	hi
-    bra		maxdepth_greater_99_84mtr
+    bra		PLED_maxdepth_full_units_only
 
 ; Display normal "xx.y"
 	lfsr	FSR2,letter
@@ -2198,11 +2277,11 @@
 	WIN_FONT 	FT_SMALL
 	return
 
-maxdepth_greater_99_84mtr:			; Display only in full meters
-	btfss	maxdepth_greater_100m	; Is max.depth>100m already?
+PLED_maxdepth_full_units_only:		; Display only in full units (meters or feet)
+	btfss	maxdepth_greater_100	; Is max.depth>100 already?
 	call	PLED_clear_maxdepth		; No, clear maxdepth area and set flag
 	; max Depth is already in hi:lo
-	; Show max depth in Full meters
+	; Show max depth in Full units
 	; That means ignore figure 4 and 5
 	lfsr	FSR2,letter
 	call	PLED_standard_color
@@ -2222,7 +2301,7 @@
 
 PLED_clear_maxdepth:
     WIN_BOX_BLACK   .184, .215, .0, .41		;top, bottom, left, right
-	bsf		maxdepth_greater_100m	; Set Flag
+	bsf		maxdepth_greater_100	; Set Flag
 	return
 
 PLED_divemins:
@@ -2376,7 +2455,6 @@
 	ostc_debug	'U'				; Sends debug-information to screen if debugmode active
 
 	WIN_TOP		.216
-	WIN_LEFT	.110
 	WIN_FONT	FT_SMALL
 	call	PLED_standard_color
 
@@ -2384,6 +2462,20 @@
 	movff	avr_rel_pressure+0,lo
 	movff	avr_rel_pressure+1,hi
 	call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
+	GETCUSTOM8  d'63'				; Check CF#63 Conversion to imperial units
+	btfss   WREG,0					; Enabled ?
+	bra PLED_stopwatch_show3		; NO
+	WIN_LEFT	.124
+	call	convert_meters_to_feet2	; converts meters to feet, don't check CF#63
+	bsf		ignore_digit4			; do not display feet fractions
+	output_16
+	bcf		ignore_digit4
+	bcf		leftbind
+	STRCAT_PRINT TXT_FOOT2
+	return
+
+PLED_stopwatch_show3:
+	WIN_LEFT	.110
 	bsf		ignore_digit5		; do not display 1cm depth
 	output_16dp	d'3'
 	bcf		leftbind
@@ -2425,14 +2517,33 @@
 	call	word_processor
 
 	ostc_debug	'U'				; Sends debug-information to screen if debugmode active
-	WIN_TOP		.136
-	WIN_LEFT	.90
+	WIN_TOP		.137
 	WIN_FONT	FT_MEDIUM
 	call	PLED_standard_color
 	lfsr	FSR2,letter
 	movff	avr_rel_pressure+0,lo
 	movff	avr_rel_pressure+1,hi
 	call	adjust_depth_with_salinity		; computes salinity setting into lo:hi [mbar]
+	GETCUSTOM8  d'63'						; Check CF#63 Conversion to imperial units
+	btfss   WREG,0							; Enabled ?
+	bra PLED_stopwatch_show_gauge2			; NO
+	WIN_LEFT	.110
+	call	convert_meters_to_feet2			; converts meters to feet, don't check CF#63
+	bsf		ignore_digit4					; do not display feet fractions
+	output_16
+	bcf		ignore_digit4
+	bcf		leftbind
+	call	word_processor
+
+	WIN_TOP		.149
+	WIN_LEFT	.145
+	WIN_FONT	FT_SMALL
+	lfsr	FSR2,letter
+	STRCPY_PRINT TXT_FOOT2
+	return
+
+PLED_stopwatch_show_gauge2:
+	WIN_LEFT	.90
 	bsf		ignore_digit5					; do not display 1cm depth
 	output_16dp	d'3'
 	bcf		leftbind
@@ -2447,8 +2558,7 @@
 	DISPLAYTEXTH	d'281'			; Avr.Depth
 
 PLED_total_average_show2:
-	WIN_TOP		.192
-	WIN_LEFT	.110
+	WIN_TOP		.193
 	WIN_FONT	FT_SMALL
 	call	PLED_standard_color
 
@@ -2456,6 +2566,20 @@
 	movff	avr_rel_pressure_total+0,lo
 	movff	avr_rel_pressure_total+1,hi
 	call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
+	GETCUSTOM8  d'63'                       ; Check CF#63 Conversion to imperial units
+	btfss   WREG,0                          ; Enabled ?
+	bra PLED_total_average_show3            ; NO
+	WIN_LEFT	.124
+	call	convert_meters_to_feet2			; converts meters to feet, don't check CF#63
+	bsf		ignore_digit4					; do not display feet fractions
+	bcf		leftbind
+	output_16
+	bcf		ignore_digit4
+	STRCAT_PRINT TXT_FOOT2
+	return
+
+PLED_total_average_show3:
+	WIN_LEFT	.110
 	bsf		ignore_digit5		; do not display 1cm depth
 	bcf		leftbind
 	output_16dp	d'3'
@@ -2572,6 +2696,17 @@
 PLED_divemode_simulator_mask:
 	    call    PLED_standard_color
         DISPLAYTEXT	.254			; Close
+		GETCUSTOM8  d'63'                       ; Check CF#63 Conversion to imperial units
+		btfss   WREG,0                          ; Enabled ?
+		bra PLED_divemode_simulator_mask2       ; NO
+        DISPLAYTEXTH .314			; +  1ft
+        DISPLAYTEXTH .315			; -  1ft
+        DISPLAYTEXTH .316			; + 10ft
+        DISPLAYTEXTH .317			; - 10ft
+		DISPLAYTEXTH .306			; Quit Sim
+        return
+
+PLED_divemode_simulator_mask2:
         DISPLAYTEXT	.250			; + 1m
         DISPLAYTEXT	.251			; - 1m
         DISPLAYTEXT	.252			; +10m
@@ -2591,7 +2726,7 @@
 PLED_decoplan_show_stop:
         ;---- Print depth ----------------------------------------------------
         WIN_LEFT .100
-        
+
         btfss   lo,7                    ; Bit set ?
         bra     PLED_decoplan_std_stop  ; No : Just an usual stop.
 
@@ -2606,9 +2741,22 @@
 PLED_decoplan_nstd_stop:        
 	    lfsr	FSR2,letter
 	    bsf     leftbind
+		GETCUSTOM8  d'63'					; Check CF#63
+		btfss   WREG,0						; Enabled ?
+		bra     PLED_decoplan_nstd_stop2    ; NO
+		movff   hi,temp11					; save hi
+		clrf    hi							; 
+		call    convert_meters_to_feet2		; converts meters to feet, don't check CF#63
+		output_16_3
+        STRCAT_PRINT "  "
+		movff   temp11,hi					; restore hi
+		bra     PLED_decoplan_nstd_stop3
+
+PLED_decoplan_nstd_stop2:
 	    output_8					    ; outputs into Postinc2!
         STRCAT_PRINT TXT_METER2
 
+PLED_decoplan_nstd_stop3:
         ;---- Print duration -------------------------------------------------
 	    WIN_LEFT	.140
 	    lfsr	FSR2,letter
@@ -2950,7 +3098,7 @@
 	return						; no, return
 
 PLED_clear_divemode_menu:
-    WIN_BOX_BLACK   .0, .168, .85, .160		;top, bottom, left, right
+    WIN_BOX_BLACK   .0, .168, .82, .160		;top, bottom, left, right
 	return
 
 PLED_divemenu_cursor:
@@ -3337,6 +3485,27 @@
 	lfsr        FSR2,letter
 	movff       char_O_EAD,lo
 	bsf         leftbind
+	GETCUSTOM8  d'63'						; Check CF#63
+	btfss       WREG,0						; Enabled ?
+	bra         PLED_show_end_ead_divemode2 ; NO: return
+	clrf        hi							; clear hi
+	call        convert_meters_to_feet2		; converts meters to feet, don't check CF#63
+	output_16								; Print EAD w/o leading space.
+	bcf	        leftbind
+	STRCAT_PRINT TXT_FOOT2
+
+	WIN_TOP     .216
+	lfsr        FSR2,letter
+	movff       char_O_END,lo
+	clrf        hi							; clear hi
+	call        convert_meters_to_feet2		; converts meters to feet, don't check CF#63
+	bsf	        leftbind
+	output_16	                            ; Print END w/o leading space.
+	bcf	        leftbind
+	STRCAT_PRINT TXT_FOOT2
+	bra         PLED_show_end_ead_divemode3
+
+PLED_show_end_ead_divemode2:
 	output_8                            ; Print EAD w/o leading space.
 	STRCAT_PRINT TXT_METER2
 
@@ -3347,6 +3516,7 @@
 	bcf	        leftbind
 	STRCAT_PRINT TXT_METER2
 
+PLED_show_end_ead_divemode3:
 ; Show ppO2[Flush] iff in CCR mode & not in Bailout:
 	btfsc       is_bailout              ; In bailout mode?
 	return                              ; Yes: done.
@@ -3859,4 +4029,71 @@
 	movff	xC+0,lo
 	movff	xC+1,hi					; restore lo and hi with updated value
 	
-	return
\ No newline at end of file
+	return
+
+
+convert_meters_to_feet:             ; convert value in lo:hi from meters to feet
+
+    GETCUSTOM8  d'63'               ; Check CF#63
+    btfss   WREG,0                  ; Enabled ?
+    return                          ; NO: return
+
+convert_meters_to_feet2:
+	movff	lo,xA+0
+	movff	hi,xA+1
+
+	movlw	LOW d'328'              ; 328feet/100m
+	movwf	xB+0
+	movlw	HIGH d'328'
+	movwf	xB+1
+
+	call	mult16x16			    ; xA*xB=xC (lo:hi * 328)
+
+	movlw	d'50'                   ; round up
+	addwf	xC+0,F
+	movlw	0
+	addwfc	xC+1,F
+	addwfc	xC+2,F
+	addwfc	xC+3,F
+
+	movlw	d'100'					
+	movwf	xB+0
+	clrf	xB+1
+
+	call	div32x16  			    ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
+
+	movff	xC+0,lo
+	movff	xC+1,hi				    ; restore lo and hi with updated value
+
+	return
+
+convert_celsius_to_fahrenheit:		; convert value in lo:hi from celsius to fahrenheit
+
+    GETCUSTOM8  d'63'               ; Check CF#63
+    btfss   WREG,0                  ; Enabled ?
+    return                          ; NO: return
+
+	movff	lo,xA+0
+	movff	hi,xA+1
+
+	movlw	d'18'                   ; 1C = 1.8F
+	movwf	xB+0
+	clrf	xB+1
+
+	call	mult16x16               ;xA*xB=xC (lo:hi * 18)
+
+	movlw	d'10'
+	movwf	xB+0
+	clrf	xB+1
+
+	call	div32x16                ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
+
+    movlw	LOW d'320'              ; 0C = 32F
+	addwf	xC+0,F
+	movlw	HIGH d'320'
+	addwfc	xC+1,F
+
+	movff	xC+0,lo
+	movff	xC+1,hi                 ; restore lo and hi with updated value
+
+	return