changeset 655:8c01edcf57fc

Allow any diluent to be "First gas" in CCR modes
author heinrichsweikamp
date Tue, 23 Oct 2012 10:03:47 +0200
parents a38d82918458
children 5063fb9f07db
files code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/menu_ppO2.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm docu/ostc_interface_description.odt
diffstat 4 files changed, 93 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Oct 16 18:20:32 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Tue Oct 23 10:03:47 2012 +0200
@@ -2058,17 +2058,16 @@
 	return
 
 set_first_gas_ccr:                      ; Set Diluent
-    movlw   .1
-    movwf   active_diluent              ; Always start with Diluent 1 (EEPROM 96/97)
-	read_int_eeprom 	d'97'			; Read He
-	movff	EEDATA,char_I_He_ratio		; And copy into hold register
-	read_int_eeprom 	d'96'			; Read O2
-	movff	EEDATA, char_I_O2_ratio		; O2 ratio
+    call    get_first_diluent           ; Read first diluent into lo(O2) and hi(He)
+	movff	hi,char_I_He_ratio          ; And copy into hold register
+	movff	lo, char_I_O2_ratio         ; O2 ratio
 	movff	char_I_He_ratio, wait_temp	; copy into bank1 register
 	bsf		STATUS,C					; Borrow bit
 	movlw	d'100'						; 100%
 	subfwb	wait_temp,W					; minus He
 	bsf		STATUS,C					; Borrow bit
-	subfwb	EEDATA,W					; minus O2
+	subfwb	lo,W        				; minus O2
 	movff	WREG, char_I_N2_ratio		; = N2!
+    read_int_eeprom d'106'              ; Read First Diluent (1-5)
+    movff   EEDATA,active_diluent
     return
\ No newline at end of file
--- a/code_part1/OSTC_code_asm_part1/menu_ppO2.asm	Tue Oct 16 18:20:32 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_ppO2.asm	Tue Oct 23 10:03:47 2012 +0200
@@ -34,6 +34,8 @@
 ; Diluent 4 (%O2,%He)
 ; EEPROM BANK0 Byte104-105:
 ; Diluent 5 (%O2,%He)
+; EEPROM BANK0 Byte106:
+; First Diluent (1-5)
 
 
 menu_const_ppO2:
@@ -115,10 +117,23 @@
 	bsf		leftbind
 	output_99
 	PUTC	':'
+	call	word_processor
+
+	WIN_LEFT	.40
+	movf	waitms_temp,W		; Load row into WREG
+	movff	WREG,win_top
+	lfsr	FSR2,letter
+
+	movlw	d'106'
+	movwf	EEADR
+	call	read_eeprom			; Get current startgas 1-5 # into EEDATA
+	decf	EEDATA,W			; 0-4
+	cpfseq	decodata+0			; =current displayed gas #?
+	bra		menu_diluentsetup_Tx; no, do not display *
+	PUTC	'*'					; display *
+    call	word_processor
 
 menu_diluentsetup_Tx:
-	call	word_processor
-
 	WIN_LEFT	.48
 	movf	waitms_temp,W		; Load row into WREG
 	movff	WREG,win_top
@@ -282,18 +297,42 @@
 menu_diluentgas0:
 	call	PLED_ClearScreen
     WIN_LEFT    .20
-	WIN_TOP		.155
+	WIN_TOP		.185
     lfsr    FSR2, letter
 	OUTPUTTEXT  .11			; Exit
     STRCAT_PRINT  ""
 
 menu_diluentgas1:
 	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
-
 	call	diluent_title_bar2			; Displays the title bar with the current Gas info
 
+	WIN_TOP		.35
 	WIN_LEFT	.20
-	WIN_TOP		.35
+	lfsr	FSR2,letter
+	OUTPUTTEXT	.88			; First Gas?
+	PUTC	' '
+
+	movlw	d'106'
+	movwf	EEADR
+	call	read_eeprom		; Get current startgas 1-5 # into EEDATA
+	decf	EEDATA,W		; 0-4
+	cpfseq	decodata+0		; =current displayed gas #?
+	bra		menu_firstdil0	; no, display three spaces
+
+	OUTPUTTEXT	.96			; Yes
+	bsf		second_FA		; Is first gas
+
+	bra		menu_firstdil1
+
+menu_firstdil0:
+	bcf		second_FA		; Is not first gas
+	STRCAT  "   "           ; 3 spaces.
+
+menu_firstdil1:
+	call	word_processor
+
+	WIN_LEFT	.20
+	WIN_TOP		.65
 	STRCPY  TXT_O2_4
 	movff	divemins+0,EEADR
 	call	read_eeprom                 ; O2 value
@@ -326,7 +365,7 @@
 	STRCAT_PRINT  TXT_METER3
 
 	WIN_LEFT	.20
-	WIN_TOP		.65
+	WIN_TOP		.95
 	STRCPY  TXT_HE4
 	incf	divemins+0,W
     movwf   EEADR
@@ -387,7 +426,7 @@
 	STRCAT_PRINT  TXT_METER3
 
     WIN_LEFT    .20
-	WIN_TOP		.95
+	WIN_TOP		.125
 	STRCPY  "+/-: "
 	movlw	'+'
 	btfsc	first_FA
@@ -395,7 +434,7 @@
 	movwf	POSTINC2
 	call	word_processor
 
-	WIN_TOP		.125
+	WIN_TOP		.155
 	lfsr	FSR2,letter
 	OUTPUTTEXT	.89			            ; Default:
     movlw   .21
@@ -430,8 +469,8 @@
 
 diluentgassetup2:
 	incf	menupos,F
-	movlw	d'6'
-	cpfseq	menupos             ; =6?
+	movlw	d'7'
+	cpfseq	menupos             ; =7?
 	bra		diluentgassetup3	; No
 	movlw	d'1'
 	movwf	menupos
@@ -447,6 +486,8 @@
 
 do_diluentgassetup:
 	dcfsnz	menupos,F
+    bra     make_first_diluent
+	dcfsnz	menupos,F
 	bra		adjust_o2_diluent
 	dcfsnz	menupos,F
 	bra		adjust_he_diluent
@@ -459,9 +500,19 @@
 	incf	menupos,F
 	bra		menu_diluentsetup_prelist
 
+make_first_diluent:
+	movff	decodata+0,EEDATA		; current gas (0-4) into EEDATA
+	incf	EEDATA,F				; current gas (1-5) into EEDATA
+	movlw	d'106'
+	movwf	EEADR
+	call	write_eeprom			; store in internal EEPROM
+	movlw	d'1'
+	movwf	menupos
+	bra		menu_diluentgas1	; return
+
 toggle_plus_minus_diluentsetup:
 	btg		first_FA
-	movlw	d'3'
+	movlw	d'4'
 	movwf	menupos
 	bra		menu_diluentgas1	; return
 
@@ -515,7 +566,7 @@
 	movff	lo,EEDATA
 	call	write_eeprom		; Low-value
 
-	movlw	d'1'
+	movlw	d'2'
 	movwf	menupos
 	bra		menu_diluentgas1	; return
 
@@ -560,7 +611,7 @@
 	movff	lo,EEDATA
 	call	write_eeprom	; Low-value
 
-	movlw	d'2'
+	movlw	d'3'
 	movwf	menupos
 	bra		menu_diluentgas1;
 
@@ -572,7 +623,7 @@
 	incf   	EEADR,F                     ; Point to He
 	clrf    EEDATA
 	call	write_eeprom
-	movlw	d'4'
+	movlw	d'5'
 	movwf	menupos
 	bra		menu_diluentgas1
 
@@ -704,22 +755,14 @@
 	OUTPUTTEXT	d'192'				; Dil.
 	PUTC	' '
 
- 	movlw	d'96'						; = address for O2 ratio
-	movwf	EEADR
-	call	read_eeprom					; Read O2 ratio
-	movff	EEDATA, lo                  ; O2 ratio
+    rcall   get_first_diluent           ; Read first diluent into lo(O2) and hi(He)
 	bsf		leftbind
-	output_99
+	output_99                           ; O2
 	PUTC	'/'
-	movlw	d'97'						; = address for He ratio
-	movwf	EEADR
-	call	read_eeprom					; Read He ratio
-	movff	EEDATA,lo                   ; And copy into hold register
-	bsf		leftbind
-	output_99
+    movff   hi,lo
+	output_99                           ; He
 	STRCAT_PRINT ")"
 
-
 	WIN_LEFT 	.20
 	WIN_TOP		.65
 
@@ -878,4 +921,19 @@
 next_ppO22:	
 	movlw	d'1'
 	movwf	menupos
-	bra		menu_const_ppO21	
\ No newline at end of file
+	bra		menu_const_ppO21
+
+get_first_diluent:              ; Read first diluent into lo(O2) and hi(He)
+    read_int_eeprom d'106'      ; Read First Diluent (1-5)
+    decf    EEDATA,W            ; WREG: 0-4
+    mullw   .2                  ; PRODL: 0-8
+    movlw   .96                 ; Base address for O2
+    addwf   PRODL,W
+    movwf   EEADR
+    call    read_eeprom         ; Read O2
+    movff   EEDATA,lo
+    incf    EEADR,F
+    call    read_eeprom         ; Read He
+    movff   EEDATA,hi
+    return
+
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Tue Oct 16 18:20:32 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Tue Oct 23 10:03:47 2012 +0200
@@ -1450,11 +1450,8 @@
 	cpfseq	apnoe_mins          ; All gases shown?
 	bra		PLED_pre_dive_screen3_loop	;no
 
-	read_int_eeprom 	d'96'			; Read O2
-	movff	EEDATA,lo
-	read_int_eeprom 	d'97'			; Read He
-    movff	EEDATA,hi
-
+
+    call    get_first_diluent           ; Read first diluent into lo(O2) and hi(He)
 	WIN_LEFT	.90
 	WIN_TOP		.100
 	STRCPY  TXT_DIL4
Binary file docu/ostc_interface_description.odt has changed