changeset 415:d022c62a1df5

fixing issue with end-of-dive threshold in high-altitude mode simulator now works up to 120m depth fix internal logbook hung up on bad profile data
author heinrichsweikamp
date Sun, 17 Jul 2011 17:23:25 +0200
parents dd4a1aa96232
children 3abf9d7dafae
files code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm code_part1/OSTC_code_asm_part1/simulator.asm
diffstat 5 files changed, 54 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Sat Jul 16 13:25:23 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Sun Jul 17 17:23:25 2011 +0200
@@ -1,7 +1,8 @@
 New in 1.94 beta:
 BETA Version - Do NOT use for diving!
 BUGFIX: CNS was not cleared with a "Reset Deco"
-
+CHANGE: Max. depth for simulator now 120m
+BUGFIX: Ascend threshold in high altitude mode
 
 New in 1.93 beta:
 BETA Version - Do NOT use for diving!
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Sat Jul 16 13:25:23 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Sun Jul 17 17:23:25 2011 +0200
@@ -43,6 +43,12 @@
 #DEFINE		FT_MEDIUM		.1
 #DEFINE		FT_LARGE		.2
 
+; "Better Gas" behavior
+; better_gas_window <= minimum_change_depth !
+; minimum_change_depth >=5 !
+#DEFINE	minimum_change_depth	.3 			; [m]
+#DEFINE	better_gas_window		.3			; [m]
+
 ; Color Definitions: 8Bit RGB b'RRRGGGBB'
 #DEFINE	color_red		d'224'
 #DEFINE	color_violet	d'235'
@@ -85,8 +91,8 @@
 
 ;=============================================================================
 
-#include "../OSTC_code_c_part2/shared_definitions.h"
-;#include "shared_definitions.h"
+;#include "../OSTC_code_c_part2/shared_definitions.h"
+#include "shared_definitions.h"
 
 ;=============================================================================
 ; Reserve space for C-code data space. Eg.when calling log.
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Sat Jul 16 13:25:23 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Sun Jul 17 17:23:25 2011 +0200
@@ -985,15 +985,15 @@
 	bra		check_gas_change2		; Yes, skip depth check
 check_gas_change1x:	
 	read_int_eeprom		d'28'		; read gas_change_depth
-	movlw	d'3'
-	cpfsgt	EEDATA					; Change depth>3m?
+	movlw	minimum_change_depth
+	cpfsgt	EEDATA					; Change depth>minimum_change_depth?
 	bra		check_gas_change2		; No, Change depth not deep enough, skip!
 	movf	xC+0,W					; load depth in m into WREG
 	cpfsgt	EEDATA					; gas_change_depth < current depth?
 	bra		check_gas_change2		; No, check next gas
-	movlw	d'3'
-	subwf	EEDATA,W				; Change depth-3m
-	cpfslt	xC+0					; current depth<Change depth-3m?
+	movlw	better_gas_window
+	subwf	EEDATA,W				; Change depth-better_gas_window
+	cpfslt	xC+0					; current depth<Change depth-better_gas_window?
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change2:					; check gas2
@@ -1005,15 +1005,15 @@
 	bra		check_gas_change3		; Yes, skip depth check
 check_gas_change2x:	
 	read_int_eeprom		d'29'		; read gas_change_depth
-	movlw	d'3'
-	cpfsgt	EEDATA					; Change depth>3m?
+	movlw	minimum_change_depth
+	cpfsgt	EEDATA					; Change depth>minimum_change_depth?
 	bra		check_gas_change3		; No, Change depth not deep enough, skip!
 	movf	xC+0,W					; load depth in m into WREG
 	cpfsgt	EEDATA					; gas_change_depth < current depth?
 	bra		check_gas_change3		; No, check next gas
-	movlw	d'3'
-	subwf	EEDATA,W				; Change depth-3m
-	cpfslt	xC+0					; current depth<Change depth-3m?
+	movlw	better_gas_window
+	subwf	EEDATA,W				; Change depth-better_gas_window
+	cpfslt	xC+0					; current depth<Change depth-better_gas_window?
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change3:					; check gas3
@@ -1025,15 +1025,15 @@
 	bra		check_gas_change4		; Yes, skip depth check
 check_gas_change3x:	
 	read_int_eeprom		d'30'		; read gas_change_depth
-	movlw	d'3'
-	cpfsgt	EEDATA					; Change depth>3m?
+	movlw	minimum_change_depth
+	cpfsgt	EEDATA					; Change depth>minimum_change_depth?
 	bra		check_gas_change4		; No, Change depth not deep enough, skip!
 	movf	xC+0,W					; load depth in m into WREG
 	cpfsgt	EEDATA					; gas_change_depth < current depth?
 	bra		check_gas_change4		; No, check next gas
-	movlw	d'3'
-	subwf	EEDATA,W				; Change depth-3m
-	cpfslt	xC+0					; current depth<Change depth-3m?
+	movlw	better_gas_window
+	subwf	EEDATA,W				; Change depth-better_gas_window
+	cpfslt	xC+0					; current depth<Change depth-better_gas_window?
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change4:					; check gas4
@@ -1045,15 +1045,15 @@
 	bra		check_gas_change5		; Yes, skip depth check
 check_gas_change4x:	
 	read_int_eeprom		d'31'		; read gas_change_depth
-	movlw	d'3'
-	cpfsgt	EEDATA					; Change depth>3m?
+	movlw	minimum_change_depth
+	cpfsgt	EEDATA					; Change depth>minimum_change_depth?
 	bra		check_gas_change5		; No, Change depth not deep enough, skip!
 	movf	xC+0,W					; load depth in m into WREG
 	cpfsgt	EEDATA					; gas_change_depth < current depth?
 	bra		check_gas_change5		; No, check next gas
-	movlw	d'3'
-	subwf	EEDATA,W				; Change depth-3m
-	cpfslt	xC+0					; current depth<Change depth-3m?
+	movlw	better_gas_window
+	subwf	EEDATA,W				; Change depth-better_gas_window
+	cpfslt	xC+0					; current depth<Change depth-better_gas_window?
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change5:					; check gas5
@@ -1065,15 +1065,15 @@
 	bra		check_gas_change6		; Yes, skip depth check
 check_gas_change5x:	
 	read_int_eeprom		d'32'		; read gas_change_depth
-	movlw	d'3'
-	cpfsgt	EEDATA					; Change depth>3m?
+	movlw	minimum_change_depth
+	cpfsgt	EEDATA					; Change depth>minimum_change_depth?
 	bra		check_gas_change6		; No, Change depth not deep enough, skip!
 	movf	xC+0,W					; load depth in m into WREG
 	cpfsgt	EEDATA					; gas_change_depth < current depth?
 	bra		check_gas_change6		; No, check next gas
-	movlw	d'3'
-	subwf	EEDATA,W				; Change depth-3m
-	cpfslt	xC+0					; current depth<Change depth-3m?
+	movlw	better_gas_window
+	subwf	EEDATA,W				; Change depth-better_gas_window
+	cpfslt	xC+0					; current depth<Change depth-better_gas_window?
 	bsf		better_gas_available	;=1: A better gas is available and a gas change is advised in divemode
 
 check_gas_change6:			;Done
@@ -1556,11 +1556,14 @@
 
 set_dive_modes:
 	btfsc	high_altitude_mode		; In high altitude (Fly) mode?
-	bra		set_dive_modes3			; Yes
+	bra		set_dive_modes3			; Yes!
 
+set_dive_modes0:
 	GETCUSTOM8	.0					; loads dive_threshold in WREG
 	movwf	sub_a+0					; dive_treshold is in cm
 	clrf	sub_a+1
+
+set_dive_modes1:
     SAFE_2BYTE_COPY rel_pressure, sub_b
 	call	sub16					; sub_c = sub_a - sub_b
 
@@ -1590,19 +1593,16 @@
 	call	PLED_divemode_timeout	; No, show the divemode timeout here...
 	return
 
-set_dive_modes3:
-	movlw	HIGH	d'1075'			; hard-wired 1075mbar threshold
+set_dive_modes3:					; High-altitude mode
+	btfsc	realdive				; dive longer then one minute?
+	bra		set_dive_modes0			; Yes -> this is a real dive -> Use CF00 threshold for ascend
+
+	movlw	HIGH	d'300'			; hard-wired 300cm threshold
 	movwf	sub_a+1
-	movlw	LOW		d'1075'			; hard-wired 1075mbar threshold
+	movlw	LOW		d'300'			; hard-wired 300cm threshold
 	movwf	sub_a+0
-    SAFE_2BYTE_COPY rel_pressure, sub_b
-	call	sub16					; sub_c = sub_a - sub_b
-	
-	btfss	neg_flag	
-	bra		set_dive_modes2			; too shallow (rel_pressure<dive_threshold)
-	
-	bra		set_dive_modes_common
-	
+	bra		set_dive_modes1
+
 set_powersafe:
 	btfsc	low_battery_state		; battery warning alread active?
 	bra		set_powersafe2			; Yes, but is it still required?
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Sat Jul 16 13:25:23 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Sun Jul 17 17:23:25 2011 +0200
@@ -372,6 +372,12 @@
 	movff		xC+0,last_temperature+0	; 
 	movff		xC+1,last_temperature+1	; = Pixels/10m (For scale, draw any xx rows a scale-line)
 
+	movf		last_temperature+0,W
+	iorwf		last_temperature+1,W		; last_temperature:2 = Null?
+	bnz			display_profile_offset4		; No, continue
+	incf		last_temperature+1,F		; Yes, make last_temperature+1>1 to make "display_profile2e" working
+
+display_profile_offset4:
 	bsf			leftbind
 	output_16dp	d'3'					; max. depth
 	STRCAT      "m "
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Sat Jul 16 13:25:23 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Sun Jul 17 17:23:25 2011 +0200
@@ -120,7 +120,7 @@
 simulator_inc_maxdepth:
 	movlw	d'3'
 	addwf	logbook_temp2,F				; Here: Maxdepth in m
-	movlw	d'99'
+	movlw	d'120'
 	cpfslt	logbook_temp2
 	movwf	logbook_temp2
 	movlw	d'4'