changeset 266:ba109a7948df

OSTC 2N uses exchanged switches...
author heinrichsweikamp
date Tue, 12 Apr 2011 08:11:50 +0200
parents ab8ce7de2b46
children 814ac3af3052
files code_part1/OSTC_code_asm_part1/isr.asm code_part1/OSTC_code_asm_part1/menu_battery.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm
diffstat 3 files changed, 32 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/isr.asm	Tue Apr 12 01:19:33 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/isr.asm	Tue Apr 12 08:11:50 2011 +0200
@@ -87,7 +87,12 @@
 		btfsc	T0CON,TMR0ON				; Timer0 running?
 		bra		timer0_restart				; Yes, restart
 
+		; OSTC 2N has flipped screen and exchanged switches...
+		movff	win_flags,WREG				; Get into Bank0
+		btfss	WREG,0
 		bsf		switch_left					; Set flag, button press is OK
+		btfsc	WREG,0
+		bsf		switch_right				; Set flag, button press is OK
 
 		bsf		T0CON,TMR0ON				; Start Timer 0
 		return
@@ -99,6 +104,11 @@
 		btfsc	T0CON,TMR0ON				; Timer0 running?
 		bra		timer0_restart				; Yes, restart
 
+		; OSTC 2N has flipped screen and exchanged switches...
+		movff	win_flags,WREG				; Get into Bank0
+		btfsc	WREG,0
+		bsf		switch_left					; Set flag, button press is OK
+		btfss	WREG,0
 		bsf		switch_right				; Set flag, button press is OK
 
 		bsf		T0CON,TMR0ON				; Start Timer 0
--- a/code_part1/OSTC_code_asm_part1/menu_battery.asm	Tue Apr 12 01:19:33 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_battery.asm	Tue Apr 12 08:11:50 2011 +0200
@@ -133,9 +133,9 @@
 	call	PLED_convert_date		; coverts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
 	STRCAT_PRINT ") "
 	
-menu_battery_state5:
-	btfss	SWITCH2
-	bra		menu_battery_state5
+;menu_battery_state5:
+;	btfss	SWITCH2
+;	bra		menu_battery_state5
 	
 	bcf		switch_left
 	bcf		switch_right
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Tue Apr 12 01:19:33 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Tue Apr 12 08:11:50 2011 +0200
@@ -441,6 +441,10 @@
 	movff		SSPBUF,lo
 	call		I2CREAD2				; read Air pressure
 	movff		SSPBUF,hi
+
+	movff		lo,average_depth_hold+2
+	movff		hi,average_depth_hold+3		; Store here for correct average
+
 	bsf			leftbind
 	output_16							; Air pressure before dive
 	STRCAT      "mbar "
@@ -598,9 +602,17 @@
 profile_display_loop2:
 	rcall		profile_view_get_depth		; reads depth, ignores temp and profile data	-> hi, lo
 
-	movf		lo,w
+	; Subtract Surface pressure
+	movff		average_depth_hold+2,sub_b+0
+	movff		average_depth_hold+3,sub_b+1	; ambient pressure in mBar
+	movff		lo,sub_a+0
+	movff		hi,sub_a+1					; depth in mBar
+	call		sub16						; sub_c = sub_a - sub_b
+
+	; add depth to average registers
+	movf		sub_c+0,W
 	addwf		average_depth_hold_total+0,F
-	movf		hi,w
+	movf		sub_c+1,W
 	addwfc		average_depth_hold_total+1,F
 	movlw		d'0'
 	addwfc		average_depth_hold_total+2,F
@@ -643,6 +655,7 @@
 profile_display_loop_done:
 	call		PLED_standard_color			; Restore color
 	movlw		d'159'
+;	movlw		d'200'
 	subfwb		ignore_digits,W				; keep number of X-pixels (For average depth display on Page 3)
 	movwf		average_divesecs+0			; Store here for compatibility
 
@@ -862,7 +875,10 @@
 
 logbook_skip_cns:
 	WIN_TOP		.50
-	movff	average_divesecs+0,xB+0
+
+	btfsc	average_divesecs+0,0				; Number of drawn pixels even?
+	incf	average_divesecs+0,W				; No, add +1 -> WREG
+	movwf	xB+0								; Copy W to xB+0
 	clrf	xB+1								; Number of x-pixels displayed
 	movff	average_depth_hold_total+0,xC+0
 	movff	average_depth_hold_total+1,xC+1