changeset 370:61742b3ef842 64kByte Logbook

Merged with dive interval
author JeanDo
date Fri, 10 Jun 2011 01:31:39 +0200
parents 584741726190 (diff) 93c0cb14b0d2 (current diff)
children d8e83ef49962
files code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/english_text.asm code_part1/OSTC_code_asm_part1/french_text.asm code_part1/OSTC_code_asm_part1/german_text.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/simulator.asm code_part1/OSTC_code_asm_part1/spanish_text.asm
diffstat 17 files changed, 430 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Fri Jun 10 01:31:39 2011 +0200
@@ -2,8 +2,12 @@
 BETA Version - Do NOT use for diving!
 BUGFIX: Ignore depths>130m in PC simulation
 BUGFIX: Avoid spurious CF55 stops with 3 gas or more
+BUGFIX: Average depth in Logbook (For dives made with >=1.91)
+CHANGE: CF02 now allows delay of more then 240seconds
+NEW: "Quit Sim" in divemode simulator menu for exiting the simulation
 NEW: Allow -2:00 to +2:00 adjustement per day (CF48).
 NEW: 1/10/100 steps in CF menu
+NEW: 64kByte Logbook (Doubled capacity compared to 1.90)
 
 New in 1.90 Stable:
 Stable release
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -36,7 +36,7 @@
 
 ;#DEFINE	__DEBUG	; 
 
-#DEFINE	logbook_profile_version	0x20        ; Do not touch!
+#DEFINE	logbook_profile_version	0x21        ; Do not touch!
 #DEFINE	T0CON_debounce	b'00000000'         ; Timer0 Switch Debounce
 
 #DEFINE		FT_SMALL		.0
@@ -270,7 +270,7 @@
 divisor_tank            res 1
 divisor_ppo2            res 1
 divisor_deco_debug      res 1
-divisor_nuy2            res 1
+divisor_cns	            res 1
 
 timeout_counter         res 1   ; Timeout counter variables
 timeout_counter2        res 1
@@ -333,6 +333,7 @@
 time_correction_value   res 1   ; Adds to Seconds on midnight
 gaslist_active          res 1	; Holds flags for active gases
 desaturation_time_buffer res 2	; buffer for desat time
+total_divetime_seconds	res 2	; counts dive seconds regardless of CF01 (18h max.)
 
 ;=============================================================================
 ; C-code Routines
@@ -426,7 +427,7 @@
 #DEFINE	second_FD			flag4,7	; 2nd 0xFD in EEPROM found
 #DEFINE	second_FA			flag4,7	; 2nd 0xFA in EEPROM found
 
-#DEfINE	eeprom_overflow		flag5,0	; EEPROM overflowed (>32KB)
+;#DEfINE	unused flag5,0	; unused
 #DEFINE	eeprom_blockwrite	flag5,1	; EEPROM blockwrite active
 #DEFINE Flag_4      		flag5,2	; unused
 #DEFINE	low_battery_state	flag5,3	;=1 if battery low
--- a/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -589,7 +589,7 @@
 
 ; shift address for header
 ; the header will be stored after the dive
-	incf_eeprom_address	d'47'				; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
+	incf_eeprom_address	d'57'				; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000
 
 store_dive_data2:
     SAFE_2BYTE_COPY rel_pressure, lo
@@ -627,9 +627,9 @@
 	movlw	d'9'				; Information length	
 	addwf	ProfileFlagByte,F	; add to ProfileFlagByte
 check_extended5:
-	decfsz	divisor_nuy2,W		; Check divisor
+	decfsz	divisor_cns,W		; Check divisor
 	bra		check_extended6		
-	movlw	d'0'				; Information length	
+	movlw	d'1'				; Information length	
 	addwf	ProfileFlagByte,F	; add to ProfileFlagByte
 check_extended6:
 
@@ -718,9 +718,9 @@
 	bra		store_extended5	
 	rcall	store_dive_decodebug
 store_extended5:
-	decfsz	divisor_nuy2,F		; Check divisor
+	decfsz	divisor_cns,F		; Check divisor
 	bra		store_extended6	
-	rcall	store_dive_nuy2
+	rcall	store_dive_cns
 store_extended6:
 
 ; The next block is required to take care of "store never"
@@ -734,8 +734,8 @@
 	clrf	divisor_ppo2			; And clear register again, so it will never reach zero...
 	btfsc	divisor_deco_debug,7	; Test highest Bit (Register must have been zero before the "decfsz" command!)
 	clrf	divisor_deco_debug		; And clear register again, so it will never reach zero...
-	btfsc	divisor_nuy2,7			; Test highest Bit (Register must have been zero before the "decfsz" command!)
-	clrf	divisor_nuy2			; And clear register again, so it will never reach zero...
+	btfsc	divisor_cns,7			; Test highest Bit (Register must have been zero before the "decfsz" command!)
+	clrf	divisor_cns				; And clear register again, so it will never reach zero...
 
 	ostc_debug	'D'		; Sends debug-information to screen if debugmode active
 
@@ -750,9 +750,11 @@
 	bcf		event_occured		; Clear the global event flag
 	return						; Done. (Sample with all informations written to EEPROM)
 	
-store_dive_nuy2:
+store_dive_cns:
+	movff	char_O_CNS_fraction,WREG
+	call	write_external_eeprom		; Store in EEPROM
 	GETCUSTOM8	d'26'
-	movwf	divisor_nuy2			; Reload divisor from CF
+	movwf	divisor_cns			; Reload divisor from CF
 	return
 
 store_dive_decodebug:
@@ -1319,10 +1321,10 @@
 	addwf	temp1,W		; copy to bits 0-3, result in WREG
 	call	write_external_eeprom
 
-	movlw	d'0'		; information size nuy2
+	movlw	d'1'		; information size cns
 	movwf	temp1		; copy to bits 0-3
 	swapf	temp1,F		; swap nibbels 0-3 with 4-7
-	GETCUSTOM8	d'26'	; Divisor nuy2
+	GETCUSTOM8	d'26'	; Divisor cns
 	addwf	temp1,W		; copy to bits 0-3, result in WREG
 	call	write_external_eeprom
 
@@ -1333,7 +1335,28 @@
 	movff	char_O_CNS_fraction,WREG	; copy into bank1
 	call	write_external_eeprom		; Stores CNS%
 
-; Add additional 10bytes here.... mH
+	movff	avr_rel_pressure_total+0,WREG	; Average Depth
+	call	write_external_eeprom
+	movff	avr_rel_pressure_total+1,WREG	; Average Depth
+	call	write_external_eeprom
+
+	movff	total_divetime_seconds+0,WREG	; Total dive time (Regardless of CF01)
+	call	write_external_eeprom
+	movff	total_divetime_seconds+1,WREG	; Total dive time (Regardless of CF01)
+	call	write_external_eeprom
+
+	clrf	WREG
+	call	write_external_eeprom			; Spare6
+	clrf	WREG
+	call	write_external_eeprom			; Spare5
+	clrf	WREG
+	call	write_external_eeprom			; Spare4
+	clrf	WREG
+	call	write_external_eeprom			; Spare3
+	clrf	WREG
+	call	write_external_eeprom			; Spare2
+	clrf	WREG
+	call	write_external_eeprom			; Spare1
 
 	movlw	0xFB						; Header stop
 	call	write_external_eeprom
@@ -1404,13 +1427,16 @@
 	
 	bcf		divemode
 	incf	timeout_counter,F
-	GETCUSTOM8	d'2'					; diveloop_timeout
-	addlw	d'2'						; adds two seconds in case timout=zero!
-	btfsc	STATUS,C					; > 255?
-	movlw	d'255'						; Set to 255...
-	decf	WREG,F						; Limit to 254
-	cpfsgt	timeout_counter
-	bsf		divemode
+	movlw	d'0'
+	addwfc	timeout_counter2,F			; timeout is 15bits
+	GETCUSTOM15	d'2'					; diveloop_timeout
+	movff	lo,sub_a+0
+	movff	hi,sub_a+1
+	movff	timeout_counter, sub_b+0
+	movff	timeout_counter2, sub_b+1
+	call	sub16						;  sub_c = sub_a - sub_b
+	btfss	neg_flag					; Result negative?
+	bsf		divemode					; No, set flag
 	return
 
 timeout_divemode2:
@@ -1695,13 +1721,15 @@
 	clrf	apnoe_secs
 	clrf	divemins+0
 	clrf	divemins+1
+	clrf 	total_divetime_seconds+0
+	clrf 	total_divetime_seconds+1
 	clrf	menupos3
 	bcf		menu3_active
 	clrf	divesecs
 	clrf	samplesecs
 	clrf	apnoe_timeout_counter		; timeout in minutes
-	clrf 	timeout_counter				; takes care of the timeout
-	clrf 	timeout_counter2			; Here: counts to six, then store deco data and temperature
+	clrf 	timeout_counter				; takes care of the timeout (Low byte)
+	clrf 	timeout_counter2			; takes care of the timeout (High byte)
 	clrf	AlarmType					; Clear all alarms
 	bcf		event_occured				; clear flag
 	bcf		setpoint_changed			; clear flag
@@ -1750,7 +1778,7 @@
 	GETCUSTOM8	d'25'
 	movwf	divisor_deco_debug
 	GETCUSTOM8	d'26'
-	movwf	divisor_nuy2
+	movwf	divisor_cns
 
 	btfss	FLAG_apnoe_mode		; In Apnoe mode?
 	bra		divemode1
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -131,6 +131,8 @@
 	movlw	d'7'						; Number of entries for this menu+1 = 7
 	btfsc	display_set_xgas			; Are we in the Gas6 menu?
 	movlw	d'7'						; Number of entries for this menu+1 = 7
+	btfsc	display_set_simulator		; Are we in the simulator menu?
+	movlw	d'7'						; Number of entries for this menu+1 = 7
 	cpfseq	menupos						; =limit?
 	bra		test_switches_divemode_menu1; No!
 	movlw	d'1'						; Yes, reset to position 1!
@@ -348,6 +350,8 @@
 	bra		divemode_menu_simulator_p10	; Adjust +10m
 	dcfsnz	menupos,F
 	bra		divemode_menu_simulator_m10	; Adjust -10m
+	dcfsnz	menupos,F
+	bra		divemode_menu_simulator_quit; Adjust to zero m
 	bra		timeout_divemenu2			; quit underwater menu!
 
 divemode_menu_simulator_common:
@@ -366,7 +370,6 @@
 	movlw	HIGH	d'14000'
 	movwf	sim_pressure+1
 	return
-
 divemode_menu_simulator_common2:
 	movlw	LOW		d'1000'             ; Compare to 1bar == 0m == 1000 mbar.
 	subwf   sim_pressure+0,W
@@ -401,6 +404,13 @@
 	movwf	menupos						; reset cursor
 	bra		divemode_menu_simulator_common
 
+divemode_menu_simulator_quit:
+	movlw	LOW		d'1000'
+	movwf	sim_pressure+0
+	movlw	HIGH	d'1000'
+	movwf	sim_pressure+1
+	bra		timeout_divemenu2			; quit menu
+
 divemode_menu_simulator_p1:
 	movlw	d'100'
 	addwf	sim_pressure+0,F
--- a/code_part1/OSTC_code_asm_part1/english_text.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/english_text.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -96,7 +96,7 @@
 ; 32 custom function descriptors I (FIXED LENGTH = 15 chars).
     TCODE    .40,  .35,      "Start Dive  [m]"           ;036 Start Dive  [m]	(depth to switch to dive mode)
     TCODE    .40,  .35,      "End Dive    [m]"           ;037 End Dive    [m]	(depth to switch back to surface mode)
-    TCODE    .40,  .35,      "End Delay [min]"           ;038 End Delay [min]  	(duration dive screen stays after end of dive)
+    TCODE    .40,  .35,      "End Delay [sec]"           ;038 End Delay [sec]  	(duration dive screen stays after end of dive)
     TCODE    .40,  .35,      "Power Off [min]"           ;039 Power Off [min]
     TCODE    .40,  .35,      "Pre-menu  [min]"           ;040 Pre-menu  [min]	(Delais to keep surface-mode menus displayed)
     TCODE    .40,  .35,      "velocity[m/min]"           ;041 velocity[m/min]
@@ -120,7 +120,7 @@
     TCODE    .40,  .35,      "Divisor NotUse1"           ;059 Divisor NotUse1
     TCODE    .40,  .35,      "Divisor ppO2   "           ;060 Divisor ppO2 
     TCODE    .40,  .35,      "Divisor Debug  "           ;061 Divisor Debug  
-    TCODE    .40,  .35,      "Divisor NotUse2"           ;062 Divisor NotUse2
+    TCODE    .40,  .35,      "Divisor CNS    "           ;062 Divisor CNS
     TCODE    .40,  .35,      "CNSshow dive[%]"           ;063 CNSshow dive[%]
     TCODE    .40,  .35,      "Logbook offset "           ;064 Logbook offset 
     TCODE    .40,  .35,      "Last Deco at[m]"           ;065 Last Deco at[m]
@@ -391,7 +391,9 @@
 	TCODE	 .50,	.130,	 "Aborted!"					 ;304 Aborted
 ;@5 variant
     TCODE    .0,    .0,      "Future TTS"                ;305 Future TTS            (=10 chars. Title for @5 customview).
+;
+    TCODE    .100,  .125,    "Quit Sim"                  ;306 Quit Sim (=8char max. Quit Simulator mode)
 ;Dive interval
-    TCODE    .20,   .35,     "Interval:"                 ;306 Interval:
-    TCODE    .0,    .0,      "Now"                       ;307 Now
+    TCODE    .20,   .35,     "Interval:"                 ;307 Interval:
+    TCODE    .0,    .0,      "Now"                       ;308 Now
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/french_text.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/french_text.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -97,7 +97,7 @@
 ; 32 custom function descriptors I (FIXED LENGTH = 15 chars).
     TCODE    .40,  .35,      "Début Plong.[m]"           ;036 Start Dive  [m]	(depth to switch to dive mode)
     TCODE    .40,  .35,      "Fin Plongée [m]"           ;037 End Dive    [m]	(depth to switch back to surface mode)
-    TCODE    .40,  .35,      "Délai Fin [min]"           ;038 End Delay [min]  	(duration dive screen stays after end of dive)
+    TCODE    .40,  .35,      "Délai Fin [sec]"           ;038 End Delay [sec]  	(duration dive screen stays after end of dive)
     TCODE    .40,  .35,      "Eteindre  [min]"           ;039 Power Off [min]
     TCODE    .40,  .35,      "Pré-menu  [min]"           ;040 Pre-menu  [min]	(Delais to keep surface-mode menus displayed)
     TCODE    .40,  .35,      "Vitesse [m/min]"           ;041 velocity[m/min]
@@ -121,7 +121,7 @@
     TCODE    .40,  .35,      "Diviseur NotUse"           ;059 Divisor NotUse1
     TCODE    .40,  .35,      "Diviseur ppO2  "           ;060 Divisor ppO2 
     TCODE    .40,  .35,      "Diviseur Debug "           ;061 Divisor Debug  
-    TCODE    .40,  .35,      "Diviseur NotUse"           ;062 Divisor NotUse2
+    TCODE    .40,  .35,      "Diviseur CNS   "           ;062 Divisor CNS
     TCODE    .40,  .35,      "Aff.CNSPlong[%]"           ;063 CNSshow dive[%]
     TCODE    .40,  .35,      "Décalage Carnet"           ;064 Logbook offset 
     TCODE    .40,  .35,      "Dern. Palier[m]"           ;065 Last Deco at[m]
@@ -392,7 +392,9 @@
 	TCODE	 .50,	.130,	 "Aborted!"					 ;304 Aborted
 ;@5 variant
     TCODE    .0,    .0,      "DTR Réchap"                ;305 Future TTS            (=10 chars. Title for @5 customview).
+;
+    TCODE    .100,  .125,    "Quit Sim"                  ;306 Quit Sim 				(=8char max. Quit Simulator mode)
 ;Dive interval
-    TCODE    .20,   .35,     "Intervalle: "               ;306 Interval:
-    TCODE    .0,    .0,      "Maintenant"                 ;307 Dive now
+    TCODE    .20,   .35,     "Intervalle: "              ;307 Interval:
+    TCODE    .0,    .0,      "Maintenant"                ;308 Dive now
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/german_text.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/german_text.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -97,7 +97,7 @@
 ; 32 custom function descriptors I (FIXED LENGTH = 15 chars).
     TCODE    .40,  .35,      "TG Start    [m]"           ;036 Start Dive  [m]	(depth to switch to dive mode)
     TCODE    .40,  .35,      "TG Ende     [m]"           ;037 End Dive    [m]	(depth to switch back to surface mode)
-    TCODE    .40,  .35,      "TGNachlauf[min]"           ;038 End Delay [min]  	(duration dive screen stays after end of dive)
+    TCODE    .40,  .35,      "TGNachlauf[sek]"           ;038 End Delay [sec]  	(duration dive screen stays after end of dive)
     TCODE    .40,  .35,      "Standby   [min]"           ;039 Power Off [min]
     TCODE    .40,  .35,      "Pre-Menü  [min]"           ;040 Pre-menu  [min]	(Delais to keep surface-mode menus displayed)
     TCODE    .40,  .35,      "Geschw. [m/min]"           ;041 velocity[m/min]
@@ -121,7 +121,7 @@
     TCODE    .40,  .35,      "Divisor frei1  "           ;059 Divisor NotUse1
     TCODE    .40,  .35,      "Divisor ppO2   "           ;060 Divisor ppO2 
     TCODE    .40,  .35,      "Divisor Debug  "           ;061 Divisor Debug  
-    TCODE    .40,  .35,      "Divisor frei2  "           ;062 Divisor NotUse2
+    TCODE    .40,  .35,      "Divisor CNS    "           ;062 Divisor CNS
     TCODE    .40,  .35,      "CNS-Anz. TG [%]"           ;063 CNSshow dive[%]
     TCODE    .40,  .35,      "Logbuch Versatz"           ;064 Logbook offset 
     TCODE    .40,  .35,      "Letzte Deko [m]"           ;065 Last Deco at[m]
@@ -392,7 +392,9 @@
 	TCODE	 .40,	.130,	 "Abgebrochen!"				 ;304 Aborted
 ;@5 variant
     TCODE    .0,    .0,      "TTS @+Min."                ;305 Future TTS            (=10 chars. Title for @5 customview).
+;
+    TCODE    .100,  .125,    "Ende Sim"                  ;306 Quit Sim (=8char max. Quit Simulator mode)
 ;Dive interval
-    TCODE    .20,   .35,     "Interval:"                 ;306 Interval:
-    TCODE    .0,    .0,      "Now"                       ;307 Now
+    TCODE    .20,   .35,     "Interval:"                 ;307 Interval:
+    TCODE    .0,    .0,      "Now"                       ;308 Now
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/i2c_eeprom.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -18,8 +18,8 @@
 ; known bugs:
 ; ToDo: use 2nd 32KB from external EEPROM for something
 
-incf_eeprom_address	macro	ext_ee_temp1	; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes
-    	movlw	ext_ee_temp1                ; care of bank switching at 0x8000
+incf_eeprom_address	macro	ext_ee_temp1	; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1"
+    	movlw	ext_ee_temp1                
     	call 	incf_eeprom_address0
 	endm
 
@@ -27,18 +27,18 @@
     	addwf		eeprom_address+0,F      ; increase address
     	movlw		d'0'
     	addwfc		eeprom_address+1,F
+		return
+;    	btfss		eeprom_address+1,7		; at address 8000?
+;    	return                              ; No, continue
+;    
+;    	; Yes, clear eeprom_address:2
+;    	clrf		eeprom_address+0		; Clear eeprom address
+;    	clrf		eeprom_address+1
+;    	return								; Done.
+;
+;=============================================================================
+; Will decrease eeprom_address:2 with the 8Bit value "ext_ee_temp1"
 
-    	btfss		eeprom_address+1,7		; at address 8000?
-    	return                              ; No, continue
-    
-    	; Yes, clear eeprom_address:2
-    	clrf		eeprom_address+0		; Clear eeprom address
-    	clrf		eeprom_address+1
-    	return								; Done.
-
-;=============================================================================
-; Will decrease eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes
-; care of bank switching at 0x8000
 
 decf_eeprom_address	macro	ext_ee_temp1
         movlw	ext_ee_temp1
@@ -49,13 +49,14 @@
         subwf		eeprom_address+0,F      ; decrease address: do a 16-8bits substract.
         movlw		d'0'
         subwfb		eeprom_address+1,F
-
-        btfss		eeprom_address+1,7		; at address 8000?
-        return                              ; No, done.
-
-        movlw		b'01111111'             ; yes, reset highbyte
-        movwf		eeprom_address+1
-    	return								; Done.
+		return
+;
+;        btfss		eeprom_address+1,7		; at address 8000?
+;        return                              ; No, done.
+;
+;        movlw		b'01111111'             ; yes, reset highbyte
+;        movwf		eeprom_address+1
+;    	return								; Done.
 
 ;=============================================================================
 
@@ -72,15 +73,14 @@
 	addwf		eeprom_address+0,F
 	movlw		d'0'
 	addwfc		eeprom_address+1,F
-	bcf			eeprom_overflow		
-	btfss		eeprom_address+1,7		; at address 8000?
-	return								; no, return
-
-	clrf		eeprom_address+0		; Clear eeprom address
-	clrf		eeprom_address+1
-	bsf			eeprom_overflow			; and set overflow bit
 	return
-
+;	btfss		eeprom_address+1,7		; at address 8000?
+;	return								; no, return
+;
+;	clrf		eeprom_address+0		; Clear eeprom address
+;	clrf		eeprom_address+1
+;	return
+;
 write_external_eeprom_block:			; Writes a block of 64Byte (one page in external EEPROM without stop condition
 #ifdef TESTING
 	; When Simulating with MPLabSIM, there is no way to emulate external EEPROM...
@@ -96,20 +96,21 @@
 	movlw		d'0'				; increase address
 	incf		eeprom_address+0,F	
 	addwfc		eeprom_address+1,F
-	bcf			eeprom_overflow		
-	
-	btfss		eeprom_address+1,7	; at address 8000
-	return						; no, return
-	
-	clrf		eeprom_address+0		; Clear eeprom address
-	clrf		eeprom_address+1
-	bsf			eeprom_overflow		; and set overflow bit
 	return
+
+;	btfss		eeprom_address+1,7	; at address 8000
+;	return						; no, return
+;	
+;	clrf		eeprom_address+0		; Clear eeprom address
+;	clrf		eeprom_address+1
+;	return
 I2CWRITE_BLOCK:
 	movwf		ext_ee_temp1				; Data byte in WREG
 	bsf			SSPCON2,SEN			; Start condition
 	rcall		WaitMSSP
-	movlw		b'10100110'			; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7		; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
 	movwf		SSPBUF				; control byte
 	rcall		WaitMSSP	
 	rcall		I2C_WaitforACK
@@ -145,7 +146,9 @@
 	rcall		WaitMSSP	
 	bsf			SSPCON2,SEN			; Start condition
 	rcall		WaitMSSP
-	movlw		b'10100110'			; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		ext_ee_temp2,7		; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
 	movwf		SSPBUF				; control byte
 	rcall		WaitMSSP	
 	btfsc		SSPCON2,ACKSTAT
@@ -160,8 +163,10 @@
 	
 	bsf			SSPCON2,RSEN		; Start condition
 	rcall		WaitMSSP
-	movlw		b'10100111'			; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF			; control byte
+	movlw		b'10101111'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		ext_ee_temp2,7		; Access Block2?
+	movlw		b'10100111'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+	movwf		SSPBUF				; control byte
 	rcall		WaitMSSP	
 	rcall		I2C_WaitforACK
 
@@ -200,10 +205,16 @@
 	addwf		ext_ee_temp1,F
 	movlw		d'0'
 	addwfc		ext_ee_temp2,F
-	
-	btfsc		ext_ee_temp2,7			; 0x8000 reached?
+
+	movlw		0xFF	
+	cpfseq		ext_ee_temp2			; =0xFFFF
+	bra			get_free_EEPROM_location2d	; No
+	cpfseq		ext_ee_temp1			; =0xFFFF
+	bra			get_free_EEPROM_location2d	; No
+
 	bra			get_free_EEPROM_location3b	; yes
-	
+
+get_free_EEPROM_location2d:
 	bsf			SSPCON2, ACKEN		; no, send Ack
 	rcall		WaitMSSP				
 	bra			get_free_EEPROM_location2	; and continue search
@@ -232,15 +243,14 @@
 	addwf		eeprom_address+0,F
 	movlw		d'0'
 	addwfc		eeprom_address+1,F
-	bcf			eeprom_overflow		
-	btfss		eeprom_address+1,7	; at 0x8000?
-	return		; no, return
-	
-	clrf		eeprom_address+0	; Yes, clear address
-	clrf		eeprom_address+1
-	bsf			eeprom_overflow		; and set overflow bit
 	return
-
+;	btfss		eeprom_address+1,7	; at 0x8000?
+;	return		; no, return
+;	
+;	clrf		eeprom_address+0	; Yes, clear address
+;	clrf		eeprom_address+1
+;	return
+;
 I2CREAD3:						; block read start with automatic address increase 
 	rcall		I2CREAD_COMMON
 	; no Stop condition here
@@ -261,8 +271,11 @@
 	rcall		WaitMSSP	
 	bsf			SSPCON2,SEN		; Start condition
 	rcall		WaitMSSP
-	movlw		b'10100110'		; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF			; control byte
+
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+	movwf		SSPBUF				; control byte
 	rcall		WaitMSSP	
 	btfsc		SSPCON2,ACKSTAT
 	bra			I2CREAD			; EEPROM NOT acknowledged, retry!	
@@ -275,8 +288,11 @@
 	
 	bsf			SSPCON2,RSEN	; Start condition
 	rcall		WaitMSSP
-	movlw		b'10100111'		; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF			; control byte
+
+	movlw		b'10101111'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100111'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+	movwf		SSPBUF				; control byte
 	rcall		WaitMSSP	
 	rcall		I2C_WaitforACK
 	
@@ -290,8 +306,10 @@
 	movwf		ext_ee_temp1				; Data byte
 	bsf			SSPCON2,SEN			; Start condition
 	rcall		WaitMSSP
-	movlw		b'10100110'			; Bit0=0: WRITE, Bit0=1: READ
-	movwf		SSPBUF			; control byte
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+	movwf		SSPBUF				; control byte
 	rcall		WaitMSSP	
 	rcall		I2C_WaitforACK
 	movff		eeprom_address+1,SSPBUF	; High Address byte
--- a/code_part1/OSTC_code_asm_part1/interface.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/interface.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -167,14 +167,16 @@
 
 	DISPLAYTEXT .18						; "Header"
 
-	clrf		uart1_temp					; low address counter
-	clrf		uart2_temp					; high address counter
+	setf		uart1_temp					; low address counter
+	setf		uart2_temp					; high address counter
 
 menu_interface3:
 	bsf		SSPCON2,SEN					; Start condition
 	call		WaitMSSP
 
-	movlw		b'10100110'					; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101110'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100110'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
 	movwf		SSPBUF					; control byte
 	call		WaitMSSP	
 	btfsc		SSPCON2,ACKSTAT
@@ -189,7 +191,10 @@
 	bsf		SSPCON2,RSEN				; Start condition
 	call		WaitMSSP
 
-	movlw		b'10100111'					; Bit0=0: WRITE, Bit0=1: READ
+	movlw		b'10101111'			; Bit0=0: WRITE, Bit0=1: READ, BLOCK2
+	btfss		eeprom_address+1,7	; Access Block2?
+	movlw		b'10100111'			; No, -> Bit0=0: WRITE, Bit0=1: READ, BLOCK1
+
 	movwf		SSPBUF					; control byte
 	call		WaitMSSP	
 	call		I2C_WaitforACK
@@ -199,27 +204,21 @@
 menu_interface2:
 	call		rs232_wait_tx				; wait for UART
 
-	bsf			SSPCON2, RCEN				; Enable recieve mode
-	call		WaitMSSP	
-
-	movff		SSPBUF, TXREG
-
 	movlw		d'1'
 	addwf		uart1_temp,F
 	movlw		d'0'
 	addwfc		uart2_temp,F
 
-	btfsc		uart2_temp,7				; 32KB done?
-	bra			menu_interface4				; Yes
-	
-	bsf			SSPCON2, ACKEN				; Ack
-	call		WaitMSSP	
-	bra			menu_interface2				; go on
+; Slow but safe...
+	call		I2CREAD2					; same as I2CREAD but with automatic address increase 
+	movff		SSPBUF, TXREG
 
-menu_interface4:
-	bsf			SSPCON2, PEN				; Stop
-	call		WaitMSSP	
-	
+	movlw		0xFF
+	cpfseq		uart2_temp					;=0xFFFF?
+	bra			menu_interface2				; No, continue
+	cpfseq		uart1_temp					;=0xFFFF?
+	bra			menu_interface2				; No, continue
+
 	DISPLAYTEXT	.20						; Done.
 
 	WAITMS	d'250'
--- a/code_part1/OSTC_code_asm_part1/isr.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/isr.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -343,12 +343,17 @@
 ; Increase re-setable average depth divetime counter
 		incf		average_divesecs+0,F	; increase stopwatch registers	
 		btfsc		STATUS,Z
-		incf		average_divesecs+1,F	; increase stopwatch registers	
-
+		incf		average_divesecs+1,F	; increase stopwatch registers
+; Increase total divetime (Regardless of CF01)
+		incf		total_divetime_seconds+0,F	; increase stopwatch registers	
+		btfsc		STATUS,Z
+		incf		total_divetime_seconds+1,F	; increase stopwatch registers
+	
 		btfss		divemode2				; displayed divetime is running?
 		bra			RTCisr2					; No (e.g. too shallow)
 
-		incf		divesecs,F				; increase divetime registers
+; increase divetime registers (Displayed dive time)
+		incf		divesecs,F				
 		movlw		d'59'
 		cpfsgt		divesecs
 		bra			RTCisr1a
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -71,14 +71,27 @@
 
     ;---- fast loop: check every other byte ----------------------------------
 menu_logbook2:
-    infsnz      divemins+0,F            ; increase 16Bit value
-	incf        divemins+1,F
-    infsnz      divemins+0,F            ; increase 16Bit value, twice
-	incf        divemins+1,F
+	movlw		d'2'
+	addwf		divemins+0,F
+	movlw		d'0'
+	addwfc		divemins+1,F			; increase 16Bit value, twice
 
-	btfsc		divemins+1,7            ; At 0x8000?
+	movlw		0xFF
+	cpfseq		divemins+1				; =0xFFFF ?
+	bra			menu_logbook2a			; No
+	cpfseq		divemins+0				; =0xFFFF ?
+	bra			menu_logbook2a			; No
 	bra			menu_logbook_reset      ; yes, restart (if not empty)
 
+menu_logbook2a:
+	movlw		0x00
+	cpfseq		divemins+1				; =0x0000 ?
+	bra			menu_logbook2b			; No
+	cpfseq		divemins+0				; =0x0000 ?
+	bra			menu_logbook2b			; No
+	bra			menu_logbook_reset      ; yes, restart (if not empty)
+
+menu_logbook2b:
 	decf_eeprom_address	d'2'			; -2 to eeprom address.
 
 	call		I2CREAD					; reads one byte (Slow! Better use Blockread!)
@@ -124,6 +137,7 @@
 	bra			menu_logbook3b				; No, Nothing to do
 
 	bsf			all_dives_shown				; Yes
+	bsf			logbook_page_not_empty
 	bra			menu_logbook_display_loop2	; rcall of get_free_eeprom_location not required here (faster)
 
 
@@ -313,6 +327,7 @@
 	call		PLED_convert_date			; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
 
 	PUTC		' '
+	PUTC		0x94						; "End of dive" icon
 	call		I2CREAD2					; hour
 	movff		SSPBUF,lo
 	output_99x			
@@ -371,15 +386,34 @@
 	call		mult16x16				; result is in xC:2 !
 
 	bsf			leftbind
+	PUTC		0x95					; "duration o dive" icon
 	output_16							; divetime minutes
 
+	btfss	logbook_format_0x21			; Dive made with new 0x21 format?
+	bra		display_profile_old_spacing	; No
+; Yes, get real sample time
+	incf_eeprom_address	d'35'			; Skip Bytes in EEPROM
+	call		I2CREAD2				; Total sample time in seconds
+	movff		SSPBUF,xA+0
+	call		I2CREAD2				; Total sample time in seconds
+	movff		SSPBUF,xA+1
+	movlw		LOW		d'600'
+	movwf		xB+0
+	movlw		HIGH	d'600'
+	movwf		xB+1					; A vertical line every 600 seconds
+	call		div16x16				; xA/xB=xC with xA as remainder
+	decf_eeprom_address	d'37'			; Macro, that subtracts 8Bit from eeprom_address:2
+	bra			display_profile_spacing	; continue below
+
+display_profile_old_spacing:
 ; Compute spacing between 10min lines
 	movff		lo,xA+0
 	movff		hi,xA+1					; divetime in minutes
 	movlw		d'10'
 	movwf		xB+0
 	clrf		xB+1					; A vertical line every 10 minutes
-	call		div16x16				;xA/xB=xC with xA as remainder
+	call		div16x16				; xA/xB=xC with xA as remainder
+display_profile_spacing:
 	; xC now holds number of lines
 	movlw		d'1'
 	addwf		xC+0					; Add one line...
@@ -394,20 +428,36 @@
 	movff		xC+1,avr_rel_pressure+1					; spacing between 10min lines (1-159)
 
 ; Restore divetime in minutes:
+	btfss	logbook_format_0x21			; Dive made with new 0x21 format?
+	bra		display_profile_old_xscale	; No
+; Yes, get real sample time
+	incf_eeprom_address	d'35'			; Skip Bytes in EEPROM
+	call		I2CREAD2				; Total sample time in seconds
+	movff		SSPBUF,xC+0
+	call		I2CREAD2				; Total sample time in seconds
+	movff		SSPBUF,xC+1
+	decf_eeprom_address	d'37'			; Macro, that subtracts 8Bit from eeprom_address:2
+	PUTC		':'
+	call		I2CREAD2				; read divetime seconds
+	movff		SSPBUF,lo
+	bra			display_profile_xscale		; continue below
+
+display_profile_old_xscale:
 	movff		lo,xA+0					; calculate x-scale for profile display
 	movff		hi,xA+1					; calculate total diveseconds first
 	movlw		d'60'					; 60seconds are one minute...
 	movwf		xB+0
 	clrf		xB+1
 	call		mult16x16				; result is in xC:2 !
-
-	PUTC		d'39'					;"'"
+	PUTC		':'
 	call		I2CREAD2				; read divetime seconds
 	movff		SSPBUF,lo
 	movf		lo,W					; add seconds to total seconds
 	addwf		xC+0
 	movlw		d'0'
 	addwfc		xC+1					; xC:2 now holds total dive seconds!
+
+display_profile_xscale:
 	movff		xC+0,xA+0				; now calculate x-scale value
 	movff		xC+1,xA+1
 	movlw		d'154'					; 154pix width available
@@ -429,7 +479,7 @@
 
 	bsf			leftbind
 	output_99x							; divetime seconds
-	STRCAT      "\" "
+	PUTC		' '
 	call		I2CREAD2	
 	movff		SSPBUF,lo
 	call		I2CREAD2	
@@ -449,9 +499,6 @@
 	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 "
@@ -504,20 +551,16 @@
 	call		I2CREAD2					; Read divisor
 	movff		SSPBUF,divisor_deco_debug	; Store divisor
 	call		I2CREAD2					; Read divisor
-	movff		SSPBUF,divisor_nuy2			; Store divisor
+	movff		SSPBUF,divisor_cns			; Store divisor
 	incf_eeprom_address	d'2'				; Skip 2Bytes in EEPROM (faster)
 	; 2 bytes salinity, GF
+	btfss	logbook_format_0x21				; 10byte extra?
+	bra		display_profile2d				; No
+	incf_eeprom_address	d'10'				; Skip another 10 byte from the header for 0x21 format
+	; Average Depth, spare bytes
 
 display_profile2d:
 	; Start Profile display
-
-;	clrf		average_divesecs+0
-;	clrf		average_divesecs+1			; Counts x-pixels for average
-;	clrf		average_depth_hold_total+0
-;	clrf		average_depth_hold_total+1
-;	clrf		average_depth_hold_total+2
-;	clrf		average_depth_hold_total+3	; Track average depth here...
-;
 ; Write 0m X-Line..
 	movlw		color_grey	
 	call		PLED_set_color				; Make this configurable?
@@ -962,18 +1005,6 @@
 	return
 
 profile_view_get_depth_new1:
-;	incf		average_divesecs+0,F			
-;	movlw		d'0'
-;	addwfc		average_divesecs+1,F			; counter for average depth
-;	; add depth to average registers
-;	movf		lo,W
-;	addwf		average_depth_hold_total+0,F
-;	movf		hi,W
-;	addwfc		average_depth_hold_total+1,F
-;	movlw		d'0'
-;	addwfc		average_depth_hold_total+2,F
-;	addwfc		average_depth_hold_total+3,F 	; Will work up to 9999mBar*60*60*24=863913600mBar
-;
 	btfsc		event_occured				; Was there an event attached to this sample?
 	rcall		profile_view_get_depth_new2	; Yes, get information about this event
 
@@ -1018,7 +1049,6 @@
 	call		PLED_set_color				; Set Color...
 	return		;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...)
 
-
 ;Keep comments for future temperature graph
 ;	call		I2CREAD2					; ignore byte
 ;	decfsz		timeout_counter2,F			; reduce counter
@@ -1128,6 +1158,11 @@
 	cpfsgt		lo							; Skip if lo>13
 	bra			display_listdive2			; use old (Pre 0x20) format
 
+	bsf			logbook_format_0x21		; Set flag for new 0x21 Format
+	movlw		0x21
+	cpfseq		lo						; Skip if 0x21
+	bcf			logbook_format_0x21		; Clear flag for new 0x21 Format
+
 	call		I2CREAD4					; Skip Profile version (Block read)
 	movff		SSPBUF,lo					; in new format, read month
 
@@ -1161,4 +1196,142 @@
 	output_16								; Divetime minutes
 	STRCAT_PRINT "'"                    	; Display header-row in list
 	incf_eeprom_address	d'37'				; 12 Bytes read from header, skip 37 Bytes in EEPROM (Remaining Header)
+	btfss	logbook_format_0x21				; 10byte extra?
+	return									; No, Done.
+	incf_eeprom_address	d'10'				; Skip another 10 byte from the header for 0x21 format
 	return
+
+logbook_convert_64k:
+	call	PLED_boot
+	call	PLED_ClearScreen		; Clear screen
+	movlw	color_red
+    call	PLED_set_color			; Set to Red
+	DISPLAYTEXTH	d'303'			; Please wait!
+	movlw	LOW		0x100
+	movwf	EEADR
+	movlw	HIGH 	0x100
+	movwf	EEADRH
+	movlw	0xAA
+	movwf	EEDATA		
+	call	write_eeprom			; write 0xAA to indicate the logbook is already converted
+return
+; convert logbook:
+; Step 1: Copy 32k from 0xFE + 1 with bank switching to bank1
+; Step 2: Copy 32k from bank1 to bank0
+; Step 3: delete bank1
+	call	get_free_EEPROM_location		; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE
+	rcall	incf_eeprom_bank0	; eeprom_address:2 now at 0xFE+1
+; Do Step 1:
+	;logbook_temp5 and logbook_temp6 hold address in bank1
+	;logbook_temp1 and logbook_temp2 hold address in bank0
+	movlw	HIGH	0x8000
+	movwf	logbook_temp6 
+	movlw	LOW		0x8000
+	movwf	logbook_temp5			; load address for bank1
+	movff	eeprom_address+0,logbook_temp1 
+	movff	eeprom_address+1,logbook_temp2	; load address for bank0
+	movlw	0x80
+	movwf	uart2_temp
+logbook_convert2:
+	clrf	uart1_temp				; counter for copy operation
+logbook_convert3:
+	; read source
+	movff	logbook_temp1,eeprom_address+0
+	movff	logbook_temp2,eeprom_address+1
+	call	I2CREAD
+	movff	SSPBUF,lo				; hold read value
+	rcall	incf_eeprom_bank0		; eeprom_address:2 +1 with bank switching
+	movff	eeprom_address+0,logbook_temp1
+	movff	eeprom_address+1,logbook_temp2	; write source address
+	; write target
+	movff	logbook_temp5,eeprom_address+0
+	movff	logbook_temp6,eeprom_address+1
+	movf	lo,W
+	call	I2CWRITE				; writes WREG into EEPROM@eeprom_address
+	movlw	d'1'
+	addwf	logbook_temp5,F
+	movlw	d'0'
+	addwfc	logbook_temp6,F			; increase target address
+	decfsz	uart1_temp,F	
+	bra		logbook_convert3
+	btg		LED_blue
+	decfsz	uart2_temp,F			; 32kByte done?
+	bra		logbook_convert2		; No, continue
+; Step 1 done.
+	bcf		LED_blue
+; Do Step 2:
+	movlw	HIGH	0x0000
+	movwf	logbook_temp6 
+	movlw	LOW		0x0000
+	movwf	logbook_temp5			; load address for bank0
+	movlw	HIGH	0x8000
+	movwf	logbook_temp2 
+	movlw	LOW		0x8000
+	movwf	logbook_temp1			; load address for bank1
+	movlw	0x80
+	movwf	uart2_temp
+logbook_convert4:
+	clrf	uart1_temp				; counter for copy operation
+logbook_convert5:
+	; read source
+	movff	logbook_temp1,eeprom_address+0
+	movff	logbook_temp2,eeprom_address+1
+	call	I2CREAD
+	movff	SSPBUF,lo				; hold read value
+	incf_eeprom_address	d'1'	
+	movff	eeprom_address+0,logbook_temp1
+	movff	eeprom_address+1,logbook_temp2	; write source address
+	; write target
+	movff	logbook_temp5,eeprom_address+0
+	movff	logbook_temp6,eeprom_address+1
+	movf	lo,W
+	call	I2CWRITE				; writes WREG into EEPROM@eeprom_address
+	incf_eeprom_address	d'1'
+	movff	eeprom_address+0,logbook_temp5
+	movff	eeprom_address+1,logbook_temp6	; write target address
+	decfsz	uart1_temp,F	
+	bra		logbook_convert5
+	btg		LED_red
+	decfsz	uart2_temp,F			; 32kByte done?
+	bra		logbook_convert4		; No, continue
+; Step 2 done.
+	bcf		LED_red
+; Do Step 3:
+	movlw	HIGH	0x8000
+	movwf	logbook_temp2 
+	movlw	LOW		0x8000
+	movwf	logbook_temp1			; load address for bank1
+	movlw	0x80
+	movwf	uart2_temp
+logbook_convert6:
+	clrf	uart1_temp				; counter for copy operation
+logbook_convert7:
+	; write target
+	movff	logbook_temp1,eeprom_address+0
+	movff	logbook_temp2,eeprom_address+1
+	movlw	0xFF
+	call	I2CWRITE				; writes WREG into EEPROM@eeprom_address
+	incf_eeprom_address	d'1'
+	movff	eeprom_address+0,logbook_temp1
+	movff	eeprom_address+1,logbook_temp2	; write target address
+	decfsz	uart1_temp,F	
+	bra		logbook_convert7
+	btg		LED_red
+	btg		LED_blue
+	decfsz	uart2_temp,F			; 32kByte done?
+	bra		logbook_convert6		; No, continue
+; Step 3 done.
+	bcf		LED_red
+	bcf		LED_blue
+	return
+
+incf_eeprom_bank0:
+	movlw		d'1'					; increase address
+	addwf		eeprom_address+0,F
+	movlw		d'0'
+	addwfc		eeprom_address+1,F
+	btfss		eeprom_address+1,7		; at address 8000?
+	return								; no, skip
+	clrf		eeprom_address+0		; Clear eeprom address
+	clrf		eeprom_address+1
+	return
\ No newline at end of file
--- a/code_part1/OSTC_code_asm_part1/menu_reset.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -110,7 +110,7 @@
     ;                          DEFAULT   MIN     MAX
 	CF_DEFAULT    CF_CENTI,	    d'100', d'50',  d'250'  ; dive_threshold	        100cm
 	CF_DEFAULT    CF_CENTI,	    d'30',  d'10',  d'100'  ; surf_threshold        	30cm
-	CF_DEFAULT    CF_SEC,	    d'240', d'30',  d'240'  ; diveloop_timeout      	240s
+	CF_DEFAULT    CF_INT15,	    d'240', d'0',   d'600'  ; diveloop_timeout      	240s
 	CF_DEFAULT    CF_SEC,	    d'120', d'30',  d'240'  ; surfloop_timeout	        120s
 	CF_DEFAULT    CF_SEC,	    d'5',   d'1',   d'30'   ; premenu_timeout	        5s
 
@@ -462,7 +462,7 @@
 	clrf	eeprom_address+0
 	clrf	eeprom_address+1
 
-	movlw	d'2'
+	movlw	d'4'
 	movwf	temp3
 reset_eeprom02:
 	clrf	temp4
@@ -482,7 +482,7 @@
 	decfsz	temp4,F
 	bra		reset_eeprom01				; do this 256 times
 	decfsz	temp3,F
-	bra		reset_eeprom02				; and this all 2 times -> 512 *64Bytes = 32KB
+	bra		reset_eeprom02				; and this all 4 times -> 1024 *64Bytes = 64KB
 
 	bcf		eeprom_blockwrite			; clear blockwrite flag
 
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -521,12 +521,12 @@
     ;---- Updates interval line ----------------------------------------------
 	WIN_TOP    .35
 	lfsr	    FSR2,letter
-	OUTPUTTEXTH .306                    ; Interval:
+	OUTPUTTEXTH .307                    ; Interval:
 
 	movff	    char_I_dive_interval,lo
     movf        lo,W
     bnz         PLED_simulator_data_1
-    OUTPUTTEXTH .307                    ; Now
+    OUTPUTTEXTH .308                    ; Now
     clrf        POSTINC2                ; End buffer.
     bra         PLED_simulator_data_2
 
@@ -955,7 +955,7 @@
 	WIN_INVERT	.1	; Init new Wordprocessor	
 	DISPLAYTEXT	.248		; OSTC Simulator
 	WIN_INVERT	.0	; Init new Wordprocessor
-    DISPLAYTEXTH    .306                ; Interval:
+    DISPLAYTEXTH    .307                ; Interval:
 	DISPLAYTEXT	    .249                ; Start Dive
 	DISPLAYTEXTH	.277                ; Bottom Time:
 	DISPLAYTEXTH	.278                ; Max. Depth:
@@ -2367,6 +2367,7 @@
         DISPLAYTEXT	.251			; - 1m
         DISPLAYTEXT	.252			; +10m
         DISPLAYTEXT	.253			; -10m
+		DISPLAYTEXTH .306			; Quit Sim
         return
 
 ;-----------------------------------------------------------------------------
@@ -2696,7 +2697,7 @@
 	cpfseq	hi				; All gases shown?
 	bra		PLED_gas_list_loop	; No
 
-	DISPLAYTEXT		d'122'		; Gas 6..
+	DISPLAYTEXT		d'122'		; More
 	return					;  return (OC mode)
 
 PLED_splist_start:	
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -24,10 +24,10 @@
 ; ToDo: 
 
 menu_simulator:
-	movlw	d'1'
-	movwf	logbook_temp1               ; Bottom time
+	movlw	d'3'
+	movwf	logbook_temp1		; Bottom time
 	movlw	d'15'
-	movwf	logbook_temp2               ; Max. Depth
+	movwf	logbook_temp2		; Max. Depth
 	movlw	d'1'
 	movwf	menupos
     clrf    WREG                        ; Interval
--- a/code_part1/OSTC_code_asm_part1/sleepmode.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/sleepmode.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -74,6 +74,8 @@
 
 	rcall	pressuretest_sleep_fast	; Gets pressure without averaging (faster!)
 
+    SAFE_2BYTE_COPY amb_pressure_avg, amb_pressure	; copy for compatibility
+
 	call	check_temp_extrema		; Check for temperature extremas
 
 	call	deco_calc_CNS_decrease_15min		; compute CNS decay in sleep only
@@ -131,12 +133,12 @@
 
 	rcall	pressuretest_sleep_fast	; Gets pressure without averaging (faster!)
 
-    ; compare current ambient pressure with threshold CF6==1160mbar.
+        ; compare current ambient pressure with threshold CF6==1160mbar.
 	GETCUSTOM15	d'6'				; loads pressure threshold into lo,hi
 	movff	lo,sub_a+0				; power on if ambient pressure is greater threshold
 	movff	hi,sub_a+1	
-    SAFE_2BYTE_COPY amb_pressure, sub_b
-	call	sub16					; Is (1160mbar - amb_pressure) < 0 ?
+        SAFE_2BYTE_COPY amb_pressure_avg, sub_b
+	call	sub16					; Is (1160mbar - averaged(amb_pressure)) < 0 ?
 	bsf		sleepmode
 	btfsc	neg_flag				; Wake up from Sleep?
 	bcf		sleepmode				; amb_pressure>pressure_offset_divemode: wake up!
@@ -182,6 +184,8 @@
 	nop
 	sleep								; Wait at least 35ms (every 16.5ms Timer1 wakeup)
 	call		get_pressure_value		; State2: Get pressure (51us)
+	clrf		amb_pressure_avg+0
+	clrf		amb_pressure_avg+1			; clear for sleep routine
 	call		calculate_compensation		; calculate temperature compensated pressure (233us)
 	return
 
--- a/code_part1/OSTC_code_asm_part1/spanish_text.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/spanish_text.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -96,7 +96,7 @@
 ; 32 custom function descriptors I (FIXED LENGTH = 15 chars).
     TCODE    .40,  .35,      "Buceo Inic. [m]"           ;036 Start Dive  [m]	(depth to switch to dive mode)
     TCODE    .40,  .35,      "Buceo Fin.  [m]"           ;037 End Dive    [m]	(depth to switch back to surface mode)
-    TCODE    .40,  .35,      "Retras Fin[min]"           ;038 End Delay [min]  	(duration dive screen stays after end of dive)
+    TCODE    .40,  .35,      "Retras Fin[sec]"           ;038 End Delay [sec]  	(duration dive screen stays after end of dive)
     TCODE    .40,  .35,      "Apagado   [min]"           ;039 Power Off [min]
     TCODE    .40,  .35,      "Pre-menú  [min]"           ;040 Pre-menu  [min]	(Delais to keep surface-mode menus displayed)
     TCODE    .40,  .35,      "Vel.    [m/min]"           ;041 velocity[m/min]
@@ -120,7 +120,7 @@
     TCODE    .40,  .35,      "Divisor SinUso1"           ;059 Divisor NotUse1
     TCODE    .40,  .35,      "Divisor ppO2   "           ;060 Divisor ppO2 
     TCODE    .40,  .35,      "Divisor Depurac"           ;061 Divisor Debug  
-    TCODE    .40,  .35,      "Divisor SinUso2"           ;062 Divisor NotUse2
+    TCODE    .40,  .35,      "Divisor CNS    "           ;062 Divisor CNS
     TCODE    .40,  .35,      "Mues.CNSbuc.[%]"           ;063 CNSshow dive[%]
     TCODE    .40,  .35,      "Despl. diario  "           ;064 Logbook offset 
     TCODE    .40,  .35,      "Ult. Deco a [m]"           ;065 Last Deco at[m]
@@ -391,7 +391,9 @@
 	TCODE	 .50,	.130,	 "¡Aborta!"					 ;304 Aborted
 ;@5 variant
     TCODE    .0,    .0,      "Futuro TTS"                ;305 Future TTS            (=10 chars. Title for @5 customview).
+;
+    TCODE    .100,  .125,    "Quit Sim"                  ;306 Quit Sim (=8char max. Quit Simulator mode)
 ;Dive interval
-    TCODE    .20,   .35,     "Interval:"                 ;306 Interval:
-    TCODE    .0,    .0,      "Now"                       ;307 Now
+    TCODE    .20,   .35,     "Interval:"                 ;307 Interval:
+    TCODE    .0,    .0,      "Now"                       ;308 Now
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/start.asm	Fri Jun 10 01:14:38 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Fri Jun 10 01:31:39 2011 +0200
@@ -135,7 +135,7 @@
 	movwf	EEDATA		
 	call	write_eeprom			; write version y
 	clrf	EEADRH					; Reset EEADRH
-	goto	reset_all_cf			; resets all custom functions bank0 and bank1 and jumps to "restart"
+;	goto	reset_all_cf			; resets all custom functions bank0 and bank1 and jumps to "restart"
 			
 restart:
 	bcf		LED_red
@@ -224,6 +224,16 @@
 	cpfseq	EEDATA
 	bcf		debug_mode				; clear flag if <> 1
 
+; Check if logbook has been converted already (Internal EEPROM 0x100=0xAA)
+	movlw	LOW		0x100
+	movwf	EEADR
+	movlw	HIGH 	0x100
+	movwf	EEADRH
+	call	read_eeprom				; read byte
+	movlw	0xAA
+	cpfseq	EEDATA					; is 0xAA already?
+	call	logbook_convert_64k		; No, convert now (And write 0xAA to internal EEPROM 0x100)
+
 	goto	surfloop				; Jump to Surfaceloop!