diff code_part1/OSTC_code_asm_part1/pled_outputs.asm @ 401:6ed12fad3b97

Ignore 5mbar pressure sensor noise in surface screen
author heinrichsweikamp
date Sun, 26 Jun 2011 18:07:51 +0200
parents 40b282821dcf
children e565392e0fcc
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sun Jun 26 12:30:42 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sun Jun 26 18:07:51 2011 +0200
@@ -1774,8 +1774,27 @@
 	btfsc	high_altitude_mode		; In high altitude mode?
 	call	PLED_warnings_color		; Yes, display ambient pressure in red
 
+    SAFE_2BYTE_COPY amb_pressure, lo
 	lfsr	FSR2,letter
-    SAFE_2BYTE_COPY amb_pressure, lo
+
+	movff	lo,sub_a+0
+	movff	hi,sub_a+1
+	movff	last_surfpressure_30min+0,sub_b+0
+	movff	last_surfpressure_30min+1,sub_b+1
+	call	sub16					; sub_c = sub_a - sub_b
+	btfsc	neg_flag				; Pressure lower?
+	rcall	update_surf_press2		; Yes, test threshold
+
+	tstfsz	sub_c+1					; >255mbar difference?
+	bra		update_surf_press_common; Yes, display!
+	movlw	d'5'
+	subwf	sub_c+0,W
+	btfsc	STATUS,C
+	bra		update_surf_press_common; Yes, display!
+;	PUTC	'+'						; For debug only
+    SAFE_2BYTE_COPY last_surfpressure_30min, lo	; Overwrite with stable value...
+
+update_surf_press_common:
 	bsf		leftbind
 	output_16
 	bcf		leftbind
@@ -1783,6 +1802,15 @@
 	call	PLED_standard_color		; Reset color
 	return
 
+update_surf_press2:
+	movff	lo,sub_b+0
+	movff	hi,sub_b+1
+	movff	last_surfpressure_30min+0,sub_a+0
+	movff	last_surfpressure_30min+1,sub_a+1
+	call	sub16					; sub_c = sub_a - sub_b
+;	PUTC	'-'						; For debug only
+	return
+
 update_batt_voltage_divemode:
 	call	PLED_warnings_color
 	DISPLAYTEXT		d'246'		; LowBatt!