changeset 647:e6ac142e82b0

New Diluent Submenu in Divemode
author heinrichsweikamp
date Sun, 07 Oct 2012 21:31:19 +0200
parents 06ffc99a405f
children 436f6d8a2bf8
files code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/divemode_menu.asm code_part1/OSTC_code_asm_part1/english_text.asm code_part1/OSTC_code_asm_part1/menu_ppO2.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/sleepmode.asm code_part1/OSTC_code_asm_part1/start.asm
diffstat 9 files changed, 130 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Sun Oct 07 21:31:19 2012 +0200
@@ -1,6 +1,6 @@
 New in 2.52:
 BETA Version - Do NOT use for diving!
-TODO: Text 61,229,110,111,230,231 TXT_DIL_C, TXT_DIL5 update
+TODO: Text 61,229,110,111,230,231,232 TXT_DIL_C, TXT_DIL5 update
 NEW: Divisor Decoplan (CF25) stores entire decoplan in logbook
 NEW: CF29 stored in divelog header (Byte 52)
 BUGFIX: Gas Setup when using "ERR" Gases (e.g. NX17)
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -334,7 +334,8 @@
 
 char_I_O2_ratio         res 1   ; 02 ratio
 
-active_gas              res 1   ; Holds number of active gas
+active_gas              res 1   ; Holds number of active gas (1-5)
+active_diluent          res 1   ; Holds number of active diluent (1-5)
 
 debug_char              res 6    ; For debugmode
 
@@ -360,6 +361,7 @@
 safety_stop_countdown	res 1	; counts seconds of safety stop
 better_gas_number		res 1	; number (1-5) of the "better gas" in divemode, =0: no better gas available
 
+
 ASSERT_BANK1    MACRO   tag
     Ifdef   __DEBUG
         local @end
@@ -550,7 +552,7 @@
 #DEFINE	toggle_customview		flag13,7	;=1: Next customview
 
 #DEFINE	enter_error_sleep		flag14,0	;=1: Sleep immediately displaying the error using LED codes
-#DEFINE nsm						flag14,1	;=1: Do not sleep
+#DEFINE display_set_diluent 	flag14,1	;=1: Diluent list active
 #DEFINE	is_bailout				flag14,2	;=1: CC mode, but bailout active!
 #DEFINE	standalone_simulator	flag14,3	;=1: Standalone Simulator active
 #DEFINE	display_set_simulator	flag14,4	;=1: Show Divemode simulator menu
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -2026,6 +2026,8 @@
 
 ; Read Start Gas and configure char_I_He_ratio, char_I_O2_ratio and char_I_N2_ratio
 set_first_gas:
+	btfsc	FLAG_const_ppO2_mode
+    bra     set_first_gas_ccr           ; In CCR mode
 	read_int_eeprom 	d'33'			; Read byte (stored in EEDATA)
 	movff	EEDATA,active_gas			; Read start gas (1-5)
     movff   EEDATA,char_I_current_gas
@@ -2054,3 +2056,19 @@
 	read_int_eeprom	d'27'
 	movff	EEDATA, gaslist_active
 	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
+	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
+	movff	WREG, char_I_N2_ratio		; = N2!
+    return
\ No newline at end of file
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -123,13 +123,15 @@
 	btfsc	display_set_gas				; Are we in the "Gaslist" menu?
 	movlw	d'7'						; Yes, Number of entries for this menu+1 = 7
 	btfsc	display_set_setpoint		; In SetPoint Menu?
-	movlw	d'5'						; Number of entries for this menu+1 = 5
+	movlw	d'6'						; Number of entries for this menu+1 = 6
 	btfsc	display_set_active			; De/Activate gases underwater menu is visible?
 	movlw	d'7'						; Number of entries for this menu+1 = 7
 	btfsc	display_set_xgas			; Are we in the Gas6 menu?
 	movlw	d'7'						; Number of entries for this menu+1 = 7
 	btfsc	display_set_simulator		; Are we in the simulator menu?
 	movlw	d'7'						; Number of entries for this menu+1 = 7
+    btfsc   display_set_diluent         ; Are we in the "Diluent" list?
+    movlw	d'6'						; Number of entries for this menu+1 = 6
 	cpfseq	menupos						; =limit?
 	bra		test_switches_divemode_menu1; No!
 	movlw	d'1'						; Yes, reset to position 1!
@@ -144,6 +146,8 @@
 	bra		test_switches_divemode_menu1a	; Skip test for sub menus
 	btfsc	display_set_active				; Are we in the "Gaslist", "SetPoint" or De/Activate gases menu?
 	bra		test_switches_divemode_menu1a	; Skip test for sub menus
+    btfsc	display_set_diluent				; Are we in the "Gaslist", "SetPoint" or De/Activate gases menu?
+    bra		test_switches_divemode_menu1a	; Skip test for sub menus
 
 	movlw	d'3'
 	cpfseq	menupos							; At position 3?
@@ -178,6 +182,9 @@
 	btfsc	display_set_simulator		; Are we in the Divemode Simulator menu?
 	goto	divemode_menu_simulator2	; Yes, so adjust depth or set and exit
 
+    btfsc	display_set_diluent         ; Are we in the "Diluent" List?
+    goto	divemode_set_diluent2       ; Yes, so choose diluent and exit
+
 ; Options for Menu 1
 	dcfsnz	menupos,F
 	bra		divemenu_set_gas			; Set gas sub-menu
@@ -607,7 +614,8 @@
 
 	call	PLED_clear_divemode_menu	; Clear Menu
 	call	PLED_splist_start			; Display SetPoints
-	DISPLAYTEXT		d'137'				; Bailout (as a sub-menu)
+	DISPLAYTEXT d'137'  				; Bailout (as a sub-menu)
+    DISPLAYTEXT d'232'                  ; Diluent (as a sub-menu)
 	movlw	d'1'
 	movwf	menupos						; reset cursor
 	call	PLED_divemenu_cursor		; update cursor
@@ -627,12 +635,31 @@
 divemenu_set_gas1:
 	movlw	d'1'				
 	cpfseq	menupos						; At the "Bailout" position?		
-	bra		divemenu_set_gas1b			; No, select SetPoint 1-3
+	bra		divemenu_set_gas1b			; No, select SetPoint 1-3 or Diluent
 	bsf		select_bailoutgas			; Set Flag
 	bcf		display_set_setpoint		; Clear Flag
 	bra		divemenu_set_gas_2			; Configure the extra gas / Select Bailout
 
 divemenu_set_gas1b:
+	movlw	d'5'
+	cpfseq	menupos						; At the "Diluent" position?
+	bra		divemenu_set_gas1c			; No, select SetPoint 1-3
+    ; Choose Diluent from list
+    bcf		display_set_setpoint		; Clear Flag
+    bcf     display_set_gas             ; Clear Flag
+    bsf     display_set_diluent         ; Set Flag
+	call	PLED_clear_divemode_menu	; Clear Menu
+	call	PLED_diluent_list			; Display all 5 diluents
+	movlw	d'1'						; Reset cursor
+	movwf	menupos						; reset cursor
+	call	PLED_divemenu_cursor		; update cursor
+	return
+
+divemode_set_diluent2:                  ; Choose diluent #menupos
+    movff  menupos,active_diluent       ; 1-5
+    bra    divemenu_set_gas1d           ; Continue here...
+
+divemenu_set_gas1c:
 	decf	menupos,F					; Adjust 1-3 to 0-2...
 	movlw	d'35'						; offset in memory
 	addwf	menupos,W					; add SP number 0-2
@@ -642,6 +669,29 @@
 	movff	EEDATA, ppO2_setpoint_store	; Store also in this byte...
 	bsf		setpoint_changed
 	bsf		event_occured				; set global event flag
+
+divemenu_set_gas1d:                     ; (Re-)Set Diluent
+    decf   active_diluent,W             ; 0-4 -> WREG mH
+    mullw   .2
+    movf    PRODL,W
+    addlw   d'97'
+    movwf   EEADR
+    call	read_eeprom					; Read He
+	movff	EEDATA,char_I_He_ratio		; And copy into hold register
+    decf   active_diluent,W             ; 0-4 -> WREG
+    mullw   .2
+    movf    PRODL,W
+    addlw   d'96'
+    movwf   EEADR
+    call	read_eeprom					; Read O2
+	movff	EEDATA, 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
+	movff	WREG, char_I_N2_ratio		; = N2!
 	bra		timeout_divemenu2			; quit menu!
 
 divemenu_set_gas1a:
@@ -745,6 +795,7 @@
 	bcf		display_set_setpoint
 	bcf		display_set_simulator
 	bcf		display_set_active
+    bcf     display_set_diluent
 	bcf		menu3_active
 	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	return
--- a/code_part1/OSTC_code_asm_part1/english_text.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/english_text.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -366,7 +366,7 @@
     TCODE    .20,   .35,     "Diluent Setup"             ;229 Diluent Setup
     TCODE    .20,   .65,     "Setpoint Setup"            ;230 Setpoint Setup
     TCODE    .5,   .2,       "Dil. Setup - Gaslist"	 	 ;231 Dil. Setup - Gaslist
-    TCODE    .0,    .0,      ""		                   	 ;232 unused
+    TCODE    .100,  .100,	 "Diluent"                   ;232 Diluent
     TCODE    .0,    .0,      ""		                     ;233 unused
     TCODE    .0,    .0,      ""     	                 ;234 unused
 
--- a/code_part1/OSTC_code_asm_part1/menu_ppO2.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_ppO2.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -23,16 +23,16 @@
 ; known bugs:
 ; ToDo: 
 ;
-; New in 2.52 Diluents stored seperately in EEPROM Bank1
-; EEPROM BANK1 Byte96-97:
+; New in 2.52 Diluents stored seperately in EEPROM Bank0
+; EEPROM BANK0 Byte96-97:
 ; Diluent 1 (%O2,%He)
-; EEPROM BANK1 Byte98-99:
+; EEPROM BANK0 Byte98-99:
 ; Diluent 2 (%O2,%He)
-; EEPROM BANK1 Byte100-101:
+; EEPROM BANK0 Byte100-101:
 ; Diluent 3 (%O2,%He)
-; EEPROM BANK1 Byte102-103:
+; EEPROM BANK0 Byte102-103:
 ; Diluent 4 (%O2,%He)
-; EEPROM BANK1 Byte104-105:
+; EEPROM BANK0 Byte104-105:
 ; Diluent 5 (%O2,%He)
 
 
@@ -99,8 +99,6 @@
 	movwf	waitms_temp		; here: stores row for gas list
 	movlw	d'94'
 	movwf	wait_temp			; here: stores eeprom address for gas list
-    movlw   .1
-    movwf   EEADRH
 
 menu_diluentsetup_list:
 	WIN_LEFT	.20
@@ -128,8 +126,6 @@
 
 	incf	wait_temp, W        ; Gas %O2
 	movwf	EEADR				; Gas %He - Set address in internal EEPROM
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom			; Read He value from EEPROM
 	movff	EEDATA,lo			; Move EEDATA -> lo
 	movf	lo,f				; Move lo -> f
@@ -140,15 +136,11 @@
 	; YES Write TX 15/55
    STRCAT  TXT_TX3
 	movff	wait_temp, EEADR	; Gas %O2 - Set address in internal EEPROM
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom			; O2 value
 	movff	EEDATA,lo
 	output_8
 	PUTC	'/'
 	incf	EEADR,F				; Gas #hi: %He - Set address in internal EEPROM
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom			; He value
 	movff	EEDATA,lo
 	output_8
@@ -157,8 +149,6 @@
 ; New v1.44se
 menu_diluentsetup_Nx:
 	movff	wait_temp, EEADR	; Gas %O2 - Set address in internal EEPROM
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom			; Read O2 value from EEPROM
 	movff	EEDATA,lo			; Move EEDATA -> lo
 	movf	lo,f				; Move lo -> f
@@ -202,7 +192,6 @@
 	DISPLAYTEXT	.11                     ; Exit
 	call	wait_switches               ; Waits until switches are released, resets flag if button stays pressed!
 	call	PLED_menu_cursor
-    clrf    EEADRH
 
 menu_diluentsetup_loop:
 	call	check_switches_logbook
@@ -307,8 +296,6 @@
 	WIN_TOP		.35
 	STRCPY  TXT_O2_4
 	movff	divemins+0,EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom                 ; O2 value
 	movff	EEDATA,lo
 	output_8
@@ -324,8 +311,6 @@
 	movff	PRODL,xA+0
 	movff	PRODH,xA+1                  ; ppO2 in [0.01bar] * 10
 	movff	divemins+0,EEADR
-	movlw   .1
-	movwf	EEADRH
 	call	read_eeprom                 ; O2 value
 	movff	EEDATA,xB+0
 	clrf	xB+1
@@ -345,8 +330,6 @@
 	STRCPY  TXT_HE4
 	incf	divemins+0,W
     movwf   EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom                 ; He value
 	movff	EEDATA,lo
 	output_8
@@ -361,8 +344,6 @@
 	movff	PRODL,xA+0
 	movff	PRODH,xA+1		            ; ppO2 in [0.01bar] * 10
     movff	divemins+0,EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom                 ; O2 value
 	movff	EEDATA,xB+0
 	clrf	xB+1
@@ -380,8 +361,6 @@
 
 	incf	divemins+0,W
     movwf   EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom                 ; He value in % -> EEDATA
 	movlw	d'100'
 	movwf	xA+0
@@ -488,8 +467,6 @@
 
 adjust_o2_diluent:
 	movff	divemins+0,EEADR			; read current value
-	movlw   .1
-	movwf	EEADRH
 	call	read_eeprom		; Low-value
 	movff	EEDATA,lo
 
@@ -512,8 +489,6 @@
 
 	incf	divemins+0,W
 	movwf	EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom		; read He value
 
 	movlw	d'100'
@@ -524,8 +499,6 @@
 adjust_o2_2_diluent:				; test if O2+He>100...
 	incf	divemins+0,W
 	movwf	EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom		; read He value
 	movf	EEDATA,W		; He value
 	addwf	lo,W			; add O2 value
@@ -540,8 +513,6 @@
 adjust_o2_3_diluent:
 	movff	divemins+0,EEADR		; save current value
 	movff	lo,EEDATA
-    movlw   .1
-    movwf   EEADRH
 	call	write_eeprom		; Low-value
 
 	movlw	d'1'
@@ -551,8 +522,6 @@
 adjust_he_diluent:
 	incf	divemins+0,W
     movwf   EEADR			; read current value
-	movlw   .1
-	movwf	EEADRH
 	call	read_eeprom		; Low-value
 	movff	EEDATA,lo
 
@@ -576,8 +545,6 @@
 adjust_he_2_diluent:				; test if O2+He>100...
 	incf	divemins+0,W
 	movwf	EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom		; read He value
 	movf	EEDATA,W		; He value
 	addwf	lo,W			; add O2 value
@@ -592,8 +559,6 @@
 	incf	divemins+0,W			; save current value
 	movwf	EEADR
 	movff	lo,EEDATA
-    movlw   .1
-    movwf   EEADRH
 	call	write_eeprom		; Low-value
 
 	movlw	d'2'
@@ -602,8 +567,6 @@
 
 restore_gas_diluent:
 	movff	divemins+0,EEADR			; save Default value (O2)
-    movlw   .1
-    movwf   EEADRH
     movlw   .21                         ; Always Air
 	movwf	EEDATA
 	call	write_eeprom
@@ -635,8 +598,6 @@
 	;He check
 	incf	divemins+0,W
 	movwf	EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom			; He value
 	movff	EEDATA,lo			; Move EEData -> lo
 	movf	lo,f				; Move lo -> f
@@ -647,8 +608,6 @@
 	; YES Write TX 15/55
     STRCAT  TXT_TX3
 	movff	divemins+0,EEADR
-	movlw   .1
-	movwf	EEADRH
 	call	read_eeprom			; O2 value
 	movff	EEDATA,lo
 	output_8					; Write O2
@@ -748,8 +707,6 @@
 
  	movlw	d'96'						; = address for O2 ratio
 	movwf	EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom					; Read O2 ratio
 	movff	EEDATA, lo                  ; O2 ratio
 	bsf		leftbind
@@ -757,11 +714,8 @@
 	PUTC	'/'
 	movlw	d'97'						; = address for He ratio
 	movwf	EEADR
-    movlw   .1
-    movwf   EEADRH
 	call	read_eeprom					; Read He ratio
 	movff	EEDATA,lo                   ; And copy into hold register
-    clrf    EEADRH
 	bsf		leftbind
 	output_99
 	STRCAT_PRINT ")"
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -1450,12 +1450,10 @@
 	cpfseq	apnoe_mins          ; All gases shown?
 	bra		PLED_pre_dive_screen3_loop	;no
 
-    movlw   .1
-    movwf   EEADRH
 	read_int_eeprom 	d'96'			; Read O2
 	movff	EEDATA,lo
 	read_int_eeprom 	d'97'			; Read He
-    clrf    EEADRH
+    movff	EEDATA,hi
 
 	WIN_LEFT	.90
 	WIN_TOP		.100
@@ -2890,6 +2888,51 @@
 	STRCPY_PRINT  "         "
 	return
 
+PLED_diluent_list:
+	ostc_debug	'm'		; Sends debug-information to screen if debugmode active
+	WIN_LEFT	.100
+	WIN_FONT	FT_SMALL
+	bsf		leftbind
+    movlw	d'94'
+	movwf	wait_temp			; here: stores eeprom address for diluent list (96-2)
+	movlw	d'231'
+	movwf	waitms_temp			; here: stores row for gas list
+	clrf	hi					; here: Diluent counter
+
+PLED_diluent_list_loop:
+   	incf	hi,F				; Increase Diluent
+    movlw   .2
+	addwf   wait_temp,F			; Increase eeprom address for gas list
+	movlw	d'25'
+	addwf	waitms_temp,F		; Increase row
+	WIN_LEFT	.100
+	movff	waitms_temp,win_top ; Set Row
+	STRCPY  TXT_DIL_C
+	movff	hi,lo			; copy dil number
+	output_8				; display dil number
+    PUTC    ':'
+	movff	wait_temp, EEADR; Dil #hi: %O2 - Set address in internal EEPROM
+	call	read_eeprom		; get byte (stored in EEDATA)
+	movff	EEDATA,lo		; copy to lo
+	output_8				; outputs into Postinc2!
+    PUTC    '/'
+	incf	EEADR,F			; Dil #hi: %He - Set address in internal EEPROM
+	call	read_eeprom		; get byte (stored in EEDATA)
+	movff	EEDATA,lo		; copy to lo
+	output_8				; outputs into Postinc2!
+
+	decf	EEADR,F			; Dil #hi: %O2 - Set address in internal EEPROM
+	call	read_eeprom		; get byte (stored in EEDATA)
+	PLED_color_code		warn_gas_in_gaslist		; Color-code output	(%O2 in "EEDATA")
+    
+	call	word_processor
+	call	PLED_standard_color
+
+	movlw	d'5'			; list all five Diluents
+	cpfseq	hi				; All diluents shown?
+	bra		PLED_diluent_list_loop	; No
+	return					;  return
+
 
 PLED_gas_list:
 	ostc_debug	'm'		; Sends debug-information to screen if debugmode active
--- a/code_part1/OSTC_code_asm_part1/sleepmode.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/sleepmode.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -56,7 +56,6 @@
 	btfss	sleepmode				; wake up? (This bit will be set in other routines)
 	goto	restart					; yes
 	nop
-	btfss	nsm
 	sleep							; Sleep until Timer1 will wake up the device
 	nop	
 	bra		sleeploop_loop			; do loop until someting happens
--- a/code_part1/OSTC_code_asm_part1/start.asm	Fri Oct 05 00:03:59 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Sun Oct 07 21:31:19 2012 +0200
@@ -212,18 +212,6 @@
 	btfss	neg_flag				; Result negative (Ambient>880mBar)?
 	bsf		high_altitude_mode		; No, Set Flag!
 	
-	; Should we disable sleep (hardware emulator)
-  Ifndef TESTING
-restart_loop:
-	btfss	0xF81,0,A
-	bra		restart_loop
-	btfss	0xF81,1,A
-	bra		restart_loop
-	movlw	0x80
-	cpfslt	0xFB3,A
-	bsf		nsm						; NO-SLEEP-MODE : for hardware debugging
-  Endif
-
 	call	gassetup_sort_gaslist       ; Sorts Gaslist according to change depth
 	WIN_TOP		.0
 	WIN_LEFT	.0