changeset 650:bc214815deb2

3.19/10.75 release
author heinrichsweikamp
date Sun, 28 Aug 2022 13:13:38 +0200
parents ef2ed7e3a895
children 682c514c53c0
files src/Docu/banks.txt src/adc_lightsensor.asm src/compass.c src/compass.h src/compass_calib.c src/compass_ops.asm src/configuration.inc src/divemenu_tree.asm src/divemode.asm src/eeprom_rs232.asm src/eeprom_rs232.inc src/hwos.asm src/hwos.inc src/i2c.asm src/menu_tree.asm src/option_table.asm src/p2_deco.c src/shared_definitions.h src/sleepmode.asm src/start.asm src/text_english.inc src/text_french.inc src/text_german.inc src/text_italian.inc src/text_multilang.asm src/tft_outputs.asm
diffstat 26 files changed, 663 insertions(+), 602 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Docu/banks.txt	Sun Aug 28 13:13:38 2022 +0200
@@ -0,0 +1,21 @@
+                  Bank Overview (FW 3.19)
+                  =======================
+
+Bank    Use                                        free Bytes
+-------------------------------------------------------------
+  0     ASM (ISR) vars                                  2
+  1     ASM vars "common"                               5
+  2     buffer                                          0
+  3     ASM / C shared vars                             3
+  4     ASM / C shared vars                           160
+  5     C vars p2_deco                                  4
+  6     C vars p2_deco                                 18
+  7     tissue pressures "real"                         0
+  8     tissue pressures "sim"                          0
+  9     C vars a:compass  b:compass_calib             153
+ 10     ASM vars "common2"                             92
+ 11     ASM / C shared vars (buffer2, backtracking)     0
+ 12     tissue pressures "vault"                        0
+ 13     C stack                                         0
+ 14     options table                                  51
+ 15     SFRs + 16 unused bytes                         16
\ No newline at end of file
--- a/src/adc_lightsensor.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/adc_lightsensor.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -81,6 +81,11 @@
 	;bra	charge_cv_active				;       YES - charging in CV mode
 
 charge_cv_active:
+    	btfss	analog_switches				; does the OSTC have analog switches?
+	bra	charge_cv_active1			; NO
+    	btfsc	surfmode_menu				; YES - in surface menus?
+	bsf	trigger_timeout				; YES - exit to surface mode during charging
+charge_cv_active1:
 	decfsz	get_bat_volt_counter,F			; decrement counter, became zero?
 	return									; NO  - not yet, done
 	movlw	.15								; YES - battery voltage >= 16*256mV (4.096V)
@@ -96,6 +101,11 @@
 	return									;         - done
 
 charge_cc_active:
+    	btfss	analog_switches				; does the OSTC have analog switches?
+	bra	charge_cc_active1			; NO
+    	btfsc	surfmode_menu				; YES - in surface menus?
+	bsf	trigger_timeout				; YES - exit to surface mode during charging
+charge_cc_active1:
 	bsf		cc_active						; set CC charging mode
 	bsf		LEDr							; indicate charging
 	bcf		CHRG_OUT						; 
@@ -258,9 +268,12 @@
 	return									; YES - done
 	btfsc	adc_is_running					; NO  - ADC in use?
 	return									;       YES - abort
+	TSTOSS	opt_use_AmbientSensor				; =1: Use the ambient sensor
+	bra	get_ambient_level0				; NO, skip and use fixed value
 	banksel	HW_descriptor					;       NO  - select bank where hardware descriptor is stored
 	btfsc	ambient_sensor					;           - ambient sensor available?
 	bra		get_ambient_level1				;             YES - use sensor
+get_ambient_level0:	
 	banksel	isr_backup						;             NO  - back to ISR default bank
 	movff	brightness,isr_lo			;                 - get brightness selection
 	incf	isr_lo,F						;                 - 0-2 -> 1-3
@@ -509,7 +522,9 @@
 get_analog_switches_1:
 	btfsc	adc_is_running					; ADC in use?
 	return									; YES - abort
-	btfsc	cc_active						; NO  - charging?
+	btfsc	cc_active						; NO  - charging constant current?
+	bra		get_analog_switches0			;       YES - abort (and clear both flags)
+	btfsc	cv_active						; NO  - charging constant voltage?
 	bra		get_analog_switches0			;       YES - abort (and clear both flags)
 
 get_analog_switches_2:
--- a/src/compass.c	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/compass.c	Sun Aug 28 13:13:38 2022 +0200
@@ -18,21 +18,29 @@
 
 
 //////////////////////////////////////////////////////////////////////////////
-// mH: crude work-around, needs to be fixed up
+//
+// Put compass data into bank 13 (stack) and bank 9 (variables)
+//
 #ifndef UNIX
-#	pragma udata overlay bank8=0x800
-	static char C_STACK[256];			// overlay C-code data stack here
-#	define RESET_C_STACK		\
-		_asm					\
-			LFSR	1, 0x800	\
-			LFSR	2, 0x800	\
+#	pragma udata overlay bank13=0xd00
+	static char C_STACK[256];				// overlay C-code data stack here
+#	define C_STACK_ADDR C_STACK
+#	define RESET_C_STACK			\
+		_asm						\
+			LFSR	1,C_STACK_ADDR	\
+			LFSR	2,C_STACK_ADDR	\
 		_endasm
-#	pragma udata overlay bank9_compass
+#	pragma udata bank9a = 0x900
 #	pragma code compass_run
+#	define PARAMETER	static
+#	define OVERLAY		overlay
 #else
 #	define RESET_C_STACK
+#	define PARAMETER
+#	define OVERLAY
 #endif
 
+
 //////////////////////////////////////////////////////////////////////////////
 // fifth order of polynomial approximation of atan(), giving 0.05 deg max error
 //
@@ -247,7 +255,7 @@
 
 	//---- Calculate sine and cosine of roll angle Phi -----------------------
 	sincos(accel_DZ_f, accel_DY_f, &sin, &cos);
-    
+
 	//---- rotate by roll angle (-Phi) ---------------------------------------
 	iBfy = imul(iBpy, cos) - imul(iBpz, sin);
 	iBpz = imul(iBpy, sin) + imul(iBpz, cos);
--- a/src/compass.h	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/compass.h	Sun Aug 28 13:13:38 2022 +0200
@@ -8,8 +8,6 @@
 #	define PARAMETER
 #	define OVERLAY
 #else
-//---- Bank 9 parameters -----------------------------------------------------
-#	pragma udata overlay bank9_compass = 0x900
 #	define PARAMETER	static
 #	define OVERLAY		overlay
 #endif
@@ -43,18 +41,18 @@
 //extern Int16 compass_roll;
 //extern Int16 compass_pitch;
 
-extern Int16 umul(PARAMETER Int16 a, PARAMETER Int16 b);
-extern Int16 imul(PARAMETER Int16 a, PARAMETER Int16 b);
-extern Int16 udiv(PARAMETER Int16 a, PARAMETER Int16 b);
-extern Angle utan(PARAMETER Int16 a, PARAMETER Int16 b);
-extern Angle itan(PARAMETER Int16 a, PARAMETER Int16 b);
+extern Int16 umul (PARAMETER Int16 a, PARAMETER Int16 b);
+extern Int16 imul (PARAMETER Int16 a, PARAMETER Int16 b);
+extern Int16 udiv (PARAMETER Int16 a, PARAMETER Int16 b);
+extern Angle utan (PARAMETER Int16 a, PARAMETER Int16 b);
+extern Angle itan (PARAMETER Int16 a, PARAMETER Int16 b);
 extern Angle cosxh(PARAMETER Int16 a, PARAMETER Int16 b);
 
 extern void sincos(PARAMETER Int16 a, PARAMETER Int16 b, Int16* sin, Int16* cos);
 
 //////////////////////////////////////////////////////////////////////////////
 // The user functions
-extern void compass(void);
+extern void compass                  (void);
 extern void compass_reset_calibration(void);
-extern void compass_add_calibration(void);
+extern void compass_add_calibration  (void);
 extern void compass_solve_calibration(void);
--- a/src/compass_calib.c	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/compass_calib.c	Sun Aug 28 13:13:38 2022 +0200
@@ -19,23 +19,28 @@
 
 //////////////////////////////////////////////////////////////////////////////
 //
-// mH: Put compass data into bank 8 (stack) and bank 9 (variables)
-// rl: could also be overlaid with p2_deco.c stack...
+// Put compass data into bank 13 (stack) and bank 9 (variables)
 //
 #ifndef UNIX
-#	pragma udata overlay bank8=0x800
+#	pragma udata overlay bank13=0xd00
 	static char C_STACK[256];				// overlay C-code data stack here
-#	define RESET_C_STACK		\
-		_asm					\
-			LFSR	1, 0x800	\
-			LFSR	2, 0x800	\
+#	define C_STACK_ADDR C_STACK
+#	define RESET_C_STACK			\
+		_asm						\
+			LFSR	1,C_STACK_ADDR	\
+			LFSR	2,C_STACK_ADDR	\
 		_endasm
-#	pragma udata overlay bank9_compass
+#	pragma udata bank9b = 0x980
 #	pragma code compass_cal
+#	define PARAMETER	static
+#	define OVERLAY		overlay
 #else
 #	define RESET_C_STACK
+#	define PARAMETER
+#	define OVERLAY
 #endif
 
+
 //////////////////////////////////////////////////////////////////////////////
 
 static unsigned short int compass_N;
--- a/src/compass_ops.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/compass_ops.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -391,7 +391,7 @@
 ; Show Calibration Progress
 ;
 TFT_compass_fast:
-	WIN_TINY .0,.50					; set font and position
+	WIN_TINY .5,.50					; set font and position
 	FONT_COLOR_MEMO					; set font color
 
 	STRCPY	"Cx:"					; print label
@@ -408,7 +408,7 @@
 
 	PRINT							; dump to screen
 
-	WIN_TINY .0,.104				; set font and position
+	WIN_TINY .5,.104				; set font and position
 	FONT_COLOR_MEMO					; set font color
 
 	STRCPY	"Ax:"					; print label
--- a/src/configuration.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/configuration.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -24,7 +24,7 @@
 #endif
 
 #define fw_version_major		0x03
-#define fw_version_minor		0x11
+#define fw_version_minor		0x13
 #define fw_version_beta			0x00
 
 
@@ -43,12 +43,12 @@
 #endif
 
 #define firmware_creation_year	0x16
-#define firmware_creation_month	0x01
-#define firmware_creation_day	0x15
+#define firmware_creation_month	0x08
+#define firmware_creation_day	0x1C
 
 #define firmware_expire_year	0x18
-#define firmware_expire_month	0x0A
-#define firmware_expire_day	0x0E
+#define firmware_expire_month	0x08
+#define firmware_expire_day	0x1C
 
 
 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -80,7 +80,7 @@
 #endif
 
 #define _language_1		en
-#define _language_2		de
+#define _language_2		none
 
 
 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
--- a/src/divemenu_tree.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/divemenu_tree.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -362,6 +362,8 @@
 	movlw	.1							; set to first option in dive mode menu
 	movwf	menu_pos_cur				; ...
 	bcf		gas6_or_EXIT				; default to presenting gas6 option
+        btfsc    alt_layout_active           ; alternative layout (big font) active?
+	bsf      gas6_or_EXIT                ; YES - do not present gas6 option
 do_lost_gas_common:
 	bsf		short_gas_descriptions		; do not show "Gas x" etc.
 	bcf		better_gas_hint				; do not mark the best gas/diluent
--- a/src/divemode.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/divemode.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -1917,8 +1917,12 @@
 	global	check_dive_modes_surf
 check_dive_modes_surf:
 	SMOVII	pressure_rel_cur,sub_a			; ISR-safe 2 byte copy of current relative pressure to sub_a
-	bcf		divetime_longer_1min			; not diving when in surface mode
-	bra		check_dive_modes				; continue with common part
+	bcf	divetime_longer_1min			; not diving when in surface mode
+	btfsc	cc_active				; charging constant current?
+	bra	check_dive_modes_shallow		; YES - abort (And reset debounce counter)
+	btfsc	cv_active				; NO  - charging constant voltage?
+	bra	check_dive_modes_shallow		; YES - abort (And reset debounce counter)
+	bra	check_dive_modes			; continue with common part
 
 
 ;-----------------------------------------------------------------------------
@@ -1963,7 +1967,7 @@
 	MOVLI	dive_threshold_norm_alt_end,sub_b	; load normal altitude end threshold
 	bra		check_dive_modes_comm				; continue with common part
 
-check_dive_modes_norm_start
+check_dive_modes_norm_start:
 	MOVLI	dive_threshold_norm_alt_start,sub_b	; load normal altitude start threshold
 	;bra	check_dive_modes_comm				; continue with common part
 
@@ -3828,6 +3832,8 @@
 	btfsc	bailout_mode				; YES - in bailout mode?
 	return								;       YES - done (deco zone flag is not updated when in bailout mode)
  ENDIF
+	TSTOSS	opt_warning_level_divemode		; Warning level set to =1 "All" ?
+	return						; NO, skip warning/advise then
 	movff	char_O_deco_info,WREG		;       NO  - get the deco info vector
 	btfss	WREG,deco_zone				;             deco zone flag set?
 	return								;             NO  - done
@@ -3859,12 +3865,14 @@
 	cpfsgt	depth_meter					; current depth > depth limit?
 	return								; NO  - done
 	bsf		warn_det_depth_limit		; YES - set warning
+	TSTOSS	opt_warning_level_divemode		; Warning level set to =1 "All" ?
+	return						; NO, skip warning/advise then
 	incf	message_counter,F			;     - increase message counter
 	goto	TFT_message_depth_limit		;     - show message
 
 
 ;-----------------------------------------------------------------------------
-; Check Bühlmann Model Violation
+; Check Bühlmann Model Violation
 ;
 check_outside:
 	bcf		warn_det_outside			; clear warning
@@ -3899,7 +3907,7 @@
 	bsf		warn_det_microbubble		; YES - set warning
 	bra		check_mbubbles_mesg			;     - show message
 
-check_mbubbles_1
+check_mbubbles_1:
 	btfss	WREG,mbubble_warning_lock	; had been in micro bubbling zone?
 	return								; NO  - done
 	bsf		attn_det_microbubble		; YES - set attention
@@ -4040,6 +4048,8 @@
 	return								; NO  - done
 
 check_gas_change_mesg:
+	TSTOSS	opt_warning_level_divemode		; Warning level set to =1 "All" ?
+	return						; NO, skip warning/advise then
 	bsf		advc_det_change_gas			; set advice
 	incf	message_counter,F			; increase message counter
 	goto	TFT_message_gas_change		; show advice and return
--- a/src/eeprom_rs232.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/eeprom_rs232.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -69,10 +69,24 @@
 write_eeprom_loop:
 	btfsc	EECON1,WR						; write completed?
 	bra		write_eeprom_loop				; NO  - loop waiting
+	btfsc	EECON1,WRERR						; All ok?
+	rcall	write_eeprom_error					; NO, something failed.
 	bcf		EECON1,WREN						; YES - disable writing
 	bsf		INTCON,GIE						;     - re-enable interrupts 
 	return									;     - done
-
+write_eeprom_error:
+	bsf	eeprom_write_error_flag					; Set error flag
+	; Try again (once)
+	movlw	0x55							; unlock sequence
+	movwf	EECON2							; ...
+	movlw	0xAA							; ...
+	movwf	EECON2							; ...
+	bsf		EECON1,WR						; start write operation
+write_eeprom_loop2:
+	btfsc	EECON1,WR						; write completed?
+	bra		write_eeprom_loop2				; NO  - loop waiting
+	return
+	
 
 ;-----------------------------------------------------------------------------
 ; EEPROM read and write Functions to be used via Macros
@@ -500,7 +514,10 @@
     bcf         NCTS            ; Clear to send
     call	wait_1s
     call	wait_1s
+    call	wait_1s
+    call	wait_1s
     bcf	PORTB,6
+    nop
     bsf	PORTB,6			; rising edge -> Command mode
     
     ; point to config table
@@ -545,7 +562,7 @@
     ; 0xFE: 20ms delay
     ; 0xFD: 1s delay
     ; .13: cr character
-    db	0xFD,0xFD						; Wait 2 seconds
+    db	0xFD,0xFD,0xFD,0xFD					; Wait 4 seconds
     db	"AT+UDSC=0,0",.13,0xFE,0xFE				; Disable SPP Server on ID0 (and wait 40ms)
     db	"AT+UDSC=0,3",.13,0xFE,0xFE				; SPP Server on ID0 (and wait 40ms)
     db	"AT+UDSC=1,0",.13,0xFE,0xFE				; Disable SPS Server on ID1 (and wait 40ms)
--- a/src/eeprom_rs232.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/eeprom_rs232.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -148,11 +148,11 @@
 ; eeprom_address: address:2 containing destination address in EEPROM
 ;
 EEPROM_CC_WRITE		macro	memory_address, eeprom_address
+	movff	memory_address,EEDATA	; copy byte to EEPROM data register
 	movlw	HIGH(eeprom_address)	; extract bank in EEPROM
 	movwf	EEADRH					; set     bank in EEPROM
 	movlw	LOW (eeprom_address)	; extract start address in EEPROM
 	movwf	EEADR					; set     start address in EEPROM
-	movff	memory_address,EEDATA	; copy byte to EEPROM data register
 	call	write_eeprom			; execute write
 	endm
 
--- a/src/hwos.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/hwos.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -454,24 +454,9 @@
 	bcf		active_reset_ostc_rx
 
 ; Power-up the Switches
-	;bra	power_up_switches
-
-
-;-----------------------------------------------------------------------------
-; Power-up the Switches
-;
-	global	power_up_switches
-power_up_switches:
 	bsf		power_sw1			; switch on power supply for switch 1
-	
-	; power_sw1 not available in less pin CPU, do not use
-;	btfss	power_sw1			; power established?
-;	bra		$-4					; NO - wait
-
+	nop
 	bsf		power_sw2			; switch on power supply for switch 2
-	btfss	power_sw2			; power established?
-	bra		$-4					; NO - wait
-
 	return						; done
 
 
--- a/src/hwos.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/hwos.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -112,7 +112,7 @@
 #DEFINE min_mv							.70			; =   7 mV
 #DEFINE max_mv							.2500		; = 250 mV
 #DEFINE ignore_mv_above					.3500		; = 350 mV (to suppress ghost readings on long open cables)
-#DEFINE ignore_mv_below					.19			; = 1.9 mv (to suppress noise readings on      open cabled)
+#DEFINE ignore_mv_below					.19			; = 1.9 mv (to suppress noise readings on open cables)
 
 
 ; ---- Profile Recording Parameters
@@ -323,11 +323,11 @@
 ; ---- Brightness Thresholds (between zero (off) and 255 (max. power consumption))
 #DEFINE ambient_light_max_high_36V		.170
 #DEFINE ambient_light_max_high_cr		.240
-#DEFINE ambient_light_max_high_15V		.140
+#DEFINE ambient_light_max_high_15V		.100
 #DEFINE ambient_light_min_high			.35
-#DEFINE ambient_light_max_medium		.125
+#DEFINE ambient_light_max_medium		.90
 #DEFINE ambient_light_min_medium		.25
-#DEFINE ambient_light_max_eco			.70
+#DEFINE ambient_light_max_eco			.50
 #DEFINE ambient_light_min_eco			.10			; must be the lowest value!
 
 
@@ -519,7 +519,7 @@
  ;---- Hardware - States 3 (stored in access RAM, NOT cleared on restart)
 #DEFINE ms5837_state			HW_flags_state3,0	; =1: result of pressure is in the ADC
 #DEFINE	i2c_busy_pressure		HW_flags_state3,1	; =1: Currently updating pressure from MS5837
-;					HW_flags_state3,2	; --- unused
+#DEFINE	eeprom_write_error_flag		HW_flags_state3,2	; =1: an EEPROM write error occurred (Reset only in a Reboot/POR)
 ;					HW_flags_state3,3	; --- unused
 ;					HW_flags_state3,4	; --- unused
 ;					HW_flags_state3,5	; --- unused
@@ -1458,9 +1458,9 @@
 
 ;---- tft_outputs.asm
 pressure_update_lag_counter		res 1		; lag time counter for fast surface pressure display updating
-
+gp_debug				res 2		; General Purpose debug registers
 
-; 201 byte used, 7 byte free (208 byte total)
+; 203 byte used, 5 byte free (208 byte total)
 
 
 ;-----------------------------------------------------------------------------
@@ -1665,6 +1665,7 @@
 opt_surface_interval			res 1		; surface interval, used by deco calculator
 opt_brightness_divemode				res 1		; =0: Eco, =1:Medium, =2:Full
 opt_brightness_surface				res 1		; =0: Eco, =1:Medium, =2:Full
+opt_use_AmbientSensor				res 1		; =1: Use the ambient sensor
 opt_salinity					res 1		; 0-5%
 opt_language					res 1		; current language: 0=EN, 1=DE, 2=FR, 3=SP
 opt_units						res 1		; 0:m/°C, 1:ft/°F
@@ -1721,6 +1722,7 @@
 opt_comm_timeout				res 1		; comm RX timeout in multiples of 10 ms
 opt_fallback					res 1		; unused dummy option for compatibility with 3rd party tools
 opt_conservatism				res 1		; unused dummy option for compatibility with 3rd party tools
+opt_warning_level_divemode			res 1		; warning verbose level (divemode) =0: Less, =1: All				
 
 ;---- RX Function Settings
 opt_transmitter_id_1			res 2		; 16 bit transmitter ID for Gas 1
--- a/src/i2c.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/i2c.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -961,6 +961,18 @@
 
 
 ;-----------------------------------------------------------------------------
+; Helper Function - Master NOT acknowledge and Stop
+;
+I2C_MasterNotAckStop:
+	bsf		SSP1CON2,ACKDT				; set ACKDT flag
+	bsf		SSP1CON2,ACKEN				; master NOT acknowledge
+	rcall	WaitMSSP					; wait for TX to complete
+	bcf		SSP1CON2,ACKDT				; reset ACKDT flag
+
+	bsf	SSP1CON2,PEN					; stop condition
+	bra	WaitMSSP					; wait for TX to complete
+	
+;-----------------------------------------------------------------------------
 ; Helper Function - check for Acknowledge by Receiver
 ;
 I2C_Check_ACK:
@@ -1113,13 +1125,8 @@
 	bsf		SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP					; wait for TX to complete
 	movff	SSP1BUF,xA+0				; copy received byte to xA+0
-	bsf		SSP1CON2,ACKDT				; set ACKDT flag
-	bsf		SSP1CON2,ACKEN				; master NOT acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bcf		SSP1CON2,ACKDT				; reset ACKDT flag
-
-	bsf		SSP1CON2,PEN				; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
+	
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
 	
 	; convert voltage from raw value to Volt
 	MOVLI	.6000,xB					; load conversion multiplicand into xB
@@ -1147,13 +1154,7 @@
 	bsf		SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP					; wait for TX to complete
 	movff	SSP1BUF,xA+0				; store raw temperature, low byte
-	bsf		SSP1CON2,ACKDT				; set ACKDT flag
-	bsf		SSP1CON2,ACKEN				; master NOT acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bcf		SSP1CON2,ACKDT				; reset ACKDT flag
-
-	bsf		SSP1CON2,PEN				; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
 
 	; convert temperature from raw value to Kelvin
 	MOVLI	.6000,xB					; load conversion multiplicand into xB
@@ -1217,13 +1218,7 @@
 	bsf		SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP					; wait for TX to complete
 	movff	SSP1BUF,sub_a+0				; copy received byte to sub_a+0
-	bsf		SSP1CON2,ACKDT				; set ACKDT flag
-	bsf		SSP1CON2,ACKEN				; master NOT acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bcf		SSP1CON2,ACKDT				; reset ACKDT flag
-
-	bsf		SSP1CON2,PEN				; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
 
 	btfsc	gauge_status_byte,0			; UVLO event ?
 	rcall	lt2942_init_again			; YES - do an re-initialization
@@ -1399,12 +1394,7 @@
 	bsf		SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP					; wait for TX to complete
 	movff	SSP1BUF,rx_firmware_cur_minor ; store as firmware version, minor
-	bsf		SSP1CON2,ACKDT				; set ACKDT flag
-	bsf		SSP1CON2,ACKEN				; master NOT acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bcf		SSP1CON2,ACKDT				; reset ACKDT flag
-	bsf		SSP1CON2,PEN				; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
 	
 	; wait for TR module becoming ready
 	movff	rx_firmware_cur_minor,i2c_temp1	; copy minor firmware version to bank common
@@ -1470,12 +1460,7 @@
 	bsf		SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP					; wait for TX to complete
 	movff	SSP1BUF,POSTINC2			; copy received byte to the rx buffer
-	bsf		SSP1CON2,ACKDT				; set ACKDT flag
-	bsf		SSP1CON2,ACKEN				; master NOT acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bcf		SSP1CON2,ACKDT				; reset ACKDT flag
-	bsf		SSP1CON2,PEN				; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
 	return							; done
 
 
@@ -1541,13 +1526,7 @@
 	movf	SSP1BUF,W					;     - get 64th byte
 	cpfseq	POSTINC2					;     - compare read-back byte with sent byte, equal?
 	bsf		i2c_error_flag				;       NO  - not equal, set error flag
-	bsf		SSP1CON2,ACKDT				;     - set ACKDT flag
-	bsf		SSP1CON2,ACKEN				;     - master NOT acknowledge
-	rcall	WaitMSSP					;     - wait for TX to complete
-	bcf		SSP1CON2,ACKDT				;     - reset ACKDT flag
-	; stop
-	bsf		SSP1CON2,PEN				; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
 	WAITMS	.1
 	; address commit
 	bsf		SSP1CON2,SEN				; start condition
@@ -1678,8 +1657,6 @@
 
 	global	I2C_get_press_val_MS5837
 I2C_get_press_val_MS5837:
-    	bsf	i2c_busy_pressure				; reading new pressure
-	
 	bsf	SSP1CON2,SEN					; start condition
 	rcall	WaitMSSP					; wait for TX to complete
 	movlw	0xEC						; address byte + write bit
@@ -1696,6 +1673,7 @@
 	rcall	WaitMSSP				; wait for TX to complete
 	rcall	I2C_Check_ACK				; check for acknowledge by receiver
 
+	bsf	i2c_busy_pressure				; reading new pressure
 	bsf	SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP				; wait for reception and return
 	movff	SSP1BUF,D1_buffer+2					; Upper byte
@@ -1709,11 +1687,10 @@
 	bsf	SSP1CON2,RCEN					; enable receive mode
 	rcall	WaitMSSP					; wait for reception
 	movff	SSP1BUF,D1_buffer+0					; Low byte
-	bsf	SSP1CON2,ACKEN					; master acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bsf	SSP1CON2,PEN					; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
 
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
+	bcf	i2c_busy_pressure				; reading new pressure done.
+	
 	; Start temperature measurement
 	bsf	SSP1CON2,SEN					; start condition
 	rcall	WaitMSSP					; wait for TX to complete
@@ -1724,13 +1701,10 @@
 	bsf	SSP1CON2,PEN					; stop condition
 	rcall	WaitMSSP					; wait for TX to complete
 	bcf	ms5837_state					; =0: result of temperature will be in the ADC
-	bcf	i2c_busy_pressure				; reading new pressure
     	return
 	
 	global	I2C_get_temp_val_MS5837	
 I2C_get_temp_val_MS5837:
-	bsf	i2c_busy_temperature				; reading new temperature
-
 	bsf	SSP1CON2,SEN					; start condition
 	rcall	WaitMSSP					; wait for TX to complete
 	movlw	0xEC						; address byte + write bit
@@ -1747,6 +1721,7 @@
 	rcall	WaitMSSP				; wait for TX to complete
 	rcall	I2C_Check_ACK				; check for acknowledge by receiver
 
+	bsf	i2c_busy_temperature				; reading new temperature
 	bsf	SSP1CON2,RCEN				; enable receive mode
 	rcall	WaitMSSP				; wait for reception and return
 	movff	SSP1BUF,D2_buffer+2					; Upper byte
@@ -1760,11 +1735,10 @@
 	bsf	SSP1CON2,RCEN					; enable receive mode
 	rcall	WaitMSSP					; wait for reception
 	movff	SSP1BUF,D2_buffer+0					; Low byte
-	bsf	SSP1CON2,ACKEN					; master acknowledge
-	rcall	WaitMSSP					; wait for TX to complete
-	bsf	SSP1CON2,PEN					; stop condition
-	rcall	WaitMSSP					; wait for TX to complete
 
+	rcall	I2C_MasterNotAckStop				; Master NOT acknowledge and Stop
+	bcf	i2c_busy_temperature				; reading new temperature done.
+	
 	; Start pressure measurement
 	bsf	SSP1CON2,SEN					; start condition
 	rcall	WaitMSSP					; wait for TX to complete
@@ -1775,7 +1749,6 @@
 	bsf	SSP1CON2,PEN					; stop condition
 	rcall	WaitMSSP					; wait for TX to complete
 	bsf	ms5837_state					; =0: result of pressure will be in the ADC
-	bcf	i2c_busy_temperature				; reading new temperature
 	return
 	
 	
--- a/src/menu_tree.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/menu_tree.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -95,6 +95,21 @@
 	call	TFT_boot								; initialize display
 	call	menu_processor_reset					; reset menu stack
 
+	; reset planning parameters to default values - only when entering the menu, thus keeping the settings between multiple calculator runs
+	lfsr	FSR0,odiveInterval			; surface interval
+	call	option_reset				; reset to default
+	lfsr	FSR0,obottomTime			; bottom time
+	call	option_reset				; reset to default
+	lfsr	FSR0,obottomDepth			; bottom depth
+	call	option_reset				; reset to default
+	lfsr	FSR0,oSimAGF				; GF/aGF
+	call	option_reset				; reset to default
+
+ IFDEF _gas_contingency
+	lfsr	FSR0,oGasContingencySim		; gas contingency
+	call	option_reset				; reset to default (volatile option)
+ ENDIF	; _gas_contingency
+
 main_menu_common:
  IFDEF _ccr_pscr
 	MENU_BEGIN	tMainMenu, .7
@@ -517,8 +532,11 @@
 ;
 do_menu_gas_tank:
  IFDEF _rx_functions
+	btfss	ostc_rx_present					; OSTC has RX module?
+	bra	do_menu_gas_tank2				; NO, skip tank menu with RX
 	TSTOSC	opt_TR_mode					; TR functions switched on?
 	bra		do_menu_gas_tank_rx			; YES
+do_menu_gas_tank2:	
  ENDIF
 
  IFDEF _ccr_pscr
@@ -692,20 +710,20 @@
 ; Simulator (Deco Calculator) Menu
 ;
 do_menu_simulator:
-	; reset planning parameters to default values
-	lfsr	FSR0,odiveInterval			; surface interval
-	call	option_reset				; reset to default
-	lfsr	FSR0,obottomTime			; bottom time
-	call	option_reset				; reset to default
-	lfsr	FSR0,obottomDepth			; bottom depth
-	call	option_reset				; reset to default
-	lfsr	FSR0,oSimAGF				; GF/aGF
-	call	option_reset				; reset to default
-
- IFDEF _gas_contingency
-	lfsr	FSR0,oGasContingencySim		; gas contingency
-	call	option_reset				; reset to default (volatile option)
- ENDIF	; _gas_contingency
+;	; reset planning parameters to default values
+;	lfsr	FSR0,odiveInterval			; surface interval
+;	call	option_reset				; reset to default
+;	lfsr	FSR0,obottomTime			; bottom time
+;	call	option_reset				; reset to default
+;	lfsr	FSR0,obottomDepth			; bottom depth
+;	call	option_reset				; reset to default
+;	lfsr	FSR0,oSimAGF				; GF/aGF
+;	call	option_reset				; reset to default
+;
+; IFDEF _gas_contingency
+;	lfsr	FSR0,oGasContingencySim		; gas contingency
+;	call	option_reset				; reset to default (volatile option)
+; ENDIF	; _gas_contingency
 
 do_menu_simulator_common_1:
 	call	restart_set_modes_and_flags	; initialize dive mode settings
@@ -803,21 +821,23 @@
 ;
 do_menu_dive_dive:
  IFDEF _cave_mode
-	MENU_BEGIN	tDiveSetup, .6
-		MENU_OPT_INC	tDvMode,					oDiveMode				; dive mode
-		MENU_OPT_INC	tCvMode,					oCaveMode				; cave mode
-		MENU_OPT_INC	tFTTSMenu,					oExtraTime				; fTTS/delay
+	MENU_BEGIN	tDiveSetup, .7
+		MENU_OPT_INC	tDvMode,				oDiveMode			; dive mode
+		MENU_OPT_INC	tCvMode,				oCaveMode			; cave mode
+		MENU_OPT_INC	tFTTSMenu,				oExtraTime			; fTTS/delay
 		MENU_OPT_INC	tTimeoutDive,				oDiveTimeout			; dive timeout
-		MENU_OPT_INC	tStoreApnoeDive,			oStoreApnoe				; store apnoe
-		MENU_CALL		tBack,						do_return_menu_dive
+		MENU_OPT_INC	tStoreApnoeDive,			oStoreApnoe			; store apnoe
+		MENU_OPT_INC	tWarningLevel,				oWarningLevel			; Warning level
+		MENU_CALL	tBack,					do_return_menu_dive
 	MENU_END
  ELSE
-	MENU_BEGIN	tDiveSetup, .5
-		MENU_OPT_INC	tDvMode,					oDiveMode				; dive mode
-		MENU_OPT_INC	tFTTSMenu,					oExtraTime				; fTTS/delay
+	MENU_BEGIN	tDiveSetup, .6
+		MENU_OPT_INC	tDvMode,				oDiveMode			; dive mode
+		MENU_OPT_INC	tFTTSMenu,				oExtraTime			; fTTS/delay
 		MENU_OPT_INC	tTimeoutDive,				oDiveTimeout			; dive timeout
-		MENU_OPT_INC	tStoreApnoeDive,			oStoreApnoe				; store apnoe
-		MENU_CALL		tBack,						do_return_menu_dive
+		MENU_OPT_INC	tStoreApnoeDive,			oStoreApnoe			; store apnoe
+		MENU_OPT_INC	tWarningLevel,				oWarningLevel			; Warning level
+		MENU_CALL	tBack,					do_return_menu_dive
 	MENU_END
  ENDIF
 
@@ -1563,9 +1583,10 @@
 ; Settings Menu - 3rd Layer - Display Settings - Brightness
 ;
 do_menu_Brightness: 
-    	MENU_BEGIN	tBright, .3
-		MENU_OPT_INC	tDvMode,					oBrightness_dive
-		MENU_OPT_INC	tBrightsurface,					oBrightness_surface
+    	MENU_BEGIN	tBright, .4
+		MENU_OPT_INC	tBrightDive,					oBrightness_dive
+		MENU_OPT_INC	tBrightSurface,					oBrightness_surface
+		MENU_OPT_INC	tUseAmbientSensor,				oUseAmbientSensor
 		MENU_CALL	tBack,						do_return_dispsets_menu
 	MENU_END
 
--- a/src/option_table.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/option_table.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -152,7 +152,7 @@
 
 	; Managing Settings
 	OPTION_UINT8    oExtraTime,          .0,                   .9,                 .0,      tMinutes,        0x028,    0x24,  char_I_extra_time				; extra bottom time for future TTS calculation
-	OPTION_ENUM8    oBrightness_dive,    .3,                                       .0,      tEco,            0x029,    0x2D,  opt_brightness_divemode				; =0: Eco, =1:Medium, =2:Full
+	OPTION_ENUM8    oBrightness_dive,    .3,                                       .0,      tEco,            0x029,    0x2D,  opt_brightness_divemode			; =0: Eco, =1:Medium, =2:Full
 	OPTION_UINT8    oDiveSalinity,   salinity_min,      salinity_max,              .0,      tPercent,        0x02A,    0x30,  opt_salinity					; 0-4%
 	OPTION_ENUM8    oCCRMode,            .3,                                       .0,      tCCRModeFixedSP, 0x02B,    0x1F,  opt_ccr_mode					; =0: Fixed SP, =1: Sensor, =2: Auto SP
 	OPTION_ENUM8    oLanguage,           .2,                                       .0,      tLang1,          0x02C,    0x32,  opt_language					; language selection
@@ -300,7 +300,7 @@
 	OPTION_BOOL     oCalcAscGas,                                                   .0,                       0x0CB,    0x5A,  opt_calc_gasvolume			; calculate OC gas volume needs for ascent
 	OPTION_ENUM8    oAltMode,            .4,                                       .0,      tAltModeFly,     0x0CC,    0x5C,  char_I_altitude_wait			; no-fly time calculation for: 0=no-fly, 1=1000m, 2=2000m, 3=3000m
 	OPTION_BOOL     oEnable_IBCD,                                                  .1,                       0x0CD,    0x5D,  opt_enable_IBCD				; =1: IBCD warning activated
-	;                                                                                                        0x0CE											; not used any more (ex ascent speed)
+	OPTION_BOOL	oUseAmbientSensor,					       .1,	                 0x0CE,	   0x83,  opt_use_AmbientSensor				; =1: Use the ambient sensor 
 	OPTION_UINT8    oGasChangeTime,      .0,                   .3,                 .0,      tMinutes,        0x0CF,    0x5B,  char_I_gas_change_time		; (extra) time at a stop to change the gas
 	OPTION_UINT8p5  osatmult,          .100,                 .140,               .110,      tPercent,        0x0D0,    0x2A,  opt_sat_multiplier_non_gf		; saturation   factor for NON-GF Mode
 	OPTION_UINT8p5  odesatmult,         .60,                 .100,                .90,      tPercent,        0x0D1,    0x2B,  opt_desat_multiplier_non_gf	; desaturation factor for NON-GF Mode
@@ -328,13 +328,13 @@
 	OPTION_ENUM8    oCaveMode,           .2,                                       .0,      tOff,            0x105,    0x90,  opt_cave_mode					; =1: cave mode switched on
 	OPTION_BOOL     oGasContingencyDive,                                           .0,                       0x106,    0x91,  opt_gas_contingency_dive		; =1: dive mode: switch to alternative gas if best gas is depleted
 	OPTION_BOOL     oGasDensityCheck,                                              .1,                       0x107,    0x92,  opt_gas_density_check			; gas density is checked (effective in CCR / pSCR modes only)
-
+	OPTION_ENUM8	oWarningLevel,	     .2,                                       .0,      tLess,           0x108,    0x93,  opt_warning_level_divemode		; =0: Less, =1: All
 	;	+---------------------------------------------------------------------------------------------------------------------------------------------+
-	;   |  .                                                                                                                                          |
+	;	|  .                                                                                                                                          |
 	;	| /|\                                                                                                                                         |
 	;	|  |  add new options here!                                                                                                                   |
 	;	|  |  EEPROM address  min: 0x012, max: 0x1FF, last used: 0x107, spare: 0x0B7-0x0B9, 0x0F5-0x0F6, disused: 0x0A8, 0x0CE                        |
-	;	|  |  serial address  min:  0x20, max:  0xF9, last used:  0x92, spare: 0x83, 0x84 (0xFA - 0xFE are reserved for internal use)                 |
+	;	|  |  serial address  min:  0x20, max:  0xF9, last used:  0x92, spare: 0x84 (0xFA - 0xFE are reserved for internal use)			      |
 	;	+---------------------------------------------------------------------------------------------------------------------------------------------+
 
 	; ppO2 warnings, sorted by ppO2 levels
--- a/src/p2_deco.c	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/p2_deco.c	Sun Aug 28 13:13:38 2022 +0200
@@ -1,5 +1,5 @@
 // ***************************************************************************
-// p2_deco.c                                  combined next generation V3.12.1
+// p2_deco.c                                  combined next generation V3.19.4
 //
 //  Created on: 12.05.2009
 //  Author: heinrichs weikamp, contributions by Ralph Lembcke and others
@@ -89,12 +89,17 @@
 
 
 #include	<math.h>
+#include	<string.h>
 #include	"p2_definitions.h"
 #define		TEST_MAIN
 #include	"shared_definitions.h"
 #include	"configuration.inc"
 
 
+// work-around for a C18 compiler bug (to avoid a warning been thrown for valid code)
+#define memcpy(a,b,c)  memcpy((a),(const void*)(b),(c))
+
+
 // *********************************************************************************************************************************
 //
 //                                         C O N S T A N T S   D E F I N I T I O N S
@@ -216,12 +221,8 @@
 #define PHASE_40_BOTTOM_GAS_NEED		0x40	// calculate gas needs for bottom segment
 #define PHASE_50_NDL_TIME				0x50	// calculate NDL time
 #define PHASE_70_ASCENT_OR_RETURN		0x70	// calculate open water ascent or cave return
-#define PHASE_80_RESULTS				0x80	// results - initialization
-#define PHASE_81_RESULTS_STOPS_TABLE	0x81	// results - publish stops table
-#define PHASE_82_RESULTS_NDL			0x82	// results - publish data / within NDL
-#define PHASE_83_RESULTS_DECO			0x83	// results - publish data / in deco
-#define PHASE_84_GAS_NEEDS_PRESSURES	0x84	// results - convert gas needs from volumes to pressures
-#define PHASE_85_GAS_NEEDS_CAVE			0x85	// results - tag gas needs as calculated in cave or open water mode
+#define PHASE_80_RESULTS				0x80	// results - NDL, TTS, TST
+#define PHASE_81_GAS_NEEDS_PRESSURES	0x81	// results - convert gas needs from volumes to pressures
 #define PHASE_90_FINISH					0x90	// finish calculation cycle
 
 
@@ -280,7 +281,7 @@
 														// gas_take_current() or gas_find_best()/gas_take_best() and gas_set_ratios().
 static void			 calc_tissues(void);				// Updates the tissues   dependent on the partial pressures of N2 and He.
 static void			 calc_CNS(void);					// Updates the CNS value dependent on the partial pressure  of the O2.
-static void			 calc_limit(PARAMETER float GF_current);
+static void			 calc_limit(PARAMETER float GF_parameter);
 														// Calculates ceiling, current supersaturation factor and some more data.
 
 // Functions for TR
@@ -305,7 +306,8 @@
 static void			 update_deco_table(PARAMETER unsigned char time_increment);
 														// Enters a new stop or extends an existing stop in the deco stops table.
 static void			 calc_required_volume(void);		// Calculates gas volume required for a given depth, time and usage (SAC rate).
-static void			 convert_volume_to_pressure(void);	// Converts gas volumes into pressures and sets respective flags.
+static void			 convert_volume_to_pressure(PARAMETER unsigned char index);
+														// Converts gas volumes into pressures and sets respective flags.
 
 // Functions for Results Reporting
 static void			 publish_deco_table(void);			// Copies the internal deco stops table to the export interface.
@@ -321,7 +323,7 @@
 static void			 read_CNS_ab_coefficient(void);		// Reads the CNS      a and b coefficients from a ROM table.
 static void			 read_CNS_c_coefficient(void);		// Reads the CNS      c       coefficient  from a ROM table.
 static void			 read_Buhlmann_coefficients(void);	// Reads the Buhlmann a and b coefficients from a ROM table.
-static void			 read_Buhlmann_times(PARAMETER char period);
+static void			 read_Buhlmann_times(PARAMETER unsigned char period);
 														// Reads pre-computed tissue increment factors from a ROM table.
 static void			 read_Buhlmann_ht(void);			// Reads the half-times from a ROM table.
 static void			 adopt_Buhlmann_coefficients(void);	// Computes average a and b coefficient by the N2/He tissue ratio.
@@ -338,14 +340,81 @@
 //
 // *********************************************************************************************************************************
 
+
+//---- Bank 13 parameters -----------------------------------------------------
+#ifndef UNIX
+#   pragma udata overlay bank13=0xd00
+static char				C_STACK[256];					// C-code data stack
+#   define C_STACK_ADDR C_STACK
+#endif
+
+// 256 byte used, bank is full
+
+
+//---- Bank 7 parameters -----------------------------------------------------
+#ifndef UNIX
+#   pragma udata bank7=0x700
+#endif
+
+// tissue pressures for the real tissues (128 byte)
+
+static float			real_pres_tissue_N2[NUM_COMP];	// 16 floats = 64 bytes  ||  keep order and position of these variables as
+static float			real_pres_tissue_He[NUM_COMP];	// 16 floats = 64 bytes  ||  they are backed-up to & restored from EEPROM!
+
+// delta-pressures for the real tissue pressures (128 byte)
+
+static float			real_pres_delta_N2[NUM_COMP];	// 16 floats = 64 bytes
+static float			real_pres_delta_He[NUM_COMP];	// 16 floats = 64 bytes
+
+// 256 byte used, bank is full
+
+
+//---- Bank 8 parameters -----------------------------------------------------
+#ifndef UNIX
+#   pragma udata bank8=0x800
+#endif
+
+// tissue pressures for the simulated tissues (128 byte)
+
+static float			sim_pres_tissue_N2[NUM_COMP];	// 16 floats = 64 bytes
+static float			sim_pres_tissue_He[NUM_COMP];	// 16 floats = 64 bytes
+
+// delta-pressures for the simulated tissues (128 byte)
+
+static float			sim_pres_delta_N2[NUM_COMP];	// 16 floats = 64 bytes
+static float			sim_pres_delta_He[NUM_COMP];	// 16 floats = 64 bytes
+
+// 256 byte used, bank is full
+
+
+//---- Bank 12 parameters -----------------------------------------------------
+
+#ifndef UNIX
+#   pragma udata bank12=0xc00
+#endif
+
+// vault for backing up real tissue pressures (128 byte)
+
+static float			vault_pres_tissue_N2[NUM_COMP];	// 16 floats = 64 bytes
+static float			vault_pres_tissue_He[NUM_COMP];	// 16 floats = 64 bytes
+
+// vault for backing up real delta-pressures (128 byte)
+
+static float			vault_pres_delta_N2[NUM_COMP];	// 16 floats = 64 bytes
+static float			vault_pres_delta_He[NUM_COMP];	// 16 floats = 64 bytes
+
+// 256 byte used, bank is full
+
+
 //---- Bank 5 parameters -----------------------------------------------------
 #ifndef UNIX
 #   pragma udata bank5=0x500
 #endif
 
-// Data that go into the deco data vault (4 byte)
-
-static float			CNS_fraction_real;				// || current real CNS (1.00 = 100%)
+// Timer5 Interface (3 byte) - Attention: keep order and keep at beginning of bank 5, i.e. at address 0x500 !
+
+static volatile unsigned short	tmr5_value;				// | timer 5 value buffer	MUST be at address 0x500
+static volatile unsigned char	tmr5_overflow;			// | timer 5 overflow flag	MUST be at address 0x502
 
 
 // Environmental and Gas Data (51 byte)
@@ -394,8 +463,9 @@
 static unsigned char	peer_tank[NUM_GAS];				// bit flag vector indicating peer tanks holding same gas
 
 
-// real Context: what we are doing now (12 byte)
-
+// real Context: what we are doing now (16 byte)
+
+static float			CNS_fraction_real;				// current real CNS (1.00 = 100%)
 static unsigned short	IBCD_tissue_vector;				// 16 bit vector to memorize all tissues that experience IBCD
 
 static float			pres_respiration_sac;			// used in SAC calculation: current depth in absolute pressure
@@ -430,7 +500,7 @@
 static unsigned short	int_time;						// time it takes for the compartment to reach the target pressure
 
 
-// Gas in Use and Gas Needs (67 byte)
+// Gas in Use and Gas Needs (66 byte)
 
 static unsigned char	start_gas_num;					// number of the gas/dil to start with
 
@@ -441,7 +511,6 @@
 static unsigned char	sim_gas_best_num;				// number       of the best gas available
 static unsigned char	sim_gas_best_depth;				// change depth of the best gas available
 
-static unsigned char	gas_needs_gas_index;			// index to the gas and tank data arrays
 static float			gas_volume_need[NUM_GAS];		// gas volumes required  for ascent / cave return in liters
 static float			gas_volume_avail[NUM_GAS];		// gas volumes available for ascent / cave return in liters
 static float			gas_volume_atten[NUM_GAS];		// attention threshold for gas volumes available
@@ -455,7 +524,13 @@
 static float			gas_needs_volume_due;			// computed amount of required gas volume
 
 
-// 243 byte used, 13 byte left in this bank (4 bytes per float, 2 bytes per short, 1 byte per char)
+// Transfer Values for convert_float_to_int() (6 byte)
+
+static float			float_value;					// input value,   float
+static unsigned short	int_value;						// output value, 16 bit
+
+
+// 251 byte used, 5 byte left in this bank (4 bytes per float, 2 bytes per short, 1 byte per char)
 
 
 //---- Bank 6 parameters -----------------------------------------------------
@@ -463,13 +538,7 @@
 #   pragma udata bank6=0x600
 #endif
 
-// Timer5 Interface (3 byte) - Attention: keep order and keep at beginning of bank 6, i.e. at address 0x600 !
-
-static volatile unsigned short	tmr5_value;				// | timer 5 value buffer		MUST be at address 0x600
-static volatile unsigned char	tmr5_overflow;			// | timer 5 overflow flag	MUST be at address 0x602
-
-
-// Modes, Sequencing and Indexing (14 byte)
+// Modes, Sequencing and Indexing (17 byte)
 
 static unsigned char	main_status;					// shadow register for char_O_main_status
 static unsigned char	deco_status;					// shadow register for char_O_deco_status
@@ -487,9 +556,10 @@
 static unsigned char	backtrack_index;				// index into the depth backtracking array char_I_backtrack_storage
 static unsigned char	backtrack_target_depth;			// current backtracking target depth
 static unsigned char	backtrack_step_counter;			// counter for number of 1/10 minute steps done
-
-
-// Result Values from Calculation Functions (28 byte)
+static unsigned char	spare;							// UNUSED YET, placed here for alignment purpose
+
+
+// Result Values from Calculation Functions (30 byte)
 
 static float			ppO2_O2;						// ppO2 calculated for breathing pure oxygen in OC   mode
 static float			ppO2_OC;						// ppO2 calculated for breathing current gas in OC   mode
@@ -519,13 +589,6 @@
 static float			var_He_ht;						// half-time  for current He tissue
 
 
-// CNS Coefficients (10 byte)
-
-static float			var_cns_gain;					// two coefficients approximation, gain
-static float			var_cns_offset;					// two coefficients approximation, offset
-static unsigned short	var_cns_value;					// one coefficient  approximation, value
-
-
 // Auxiliary Variables for Data Buffering (28 byte)
 
 static float			N2_equilibrium;					// used for N2 tissue graphics scaling
@@ -533,14 +596,29 @@
 static float			float_pSCR_factor;				// pre-computed factor for pSCR ppO2 drop calculation
 static float			calc_pres_tissue_N2;			// auxiliary variable to buffer tissue N2 pressure
 static float			calc_pres_tissue_He;			// auxiliary variable to buffer tissue He pressure
-static float			pres_tissue;					// auxiliary variable to buffer total tissue pressure
+static float			calc_pres_tissue;				// auxiliary variable to buffer total tissue pressure
 static float			old_pres_respiration;			// auxiliary variable to buffer sim_pres_respiration
 
 
-// Transfer Values for convert_float_to_int() (6 byte)
-
-static float			float_value;					// input value,   float
-static unsigned short	int_value;						// output value, 16 bit
+// CNS Coefficients (10 byte)
+
+static float			var_cns_gain;					// two coefficients approximation, gain
+static float			var_cns_offset;					// two coefficients approximation, offset
+static unsigned short	var_cns_value;					// one coefficient  approximation, value
+
+
+// Vault to back-up & restore Tissue related Data (6 byte)
+
+static float			vault_CNS_fraction_real;		// stores CNS percentage (1.0 = 100%)
+static unsigned char	vault_deco_warnings;			// stores warnings status
+static unsigned char	vault_deco_info;				// stores info     status
+
+
+// stops table (96 byte)
+
+static unsigned char	internal_deco_depth[NUM_STOPS];	// depths     of the stops in meters
+static unsigned char	internal_deco_time[NUM_STOPS];	// durations  of the stops in minutes
+static unsigned char	internal_deco_gas[NUM_STOPS];	// gases used on the stops (0 / 1-5)
 
 
 // Performance Profiling (4 byte)
@@ -550,67 +628,17 @@
 static unsigned char	profiling_phase;				// performance measurement: current calculation phase
 
 
-// 7 byte occupied by compiler-placed vars
-
-
-// 139 byte used, 117 byte left in this bank (4 bytes per float, 2 bytes per short, 1 byte per char)
-
-
-
-//---- Bank 12 parameters -----------------------------------------------------
-#ifndef UNIX
-#   pragma udata bank12=0xc00
-#endif
-
-// stops table (96 byte)
-
-static unsigned char	internal_deco_depth[NUM_STOPS];	// depths     of the stops in meters
-static unsigned char	internal_deco_time[NUM_STOPS];	// durations  of the stops in minutes
-static unsigned char	internal_deco_gas[NUM_STOPS];	// gases used on the stops (0 / 1-5)
-
-
-// Vault to back-up & restore Tissue related Data (134 byte)
-
-static float			vault_pres_tissue_N2[NUM_COMP];	// stores the nitrogen tissue pressures
-static float			vault_pres_tissue_He[NUM_COMP];	// stores the helium   tissue pressures
-static float			vault_CNS_fraction_real;		// stores CNS percentage (1.0 = 100%)
-static unsigned char	vault_deco_warnings;			// stores warnings status
-static unsigned char	vault_deco_info;				// stores info     status
-
-// 230 byte used, 26 byte left in this bank (4 bytes per float, 2 bytes per short, 1 byte per char)
-
-
-//---- Bank 7 parameters -----------------------------------------------------
-#ifndef UNIX
-#   pragma udata bank7=0x700
-#endif
-
-// Keep order and position of the variables in bank 7 as they are backed-up to & restored from EEPROM
-
-static float			real_pres_tissue_N2[NUM_COMP];		// 16 floats = 64 bytes
-static float			real_pres_tissue_He[NUM_COMP];		// 16 floats = 64 bytes
-
-static float			sim_pres_tissue_N2[NUM_COMP];		// 16 floats = 64 bytes
-static float			sim_pres_tissue_He[NUM_COMP];		// 16 floats = 64 bytes
-
-// 256 byte used, bank is full
-
-
-//---- Bank 8 parameters -----------------------------------------------------
-#ifndef UNIX
-#   pragma udata overlay bank8=0x800
-
-static char				md_pi_subst[256];				// overlay C-code data stack here, too
-
-#   define C_STACK md_pi_subst
-#endif
-
-
-// Back to bank6 for further tmp data
-// Do not delete this assignment, it is needed by the compiler/linker.
-#ifndef UNIX
-#   pragma udata bank6
-#endif
+// Function Parameters placed by the C Compiler (7 byte)
+/*
+static unsigned char	period
+static float			parameter
+static unsigned char	time_increment
+static unsigned char	time_interval
+*/
+
+
+// 238 byte used, 18 byte left in this bank (4 bytes per float, 2 bytes per short, 1 byte per char)
+
 
 
 // *********************************************************************************************************************************
@@ -850,21 +878,21 @@
 		void fillDataStack(void)
 		{
 			_asm
-				LFSR	1,C_STACK
+				LFSR	1,C_STACK_ADDR
 				MOVLW	0xCC
 		loop:	MOVWF	POSTINC1,0
 				TSTFSZ	FSR1L,0
 				BRA		loop
 
-				LFSR	1,C_STACK
-				LFSR	2,C_STACK
+				LFSR	1,C_STACK_ADDR
+				LFSR	2,C_STACK_ADDR
 			_endasm
 		}
 #	else
-#		define	RESET_C_STACK	\
-		_asm					\
-			LFSR	1,C_STACK	\
-			LFSR	2,C_STACK	\
+#		define	RESET_C_STACK		\
+		_asm						\
+			LFSR	1,C_STACK_ADDR	\
+			LFSR	2,C_STACK_ADDR	\
 		_endasm
 #	endif
 #endif
@@ -882,8 +910,8 @@
 {
 #ifndef CROSS_COMPILE
 	_asm
-		movff	0x601,0xF7D		// bank-safe load TMR5H from C variable tmr5_value first
-		movff	0x600,0xF7C		// bank-safe load TMR5L from C variable tmr5_value thereafter
+		movff	0x501,0xF7D		// bank-safe load TMR5H from C variable tmr5_value first
+		movff	0x500,0xF7C		// bank-safe load TMR5L from C variable tmr5_value thereafter
 		bcf		0xFBA,1,0		// clear timer 5 overrun flag (0xFBA = PIR5, bit 1 = TMR5IF)
 	_endasm
 #else
@@ -905,12 +933,12 @@
 {
 #ifndef CROSS_COMPILE
 	_asm
-		movff	0xF7C,0x600		// copy TMR5L to C variable tmr5_value, low  byte first
-		movff	0xF7D,0x601		// copy TMR5H to C variable tmr5_value, high byte thereafter
+		movff	0xF7C,0x500		// copy TMR5L to C variable tmr5_value, low  byte first
+		movff	0xF7D,0x501		// copy TMR5H to C variable tmr5_value, high byte thereafter
 		clrf	WREG,0			// clear WREG to 0x00 = no overrun by default
 		btfsc	0xFBA,1,0		// did timer 5 overrun? (0xFBA = PIR5, bit 1 = TMR5IF)
 		setf	WREG,0			// YES - set WREG to 0xff = overrun detected
-		movff	WREG,0x602		// copy WREG to C variable tmr5_overflow
+		movff	WREG,0x502		// copy WREG to C variable tmr5_overflow
 	_endasm
 #else
 	return;
@@ -998,7 +1026,7 @@
 // If period == 0 :  2 sec interval
 //              1 :  1 min interval
 //              2 : 10 min interval
-static void read_Buhlmann_times(PARAMETER char period)
+static void read_Buhlmann_times(PARAMETER unsigned char period)
 {
 #ifndef CROSS_COMPILE
 	// Note: We don't use far ROM pointer, because handling
@@ -1094,7 +1122,7 @@
 //         var_He_a, var_He_b       coefficients for He
 //         calc_pres_tissue_N2      partial pressure of N2 in tissue
 //         calc_pres_tissue_He      partial pressure of He in tissue
-//         pres_tissue              total pressure in tissue
+//         calc_pres_tissue         total pressure in tissue
 //
 // Output: var_a, var_b             coefficients adopted by N2/He ratio
 //
@@ -1104,8 +1132,8 @@
 
 #ifdef _helium
 
-	var_a = (var_N2_a * calc_pres_tissue_N2 + var_He_a * calc_pres_tissue_He) / pres_tissue;
-	var_b = (var_N2_b * calc_pres_tissue_N2 + var_He_b * calc_pres_tissue_He) / pres_tissue;
+	var_a = (var_N2_a * calc_pres_tissue_N2 + var_He_a * calc_pres_tissue_He) / calc_pres_tissue;
+	var_b = (var_N2_b * calc_pres_tissue_N2 + var_He_b * calc_pres_tissue_He) / calc_pres_tissue;
 
 #else
 
@@ -2058,6 +2086,9 @@
 		real_pres_tissue_He[ci]    = 0.0;				// He
 		real_pres_tissue_N2[ci]    = N2_equilibrium;	// N2
 
+		real_pres_delta_He[ci]     = 0.0;				// He
+		real_pres_delta_N2[ci]     = 0.0;				// N2
+
 		// reset tissue pressures for scaled tissue graphics
 		char_O_tissue_pres_He[ci]  =  0;				// He
 		char_O_tissue_pres_N2[ci]  = 10;				// N2
@@ -2161,7 +2192,7 @@
 		main_status = char_O_main_status;
 		deco_status = char_O_deco_status;
 
-		// clear all command flags on the master mode to signal that the command is read
+		// clear all command flags on the master mode to signal that the command is read and in processing
 		char_O_deco_status &= ~COMMAND_MASK;
 
 		// clear the initialization flag on the shadow copy
@@ -2183,7 +2214,7 @@
 		main_status = char_O_main_status;
 		deco_status = char_O_deco_status;
 
-		// clear all command flags on the master mode to signal that the command is read
+		// clear all command flags on the master mode to signal that the command is read and in processing
 		char_O_deco_status &= ~COMMAND_MASK;
 
 		// set the calculation phase to start with to doing the cyclic initialization
@@ -2325,7 +2356,7 @@
 		//      (7 meters chosen as to be 2 stop depth intervals plus 1 additional meter below)
 		if (    ( deco_info & DECO_MODE ) > 0                        )
 		if (    ( char_depth_real       ) > char_O_deco_depth[0] + 7 )
-				  deco_info &= ~DECO_MODE;
+		          deco_info &= ~DECO_MODE;
 
 		// Set the deco mode flag if:
 		//     deco mode is not set
@@ -2340,7 +2371,7 @@
 		     || ( char_I_current_gas_type == 0 )
 		     || ( char_O_deco_depth[0]     > 0 )
 		   )
-				  deco_info |=  DECO_MODE;
+		          deco_info |=  DECO_MODE;
 
 
 		//---- Compute ppO2 Warnings ------------------------------------------------------------------
@@ -2511,11 +2542,7 @@
 		else                          deco_info &= ~DECO_STOPS_ALT;
 
 		// initialize the simulated tissues with the current state of the real tissues
-		for( i = 0; i < NUM_COMP; i++ )
-		{
-			sim_pres_tissue_N2[i] = real_pres_tissue_N2[i];
-			sim_pres_tissue_He[i] = real_pres_tissue_He[i];
-		}
+		memcpy(sim_pres_tissue_N2, real_pres_tissue_N2, 256);
 
 		// initialize the gas types
 		for( i = 0; i < NUM_GAS; i++ )
@@ -2632,9 +2659,6 @@
 		NDL_tissue      = NDL_tissue_start;
 		NDL_tissue_lead = NDL_tissue_start;
 
-		// initialization for convert_volume_to_pressure()
-		gas_needs_gas_index = 0;
-
 		// tag gas needs as not calculated in fTTS mode by default
 		deco_info &= ~GAS_NEEDS_fTTS;
 
@@ -2934,8 +2958,8 @@
 			// shall calculate gas needs?
 			if( main_status & CALC_VOLUME )
 			{
-				overlay unsigned char index_last_gas = sim_gas_last_num-1;
-				overlay unsigned char index_curr_gas = sim_gas_current_num-1;
+				overlay unsigned char index_last_gas = sim_gas_last_num    - 1;
+				overlay unsigned char index_curr_gas = sim_gas_current_num - 1;
 
 #ifdef _cave_mode
 				// in cave mode?
@@ -3087,7 +3111,7 @@
 				TTS_time += 1;
 			}
 
-		} // overlay
+		}
 
 		// calculate absolute pressure at the current depth
 		sim_pres_respiration = (float)char_depth_sim * METER_TO_BAR + pres_surface;
@@ -3117,132 +3141,94 @@
 		// convert the CNS value to integer
 		convert_sim_CNS_for_display();
 
-		// normal or alternative plan?
-		if( deco_status & CALC_NORM )
-		{
-			// normal plan - export the integer CNS value
-			int_O_CNS_norm  = int_sim_CNS_fraction;
-		}
-		else
-		{
-			// alternative plan - export the integer CNS value
-			int_O_CNS_alt   = int_sim_CNS_fraction;
-		}
-
 		// limit total time to surface to display max. and rescale to full minutes
 		if( TTS_time < 9995 ) TTS_time = (TTS_time + 5) / 10;
 		else                  TTS_time = 999 | INT_FLAG_INVALID;
 
-		// The next calculation phase will
-		// - publish the stops table if in normal plan mode,
-		// - proceed with remaining results dependent on if within NDL, or
-		// - in deco
-		if      ( deco_status & CALC_NORM ) next_planning_phase = PHASE_81_RESULTS_STOPS_TABLE;
-		else if ( NDL_time                ) next_planning_phase = PHASE_82_RESULTS_NDL;
-		else                                next_planning_phase = PHASE_83_RESULTS_DECO;
-
-		break;
-
-
-		///
-		//--- Publish Stops Table -----------------------------------------------------------------
-		//
-		case PHASE_81_RESULTS_STOPS_TABLE:
-
-		// publish the stops table to the display functions
-		publish_deco_table();
-
-		// When entering deco and the ceiling depth becomes > 0 but the
-		// deco calculation reveals no distinct deco stop yet because
-		// the deco obligation will vanish during the ascent, create an
-		// artificial stop to signal that expedite surfacing ("popping
-		// up") is not allowed anymore.
-		if( char_O_deco_depth[0] == 0 )		// simulated ascent reveals no required stops
-		if( int_O_ceiling        >  0 )		// real tissues have a ceiling
-		{
-			// set a pro forma stop at the configured last stop depth
-			char_O_deco_depth[0] = char_I_last_stop_depth;
-
-			// set a stop time of 0 minutes, this will be displayed as "..'"
-			char_O_deco_time[0]  = 0;
-		}
-
-		// The next calculation phase will publish the main results dependent on being
-		// - within NDL,
-		// - in deco.
-		if   ( NDL_time ) next_planning_phase = PHASE_82_RESULTS_NDL;
-		else              next_planning_phase = PHASE_83_RESULTS_DECO;
-
-		break;
-
-
-		///
-		//--- Results - within NDL ----------------------------------------------------------------
-		//
-		case PHASE_82_RESULTS_NDL:
+		// limit total stops time to display max.
+		if( TST_time >  999 ) TST_time = 999 | INT_FLAG_INVALID;
 
 		// normal or alternative plan?
 		if( deco_status & CALC_NORM )
 		{
-			// normal plan - output the NDL and TTS time
-			int_O_NDL_norm = NDL_time;
-			int_O_TTS_norm = TTS_time;
-
-			// clear the stops time
-			int_O_TST_norm = 0;
+			// normal plan
+
+			// export the integer CNS value
+			int_O_CNS_norm  = int_sim_CNS_fraction;
+
+			// publish the stops table to the display functions
+			publish_deco_table();
+
+			// When in deco and the ceiling depth is > 0 but the deco calculation
+			// reveals no distinct deco stop yet because the deco obligation will
+			// vanish during the ascent, create an artificial stop to signal that
+			// expedite surfacing ("popping up") is not allowed any more.
+			if( char_O_deco_depth[0] == 0 )		// simulated ascent reveals no required stops
+			if( int_O_ceiling         > 0 )		// real tissues have a ceiling
+			{
+				// set a pro forma stop at the configured last stop depth
+				char_O_deco_depth[0] = char_I_last_stop_depth;
+
+				// set a stop time of 0 minutes, this will be displayed as "..'"
+				char_O_deco_time[0]  = 0;
+			}
+
+			// within NDL?
+			if ( NDL_time )
+			{
+				// YES - output the NDL and TTS time
+				int_O_NDL_norm = NDL_time;
+				int_O_TTS_norm = TTS_time;
+
+				// clear the stops time
+				int_O_TST_norm = 0;
+			}
+			else
+			{
+				// NO - clear the normal NDL time
+				int_O_NDL_norm = 0;
+
+				// export the TTS and total stops time
+				int_O_TTS_norm = TTS_time;
+				int_O_TST_norm = TST_time;
+			}
 		}
 		else
 		{
-			// alternative plan - output the NDL time
-			int_O_NDL_alt = NDL_time;
-			int_O_TTS_alt = TTS_time;
-
-			// clear the alternative TTS and stops time
-			int_O_TST_alt = 0 + INT_FLAG_ZERO;
+			// alternative plan
+
+			// export the integer CNS value
+			int_O_CNS_alt   = int_sim_CNS_fraction;
+
+			// within NDL?
+			if ( NDL_time )
+			{
+				// YES - output the NDL time
+				int_O_NDL_alt = NDL_time;
+				int_O_TTS_alt = TTS_time;
+
+				// clear the alternative TTS and stops time
+				int_O_TST_alt = 0 + INT_FLAG_ZERO;
+			}
+			else
+			{
+				// NO - clear the alternative NDL time
+				int_O_NDL_alt = 0;
+
+				// export the TTS and total stops time
+				int_O_TTS_alt = TTS_time;
+				int_O_TST_alt = TST_time;
+			}
 		}
 
+		// export deco infos and warnings
+		char_O_deco_info     = deco_info;
+		char_O_deco_warnings = deco_warnings;
+
 		// The next calculation phase will
 		// - convert the gas needs from volume to pressure if gas needs calculation is configured
 		// - else finish the calculation cycle
-		if   ( main_status & CALC_VOLUME ) next_planning_phase = PHASE_84_GAS_NEEDS_PRESSURES;
-		else                               next_planning_phase = PHASE_90_FINISH;
-
-		break;
-
-
-		///
-		//--- Results - in Deco -------------------------------------------------------------------
-		//
-		case PHASE_83_RESULTS_DECO:
-
-		// limit total stops time to display max.
-		if( TST_time > 999 ) TST_time = 999 | INT_FLAG_INVALID;
-
-
-		// normal or alternative plan?
-		if( deco_status & CALC_NORM )
-		{
-			// normal plan - clear the normal NDL time
-			int_O_NDL_norm = 0;
-
-			// export the TTS and total stops time
-			int_O_TTS_norm = TTS_time;
-			int_O_TST_norm = TST_time;
-		}
-		else
-		{
-			// alternative plan - clear the alternative NDL time
-			int_O_NDL_alt  = 0;
-
-			// export the TTS and total stops time
-			int_O_TTS_alt  = TTS_time;
-			int_O_TST_alt  = TST_time;
-		}
-
-		// The next calculation phase will
-		// - convert the gas needs from volume to pressure if gas needs calculation is configured
-		// - else finish the calculation cycle
-		if   ( main_status & CALC_VOLUME ) next_planning_phase = PHASE_84_GAS_NEEDS_PRESSURES;
+		if   ( main_status & CALC_VOLUME ) next_planning_phase = PHASE_81_GAS_NEEDS_PRESSURES;
 		else                               next_planning_phase = PHASE_90_FINISH;
 
 		break;
@@ -3251,49 +3237,28 @@
 		//
 		//--- Results - convert Gas Needs Volumes to Pressures ------------------------------------
 		//
-		case PHASE_84_GAS_NEEDS_PRESSURES:
-
-		// convert required volume of the gas pointed to by gas_needs_gas_index
-		// into the respective pressure and set the flags
-		convert_volume_to_pressure();
-
-		// increment index to address next gas
-		gas_needs_gas_index++;
-
-		// if all gases have been converted, advance to next calculation phase
-#ifdef _cave_mode
-		if( gas_needs_gas_index == NUM_GAS ) next_planning_phase = PHASE_85_GAS_NEEDS_CAVE;
-#else
-		if( gas_needs_gas_index == NUM_GAS ) next_planning_phase = PHASE_90_FINISH;
-#endif
-
-		break;
-
+		case PHASE_81_GAS_NEEDS_PRESSURES:
+
+		// step through all gases
+		for (i = 0; i < NUM_GAS; i++)
+		{
+			// convert required volume of the gas into the respective pressure and set the flags
+			convert_volume_to_pressure(i);
+		}
 
 #ifdef _cave_mode
-		//
-		//--- Results - tag Gas Needs as Cave or Open Water Mode ----------------------------------
-		//
-		case PHASE_85_GAS_NEEDS_CAVE:
-
-		// in cave mode?
-		if( main_status & CAVE_MODE )
-		{
-			// YES - tag gas needs as calculated in cave mode (return along recorded depth profile)
-			deco_info |= GAS_NEEDS_CAVE;
-		}
-		else
-		{
-			// NO  - tag gas needs as calculated in open water mode (vertical ascent)
-			deco_info &= ~GAS_NEEDS_CAVE;
-		}
+		// tag gas needs as calculated in cave mode or in open water mode
+		if( main_status & CAVE_MODE ) deco_info |=  GAS_NEEDS_CAVE;
+		else                          deco_info &= ~GAS_NEEDS_CAVE;
+
+		// export updated deco info
+		char_O_deco_info = deco_info;
+#endif
 
 		// advance to next calculation phase
 		next_planning_phase = PHASE_90_FINISH;
 
 		break;
-#endif
-
 
 		//
 		//--- finish Calculation Cycle ------------------------------------------------------------
@@ -3309,16 +3274,15 @@
 		if( !(int_O_TTS_alt & INT_FLAG_INVALID) )
 		if( !(deco_status   & BAILOUT_MODE    ) )
 		{
-			if( int_O_TTS_alt < int_O_TTS_norm ) deco_info |=  DECO_ZONE;
-			if( int_O_TTS_alt > int_O_TTS_norm ) deco_info &= ~DECO_ZONE;
+			if     ( int_O_TTS_alt < int_O_TTS_norm ) deco_info |=  DECO_ZONE;
+			else if( int_O_TTS_alt > int_O_TTS_norm ) deco_info &= ~DECO_ZONE;
+
+			// export updated deco info
+			char_O_deco_info = deco_info;
 		}
 
-		// export updated deco infos and warnings
-		char_O_deco_info     = deco_info;
-		char_O_deco_warnings = deco_warnings;
-
-		// restore command flag to indicate that deco calculation cycle has finished
-		char_O_deco_status   = deco_status;
+		// restore command flag to indicate that the deco calculation cycle has finished
+		char_O_deco_status  = deco_status;
 
 		// signal end of deco calculation
 		next_planning_phase = PHASE_00_DONE;
@@ -3471,13 +3435,13 @@
 static void calc_tissues()
 {
 	overlay unsigned char	period;
-	overlay float			temp_tissue_N2;
+	overlay float			last_press_tissue;
+	overlay float			delta_press_N2;
 
 #ifdef _helium
-	overlay float			temp_tissue_He;
+	overlay float			delta_press_He;
 #endif
 
-
 	assert( 0.00 <= ppN2 && ppN2 < 11.2 );  // 80% N2 at 130m
 	assert( 0.00 <= ppHe && ppHe < 12.6 );  // 90% He at 130m
 
@@ -3506,43 +3470,100 @@
 
 		do
 		{
-			//---- N2 --------------------------------------------------------
-
-			temp_tissue = (tissue_increment & TISSUE_SELECTOR) ? real_pres_tissue_N2[ci] : sim_pres_tissue_N2[ci];
-
-			temp_tissue = (ppN2 - temp_tissue) * var_N2_e;
-
-			apply_saturation_factors();
-
-			if( tissue_increment & TISSUE_SELECTOR )
+			if (tissue_increment & TISSUE_SELECTOR)
 			{
-				temp_tissue_N2           = temp_tissue;
-				real_pres_tissue_N2[ci] += temp_tissue;
+				//---- real N2 --------------------------------------
+
+				// get the real tissue pressure
+				last_press_tissue = real_pres_tissue_N2[ci];
+
+				// calculate the pressure change
+				temp_tissue = (ppN2 - last_press_tissue) * var_N2_e;
+
+				// apply the saturation / desaturation factor on temp_tissue
+				apply_saturation_factors();
+
+				// store the pressure change for IBCD check and tissue graphics
+				delta_press_N2 = temp_tissue;
+
+				// update the delta accumulator
+				real_pres_delta_N2[ci] += temp_tissue;
+
+				// update the real tissue pressure
+				real_pres_tissue_N2[ci] += real_pres_delta_N2[ci];
+
+				// reduce the delta accumulator
+				real_pres_delta_N2[ci]  -= real_pres_tissue_N2[ci] - last_press_tissue;
+
+#ifdef _helium
+				//---- real He --------------------------------------
+
+				// get the real tissue pressure
+				last_press_tissue = real_pres_tissue_He[ci];
+
+				// calculate the pressure change
+				temp_tissue = (ppHe - last_press_tissue) * var_He_e;
+
+				// apply the saturation / desaturation factor on temp_tissue
+				apply_saturation_factors();
+
+				// store the pressure change for IBCD check and tissue graphics
+				delta_press_He = temp_tissue;
+
+				// update the delta accumulator
+				real_pres_delta_He[ci] += temp_tissue;
+
+				// update the real tissue pressure
+				real_pres_tissue_He[ci] += real_pres_delta_He[ci];
+
+				// reduce the delta accumulator
+				real_pres_delta_He[ci]  -= real_pres_tissue_He[ci] - last_press_tissue;
+#endif
 			}
 			else
 			{
-				sim_pres_tissue_N2[ci]  += temp_tissue;
-			}
+				//---- simulated N2 ---------------------------------
+
+				// get the simulated tissue pressure
+				last_press_tissue = sim_pres_tissue_N2[ci];
+
+				// calculate the pressure change
+				temp_tissue = (ppN2 - last_press_tissue) * var_N2_e;
+
+				// apply the saturation / desaturation factor on temp_tissue
+				apply_saturation_factors();
+
+				// update the delta accumulator
+				sim_pres_delta_N2[ci] += temp_tissue;
+
+				// update the simulated tissue pressure
+				sim_pres_tissue_N2[ci] += sim_pres_delta_N2[ci];
+
+				// reduce the delta accumulator
+				sim_pres_delta_N2[ci]  -= sim_pres_tissue_N2[ci] - last_press_tissue;
 
 #ifdef _helium
-			//---- He --------------------------------------------------------
-
-			temp_tissue = (tissue_increment & TISSUE_SELECTOR) ? real_pres_tissue_He[ci] : sim_pres_tissue_He[ci];
-
-			temp_tissue = (ppHe - temp_tissue) * var_He_e;
-
-			apply_saturation_factors();
-
-			if( tissue_increment & TISSUE_SELECTOR )
-			{
-				temp_tissue_He           = temp_tissue;
-				real_pres_tissue_He[ci] += temp_tissue;
+				//---- simulated He ---------------------------------
+
+				// get the simulated tissue pressure
+				last_press_tissue = sim_pres_tissue_He[ci];
+
+				// calculate the pressure change
+				temp_tissue = (ppHe - last_press_tissue) * var_He_e;
+
+				// apply the saturation / desaturation factor on temp_tissue
+				apply_saturation_factors();
+
+				// update the delta accumulator
+				sim_pres_delta_He[ci] += temp_tissue;
+
+				// update the simulated tissue pressure
+				sim_pres_tissue_He[ci] += sim_pres_delta_He[ci];
+
+				// reduce the delta accumulator
+				sim_pres_delta_He[ci]  -= sim_pres_tissue_He[ci] - last_press_tissue;
+#endif
 			}
-			else
-			{
-				sim_pres_tissue_He[ci]  += temp_tissue;
-			}
-#endif
 
 			//---- decrement loop counter and adjust step size ---------------
 
@@ -3564,10 +3585,8 @@
 		{
 
 #ifdef _helium
-
 			// net tissue balance
-			temp_tissue = temp_tissue_N2 + temp_tissue_He;
-
+			temp_tissue = delta_press_N2 + delta_press_He;
 
 			// check tissue on-/off-gassing and IBCD with applying a threshold of +/-HYST
 			//
@@ -3579,14 +3598,13 @@
 			else if ( temp_tissue > +HYST )				// check if the tissue in on-gassing
 			{
 				// check for counter diffusion
-				if(    ((temp_tissue_N2 > 0.0) && (temp_tissue_He < 0.0))
-				    || ((temp_tissue_N2 < 0.0) && (temp_tissue_He > 0.0)) )
+				if(    ((delta_press_N2 > 0.0) && (delta_press_He < 0.0))
+				    || ((delta_press_N2 < 0.0) && (delta_press_He > 0.0)) )
 				{
 					// tag tissue as experiencing mentionable IBCD
 					IBCD_tissue_vector |= (1 << ci);
 				}
 			}
-
 #endif
 
 			// For N2 tissue pressure display purpose:
@@ -3594,19 +3612,19 @@
 			// basically keep the on-gassing / off-gassing flag from last invocation, but flip
 			// it in case the rate exceeds a set hysteresis (actual value: see #define of HYST)
 			char_O_tissue_pres_N2[ci]  &= 128;
-			if      ( temp_tissue_N2 > +HYST ) char_O_tissue_pres_N2[ci]  = 128; // set flag for tissue pressure is increasing
-			else if ( temp_tissue_N2 < -HYST ) char_O_tissue_pres_N2[ci]  =   0; // clear flag (-> tissue pressure is decreasing)
+			if      ( delta_press_N2 > +HYST ) char_O_tissue_pres_N2[ci]  = 128; // set flag for tissue pressure is increasing
+			else if ( delta_press_N2 < -HYST ) char_O_tissue_pres_N2[ci]  =   0; // clear flag (-> tissue pressure is decreasing)
 
 			// scale N2 tissue pressure such that the surface steady-state tissue loading
 			// of [0.7902 * (1013 hPa - ppWater)] bar will give a 8, which aligns with
 			// the 2nd scale line.
-			temp_tissue_N2 = (8 / (0.7902 * (1.013 - ppWater))) * real_pres_tissue_N2[ci];
+			delta_press_N2 = (8 / (0.7902 * (1.013 - ppWater))) * real_pres_tissue_N2[ci];
 
 			// limit to 127 to protect the uppermost bit which holds the sat/desat flag
-			if (temp_tissue_N2 > 127) temp_tissue_N2 = 127;
+			if (delta_press_N2 > 127) delta_press_N2 = 127;
 
 			// convert to integer and combine with sat/desat flag
-			char_O_tissue_pres_N2[ci] += (unsigned char)temp_tissue_N2;
+			char_O_tissue_pres_N2[ci] += (unsigned char)delta_press_N2;
 
 #ifdef _helium
 
@@ -3615,19 +3633,18 @@
 			// basically keep the on-gassing / off-gassing flag from last invocation, but flip
 			// it in case the rate exceeds a set hysteresis (actual value: see #define of HYST)
 			char_O_tissue_pres_He[ci]  &= 128;
-			if      ( temp_tissue_He > +HYST ) char_O_tissue_pres_He[ci]  = 128; // set flag for tissue pressure is increasing
-			else if ( temp_tissue_He < -HYST ) char_O_tissue_pres_He[ci]  =   0; // clear flag (-> tissue pressure is decreasing)
+			if      ( delta_press_He > +HYST ) char_O_tissue_pres_He[ci]  = 128; // set flag for tissue pressure is increasing
+			else if ( delta_press_He < -HYST ) char_O_tissue_pres_He[ci]  =   0; // clear flag (-> tissue pressure is decreasing)
 
 			// scale He tissue pressure alike it is done for N2.
 			// With no He in a tissue, the result will be 0.
-			temp_tissue_He = (8 / (0.7902 * (1.013 - ppWater))) * real_pres_tissue_He[ci];
+			delta_press_He = (8 / (0.7902 * (1.013 - ppWater))) * real_pres_tissue_He[ci];
 
 			// limit to 127 to protect the uppermost bit which holds the sat/desat flag
-			if (temp_tissue_He > 127) temp_tissue_He = 127;
+			if (delta_press_He > 127) delta_press_He = 127;
 
 			// convert to integer and combine with sat/desat flag
-			char_O_tissue_pres_He[ci] += (unsigned char)temp_tissue_He;
-
+			char_O_tissue_pres_He[ci] += (unsigned char)delta_press_He;
 
 			// For combined tissue pressure display purpose:
 
@@ -3638,7 +3655,7 @@
 			else if ( temp_tissue    < -HYST ) char_O_tissue_pressure[ci] =   0; // clear flag (-> tissue pressure is decreasing)
 
 			// add the two scaled pressures.
-			temp_tissue = temp_tissue_N2 + temp_tissue_He;
+			temp_tissue = delta_press_N2 + delta_press_He;
 
 			// limit to 127 to protect the uppermost bit which holds the sat/desat flag
 			if (temp_tissue > 127) temp_tissue = 127;
@@ -3732,12 +3749,12 @@
 		}
 
 		// overall tissue pressure
-		pres_tissue = calc_pres_tissue_N2 + calc_pres_tissue_He;
+		calc_pres_tissue = calc_pres_tissue_N2 + calc_pres_tissue_He;
 
 #else
 
 		// get the tissue pressure
-		pres_tissue = ( tissue_increment & TISSUE_SELECTOR ) ? real_pres_tissue_N2[ci] : sim_pres_tissue_N2[ci];
+		calc_pres_tissue = ( tissue_increment & TISSUE_SELECTOR ) ? real_pres_tissue_N2[ci] : sim_pres_tissue_N2[ci];
 
 #endif
 
@@ -3753,14 +3770,14 @@
 
 
 			// check if tissue is in supersaturation
-			if( pres_tissue > real_pres_respiration )
+			if( calc_pres_tissue > real_pres_respiration )
 			{
 				// calculate maximum allowed tissue pressure at current ambient pressure
 				pres_tissue_max = real_pres_respiration / var_b + var_a;
 
 				// calculate current supersaturation value (1.0 = 100%) of this tissue according to straight Buhlmann
-				supersat =    ( pres_tissue     - real_pres_respiration )
-				            / ( pres_tissue_max - real_pres_respiration );
+				supersat =    ( calc_pres_tissue - real_pres_respiration )
+				            / ( pres_tissue_max  - real_pres_respiration );
 
 				// calculate supersaturation value for display purpose: 1.35 = 135% = 86 pixel
 				if( supersat <= 1.35 ) char_O_tissue_saturation[ci] = (unsigned char)(supersat * 64);
@@ -3814,13 +3831,13 @@
 		if( char_I_model == 0 )
 		{
 			// straight Buhlmann
-			pres_ambient_min_tissue = (pres_tissue - var_a) * var_b;
+			pres_ambient_min_tissue = (calc_pres_tissue - var_a) * var_b;
 		}
 		else
 		{
 			// Buhlmann with Eric Baker's varying gradient factor correction
 			// note: this equation [1] is the inverse of equation [2]
-			pres_ambient_min_tissue =   ( pres_tissue        - (var_a        * GF_parameter) )
+			pres_ambient_min_tissue =   ( calc_pres_tissue   - (var_a        * GF_parameter) )
 			                          / ( 1.0 - GF_parameter + (GF_parameter / var_b       ) );
 		}
 
@@ -3903,7 +3920,7 @@
 #else
 
 	// get the current simulated tissue pressure
-	pres_tissue = last_pres_tissue = sim_pres_tissue_N2[ci];
+	calc_pres_tissue = last_pres_tissue = sim_pres_tissue_N2[ci];
 
 	// set the a and b coefficients
 	adopt_Buhlmann_coefficients();
@@ -3917,7 +3934,7 @@
 #ifdef _helium
 
 		// calculate the total tissue pressure
-		pres_tissue = calc_pres_tissue_N2 + calc_pres_tissue_He;
+		calc_pres_tissue = calc_pres_tissue_N2 + calc_pres_tissue_He;
 
 		// adopt a and b coefficients to current N2/He ratio inside the tissue
 		adopt_Buhlmann_coefficients();
@@ -3938,7 +3955,7 @@
 		}
 
 		// is the tissue pressure higher than the maximum tissue pressure allowed?
-		if( pres_tissue > pres_limit)
+		if( calc_pres_tissue > pres_limit)
 		{
 			// YES - tissue is outside NDL
 
@@ -3977,7 +3994,7 @@
 #else
 
 				// go back to last pressure
-				pres_tissue = last_pres_tissue;
+				calc_pres_tissue = last_pres_tissue;
 
 #endif
 
@@ -4029,7 +4046,7 @@
 #else
 
 			// back-up current tissue pressure
-			last_pres_tissue    = pres_tissue;
+			last_pres_tissue    = calc_pres_tissue;
 
 #endif
 
@@ -4051,9 +4068,9 @@
 #else
 
 			// step forward tissue pressure
-			temp_tissue          = (ppN2 - pres_tissue        ) * var_N2_e;		// pressure delta breathed - tissue
+			temp_tissue          = (ppN2 - calc_pres_tissue   ) * var_N2_e;		// pressure delta breathed - tissue
 			apply_saturation_factors();											// apply safety factor
-			pres_tissue         += temp_tissue;									// add pressure delta to tissue
+			calc_pres_tissue    += temp_tissue;									// add pressure delta to tissue
 
 #endif
 
@@ -5112,7 +5129,7 @@
 //
 // Converts gas volumes into pressures and sets respective flags
 //
-// Input:  gas_needs_gas_index       index of the gas to convert (0-4)
+// Input:  index                     index of the gas to convert (0-4)
 //         gas_volume_need[]         needed gas volume in liters
 //         char_I_gas_avail_pres[]   available gas volume in bar
 //         char_I_gas_avail_size[]   size of the tanks in liters
@@ -5122,10 +5139,10 @@
 //         int_O_gas_need_pres[]     required gas amount in bar, including flags
 //         int_O_pressure_need[]     required gas amount for reading 1/2 (TR only)
 //
-static void convert_volume_to_pressure(void)
+static void convert_volume_to_pressure(PARAMETER unsigned char index)
 {
 	// just to make the code more readable...
-	i = gas_needs_gas_index;
+	i = index;
 
 	if( gas_volume_need[i] >= 65534.5 )
 	{
@@ -5343,16 +5360,8 @@
 	vault_deco_warnings     = char_O_deco_warnings;
 	vault_deco_info         = char_O_deco_info;
 
-	// store the tissue pressures
-	for( i = 0; i < NUM_COMP; i++ )
-	{
-		vault_pres_tissue_N2[i] = real_pres_tissue_N2[i];
-#ifdef _helium
-		vault_pres_tissue_He[i] = real_pres_tissue_He[i];
-#else
-		vault_pres_tissue_He[i] = 0;
-#endif
-	}
+	// copy the real pressures to the vault
+	memcpy(vault_pres_tissue_N2, real_pres_tissue_N2, 256);
 }
 
 static void pull_tissues_from_vault(void)
@@ -5365,16 +5374,8 @@
 	// convert the CNS value to integer
 	convert_cur_CNS_for_display();
 
-	// restore the tissue pressures
-	for( i = 0; i < NUM_COMP; i++ )
-	{
-		real_pres_tissue_N2[i] = vault_pres_tissue_N2[i];
-#ifdef _helium
-		real_pres_tissue_He[i] = vault_pres_tissue_He[i];
-#else
-		real_pres_tissue_He[i] = 0;
-#endif
-	}
+	// copy the vault back to the real pressures
+	memcpy(real_pres_tissue_N2, vault_pres_tissue_N2, 256);
 }
 
 
--- a/src/shared_definitions.h	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/shared_definitions.h	Sun Aug 28 13:13:38 2022 +0200
@@ -88,12 +88,13 @@
 
 #ifdef __18CXX
 	//---- BANK 3 DATA -------------------------------------------------------
-	// Gather all Data C-Code --> ASM-Code
+	// Gather all Data C-Code <--> ASM-Code
 	//
 	// Attention: keep the first block of variables on position and also do not change
 	//            their relative position - this block goes into the deco data vault!
 	//
 	// Memory usage: 253 Byte used, 3 Byte free
+	//
 #   pragma udata overlay bank3=0x300
 #else
 	; in ASM, put the same bank, in overlay mode, at the same address
@@ -236,6 +237,7 @@
 	//---- BANK 4 DATA -------------------------------------------------------
 	// Gather all Data ASM-Code --> C-Code
 	// Memory usage: 96 Byte used, 160 byte free
+	//
 #   pragma udata overlay bank4=0x400
 #else
 	; in ASM, put the same bank, in overlay mode, at the same address
@@ -252,6 +254,7 @@
 	//---- BANK 11 DATA -------------------------------------------------------
 	// Backtracking Data ASM-Code --> C-Code
 	// Memory usage: 256 Byte used, 0 byte free
+	//
 #   pragma udata overlay bank11=0xB00
 #else
 	; in ASM, put the same bank, in overlay mode, at the same address
--- a/src/sleepmode.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/sleepmode.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -28,7 +28,6 @@
 
 	extern	eeprom_deco_data_write
 	extern	option_check_and_store_all
-	extern	power_up_switches			; from hwos.asm
 
 
 ;---- Private local Variables -------------------------------------------------
@@ -152,7 +151,9 @@
 deepsleep_loop_exit:
 	bcf		deep_sleep						; clear flag (again)
 	clrf	sm_10min_counter				; clear 10mins counter
-	call	power_up_switches				; turn on    the analog switches
+	bsf		power_sw1			; switch on power supply for switch 1
+	nop
+	bsf		power_sw2			; switch on power supply for switch 2
 	rcall	init_avg_switches				; initialize the averaging system
 
 	bsf		PIE1,TMR1IE						; enable timer 1 interrupt
@@ -179,12 +180,26 @@
 ;
 one_sec_sleep:
 	bcf		trigger_full_second				; clear trigger flag
+	
+	btfss	button_hold_down_allowed			; mechanical push buttons?
+	bra	one_sec_sleep_piezo_buttons			; No
+		
+	btfss	switch_left					; left switch pressed?
+	bra	one_sec_sleep_buttons_done			; no, done
+	btfss	switch_right					; right switch pressed?
+	bra	one_sec_sleep_buttons_done			; no, done
+	bcf	sleepmode					; Both pressed, wake up
+	bra	one_sec_sleep_buttons_done			; Done.
 
-	btfsc	switch_left						; left switch pressed?
-	bcf		sleepmode						; YES - terminate sleep mode
+one_sec_sleep_piezo_buttons:	
+	btfsc	switch_left					; left switch pressed?
+	bcf	sleepmode					; YES - terminate sleep mode
+	btfsc	switch_right					; right switch pressed?
+	bcf	sleepmode					; YES - terminate sleep mode
 
-	btfsc	switch_right					; right switch pressed?
-	bcf		sleepmode						; YES - terminate sleep mode
+one_sec_sleep_buttons_done:
+    	bcf		switch_right				; clear right button event
+	bcf		switch_left				; clear left  button event
 
 	btfsc	battery_gauge_available			; is a battery gauge IC available?
 	bra		one_sec_sleep_1					; YES - check for charger
@@ -240,14 +255,12 @@
 	return							; No, done.
 
 	btfsc	ms5837_state					; =0: result of temperature is in the ADC
-	bra	one_sec_sleep_3
-	call	I2C_get_temp_val_MS5837				; (Will set ms5837_state)
-	return
-one_sec_sleep_3:
-	call	I2C_get_press_val_MS5837			; (Will clear ms5837_state)
-	return									; done
+	goto	I2C_get_press_val_MS5837			; (Will clear ms5837_state) (And return!)
+	goto	I2C_get_temp_val_MS5837				; (Will set ms5837_state) (And return!)
+	; done.
 
 
+	
 ;-----------------------------------------------------------------------------
 ; Helper Function - Tasks every 10 Seconds in Sleep Mode
 ;
--- a/src/start.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/start.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -396,42 +396,12 @@
 	bsf		ble_available					;       YES - BT available
 
 restart3:
-	bsf		PORTE,0							; power down BT chip
-	btfsc	ble_available					; BT available?
-	bra		restart4						; YES - can't be a cR then
-	btfss	battery_gauge_available			; NO  - rechargeable?
-	bra		restart4						;       NO  - can't be a cR
-	bsf		ext_input_s8_ana				;       YES - it's a cR, S8/analog sensor input available
-
-restart4:
-    ; Do the check for BLE-cR
-   IFDEF _external_sensor
-    bsf		mcp_power					; power-up instrumentation amp (used by S8 and analog input)
-    btfss	mcp_power					; power-up completed?
-    bra		$-4						; NO - loop
-    WAITMS	.1
-    banksel	BAUDCON2					; select bank for IO register access
-    movlw	b'00000000'					; speed generator configuration: BRG16=0, normal for S8
-    movwf	BAUDCON2					; ...
-    movlw	b'00100000'					; TX configuration: BRGH=0, SYNC=0
-    movwf	TXSTA2						; ...
-    movlw	.25							; speed configuration: SPBRGH:SPBRG = .25 : 9615 BAUD @ 16 MHz
-    movwf	SPBRG2						; ...
-    movlw	b'10010000'					; RX configuration
-    movwf	RCSTA2						; ...
-    banksel	common						; back to bank common
-    WAITMS	.1
-    ; Check sensor 1 input with no limits
-    movlw	b'00000000'					; AVDD Vref+
-    movwf	ADCON1						; ...
-    ; set to read Sensor 1
-    extern	wait_adc
-    movlw	b'00100001'					; power on ADC, select AN8
-    call	wait_adc					; wait for ADC
-    movlw	.10			    ; ~ >1,900V
-    cpfslt	ADRESH			    ; >10 on the high byte -> confident that there is cR circuity
-    bsf		ext_input_s8_ana				;       YES - it's a cR, S8/analog sensor input available
-    call	disable_ir_s8_analog				; power-down circuity again
+   IFDEF _external_sensor						; Compiled for external analog interface?
+    bsf	    ext_input_s8_ana					;       YES - Set the flag
+    call    eeprom_serial_number_read	; read OSTC serial number
+    movlw   .31
+    cpfslt  hi				; bigger than WREG?
+    bsf	    ble_available		; NO - must be new OSTC+ with interface
    ENDIF
    
    
--- a/src/text_english.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/text_english.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -192,13 +192,16 @@
 
 
 ; Dive settings
-	TCODE	tDvMode,			"Dive Mode   : "		; Dive Mode
+	TCODE	tDvMode,			"Dive Mode    :"		; Dive Mode
  IFDEF _cave_mode
-	TCODE	tCvMode,			"Cave Mode   : "		; Cave Mode
+	TCODE	tCvMode,			"Cave Mode    :"		; Cave Mode
  ENDIF
-	TCODE	tFTTSMenu,			"fTTS/Delay  : "		; Future TTS / Ascent Delay
-	TCODE	tTimeoutDive,		"Dive Timeout: "		; Dive Timeout
-	TCODE	tStoreApnoeDive,	"Store Apnea : "		; Store Apnoe Dives
+	TCODE	tFTTSMenu,			"fTTS/Delay   :"		; Future TTS / Ascent Delay
+	TCODE	tTimeoutDive,			"Dive Timeout :"		; Dive Timeout
+	TCODE	tStoreApnoeDive,		"Store Apnea  :"		; Store Apnoe Dives
+	TCODE   tWarningLevel,			"Warning level:"		; Warning level
+	TCODE	tLess,				"Less"				; Less
+	TCODE	tFull,				"Full"				; Full
 	TCODE	tDvOC,				"OC"					; 0 | keep order, enum!
 	TCODE	tDvCCR,				"CCR"					; 1 |
 	TCODE	tDvGauge,			"Gauge"					; 2 |
@@ -288,7 +291,9 @@
 
 ; Display settings
 	TCODE	tBright,			"Brightness"			; Brightness
-	TCODE	tBrightsurface,			"Surface Mode: "		; Surface Mode: 
+	TCODE	tBrightDive,			"Dive Mode:"			; Dive Mode
+	TCODE	tBrightSurface,			"Surface Mode:"			; Surface Mode: 
+	TCODE	tUseAmbientSensor,		"Light Sensor:"			; Light Sensor
 	TCODE	tLayout,			"Layout    : "			; Layout
 	TCODE	tUnits,				"Units     : "			; Units
  IF _language_2!=none
--- a/src/text_french.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/text_french.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -197,8 +197,11 @@
 	TCODE	tCvMode,			"Spéléo      : "		; Cave Mode
  ENDIF
 	TCODE	tFTTSMenu,			"Future DTR  : "		; Future TTS
-	TCODE	tTimeoutDive,		"Fin Plongée : "		; Dive Timeout
-	TCODE	tStoreApnoeDive,	"Carnet Apnée: "		; Store Apnoe Dives
+	TCODE	tTimeoutDive,			"Fin Plongée : "		; Dive Timeout
+	TCODE	tStoreApnoeDive,		"Carnet Apnée: "		; Store Apnoe Dives
+	TCODE   tWarningLevel,			"Niv. d'alerte:"		; Warning level
+	TCODE	tLess,				"Moins"				; Less
+	TCODE	tFull,				"Tous"				; Full
 	TCODE	tDvOC,				"OC"					; 0 | keep order, enum!
 	TCODE	tDvCCR,				"CCR"					; 1 |
 	TCODE	tDvGauge,			"Gauge"					; 2 |
@@ -288,7 +291,9 @@
 
 ; Display Settings
 	TCODE	tBright,			"Luminosité"			; Brightness
-	TCODE	tBrightsurface,			"Mode Surface: "		; ...Surface
+	TCODE	tBrightDive,			"Mode plongee:"			; Dive Mode
+	TCODE	tBrightSurface,			"Mode Surface:"			; ...Surface
+	TCODE	tUseAmbientSensor,		"capteur lumière:"		; Use light sensor
 	TCODE	tLayout,			"Affichage : "			; Layout
 	TCODE	tUnits,				"Unités    : "			; Units
  IF _language_2!=none
--- a/src/text_german.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/text_german.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -197,8 +197,11 @@
 	TCODE	tCvMode,			"Höhlenmodus : "		; Cave Mode
  ENDIF
 	TCODE	tFTTSMenu,			"fTTS/Verz.  : "		; Future TTS
-	TCODE	tTimeoutDive,		"TG-Ende nach: "		; Dive Timeout
-	TCODE	tStoreApnoeDive,	"Log Apnoe   : "		; Store Apnoe Dives
+	TCODE	tTimeoutDive,			"TG-Ende nach: "		; Dive Timeout
+	TCODE	tStoreApnoeDive,		"Log Apnoe   : "		; Store Apnoe Dives
+	TCODE   tWarningLevel,			"Warnstufe: "		; Warning level
+	TCODE	tLess,				"Weniger"				; Less
+	TCODE	tFull,				"Alle"				; Full
 	TCODE	tDvOC,				"OC"					; 0 | keep order, enum!
 	TCODE	tDvCCR,				"CCR"					; 1 |
 	TCODE	tDvGauge,			"Gauge"					; 2 |
@@ -288,7 +291,9 @@
 
 ; Display Settings
 	TCODE	tBright,			"Helligkeit"			; Brightness
-	TCODE	tBrightsurface,			"Oberfläche  : "		; ...Surface
+	TCODE	tBrightDive,			"Tauchmodus:"			; Dive Mode
+	TCODE	tBrightSurface,			"Oberfläche:"			; ...Surface
+	TCODE	tUseAmbientSensor,		"Nutze Sensor:"			; Use light sensor
 	TCODE	tLayout,			"Layout    : "			; Layout
 	TCODE	tUnits,				"Einheiten : "			; Units
  IF _language_2!=none
--- a/src/text_italian.inc	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/text_italian.inc	Sun Aug 28 13:13:38 2022 +0200
@@ -197,8 +197,11 @@
 	TCODE	tCvMode,			"Cave Mode     : "		; Cave Mode
  ENDIF
 	TCODE	tFTTSMenu,			"TTS Futuro    : "		; Future TTS
-	TCODE	tTimeoutDive,		"Timeout Immsni: "		; Dive Timeout
-	TCODE	tStoreApnoeDive,	"Salva Apnee   : "		; Salva Tuffi Apnea
+	TCODE	tTimeoutDive,			"Timeout Immsni: "		; Dive Timeout
+	TCODE	tStoreApnoeDive,		"Salva Apnee   : "		; Salva Tuffi Apnea
+	TCODE   tWarningLevel,			"Liv. d'allarme:"		; Warning level
+	TCODE	tLess,				"Meno"				; Less
+	TCODE	tFull,				"Tutti"				; Full
 	TCODE	tDvOC,				"OC"					; 0 | keep order, enum!
 	TCODE	tDvCCR,				"CCR"					; 1 |
 	TCODE	tDvGauge,			"Gauge"					; 2 |
@@ -288,7 +291,9 @@
 
 ; Display Settings
 	TCODE	tBright,			"Luminosita'"			; Brightness
-	TCODE	tBrightsurface,			"Superficie  : "		; ...Surface
+	TCODE	tBrightDive,			"Immersione:"			; Dive Mode
+	TCODE	tBrightSurface,			"Superficie:"			; ...Surface
+	TCODE	tUseAmbientSensor,		"Sensore luce:"			; Use light sensor
 	TCODE	tLayout,			"Layout     : "			; Layout
 	TCODE	tUnits,				"Unita'     : "			; Units
  IF _language_2!=none
--- a/src/text_multilang.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/text_multilang.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -22,7 +22,7 @@
 ; fast hack **ONLY** for **CHANGING** languages ( en / de / fr / it )
 
 ;#undefine _language_1
-;#define   _language_1 fr
+;#define   _language_1 it
 
 ;#undefine _language_2
 ;#define   _language_2 it
--- a/src/tft_outputs.asm	Fri Mar 04 08:30:23 2022 +0100
+++ b/src/tft_outputs.asm	Sun Aug 28 13:13:38 2022 +0200
@@ -3079,7 +3079,7 @@
 ; Dive Mode - Message - Saturation
 ;
 	global	TFT_message_saturation
-TFT_message_saturation
+TFT_message_saturation:
 	rcall	TFT_message_open			; set row and column for the message
 	tstfsz	WREG						; is there room for the message?
 	return								; NO  - skip message in this cycle
@@ -3330,7 +3330,7 @@
 ; Dive Mode - Message - Deco Info
 ;
 	global	TFT_message_deco_info
-TFT_message_deco_info
+TFT_message_deco_info:
 	rcall	TFT_message_open			; set row and column for the message
 	tstfsz	WREG						; is there room for the message?
 	return								; NO  - skip message in this cycle
@@ -6070,16 +6070,13 @@
 ;	WIN_TINY   .0, .		0					; dive    mode: overwrites depth label
 	FONT_COLOR_MEMO								; set color
 	
-	movff	ambient_light+0,lo
+	movff	gp_debug+0,lo
 	output_256
 	PUTC	","
-	movff	ambient_light+0,lo
-	movff	ambient_light+1,hi
-	output_65535
-
-	
-
-;	; deco engine scheduling performance
+	movff	gp_debug+1,lo
+	output_256
+
+	;	; deco engine scheduling performance
 ;	MOVII	int_O_profiling_overrun,mpr			; runtime +/- versus target
 ;	btfss	mpr+1,7								; overrun?
 ;	bra		TFT_debug_output_1					; YES