diff src/customview.asm @ 560:b7eb98dbd800

bump to 2.96beta (REFACTORED VERSION)
author heinrichsweikamp
date Wed, 31 Jan 2018 19:39:37 +0100
parents d36f9fca10ae
children 690bfb76911c
line wrap: on
line diff
--- a/src/customview.asm	Wed Dec 27 14:34:11 2017 +0100
+++ b/src/customview.asm	Wed Jan 31 19:39:37 2018 +0100
@@ -1,6 +1,6 @@
 ;=============================================================================
 ;
-;   File customview.asm
+;   File customview.asm								REFACTORED VERSION V2.95
 ;
 ;   Customview in Surfacemode and Divemode
 ;
@@ -21,6 +21,7 @@
 #include	"convert.inc"
 #include	"divemode.inc"
 #include    "i2c.inc"
+#include    "start.inc"	
 
 gui     CODE
 
@@ -29,46 +30,60 @@
 
 	global	customview_second
 customview_second:
-	movff	menupos3,WREG               ; copy current view (1-...)
+	movff	menupos3,WREG			; copy current view (1-...)
 	dcfsnz	WREG,F
-	goto    TFT_update_ppo2_sensors         ; Update Sensor data ; and return
+	goto    TFT_update_ppo2_sensors	; Update Sensor data ; and return
 	dcfsnz	WREG,F
-	goto    TFT_update_avr_stopwatch        ; Update average depth and stopwatch; and return
+	goto    TFT_update_avr_stopwatch ; Update average depth and stopwatch; and return
 	dcfsnz	WREG,F
-	goto    TFT_decoplan                    ; Show decoplan ; and return
+	goto    TFT_decoplan			; Show decoplan ; and return
 	dcfsnz	WREG,F
-	goto    TFT_battinfo_tissues_clock       ; Update Battery, Tissues and clock ; and return
+	goto    TFT_battinfo_tissues_clock ; Update Battery, Tissues and clock ; and return
 	dcfsnz	WREG,F
-	goto    TFT_gf_info                     ; Update GF informations ; and return
+	goto    TFT_gf_info				; Update GF informations ; and return
 	dcfsnz	WREG,F
-        return  ; Compass updated seperately (Faster) in divemode;
+	return							; Compass updated separately (faster) in divemode;
 	dcfsnz	WREG,F
-	goto    TFT_dyn_gaslist                 ; Update the gaslist ; and return
+	nop								; ex goto TFT_dyn_gaslist
 	dcfsnz	WREG,F
-	goto    TFT_hud_voltages                ; Show HUD details	; and return
+	goto	TFT_CNS					; Show CNS values for end-of-dive, ex goto TFT_hud_voltages
 	dcfsnz	WREG,F
-	bra	customview_1sec_view9           ; Make sure to change value in "check_ppo2_display:" when moving around custom views
+	bra		customview_1sec_view9	; Make sure to change value in "check_ppo2_display:" when moving around custom views
 	dcfsnz	WREG,F
-	goto    TFT_sensor_check                ; Show ppO2 of O2 and Diluent ; and return
+	goto    TFT_sensor_check		; Show ppO2 of O2 and Diluent ; and return
 	dcfsnz	WREG,F
-	goto	TFT_ppo2_ead_end_cns            ; Show ppO2, END/EAD and CNS; and return
+	goto	TFT_ppo2_ead_end_cns	; Show ppO2, END/EAD and CNS; and return
 	dcfsnz	WREG,F
 	goto	TFT_pscr_info			; Show ppO2, drop and lung ratio; and return
+	dcfsnz	WREG,F
+	goto	TFT_gas_needs			; Show gas needs
 
 	; Menupos3=0, do nothing
 	return
 
-customview_1sec_view9:                      ; Ceiling
-    call    TFT_ceiling                     ; Show Ceiling
-    ; ppO2 value
-    call    TFT_display_ppo2_val
-    ; current GF value
-    extern  char_I_deco_model
-    TSTOSS  char_I_deco_model               ; 0 = ZH-L16, 1 = ZH-L16-GF
-    return                                  ; No GF info for non-GF modes
-    goto    TFT_gf_info                     ; Update GF informations ; and return
+customview_1sec_view9:              ; Ceiling
+    call    TFT_ceiling             ; Show Ceiling
+    call    TFT_display_pure_ppo2	; ppO2 value
+    extern  char_I_deco_model		; current GF value
+    TSTOSS  char_I_deco_model       ; 0 = ZH-L16, 1 = ZH-L16-GF
+    return                          ; No GF info for non-GF modes
+    goto    TFT_gf_info             ; Update GF informations ; and return
 
+    global  customview_alternative_second
+customview_alternative_second:    
+	movff	menupos3,WREG			; copy current view (1-...)
+	dcfsnz	WREG,F
+	bra		customview_alt_second_view1	; View 1
+	dcfsnz	WREG,F
+	nop 							; View 2
 
+	; Menupos3=0, do nothing
+	return
+	
+customview_alt_second_view1:
+    bsf	    FLAG_TFT_max_depth_alt
+    bsf	    FLAG_TFT_big_deco_alt
+    return
 
 ;=============================================================================
 ; Do every-minute tasks for the custom view area
@@ -76,7 +91,7 @@
 	global	customview_minute
 customview_minute:
     return
-;	movff	menupos3,WREG               ; copy
+;	movff	menupos3,WREG           ; copy
 ;	dcfsnz	WREG,F
 ;	bra		customview_1min_view1
 ;	dcfsnz	WREG,F
@@ -119,7 +134,7 @@
 surf_customview_toggle:
 	bcf		switch_right
 	incf	menupos3,F			            ; Number of customview to show
-	movlw	d'9'					; Max number of customsviews in surface mode
+	movlw	d'9'							; Max number of customsviews in surface mode
 	cpfsgt	menupos3			            ; Max reached?
 	bra		surf_customview_mask		    ; No, show
     movlw   .1
@@ -204,21 +219,21 @@
     call	TFT_splist_surfmode             ; Show Setpoint list
     bra		customview_toggle_exit          ; Done.
     
-surf_customview_init_view9:		    ; View 9: Sensor mV on the surface
+surf_customview_init_view9:		    		; View 9: Sensor mV on the surface
     btfsc   FLAG_ccr_mode 
     bra	    surf_customview_init_view9a	    ; we are in CCR mode 
     btfsc   FLAG_pscr_mode
     bra	    surf_customview_init_view9a	    ; we are in PSCR mode 
-    bra	    surf_customview_toggle	    ; we are not in any rebreather mode, so skip 
+    bra	    surf_customview_toggle	    	; we are not in any rebreather mode, so skip 
 surf_customview_init_view9a: 
-    movff   opt_ccr_mode,WREG		    ; =0: Fixed SP, =1: Sensor, =2: Auto SP 
-    sublw   .1				    ; opt_ccr_mode = 1 (Sensor)? 
-    bnz	    surf_customview_toggle	    ; sorry, no sensors, skip again 
+    movff   opt_ccr_mode,WREG		    	; =0: Fixed SP, =1: Sensor, =2: Auto SP 
+    sublw   .1				    			; opt_ccr_mode = 1 (Sensor)? 
+    bnz	    surf_customview_toggle	    	; sorry, no sensors, skip again 
     STRCPY_TEXT_PRINT tSensorMilliVolt	    ; Title of customview 
     call    TFT_standard_color 
     extern  TFT_sensor_mV
-    call    TFT_sensor_mV		    ; write sensor mV readings to screen 
-    bra	    customview_toggle_exit		; Done.
+    call    TFT_sensor_mV		    		; write sensor mV readings to screen 
+    bra	    customview_toggle_exit			; Done.
 
 surf_customview_init_view4:                 ; View4: Custom text
     call    TFT_standard_color
@@ -242,36 +257,49 @@
     bra		customview_toggle_exit          ; Done.
     
 surf_customview_init_view7:
-    btfsc   FLAG_gauge_mode		    ; View7: Deco settings
+    btfsc   FLAG_gauge_mode		    		; View7: Deco settings
     bra     surf_customview_toggle
     btfsc   FLAG_apnoe_mode
     bra     surf_customview_toggle
-    extern  deco_setup_dive
-    call    deco_setup_dive
+	
     call    TFT_surface_decosettings        ; Show all deco settings
     bra		customview_toggle_exit          ; Done.
 
 surf_customview_init_view8:                 ; View8: Last dive info
-    call	TFT_surface_lastdive		; Show last dive interval
+    call	TFT_surface_lastdive			; Show last dive interval
     bra		customview_toggle_exit          ; Done.
     
     
     global  menuview_toggle
-menuview_toggle:            ; Show Menu or the simulator tasks
+menuview_toggle:            				; Show Menu or the simulator tasks
+    btfss   alternative_divelayout			; In alternative layout mode?
+    bra	    menuview_toggle2				; No
+    ; Switch back to normal mode for any menu tasks
+    bcf	    alternative_divelayout			; clear flag
+    bsf	    FLAG_TFT_divemode_mask			; Set flag for mask
+    bsf	    FLAG_TFT_max_depth				; set flag
+    btfss   decostop_active             	; deco?
+    bsf	    FLAG_TFT_display_ndl_mask   	; NDL
+    btfsc   decostop_active             	; deco?
+    bsf	    FLAG_TFT_display_deko_mask		; Deco
+    call    TFT_ClearScreen					; Clear screen
+    rcall   customview_mask					; Re-Draw customview
+    
+menuview_toggle2:
     movlw   divemode_menuview_timeout
     movwf   timeout_counter3
     bsf     menuview
-	bcf		switch_left
-	incf	menupos2,F			            ; Number of options to show
-	movlw	d'9'							; Max number of options in divemode
-	cpfsgt	menupos2			            ; Max reached?
-	bra		menuview_mask		            ; No, show
+    bcf		switch_left
+    incf	menupos2,F			            ; Number of options to show
+    movlw	d'10'					        ; Max number of options in divemode
+    cpfsgt	menupos2			            ; Max reached?
+    bra		menuview_mask		            ; No, show
     global  menuview_toggle_reset
-menuview_toggle_reset:                      ; Timeout occured
-	clrf	menupos2
+menuview_toggle_reset:                      ; Timeout occurred
+    clrf    menupos2
     bcf     menuview
 menuview_mask:
-    WIN_BOX_BLACK   dm_simtext_row, dm_simtext_row+.23, dm_simtext_column, dm_simtext_column+.49 ; top, bottom, left, right
+    WIN_BOX_BLACK   dm_simtext_row, dm_simtext_row+.23, dm_simtext_column, dm_simtext_column+.45 ; top, bottom, left, right - old value was .49
     btfss   FLAG_gauge_mode
     bra     menuview_mask2
     ; Clear some more in gauge mode  -- "Reset Avg." text is longer than normal simtext
@@ -280,7 +308,7 @@
     call    TFT_draw_gassep_line
     movlw   color_yellow
     call	TFT_set_color
-    bsf     win_invert                  ; Set invert flag
+    bsf     win_invert                  	; Set invert flag
     WIN_SMALL   dm_simtext_column,dm_simtext_row
 	movff	menupos2,WREG                   ; Menupos2 holds number of menu option to show
 	dcfsnz	WREG,F
@@ -301,9 +329,12 @@
 	bra		menuview_view7                  ; "Sim:+5mins"  (Sim only)
 	dcfsnz	WREG,F
 	bra		menuview_view8                  ; "Heading"  (When compass is shown)
+	dcfsnz	WREG,F
+	bra		menuview_view9                  ; "Layout"  (Alternative Layout, aka Blind mode)
+	
 menuview_exit:
     call	TFT_standard_color
-    bcf     win_invert              ; Reset invert flag
+    bcf     win_invert              		; Reset invert flag
 	return                                  ; Menupos2 = 0, Show nothing
 
 
@@ -336,12 +367,12 @@
 menuview_view3:
     btfss  	simulatormode_active			; View only for simulator mode
 	bra		menuview_toggle 				; Call next option
-	STRCPY_PRINT "Sim:-1m"
+	STRCPY_PRINT "Sim-1m"					; CHANGED, now "-" for going down
     bra     menuview_exit                   ; Done.
 menuview_view4:
     btfss  	simulatormode_active			; View only for simulator mode
 	bra		menuview_toggle 				; Call next option
-	STRCPY_PRINT "Sim:+1m"
+	STRCPY_PRINT "Sim+1m"					; CHANGED, now "+" for going up
     bra     menuview_exit                   ; Done.
 menuview_view5:
 	btfss	FLAG_apnoe_mode					; In Apnoe mode?
@@ -363,7 +394,7 @@
 	bra		menuview_toggle 				; Yes, call next option
 	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
 	bra		menuview_toggle 				; Yes, call next option
-	STRCPY_PRINT	"Sim:+5'"
+	STRCPY_PRINT	"Sim+5'"
 	bra     menuview_exit                   ; Done.
 menuview_view8:
     movlw   .6
@@ -371,27 +402,81 @@
 	bra		menuview_toggle 				; No, call next option
 	STRCPY_TEXT_PRINT	tSetHeading         ; "Heading"
 	bra     menuview_exit                   ; Done.
+menuview_view9:
+	STRCPY_PRINT	"Layout"
+	bra     menuview_exit                   ; Done.
 
 
+	
+	
 ;=============================================================================
+	
+customview_toggle_alternative:
+	movlw	d'1'				    ; Max number of customviews in divemode, alternative layout
+	cpfsgt	menupos3			    ; Max reached?
+	bra 	customview_mask_alternative         ; No, show
+	movlw	.1
+	movwf	menupos3			    ; Reset to one, always one customview visible in alternative layout
+customview_mask_alternative:	
+    ; Clear custom view area in divemode
+	WIN_BOX_BLACK    dm_customview_row, .239, .0, .159	; top, bottom, left, right
+	call	TFT_standard_color
+	movff	menupos3,WREG           ; Menupos3 holds number of customview function
+	dcfsnz	WREG,F
+	bra	customview_alt_init_view1   ; View 1: Big deco/ndl and max. depth
+	dcfsnz	WREG,F
+	bra	customview_alt_init_view2   ; View 2: 
+
+	;bra	customview_alternative_toggle_exit  ; No view (menupos3=0)
+	
+customview_alt_toggle_exit:
+    call    TFT_standard_color
+    bcf	    toggle_customview		; Clear flag
+    return
+
+customview_alt_init_view1:  ; View 1: Big deco/ndl and max. depth
+    call    TFT_max_depth_alternative
+    call    TFT_big_deco_alt
+    bra	    customview_alt_toggle_exit
+
+customview_alt_init_view2:
+    ; /* Just for test...
+    call    TFT_mask_avr_stopwatch		; Show mask for average depth and stopwatch
+    call    TFT_update_avr_stopwatch	; Update average depth and stopwatch
+    ; ...Just for test */
+    
+    bra	    customview_alt_toggle_exit
+    
+	
 ; Show next customview (and delete this flag)
-customview_toggle_reset:					; Timeout occured
-	clrf	menupos3			            ; Reset to zero (Zero=no custom view)
+	global	customview_toggle
+customview_toggle:
+	bcf	switch_right
+	incf	menupos3,F			    ; Number of customview to show
+	
+	btfsc   alternative_divelayout		    ; In alternative layout mode?
+	bra		customview_toggle_alternative	; Yes, use the big ones instead
+	
+	movlw	d'13'				    ; Max number of customviews in divemode
+	cpfsgt	menupos3			    ; Max reached?
+	bra 	customview_mask		            ; No, show
+	clrf	menupos3			    ; Reset to zero (Zero=no custom view)
+
     global  customview_mask
 customview_mask:	
     ; Clear custom view area in divemode
-    WIN_BOX_BLACK    dm_customview_row, dm_customview_bot, dm_customview_column, dm_customview_rgt	; top, bottom, left, right
+    WIN_BOX_BLACK    dm_customview_row, dm_customview_bot-.2, dm_customview_column, dm_customview_rgt	; top, bottom, left, right
 	WIN_SMALL	dm_customview_column,dm_customview_row
 	call	TFT_standard_color
 	movff	menupos3,WREG                   ; Menupos3 holds number of customview function
 	dcfsnz	WREG,F
-	bra		customview_init_view1		; Update Sensor data
+	bra		customview_init_view1			; Update Sensor data
 	dcfsnz	WREG,F
-	bra		customview_init_view2		; average depth and stopwatch
+	bra		customview_init_view2			; average depth and stopwatch
 	dcfsnz	WREG,F
-	bra		customview_init_view3		; Decoplan
+	bra		customview_init_view3			; Decoplan
 	dcfsnz	WREG,F
-	bra		customview_init_view4		; Battery info, Tissues and clock
+	bra		customview_init_view4			; Battery info, Tissues and clock
 	dcfsnz	WREG,F
 	bra		customview_init_view5           ; GF informations
 	dcfsnz	WREG,F
@@ -399,7 +484,7 @@
 	dcfsnz	WREG,F
 	bra		customview_init_view7           ; Dynamic gaslist
 	dcfsnz	WREG,F
-	bra		customview_init_view8           ; HUD voltages
+	bra		customview_init_view8           ; HIJACKED for CNS (ex HUD voltages)
 	dcfsnz	WREG,F
 	bra		customview_init_view9           ; ppO2, Ceiling and current GF
 	dcfsnz	WREG,F
@@ -408,17 +493,20 @@
 	bra		customview_init_view11          ; ppO2, END/EAD and CNS
 	dcfsnz	WREG,F
 	bra		customview_init_view12          ; PSCR Info
-
+	; NEW	## bailout gas needs
+	dcfsnz	WREG,F
+	bra		customview_init_view13			; Gas needs
+	
 customview_init_nocustomview:
     call    I2C_sleep_accelerometer         ; Stop accelerometer
     call    I2C_sleep_compass               ; Stop compass
-	bra		customview_toggle_exit	
+    bra		customview_toggle_exit	
 
 customview_init_view1:
     btfsc	FLAG_apnoe_mode					; In Apnoe mode?
     bra		customview_toggle				; yes, Call next view...
     btfsc	FLAG_pscr_mode					; In PSCR mode?
-    bra		customview_init_view1a				; Yes
+    bra		customview_init_view1a			; Yes
     btfss	FLAG_ccr_mode					; In CC mode?
     bra		customview_toggle				; no, Call next view...
     
@@ -432,18 +520,15 @@
     btfsc   STATUS,Z
     bra		customview_toggle				; no, Call next view...
 
-    bsf     dive_hud1_displayed         ; Set display flag
-    bsf     dive_hud2_displayed         ; Set display flag
-    bsf     dive_hud3_displayed         ; Set display flag
-    call    TFT_hud_mask                ; Setup HUD mask
-    call    TFT_update_ppo2_sensors     ; Update Sensor data
+    call    TFT_hud_mask					; Setup HUD mask
+    call    TFT_update_ppo2_sensors			; Update Sensor data
     bra	    customview_toggle_exit	
 
 customview_init_view2:
 	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
 	bra		customview_toggle				; Yes, Call next view...
-    call    TFT_mask_avr_stopwatch     ; Show mask for average depth and stopwatch
-    call    TFT_update_avr_stopwatch   ; Update average depth and stopwatch
+    call    TFT_mask_avr_stopwatch			; Show mask for average depth and stopwatch
+    call    TFT_update_avr_stopwatch		; Update average depth and stopwatch
     bra		customview_toggle_exit
 
 customview_init_view3:
@@ -455,8 +540,8 @@
     bra		customview_toggle_exit
 
 customview_init_view4:
-    call    TFT_battinfo_tissues_clock_mask  ; Setup Mask
-    call    TFT_battinfo_tissues_clock       ; Show Battery info, Tissues and clock
+    call    TFT_battinfo_tissues_clock_mask	; Setup Mask
+    call    TFT_battinfo_tissues_clock		; Show Battery info, Tissues and clock
     bra		customview_toggle_exit
 
 customview_init_view5:
@@ -480,172 +565,172 @@
     call	TFT_dive_compass_mask           ; Show compass
     bra		customview_toggle_exit
 
+; MODIFIED - view disabled	## memory
 customview_init_view7:                      ; Dynamic gaslist (View 7)
-	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
-	bra		customview_toggle				; Yes, Call next view...
-	btfsc	FLAG_ccr_mode					; In CC mode?
+;	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
 	bra		customview_toggle				; Yes, Call next view...
-    call    TFT_dyn_gaslist                 ; Show the dyn gaslist
-    bra		customview_toggle_exit
+;	btfsc	FLAG_ccr_mode					; In CC mode?
+;	bra		customview_toggle				; Yes, Call next view...
+;   call    TFT_dyn_gaslist                 ; Show the dyn gaslist
+;   bra		customview_toggle_exit
 
-customview_init_view8:                      ; Sensor millivolts
+customview_init_view8:                      ; HIJACKED for CNS outputs (ex Sensor millivolts)
 	btfsc	FLAG_gauge_mode					; In Gauge mode?
 	bra		customview_toggle				; Yes, Call next view...
 	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
 	bra		customview_toggle				; yes, Call next view...
-        btfsc	FLAG_pscr_mode					; In PSCR mode?
-	bra		customview_init_view8a				; Yes
-	btfss	FLAG_ccr_mode					; In CC mode?
-	bra		customview_toggle				; no, Call next view...
-customview_init_view8a:    
-    movf    hardware_flag,W
-    sublw   0x13        ; +
-    btfsc   STATUS,Z
-    bra		customview_toggle				; no, Call next view...
+	; REPLACE	## CNS at end-of-dive
+	; btfsc	FLAG_pscr_mode					; In PSCR mode?
+	; bra		customview_init_view8a		; Yes
+	; btfss	FLAG_ccr_mode					; In CC mode?
+	; bra		customview_toggle			; no, Call next view...
+; customview_init_view8a:    
+    ; movf    hardware_flag,W
+    ; sublw   0x13        ; +
+    ; btfsc   STATUS,Z
+    ; bra	  customview_toggle				; no, Call next view...
+    ; movff   opt_ccr_mode,WREG             ; =0: Fixed SP, =1: Sensor,  =2: Auto SP
+    ; sublw   .1                            ; opt_ccr_mode = 1 (Sensor)?
+    ; bnz     customview_toggle				; no, Call next view...
+    ; call    TFT_hud_mask                  ; Setup HUD mask
+    ; call    TFT_hud_voltages              ; Show HUD details
+	; BY
+	call	TFT_CNS_mask
+	call	TFT_CNS
 
-    movff   opt_ccr_mode,WREG               ; =0: Fixed SP, =1: Sensor,  =2: Auto SP
-    sublw   .1                              ; opt_ccr_mode = 1 (Sensor)?
-    bnz     customview_toggle				; no, Call next view...
-    call    TFT_hud_mask                    ; Setup HUD mask
-    call    TFT_hud_voltages                ; Show HUD details
-    goto    customview_toggle_exit
+	goto    customview_toggle_exit
 
 customview_init_view9:                      ; ppO2, Ceiling and current GF
 	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
-	bra	customview_toggle				; yes, Call next view...
+	bra	customview_toggle					; yes, Call next view...
 	btfsc	FLAG_gauge_mode					; In Gauge mode?
-	bra	customview_toggle				; Yes, Call next view...
+	bra	customview_toggle					; Yes, Call next view...
     call    TFT_ceiling_mask                ; Setup mask
     call    TFT_ceiling                     ; Show Ceiling
 
     ; ppO2 value
     call    TFT_mask_ppo2
-    call    TFT_display_ppo2_val
+    call    TFT_display_pure_ppo2
 
     ; current GF value
     extern  char_I_deco_model
     TSTOSS  char_I_deco_model               ; 0 = ZH-L16, 1 = ZH-L16-GF
-    bra	    customview_toggle_exit	    ; No GF info for non-GF modes
+    bra	    customview_toggle_exit	   		; No GF info for non-GF modes
     ; current GF value
     call    TFT_gf_mask_cGF                 ; Setup Mask - current GF only
     call    TFT_gf_info                     ; Show GF informations
     bra	    customview_toggle_exit
 
-
-;=============================================================================
-; Show next customview (and delete this flag)
-	global	customview_toggle
-customview_toggle:
-	bcf	switch_right
-	incf	menupos3,F			            ; Number of customview to show
-	movlw	d'12'							; Max number of customsviews in divemode
-	cpfsgt	menupos3			            ; Max reached?
-	goto	customview_mask		            ; No, show
-	goto	customview_toggle_reset
-    
-    
 customview_init_view10:                     ; Sensor check
-    btfsc   FLAG_apnoe_mode		    ; In Apnoe mode?
-    bra	    customview_toggle		    ; yes, Call next view...
-    btfsc   FLAG_gauge_mode		    ; In Gauge mode?
-    bra	    customview_toggle		    ; Yes, Call next view...
-    btfss   FLAG_ccr_mode		    ; In CC mode?
-    bra	    customview_toggle		    ; no, Call next view...
+    btfsc   FLAG_apnoe_mode		    		; In Apnoe mode?
+    bra	    customview_toggle		    	; yes, Call next view...
+    btfsc   FLAG_gauge_mode		    		; In Gauge mode?
+    bra	    customview_toggle		    	; Yes, Call next view...
+    btfss   FLAG_ccr_mode		    		; In CC mode?
+    bra	    customview_toggle		   		; no, Call next view...
 
     call    TFT_sensor_check_mask           ; Show ppO2 of O2 and Diluent mask
     call    TFT_sensor_check                ; Show ppO2 of O2 and Diluent
     bra		customview_toggle_exit
 
 customview_init_view11:                     ; ppO2, END/EAD and CNS
-    btfsc   FLAG_apnoe_mode		    ; In Apnoe mode?
-    bra	    customview_toggle		    ; yes, Call next view...
-    btfsc   FLAG_gauge_mode		    ; In Gauge mode?
-    bra	    customview_toggle		    ; Yes, Call next view...
+    btfsc   FLAG_apnoe_mode		    		; In Apnoe mode?
+    bra	    customview_toggle		    	; yes, Call next view...
+    btfsc   FLAG_gauge_mode		    		; In Gauge mode?
+    bra	    customview_toggle		    	; Yes, Call next view...
 
     call    TFT_ppo2_ead_end_cns_mask       ; Show ppO2, END/EAD and CNS mask
     call    TFT_ppo2_ead_end_cns            ; Show ppO2, END/EAD and CNS
     goto    customview_toggle_exit
 
-customview_init_view12:		            ; PSCR Info    
-    btfss   FLAG_pscr_mode		    ; In PSCR mode?
-    bra	    customview_toggle		    ; No, Call next view...
+customview_init_view12:		            	; PSCR Info    
+    btfss   FLAG_pscr_mode		    		; In PSCR mode?
+    bra	    customview_toggle		    	; No, Call next view...
     
-    call    TFT_pscr_info_mask		    ; Show ppO2, drop and lung ratio
-    call    TFT_pscr_info		    ; Show ppO2, drop and lung ratio
+    call    TFT_pscr_info_mask		   		; Show ppO2, drop and lung ratio
+    call    TFT_pscr_info		    		; Show ppO2, drop and lung ratio
     bra		customview_toggle_exit
-    
+
+; NEW	## bailout gas needs
+customview_init_view13:						; Gas Needs
+    TSTOSS  opt_calc_asc_gasvolume			; check if gas volume calculations is switched on
+    bra	    customview_toggle				; NO  - Call next view...
+    call    TFT_gas_needs_mask				; YES - Show the mask for gas needs
+    call    TFT_gas_needs					; 		Show the gas needs
+    bra	    customview_toggle_exit
+	
 customview_toggle_exit:
-	btfsc	divemode		    ; In Dive Mode?
-	call    TFT_temp_divemode	    ; Yes, redraw temperature
-	call	TFT_standard_color
-	bcf		toggle_customview			; Clear flag
-	return
+    btfsc   divemode				; In Dive Mode?
+    bsf	    FLAG_TFT_temp_divemode		; Set flag to redraw temp
+    call    TFT_standard_color
+    bcf	toggle_customview			; Clear flag
+    return
 
 	global 	customview_show_change_depth
-customview_show_change_depth:       ; Put " lom" or " loft" into Postinc2
+customview_show_change_depth:       		; Put " lom" or " loft" into Postinc2
     PUTC    " "
-    TSTOSS  opt_units   			; 0=m, 1=ft
+    TSTOSS  opt_units   					; 0=m, 1=ft
 	bra		customview_show_mix_metric
     movf    lo,W
-    mullw   .100                    ; convert meters to mbar
+    mullw   .100                    		; convert meters to mbar
     movff   PRODL,lo
     movff   PRODH,hi
-    call	convert_mbar_to_feet    ; convert value in lo:hi from mbar to feet
+    call	convert_mbar_to_feet    		; convert value in lo:hi from mbar to feet
     bsf     leftbind
-    output_16						; Change depth in lo:hi
+    output_16								; Change depth in lo:hi
     bcf     leftbind
     STRCAT_TEXT		tFeets
     return
 customview_show_mix_metric:
-    output_99						; Change depth in lo
+    output_99								; Change depth in lo
     STRCAT_TEXT		tMeters
     return
 
 
 	global 	customview_show_mix
-customview_show_mix:                ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
-    tstfsz  hi                      ; He=0?
-    bra     customview_show_mix5    ; No, Show a TX
+customview_show_mix:                		; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
+    tstfsz  hi                      		; He=0?
+    bra     customview_show_mix5    		; No, Show a TX
 	movlw	.21
 	cpfseq	lo								; Air?
-	bra		customview_show_mix2	; No
+	bra		customview_show_mix2			; No
 	STRCAT_TEXT		tSelectAir				; Yes, show "Air"
     bra     customview_show_mix4b
 customview_show_mix2:
 	movlw	.100
 	cpfseq	lo								; O2?
-	bra		customview_show_mix3	; No
+	bra		customview_show_mix3			; No
 	STRCAT_TEXT		tSelectO2				; Yes, show "O2"
     bra     customview_show_mix4b
 
 customview_show_mix3:
 	movlw	.21
 	cpfslt	lo								; < Nx21?
-	bra		customview_show_mix4    ; No
-	STRCAT_TEXT		tGasErr        	; Yes, show "Err"
-	output_99						; O2 ratio is still in "lo"
+	bra		customview_show_mix4    		; No
+	STRCAT_TEXT		tGasErr        			; Yes, show "Err"
+	output_99								; O2 ratio is still in "lo"
     bra     customview_show_mix4c
 
 customview_show_mix4:
-	STRCAT_TEXT		tSelectNx		; Show "Nx"
-	output_99						; O2 ratio is still in "lo"
+	STRCAT_TEXT		tSelectNx				; Show "Nx"
+	output_99								; O2 ratio is still in "lo"
 customview_show_mix4b:
     STRCAT  " "
 customview_show_mix4c:
-    btfsc   divemode                ; In divemode
-	return                          ; Yes
+    btfsc   divemode                		; In divemode
+	return                          		; Yes
     STRCAT  "  "
     return
 
 customview_show_mix5:
     btfsc   divemode
     bra     customview_show_mix6
-    STRCAT_TEXT		tSelectTx   	; Show "Tx"
+    STRCAT_TEXT		tSelectTx   			; Show "Tx"
 customview_show_mix6:
-    output_99						; O2 ratio is still in "lo"
+    output_99								; O2 ratio is still in "lo"
     PUTC    "/"
     movff   hi,lo
-    output_99						; He ratio
+    output_99								; He ratio
     return
 
 	END
\ No newline at end of file