changeset 274:a728b4a1b660

Setpoint changes stored in profile, EAD and END displayed in divemode (Customview 7)
author heinrichsweikamp
date Sun, 17 Apr 2011 17:57:44 +0200
parents 35bbab4d3c6f
children 4310ab395dbe
files code_part1/OSTC_code_asm_part1/customview.asm code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode.asm code_part1/OSTC_code_asm_part1/divemode_menu.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/sleepmode.asm
diffstat 6 files changed, 101 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/customview.asm	Wed Apr 13 10:07:37 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/customview.asm	Sun Apr 17 17:57:44 2011 +0200
@@ -73,6 +73,9 @@
 	bra		customview_1sec_average     ; Update the Average depth
 	dcfsnz	WREG,F
 	bra		customview_1sec_graphs      ; Update the leading tissue
+	dcfsnz	WREG,F
+	bra		customview_1sec_ead_end		; Show END and EAD in divemode
+
 	; Menupos3=0, do nothing
 	return
 
@@ -100,6 +103,10 @@
 	call	PLED_tissue_saturation_graph
 	return
 
+customview_1sec_ead_end:
+	call	PLED_show_end_ead_divemode
+	return
+
 ;=============================================================================
 ; Do every-minute tasks for the custom view area
 
@@ -114,9 +121,12 @@
 	dcfsnz	WREG,F
 	bra		customview_minute_lead_tiss ; Update the leading tissue
 	dcfsnz	WREG,F
-	bra		customview_minute_average		; Update the Average depth
+	bra		customview_minute_average	; Update the Average depth
 	dcfsnz	WREG,F
 	bra		customview_minute_graphs	; Update the graphs
+	dcfsnz	WREG,F
+	bra		customview_minute_ead_end	; Show END and EAD in divemode
+
 	; Menupos3=0, do nothing
 	return
 
@@ -128,10 +138,11 @@
 	call	PLED_show_leading_tissue_2  ; Update the leading tissue
 	return
 
+customview_minute_ead_end:              ; Do nothing extra
 customview_minute_marker:               ; Do nothing extra
 customview_minute_stopwatch:            ; Do nothing extra
 customview_minute_average:				; Do nothing extra
-customview_minute_graphs:
+customview_minute_graphs:               ; Do nothing extra
 	return
 
 ;=============================================================================
@@ -144,7 +155,7 @@
 	bra		customview_toggle_exit			; Yes, ignore custom view in divemode completely
 
 	incf	menupos3,F			            ; Number of customview to show
-	movlw	d'6'							; Max number
+	movlw	d'7'							; Max number
 	cpfsgt	menupos3			            ; Max reached?
 	bra		customview_mask		            ; No, show
 	clrf	menupos3			            ; Reset to zero (Zero=no custom view)
@@ -163,6 +174,8 @@
 	bra		customview_init_average			; Show Total average depth
 	dcfsnz	WREG,F
 	bra		customview_init_graphs		    ; Show the graphs
+	dcfsnz	WREG,F
+	bra		customview_init_ead_end		    ; Show END and EAD in divemode
 
 customview_init_nocustomview:
 	bra		customview_toggle_exit	
@@ -203,6 +216,10 @@
 	call	    PLED_show_leading_tissue
 	bra		    customview_toggle_exit	
 
+customview_init_ead_end:
+	call		PLED_show_end_ead_divemode
+	bra		    customview_toggle_exit	
+
 customview_init_graphs:					; Show tissue graph
  	GETCUSTOM8	d'52'					; Show Tissue Graph? (=1 in WREG)
 	decfsz		WREG,F					; WREG=1?	
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Wed Apr 13 10:07:37 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Sun Apr 17 17:57:44 2011 +0200
@@ -85,7 +85,7 @@
 
 ;=============================================================================
 
-#include "../OSTC_code_c_part2/shared_definitions.h"
+#include "shared_definitions.h"
 
 ;=============================================================================
 ; Reserve space for C-code data space. Eg.when calling log.
@@ -486,8 +486,8 @@
 #DEFINE	initialize_battery2		flag11,6	;=1: Battery memory need to be initialised
 #DEFINE	charge_started			flag11,7	;=1: Charger started in CC mode
 
-#DEFINE	switch_left_isr			flag12,0	;=1: left switch pressed (Only modified in ISR!)
-#DEFINE	switch_right_isr		flag12,1	;=1: right switch pressed (Only modified in ISR!)
+#DEFINE	setpoint_changed		flag12,0	;=1: Setpoint was changed in divemode, store in profile
+; #DEFINE	free		flag12,1	;=1: 
 #DEFINE	debug_mode				flag12,2	;=1: Debugmode active
 #DEFINE	neg_flag_isr			flag12,3	;=1: ISR Negative flag (Math)
 #DEFINE	select_bailoutgas		flag12,4	;=1: Select Bailout instead of Setpoint in Gaslist
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Wed Apr 13 10:07:37 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Sun Apr 17 17:57:44 2011 +0200
@@ -635,6 +635,12 @@
 	addwf	ProfileFlagByte,F	; add to ProfileFlagByte
 	bsf		EventByte,5			; Also set Flag in EventByte!
 check_event2:
+	btfss	setpoint_changed	; Check flag	
+	bra		check_event3
+	movlw	d'1'				; Information length	
+	addwf	ProfileFlagByte,F	; add to ProfileFlagByte
+	bsf		EventByte,6			; Also set Flag in EventByte!
+check_event3:
 	bsf		ProfileFlagByte,7	; Set EventByte Flag in ProfileFlagByte
 
 store_dive_data3:
@@ -648,7 +654,7 @@
 	movf	EventByte,W		
 	call	write_external_eeprom
 
-	btfss	manual_gas_changed	; Check flag	
+	btfss	manual_gas_changed		; Check flag	
 	bra		store_dive_data3a
 	read_int_eeprom	d'24'			; % O2 Gas6
 	movf	EEDATA,W
@@ -656,19 +662,17 @@
 	read_int_eeprom	d'25'			; % He Gas6
 	movf	EEDATA,W
 	call	write_external_eeprom
+	bcf		manual_gas_changed		; Clear this event
 
 store_dive_data3a:
 	btfss	stored_gas_changed	; Check flag	
 	bra		store_dive_data3b			
 	movf	active_gas,W		; Store active gas
 	call	write_external_eeprom
-
+	bcf		stored_gas_changed	; Clear this event
 store_dive_data3b:
 
 store_dive_data4:
-	bcf		event_occured		; Clear the global event flag
-	bcf		manual_gas_changed	; Clear all events
-	bcf		stored_gas_changed	; Clear all events
 
 ; Store extended informations
 	decfsz	divisor_temperature,F	; Check divisor
@@ -711,7 +715,17 @@
 	clrf	divisor_nuy2			; And clear register again, so it will never reach zero...
 
 	ostc_debug	'D'		; Sends debug-information to screen if debugmode active
-	return				; Done.
+
+; SetPoint change appended to information due to compatibility reasons
+	btfss	setpoint_changed		; Check flag	
+	bra		store_dive_data5
+	movff	char_I_const_ppO2,WREG	; SetPoint in cBar
+	call	write_external_eeprom
+	bcf		setpoint_changed		; Clear this event
+
+store_dive_data5:
+	bcf		event_occured		; Clear the global event flag
+	return						; Done. (Sample with all informations written to EEPROM)
 	
 store_dive_nuy2:
 	GETCUSTOM8	d'26'
@@ -1665,6 +1679,7 @@
 	clrf 	timeout_counter2			; Here: counts to six, then store deco data and temperature
 	clrf	AlarmType					; Clear all alarms
 	bcf		event_occured				; clear flag
+	bcf		setpoint_changed			; clear flag
 	rcall	reset_average1				; Reset the resettable average depth
 	clrf	average_depth_hold_total+0
 	clrf	average_depth_hold_total+1
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Wed Apr 13 10:07:37 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sun Apr 17 17:57:44 2011 +0200
@@ -594,6 +594,7 @@
 	call	read_eeprom					; Read SetPoint
 	movff	EEDATA, char_I_const_ppO2	; Use SetPoint
 	movff	EEDATA, ppO2_setpoint_store	; Store also in this byte...
+	bsf		setpoint_changed
 
 divemenu_set_gas1a:
 	bcf		display_set_setpoint		; Clear Display Flag
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Wed Apr 13 10:07:37 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sun Apr 17 17:57:44 2011 +0200
@@ -3040,6 +3040,62 @@
 	call	PLED_standard_color
 	return
 
+PLED_show_end_ead_divemode:
+	WIN_LEFT	.95
+	WIN_TOP		.192
+	WIN_FONT	FT_SMALL
+	call		PLED_divemask_color	; Set Color for Divemode mask
+	lfsr	FSR2,letter
+	STRCAT_PRINT  "EAD:"
+	WIN_LEFT	.95
+	WIN_TOP		.216
+	lfsr	FSR2,letter
+	STRCAT_PRINT  "END:"
+; Show EAD: char_I_N2_ratio/0.79*rel_pressure:2*10 -> char_I_N2_ratio*rel_pressure:2/7900 -> EAD in m
+	call	PLED_standard_color
+	WIN_LEFT	.125
+	WIN_TOP		.192
+	movff	char_I_N2_ratio,xA+0
+	clrf	xA+1
+	movff	rel_pressure+0,xB+0
+	movff	rel_pressure+1,xB+1
+	call	mult16x16                   ; xA*xB=xC
+	movlw	LOW		d'7900'
+	movwf	xB+0
+	movlw	HIGH	d'7900'
+	movwf	xB+1
+	call	div32x16  ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
+	movff	xC+0,lo
+	movff	xC+1,hi						; lo:hi now hold EAD in m
+	lfsr	FSR2,letter
+	output_16_3							; Display only full meters
+	STRCAT_PRINT  "m"					; Display EAD
+
+	WIN_LEFT	.125
+	WIN_TOP		.216
+; Show END = rel_pressure × (100 - char_I_He_ratio)/10000 -> Result in m
+	movff	char_I_He_ratio,lo			; temp
+	movlw	d'100'
+	bsf		STATUS,C	
+	subfwb	lo,W
+	movwf	xA+0
+	clrf	xA+1
+	movff	rel_pressure+0,xB+0
+	movff	rel_pressure+1,xB+1
+	call	mult16x16                   ; xA*xB=xC
+	movlw	LOW		d'10000'
+	movwf	xB+0
+	movlw	HIGH	d'10000'
+	movwf	xB+1
+	call	div32x16  ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
+	movff	xC+0,lo
+	movff	xC+1,hi						; lo:hi now hold END in m
+	lfsr	FSR2,letter
+	output_16_3
+	STRCAT_PRINT  "m"					; Display END
+	return
+
+
 PLED_show_leading_tissue:
 	call		PLED_divemask_color	; Set Color for Divemode mask
 	DISPLAYTEXTH	.282		; L. Tissue:
--- a/code_part1/OSTC_code_asm_part1/sleepmode.asm	Wed Apr 13 10:07:37 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/sleepmode.asm	Sun Apr 17 17:57:44 2011 +0200
@@ -150,8 +150,6 @@
 ; No button pressed
 	bcf		INTCON,INT0IF				; Clear flag
 	bcf		INTCON3,INT1IF				; Clear flag
-	bcf		switch_right_isr
-	bcf		switch_left_isr
 	bcf		switch_right
 	bcf		switch_left
 	bcf		T0CON,TMR0ON				; Stop Timer 0
@@ -159,8 +157,6 @@
 onesec_sleep1a:	; At least one button pressed....
 	bcf		INTCON,INT0IF				; Clear flag
 	bcf		INTCON3,INT1IF				; Clear flag
-	bcf		switch_right_isr
-	bcf		switch_left_isr
 	bcf		switch_right
 	bcf		switch_left
 	bcf		T0CON,TMR0ON				; Stop Timer 0