changeset 430:f36b93f2fbed

Minor logbook cleanups. Created a 20byte tmp area, safe from C-library footprint.
author JeanDo
date Thu, 04 Aug 2011 18:54:26 +0200
parents 1da600c4e139
children db57241d36f3 1f1af9482d00
files code_part1/OSTC_code_asm_part1/changelog.txt code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/simulator.asm
diffstat 5 files changed, 113 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/changelog.txt	Thu Aug 04 07:44:03 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/changelog.txt	Thu Aug 04 18:54:26 2011 +0200
@@ -1,3 +1,6 @@
+New in 1.96 beta:
+NEW: Logbook displays ceilings and temperature curve.
+
 New in 1.95 beta:
 CHANGE: 0.98bar equal 10m depths with salinity set to 1.00kg/l
 
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Thu Aug 04 07:44:03 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Thu Aug 04 18:54:26 2011 +0200
@@ -96,8 +96,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.
@@ -105,6 +105,13 @@
 c_code_data_stack   EQU 0x800
 
 ;=============================================================================
+; ACCESS0 data
+;
+tmp0            udata_acs 0x04C     ; Bank 0 ACCESS area for small tmp data.
+tmp             equ       0x04C
+                res .20             ; What is left from the C library.
+
+;=============================================================================
 ; BANK0 data
 ;
 bank0           udata 0x060     ;Bank 0
@@ -333,18 +340,6 @@
 
 fatal_error_code        res 1   ; holds error code value 
 
-logbook_temp1           res 1   ; Temp used in logbook display&Divemode&Gassetup
-logbook_temp2           res 1   ; Temp used in logbook display&Divemode&Gassetup
-logbook_temp3           res 1   ; Temp used in logbook display&Divemode&Gassetup
-logbook_temp4           res 1   ; Temp used in logbook display&Divemode&Gassetup
-logbook_temp5           res 1   ; Temp used in logbook display&Divemode&Gassetup
-logbook_temp6           res 1   ; Temp used in logbook display&Divemode&Gassetup
-logbook_cur_depth       res 2   ; Current depth, for drawing profile.
-logbook_cur_tp          res 2   ; Current temperature, for drawing profile.
-logbook_last_tp         res 1   ; Y of the last item in Tp° curve.
-logbook_min_tp          res 2   ; Min temperature, for drawing profile.
-logbook_ceiling         res 1   ; Current ceiling, for drawing profile.
-
 convert_value_temp      res 3   ; used in menu_battery_state_convert_date
 time_correction_value   res 1   ; Adds to Seconds on midnight
 gaslist_active          res 1	; Holds flags for active gases
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Thu Aug 04 07:44:03 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Thu Aug 04 18:54:26 2011 +0200
@@ -23,6 +23,22 @@
 ; known bugs: 
 ; ToDo: 
 
+;=============================================================================
+; Temp data, local to this module, moved to ACCES0 area.
+;
+    CBLOCK 0x010                ; Keep space for aa_wordprocessor's temp.
+        count_temperature       ; Current sample count for temperature divisor
+        count_deco              ; Current sample count for deco (ceiling) divisor
+        logbook0_ptr:2          ; Loogbook pointer inside EEPROM Bank0
+        logbook1_ptr:2          ; Loogbook pointer inside EEPROM Bank1
+        logbook_cur_depth:2     ; Current depth, for drawing profile.
+        logbook_cur_tp:2        ; Current temperature, for drawing profile.
+        logbook_last_tp         ; Y of the last item in Tp° curve.
+        logbook_min_tp:2        ; Min temperature, for drawing profile.
+        logbook_ceiling         ; Current ceiling, for drawing profile.
+    ENDC
+
+;=============================================================================
 ; searches external EEPROM for dive headers and displays them in a list
 ; a detailed view with all informations and profile can be selected
 ; does not require a FAT, will work with other profile intervals as ten seconds, too
@@ -47,8 +63,8 @@
 	call 		I2CReset					; Reset I2C Bus
 	call		get_free_EEPROM_location	; search from "here" backwards through the external memory
 
-	movff		eeprom_address+0,logbook_temp5
-	movff		eeprom_address+1,logbook_temp6	; Store Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
+	movff		eeprom_address+0,logbook1_ptr+0
+	movff		eeprom_address+1,logbook1_ptr+1	; Store Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
 
 menu_logbook1a_no_get_free:				; Without repeated search for dive
 	clrf		divemins+0					; Here: used as temp variables
@@ -253,8 +269,8 @@
 
 	clrf		divenumber						; search from scratch
 
-	movff		logbook_temp5,eeprom_address+0
-	movff		logbook_temp6,eeprom_address+1	; Restore Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
+	movff		logbook1_ptr+0,eeprom_address+0
+	movff		logbook1_ptr+1,eeprom_address+1	; Restore Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display
 
 	bra			menu_logbook1a_no_get_free		; Start Search for Dive (Without get_free_EEPROM_location)
 
@@ -522,13 +538,13 @@
 	movf		SSPBUF,W
 	andlw       0x0F                        ; Clear extra bits.
 	movwf       divisor_temperature	        ; Store divisor
-	movwf       logbook_temp1               ; Store to tp° counter too.
+	movwf       count_temperature           ; Store to tp° counter too.
 
 	call		I2CREAD2					; Read divisor
 	movf        SSPBUF,W
 	andlw       0x0F
 	movwf       divisor_deco      			; Store divisor
-	movwf		logbook_temp2               ; Store as temp, too
+	movwf		count_deco                  ; Store as temp, too
 
 	call		I2CREAD2					; Read divisor
 	movff		SSPBUF,divisor_gf			; Store divisor
@@ -1173,7 +1189,7 @@
     ;---- Read Tp°, if any AND divisor reached AND bytes available -----------
     movf        divisor_temperature,W       ; Is Tp° divisor null ?
     bz          profile_view_get_depth_no_tp; Yes: no Tp° curve.
-    decf        logbook_temp1,F             ; Decrement tp° counter
+    decf        count_temperature,F         ; Decrement tp° counter
     bnz         profile_view_get_depth_no_tp; No temperature this time
     
     call		I2CREAD2					; Tp° low
@@ -1182,19 +1198,19 @@
 	movff		SSPBUF,logbook_cur_tp+1
 	decf        timeout_counter2,F
 	decf        timeout_counter2,F
-	movff       divisor_temperature,logbook_temp1   ; Restart counter.
+	movff       divisor_temperature,count_temperature   ; Restart counter.
     
     ;---- Read deco, if any AND divisor=0 AND bytes available ----------------
 profile_view_get_depth_no_tp:
     movf        divisor_deco,W
     bz          profile_view_get_depth_no_deco
-    decf        logbook_temp2,F
+    decf        count_deco,F
     bnz         profile_view_get_depth_no_deco
     
     call		I2CREAD2
 	movff		SSPBUF,logbook_ceiling
 	decf        timeout_counter2,F
-	movff       divisor_deco,logbook_temp2  ; Restart counter.
+	movff       divisor_deco,count_deco     ; Restart counter.
 
     ;---- Read GF, if any AND divisor=0 AND bytes available ------------------
 profile_view_get_depth_no_deco:
@@ -1394,101 +1410,101 @@
 ; 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
+	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
+	;logbook1_ptr+0 and logbook1_ptr+1 hold address in bank1
+	;logbook0_ptr+0 and logbook0_ptr+1 hold address in bank0
 	movlw	HIGH	0x8000
-	movwf	logbook_temp6 
+	movwf	logbook1_ptr+1 
 	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
+	movwf	logbook1_ptr+0			    ; load address for bank1
+	movff	eeprom_address+0,logbook0_ptr+0 
+	movff	eeprom_address+1,logbook0_ptr+1	; load address for bank0
 	movlw	0x80
 	movwf	uart2_temp
 logbook_convert2:
-	clrf	uart1_temp				; counter for copy operation
+	clrf	uart1_temp				    ; counter for copy operation
 logbook_convert3:
 	; read source
-	movff	logbook_temp1,eeprom_address+0
-	movff	logbook_temp2,eeprom_address+1
+	movff	logbook0_ptr+0,eeprom_address+0
+	movff	logbook0_ptr+1,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
+	movff	eeprom_address+0,logbook0_ptr+0
+	movff	eeprom_address+1,logbook0_ptr+1	; write source address
 	; write target
-	movff	logbook_temp5,eeprom_address+0
-	movff	logbook_temp6,eeprom_address+1
+	movff	logbook1_ptr+0,eeprom_address+0
+	movff	logbook1_ptr+1,eeprom_address+1
 	movf	lo,W
-	call	I2CWRITE				; writes WREG into EEPROM@eeprom_address
+	call	I2CWRITE				    ; writes WREG into EEPROM@eeprom_address
 	movlw	d'1'
-	addwf	logbook_temp5,F
+	addwf	logbook1_ptr+0,F
 	movlw	d'0'
-	addwfc	logbook_temp6,F			; increase target address
+	addwfc	logbook1_ptr+1,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
+	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 
+	movwf	logbook1_ptr+1 
 	movlw	LOW		0x0000
-	movwf	logbook_temp5			; load address for bank0
+	movwf	logbook1_ptr+0              ; load address for bank0
 	movlw	HIGH	0x8000
-	movwf	logbook_temp2 
+	movwf	logbook0_ptr+1 
 	movlw	LOW		0x8000
-	movwf	logbook_temp1			; load address for bank1
+	movwf	logbook0_ptr+0		        ; load address for bank1
 	movlw	0x80
 	movwf	uart2_temp
 logbook_convert4:
-	clrf	uart1_temp				; counter for copy operation
+	clrf	uart1_temp				    ; counter for copy operation
 logbook_convert5:
 	; read source
-	movff	logbook_temp1,eeprom_address+0
-	movff	logbook_temp2,eeprom_address+1
+	movff	logbook0_ptr+0,eeprom_address+0
+	movff	logbook0_ptr+1,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
+	movff	eeprom_address+0,logbook0_ptr+0
+	movff	eeprom_address+1,logbook0_ptr+1    ; write source address
 	; write target
-	movff	logbook_temp5,eeprom_address+0
-	movff	logbook_temp6,eeprom_address+1
+	movff	logbook1_ptr+0,eeprom_address+0
+	movff	logbook1_ptr+1,eeprom_address+1
 	movf	lo,W
-	call	I2CWRITE				; writes WREG into EEPROM@eeprom_address
+	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
+	movff	eeprom_address+0,logbook1_ptr+0
+	movff	eeprom_address+1,logbook1_ptr+1; write target address
 	decfsz	uart1_temp,F	
 	bra		logbook_convert5
 	btg		LED_red
-	decfsz	uart2_temp,F			; 32kByte done?
-	bra		logbook_convert4		; No, continue
+	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 
+	movwf	logbook0_ptr+1 
 	movlw	LOW		0x8000
-	movwf	logbook_temp1			; load address for bank1
+	movwf	logbook0_ptr+0              ; load address for bank1
 	movlw	0x80
 	movwf	uart2_temp
 logbook_convert6:
-	clrf	uart1_temp				; counter for copy operation
+	clrf	uart1_temp				    ; counter for copy operation
 logbook_convert7:
 	; write target
-	movff	logbook_temp1,eeprom_address+0
-	movff	logbook_temp2,eeprom_address+1
+	movff	logbook0_ptr+0,eeprom_address+0
+	movff	logbook0_ptr+1,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
+	movff	eeprom_address+0,logbook0_ptr+0
+	movff	eeprom_address+1,logbook0_ptr+1	; write target address
 	decfsz	uart1_temp,F	
 	bra		logbook_convert7
 	btg		LED_red
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Thu Aug 04 07:44:03 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Thu Aug 04 18:54:26 2011 +0200
@@ -549,7 +549,7 @@
 	lfsr        FSR2,letter
 	OUTPUTTEXTH .277                    ; Bottom Time:
 
-	movff	logbook_temp1,lo
+	movff	sim_btm_time,lo
 	bsf		leftbind
 	output_8
 	STRCAT_PRINT  "min "
@@ -559,7 +559,7 @@
 	lfsr	FSR2,letter
 	OUTPUTTEXTH .278                    ; Max. Depth:
 
-	movff	logbook_temp2,lo
+	movff	sim_btm_depth,lo
 	bsf		leftbind
 	output_8
 	STRCAT_PRINT  "m  "
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Thu Aug 04 07:44:03 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Thu Aug 04 18:54:26 2011 +0200
@@ -23,11 +23,22 @@
 ; known bugs:
 ; ToDo: 
 
+;=============================================================================
+; Temp data, local to this module, moved to ACCES0 area.
+;
+    CBLOCK tmp                  ; Into safe (from C library) area.
+        sim_btm_time            ; Simulated bottom time
+        sim_btm_depth           ; Simulated max depth
+        sim_CNS                 ; Backup CNS value during decoplanning.
+    ENDC
+
+;=============================================================================
+
 menu_simulator:
 	movlw	d'3'
-	movwf	logbook_temp1		; Bottom time
+	movwf	sim_btm_time		; Bottom time
 	movlw	d'15'
-	movwf	logbook_temp2		; Max. Depth
+	movwf	sim_btm_depth		; Max. Depth
 	movlw	d'1'
 	movwf	menupos
     clrf    WREG                        ; Interval
@@ -109,20 +120,20 @@
     
 simulator_inc_bottomtime:
 	movlw	d'2'
-	addwf	logbook_temp1,F				; Here: Bottomtime in m
+	addwf	sim_btm_time,F				; Here: Bottomtime in m
 	movlw	d'199'
-	cpfslt	logbook_temp1
-	movwf	logbook_temp1
+	cpfslt	sim_btm_time
+	movwf	sim_btm_time
 	movlw	d'3'
 	movwf	menupos
 	bra		menu_simulator2
 
 simulator_inc_maxdepth:
 	movlw	d'3'
-	addwf	logbook_temp2,F				; Here: Maxdepth in m
+	addwf	sim_btm_depth,F				; Here: Maxdepth in m
 	movlw	d'120'
-	cpfslt	logbook_temp2
-	movwf	logbook_temp2
+	cpfslt	sim_btm_depth
+	movwf	sim_btm_depth
 	movlw	d'4'
 	movwf	menupos
 	bra		menu_simulator2
@@ -136,7 +147,7 @@
 	bsf		simulatormode_active			; normal simulator mode
 	bsf		standalone_simulator			; Standalone Simulator active
 
-	movff	logbook_temp2,xA+0
+	movff	sim_btm_depth,xA+0
 	clrf	xA+1
 	movlw	d'100'
 	movwf	xB+0
@@ -210,7 +221,7 @@
         output_8
 
         STRCAT  "%\x92"                 ; Right-arrow
-        movff   logbook_temp3,lo        ; Get back CNS value.
+        movff   sim_CNS,lo              ; Get back CNS value.
         output_8                        ; CNS after dive.
         STRCAT_PRINT    "%"
 
@@ -352,10 +363,10 @@
 	call	diveloop_boot               ; configure gases, etc.
 
     ; Save dive parameters for gas volume estimation:
-    movff   logbook_temp2,char_I_bottom_depth
-    movff   logbook_temp1,char_I_bottom_time
+    movff   sim_btm_depth,char_I_bottom_depth
+    movff   sim_btm_time,char_I_bottom_time
 
-	movff	logbook_temp2,xA+0          ; Bottom depth. 
+	movff	sim_btm_depth,xA+0          ; Bottom depth. 
 	clrf	xA+1
 	movlw	d'100'
 	movwf	xB+0
@@ -395,7 +406,7 @@
     call	deco_calc_CNS_fraction      ; Also calculate CNS (in 1min loop)
 	movlb	b'00000001'                 ; rambank 1 selected
 
-    decf    logbook_temp1,F             ; One minute done.
+    decf    sim_btm_time,F              ; One minute done.
 
     ; Loop for bottom time duration
 simulator_calc_deco_loop2:
@@ -406,7 +417,7 @@
     movlb	b'00000001'                 ; rambank 1 selected
     ostc_debug	'C'	                    ; Sends debug-information to screen if debugmode active
 
-    decfsz  logbook_temp1,F             ; Decrement bottom time,
+    decfsz  sim_btm_time,F              ; Decrement bottom time,
 	bra     simulator_calc_deco_loop2   ; and loop while not finished.
 
     ; No the bottom time is finish, restart a full ascent simulation,
@@ -420,7 +431,7 @@
 	call	deco_calc_hauptroutine		; calc_tissue
 	movlb	b'00000001'                 ; rambank 1 selected
 
-    movff   char_O_deco_last_stop,logbook_temp2
+    movff   char_O_deco_last_stop,sim_btm_depth
     call    PLED_simulator_data         ; Animate ascent simu.
 
 	dcfsnz	timeout_counter2,F			; Abort loop (max. 256 tries)?
@@ -432,7 +443,7 @@
 
 ; Finished
 simulator_calc_deco3:
-    movff   char_O_CNS_fraction,logbook_temp3   ; Save calculated CNS.     
+    movff   char_O_CNS_fraction,sim_CNS ; Save calculated CNS.     
 	rcall	simulator_restore_tissue_data	; Restore CNS & 32 floats "pre_tissue" from vault
 
 	bcf		simulatormode_active        ; normal simulator mode
@@ -445,8 +456,8 @@
 
 	movlw	d'5'                        ; Pre-Set Cursor to "Show Decoplan"
 	movwf	menupos
-	movff	char_I_bottom_time,logbook_temp1    ; Restore bottom time,
-	movff   char_I_bottom_depth,logbook_temp2   ; and depth.
+	movff	char_I_bottom_time,sim_btm_time    ; Restore bottom time,
+	movff   char_I_bottom_depth,sim_btm_depth   ; and depth.
 
 	clrf	timeout_counter2            ; Restart menu timeout.
     bra     simulator_show_decoplan     ; Done.