diff code_part1/OSTC_code_asm_part1/menu_custom.asm @ 86:b40a0a6284da

adding custom functions with limits (jeando)
author heinrichsweikamp
date Thu, 09 Dec 2010 20:41:56 +0100
parents 0f4c175ef824
children 6655b1c59adc
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/menu_custom.asm	Wed Dec 08 08:37:03 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm	Thu Dec 09 20:41:56 2010 +0100
@@ -48,15 +48,30 @@
 ; define the display format:
 
 CF_INT8		EQU	0	; Default display, 8 or 15 bits values.
-CF_PERCENT	EQU	1	; Displays 110%
-CF_DECI		EQU	2	; Displays 1.6
-CF_CENTI	EQU	3	; Displays 1.50
-CF_MILI		EQU	4	; Displays 1.015
-CF_BOOL		EQU	5	; Displays ON/OFF
-CF_SEC		EQU	6	; Displays 4:00
-CF_COLOR	EQU	7	; Display 240 plus a color watch (inverse video space)
+CF_PERCENT	EQU	1	    ; Displays 110%
+CF_DECI		EQU	2	    ; Displays 1.6
+CF_CENTI	EQU	3	    ; Displays 1.50
+CF_MILI		EQU	4	    ; Displays 1.015
+CF_BOOL		EQU	5	    ; Displays ON/OFF
+CF_SEC		EQU	6	    ; Displays 4:00
+CF_COLOR	EQU	7	    ; Display 240 plus a color watch (inverse video space)
+;
+CF_TYPES    EQU 0x1F    
+CF_MAX_BIT  EQU 6       ; Default is the highest safe value.
+CF_MAX      EQU (1<<CF_MAX_BIT)
+CF_MIN_BIT  EQU 5       ; Default is the lowest safe value.
+CF_MIN      EQU (1<<CF_MIN_BIT)
+;
 CF_INT15	EQU	0x80; Default display. Flag for 15bit, typeless values.
 
+; Overlay our tmp data with some unused variables. But use more
+; meaningfull labels...
+cf32_x4     EQU divemins+0      ; CF# modulus 32, time 4.
+cf_type     EQU divemins+1      ; Type of the edited CF
+cf_value    EQU divesecs
+cf_min      EQU apnoe_mins
+cf_max      EQU apnoe_secs
+            
 GETCUSTOM8	macro	custom8
 	movlw	custom8
 	call	getcustom8_1
@@ -144,7 +159,7 @@
 	bcf		cursor
 	bcf		sleepmode
 	clrf	decodata+0				; here: # of CustomFunction
-	clrf	divemins+0				; here: # of CustomFunction*4
+	clrf	cf32_x4                 ; here: # of CustomFunction*4
 	bcf		first_FA				; here: =1: -, =0: +
 	bcf		second_FA				; here: =1: stepsize 1, =0: stepsize 10
 
@@ -176,14 +191,13 @@
 	WIN_LEFT 	.20
 	WIN_TOP		.35
 	lfsr	FSR2,letter
-	movff	decodata+0,lo
-	
+	movff	decodata+0,lo               ; decodata == CF number % 32
+
 	movlw	d'0'
-	btfsc	customfunction_page			; Add offset for display
+	btfsc	customfunction_page			; Add offset for display in CF menu II
 	movlw	d'32'
 	addwf	lo,F
-	movff	lo, apnoe_mins     			; Copy use when NO_CF_TYPES
-				
+
 	output_99x
 	movlw	':'
 	movwf	POSTINC2
@@ -195,53 +209,15 @@
 	addwf	decodata+0,W				; add # of current custom function, place result in wreg
 	call	displaytext1				; shows descriptor
 
-	; Read defaults into hi:lo
-	movf	divemins+0,W
-	addlw	0x80
-	movwf	EEADR
-	call	read_eeprom					; Lowbyte
-	movff	EEDATA,lo
-	movf	divemins+0,W
-	addlw	0x81
-	movwf	EEADR
-	call	read_eeprom						; Highbyte
-	movff	EEDATA,hi
-
-#ifdef	NO_CF_TYPES
-	movlw	binary_cf1
-	subwf	apnoe_mins,W				; Binary cf?
-	bz		menu_custom_functions10c	; Yes
+; Read default, type and min/max from reset table.
+    rcall    cf_read_default
 
-	movlw	binary_cf2
-	subwf	apnoe_mins,W				; Binary cf?
-	bz		menu_custom_functions10c	; Yes
-
-	movlw	binary_cf3
-	subwf	apnoe_mins,W				; Binary cf?
-	bz		menu_custom_functions10c	; Yes
-
-	movlw	binary_cf4
-	subwf	apnoe_mins,W				; Binary cf?
-	bz		menu_custom_functions10c	; Yes
-
-	movlw	binary_cf5
-	subwf	apnoe_mins,W				; Binary cf?
-	bz		menu_custom_functions10c	; Yes
-
-	movlw	binary_cf6
-	subwf	apnoe_mins,W				; Binary cf?
-	bz		menu_custom_functions10c	; Yes
-	
-	bra     menu_custom_functions10a    ; Not a binary CF...
-#else
-	movf	hi,W						; Is it a ON/OFF flag ?
+	movf	cf_type,W					; Is it a ON/OFF flag ?
 	xorlw	CF_BOOL
 	bnz		menu_custom_functions10a	; Not a  binary CF selected
-#endif
 
 menu_custom_functions10c:
-	setf	apnoe_mins					; Yes, set apnoe_mins to 0xFF
-
+    ; Erase unused lines when editing boolean...
 	WIN_LEFT 	.20
 	WIN_TOP		.65
 	lfsr	FSR2,letter					; Make a string of 8 spaces
@@ -250,12 +226,10 @@
 
 	WIN_TOP		.95
 	call	word_processor				; Clear 1/10 line
-	
+ 
 	bra		menu_custom_functions10b
 
 menu_custom_functions10a:
-	clrf	apnoe_mins					; Yes, clear apnoe_mins
-
 	WIN_LEFT 	.20
 	WIN_TOP		.65
 	lfsr	FSR2,letter
@@ -297,15 +271,13 @@
 	movwf	POSTINC2
 	movlw	' '
 	movwf	POSTINC2
-	call	word_processor		
+	call	word_processor
 
 menu_custom_functions10b:
 	WIN_LEFT 	.20
 	WIN_TOP		.125
 	lfsr	FSR2,letter
 	OUTPUTTEXT	d'89'				;"Default:"
-	movlw	' '
-	movwf	POSTINC2
 
 	call	display_customfunction	; Typed display.
 
@@ -313,30 +285,24 @@
 	WIN_TOP		.155
 	lfsr	FSR2,letter
 	OUTPUTTEXT	d'97'				; "Current:"
-	movlw	' '
-	movwf	POSTINC2
 
-	movf	divemins+0,W
+	movf	cf32_x4,W
 	addlw	0x82
 	movwf	EEADR
 	call	read_eeprom				; Lowbyte
 	movff	EEDATA,lo
+	movff   EEDATA, cf_value        ; Backup low 8bit value.
 
-	movf	divemins+0,W
+	movf	cf32_x4,W
 	addlw	0x83
 	movwf	EEADR
 	call	read_eeprom				; Highbyte
-
-	btfss	hi,7					; A 15bit value ?
-	bra		menu_custom_functions1b	; No : keep types there !
+	movff	EEDATA,hi
 
-	movff	EEDATA,hi
-	bsf		hi,7					; Mark it a 15bit value.
-
-menu_custom_functions1b:
 	call	display_customfunction
 
-menu_custom_functions1a:
+; End of mask: min/max and the exit line...
+	rcall display_minmax
 	DISPLAYTEXT	.11					; Exit
 
 	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
@@ -393,79 +359,212 @@
 	bra		customfunctions_loop
 
 ;-----------------------------------------------------------------------------
-; Input : hi:lo = data to display, with type embebed into hi
+; Read default value (into hi:lo), cf_type, and cf_min/cf_max if any.
+;
+cf_read_default:
+    movlw   LOW(cf_default_table0)      ; Get 24bit PROM pointer. SKIP 
+    movwf   TBLPTRL
+    movlw   HIGH(cf_default_table0)
+    movwf   TBLPTRH
+    movlw   UPPER(cf_default_table0)
+    movwf   TBLPTRU
+
+    movlw   0
+	btfsc	customfunction_page	        ; Page II CF# ?
+	movlw   0x80                        ; YES: add 128 to ptr.
+	addwf   cf32_x4,W                   ; Add 4 x (CF index modulus 32)
+    addwf   TBLPTRL,F                   ; And to a 8+16 add into TBLPTR
+    movlw   0                           ; (keep carry)
+    addwfc  TBLPTRH,F                   ; Propagate to 16bit (but not 24bits).
+
+    tblrd*+
+    movff   TABLAT,lo                   ; Low byte --> lo
+    tblrd*+
+    movff   TABLAT,hi                   ; High byte --> hi
+    btfss   hi,7                        ; 15bit ?
+    clrf    hi                          ; NO: clear extra type flags
+    bcf     hi,7                        ; clear 15bit flag
+    
+    movff   TABLAT,cf_type              ; type (high byte) --> cf_type
+    movlw   CF_MILI
+    btfsc   cf_type,7                   ; Display all 15bits as 1.234 floats.
+    movwf   cf_type
+
+    tblrd*+
+    movff   TABLAT,cf_min               ; Then get optional min/max
+    tblrd*+
+    movff   TABLAT,cf_max
+
+    return
+
+;-----------------------------------------------------------------------------
+; Display a 8/15bit value, plus optional min and max bound.
+; Input : hi:lo = data to display.
+;         cf_type = the type.
+;         cf_min, cf_max : the optional min/max.
 ;         FSR2  = current string pointer.
-; Trash : FSR1 (used to backup EEADRH and hi)
+; Trash : hi:lo (when displaying min/max)
 
 display_customfunction:
-#ifndef NO_CF_TYPES
+	movff	EEADRH, FSR1H		; Backup...
+
+	rcall   display_formated
+    rcall   cf_fill_line
+	call	word_processor
+
+	movff	FSR1H, EEADRH
+	return
+
+;-----------------------------------------------------------------------------
+; Display optional min/max values.
+; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max).
+; Trashed: hi:lo while display min and max values.
+display_minmax:
 	movff	EEADRH, FSR1H		; Backup...
-	movff	hi, FSR1L
+
+; Display min line
+    WIN_TOP  .65
+    WIN_LEFT .100
+    lfsr    FSR2, letter
+
+    btfss   cf_type, CF_MIN_BIT ; A min value exists ?
+    bra     cf_no_min
+
+    movf    cf_min,W            ; Retrieve current 8b value
+    subwf   cf_value,W          ; Compute (lo-min)
+    bc     cf_min_passed        ; Ok if CARRY, ie. min >= lo
+    call    PLED_warnings_color
+    WIN_INVERT  1
+cf_min_passed:
+    
+    movlw   '>'                 ; A min value follows
+    movwf   POSTINC2
+    movlw   ' '
+    movwf   POSTINC2
+    movff   cf_min, lo
+    rcall   display_formated
+
+cf_no_min:
+    rcall   cf_fill_line        ; Fill buffer
+    lfsr    FSR2, letter+.7     ; Limit to 8 chars btw.
+	call	word_processor
+
+; Display max line
+    WIN_TOP  .95
+    call    PLED_standard_color
+    WIN_INVERT 0
+    lfsr    FSR2, letter
+
+    btfss   cf_type, CF_MAX_BIT ; A max value exists ?
+    bra     cf_no_max
+
+    movf    cf_value,W          ; Retrieve current max bound
+    subwf   cf_max,W            ; Compute (max-lo)
+    bc     cf_max_passed        ; Ok if no carry, ie. max <= lo
+    call    PLED_warnings_color
+    WIN_INVERT  1
+cf_max_passed:
+    
+    movlw   '<'                 ; A max value follows
+    movwf   POSTINC2
+    movlw   ' '
+    movwf   POSTINC2
+    movff   cf_max, lo
+    rcall   display_formated
+
+cf_no_max:
+    rcall   cf_fill_line        ; Fill buffer
+    lfsr    FSR2, letter+.7     ; Limit to 8 chars btw.
+	call	word_processor
+
+cf_minmax_done:
+    call    PLED_standard_color
+    WIN_INVERT  0
+	movff	FSR1H, EEADRH
+	return
+
+;-----------------------------------------------------------------------------
+; Display a single 8/15 bit value, according to cf_type.
+; Input : hi:lo = data to display.
+;         cf_type = the type.
+;         cf_min, cf_max : the optional min/max.
+;         FSR2  = current string pointer.
+display_formated:
 
 	;---- decode type --------------------------------------------------------
-	movf	hi,W				; Just set N/Z flags
-	bn		cf_type_0			; Keep 15bits value in old format.
-	bz		cf_type_99			; 8bit standard mode
+	movf	cf_type,W			; Just set N/Z flags
+	bn		cf_type_neg			; Keep 15bits value in old format.
+	andlw   CF_TYPES            ; Look just at types
+	bz		cf_type_00			; 8bit standard mode
 
-	; Jump table:
-	dcfsnz	hi
+	; Jump table:               ; test the value with cleared flags...
+	dcfsnz	WREG
 	bra		cf_type_01
-	dcfsnz	hi
+	dcfsnz	WREG
 	bra		cf_type_02
-	dcfsnz	hi
+	dcfsnz	WREG
 	bra		cf_type_03
-	dcfsnz	hi
+	dcfsnz	WREG
 	bra		cf_type_04
-	dcfsnz	hi
+	dcfsnz	WREG
 	bra		cf_type_05
-	dcfsnz	hi
+	dcfsnz	WREG
 	bra		cf_type_06
-	dcfsnz	hi
+	dcfsnz	WREG
 	bra		cf_type_07
-	bra		cf_type_99			; Default to 8bit mode...
+	bra		cf_type_00			; Default to 8bit mode...
 
-cf_type_01:						; Type == 1 is percent mode
-	output_16dp	0				; NOTE : hi is already reseted...
+cf_type_01:						; Type == 1 is CF_PERCENT mode
+    bcf     leftbind
+	output_8
 	movlw	'%'
 	movwf	POSTINC2
-	bra		cf_do_wp
+	retlw   0
 
-cf_type_02:						; Type == 2 is deci mode.
+cf_type_02:						; Type == 2 is CF_DECI mode.
+    clrf    hi
+    bsf     leftbind
 	output_16dp	4
-	bra		cf_do_wp
+	retlw   0
 
-cf_type_03:						; Type == 3 is centi mode.
+cf_type_03:						; Type == 3 is CF_CENTI mode.
+    clrf    hi
+    bsf     leftbind
 	output_16dp	3
-	bra		cf_do_wp
+	retlw   0
 
-cf_type_04:						; Type == 4 is mili mode
+cf_type_04:						; Type == 4 is CF_MILI mode
 	output_16dp	2
-	bra		cf_do_wp
+	retlw   0
 
-cf_type_05:						; Type == 5 is on/off mode.
+cf_type_05:						; Type == 5 is CF_BOOL mode.
 	movf	lo,W				; Get flag value...
 	bz		cf_type_off
 	OUTPUTTEXT	d'130'			; ON
-	bra		cf_do_wp
+	retlw   0
+
 cf_type_off:
 	OUTPUTTEXT	d'131'			; OFF
-	bra		cf_do_wp
+	retlw   0
 
-cf_type_06:						; Type == 6 is mm:ss mode (... or hh:mm)
+cf_type_06:						; Type == 6 is CF_SECS mode (mm:ss or hh:mm)
+    clrf    hi
 	call	convert_time		; Convert to min:sec into hi:low.
 	movff	lo,wp_temp			; Save seconds,
 	movff	hi,lo				; Get minutes
+    bsf     leftbind            ; Skip leading space(s).
 	output_8					; Print them
 	movlw	':'					; Separator
 	movwf	POSTINC2
 	movff	wp_temp,lo			; Get back seconds
 	output_99x					; lo in 2 digits with trailing zeros.
-	bra		cf_do_wp
+	retlw   0
 
-cf_type_07:						; Type == 7 is Color swatch.
+cf_type_07:						; Type == 7 is CF_COLOR swatch.
+    bcf     leftbind            ; Keep leading space (better alignement)
 	output_8
-
-    call    cf_fill_line        ; it does less flickering when editing colors...
+	movlw	' '
+	movwf	POSTINC2
 	call    word_processor
 
 	movf	lo,W				; Get color.
@@ -476,68 +575,31 @@
 	movff	WREG,box_temp+2		; row bottom (0-239)
 	movlw	.110
 	movff	WREG,box_temp+3		; column left (0-159)
-	movlw	.140	
+	movlw	.148	
 	movff	WREG,box_temp+4		; column right (0-159)
 
 	call	PLED_box
-	bra		cf_done				; wp already done. Skip it...
+    retlw   -1  				; wp already done. Skip it...
 
-cf_type_99:						; 8bit mode. Or unrecognized type...
+cf_type_00:						; 8bit mode. Or unrecognized type...
 	clrf	hi
+    bsf     leftbind
 
-cf_type_0:						; 15bit mode.
+cf_type_neg:					; 15bit mode.
 	bcf		hi,7
 	output_16
-
-cf_do_wp:                       ; Process by calling wordprocessor
-    call    cf_fill_line
-	call	word_processor
+	retlw   0
 
-cf_done:
-	movff	FSR1L, hi			; And restore saved registers before return.
-	movff	FSR1H, EEADRH
-	return
+;-----------------------------------------------------------------------------
 
 cf_fill_line:                   ; Mattias: No flicker if u clear just what you need...
 	movf    FSR2L,W             ; How many chars lefts ?
-	sublw   (LOW letter) + .17  ; Remaining chars to fill: (letter + 21) - PTR
+	sublw   (LOW letter) + .18  ; Remaining chars to fill: (letter + 18) - PTR
 	btfsc   STATUS,N            ; Add chars until none left...
 	return
 	movlw   ' '
 	movwf   POSTINC2
 	bra     cf_fill_line
-	
-#else
-	bcf		hi,7				; clear Bit 7 of value
-	output_16
-
-	movff	win_top,WREG		; Get "Default:" line position (BANK0 !)
-	xorlw	.125				; This is the default value ?
-	bnz		cf_no_bits			; NO: skip bits for current value
-
-	movlw	','
-	movwf	POSTINC2
-
-	movlw	'1'
-	btfss	EEDATA,7			; 15Bit?
-	movlw	'8'					; 8Bit!
-	tstfsz  apnoe_mins			; apnoe_mins=0?
-	movlw	'1'					; No, 1Bit!
-	movwf	POSTINC2
-
-	movlw	'5'
-	btfsc	EEDATA,7			; 15Bit?
-	movwf	POSTINC2
-	movlw	'B'
-	movwf	POSTINC2
-
-cf_no_bits:
-	movlw	' '
-	movwf	POSTINC2
-	movwf	POSTINC2
-	movwf	POSTINC2
-	goto	word_processor		
-#endif
 
 ;-----------------------------------------------------------------------------
 
@@ -558,6 +620,8 @@
 	dcfsnz	menupos,F
 	bra		adjust_cfn_value
 
+;-----------------------------------------------------------------------------
+
 exit_customfunctions:
 	movlw	d'2'					; Return to correct list entry
 	btfss	customfunction_page
@@ -566,6 +630,8 @@
 	clrf	EEADRH					; Clear EEADRH !
 	goto	setup_menu2				; exit...
 
+;-----------------------------------------------------------------------------
+
 next_customfunction:
 	incf	decodata+0
 	btfsc	decodata+0,5			;>31?
@@ -573,11 +639,13 @@
 	
 	movf	decodata+0,W
 	mullw	d'4'
-	movff	PRODL, divemins+0		;divemins+0 for correct addressing
+	movff	PRODL, cf32_x4          ; 12bit address for correct addressing
 
 	movlw	d'1'
 	movwf	menupos
-	bra		menu_custom_functions1	; also debounces switches
+	bra		menu_custom_functions1  ; also debounces switches
+
+;-----------------------------------------------------------------------------
 
 toggle_plusminus:
 	btg		first_FA
@@ -585,31 +653,25 @@
 	movwf	menupos
 	bra		menu_custom_functions1	; also debounces switches
 
+;-----------------------------------------------------------------------------
+
 toggle_oneorten:
 	btg		second_FA
 	movlw	d'3'
 	movwf	menupos
 	bra		menu_custom_functions1	; also debounces switches
 
+;-----------------------------------------------------------------------------
+
 restore_cfn_value:
-	movf	divemins+0,W			; read default value
-	addlw	0x80
-	movwf	EEADR
-	call	read_eeprom				; Lowbyte
-	movff	EEDATA,lo
-	movf	divemins+0,W
-	addlw	0x81
-	movwf	EEADR
-	call	read_eeprom				; Highbyte
-	movff	EEDATA,hi
-	bcf		hi,7					; clear bit 7 of value
+    rcall    cf_read_default        ; hi:lo is trashed by min/max display.
 
-	movf	divemins+0,W			; store default value
+	movf	cf32_x4,W               ; store default value
 	addlw	0x82
 	movwf	EEADR
 	movff	lo,EEDATA
 	call	write_eeprom			; Lowbyte
-	movf	divemins+0,W
+	movf	cf32_x4,W
 	addlw	0x83
 	movwf	EEADR
 	movff	hi,EEDATA
@@ -619,253 +681,66 @@
 	movwf	menupos
 	bra		menu_custom_functions1	; also debounces switches
 
+;-----------------------------------------------------------------------------
+; Adjust current value.
 adjust_cfn_value:
-	movf	divemins+0,W			; get current value
+	movf	cf32_x4,W               ; get current value
 	addlw	0x82
 	movwf	EEADR
 	call	read_eeprom				; Lowbyte
 	movff	EEDATA,lo
-	movf	divemins+0,W
+	movf	cf32_x4,W
 	addlw	0x83
 	movwf	EEADR
 	call	read_eeprom				; Highbyte
 	movff	EEDATA,hi
 
-	movf	divemins+0,W
-	addlw	0x81
-	movwf	EEADR
-	call	read_eeprom				; Highbyte
-	movff	EEDATA,divemins+1		; Highbyte of default value
+    movf    cf_type,W
+    xorlw   CF_BOOL
+    bnz      adjust_cfn_value1
 
-	btfss	apnoe_mins,0			; If apnoe_mins=1 then CF is binary
-	bra		adjust_cfn_value1		; Not Binary
-
-	tstfsz	lo				; =0?
-	setf	lo				; No, Set to 255
-	incf	lo,F			; Increase by one
-	clrf	hi				; Delete hi byte (Not required but to make sure...)
-	bra		adjust_cfn_value3		; Store result
+	btg     lo,0			            ; Change lower bit.
+	bra		adjust_cfn_value3		    ; Store result
 
 adjust_cfn_value1:
-	btfss	first_FA				; Minus?
-	bra		adjust_cfn_value2		; No, Plus
-
 	movlw	d'1'
-	btfsc	second_FA				; -10?
+	btfsc	second_FA			    	; -10?
 	movlw	d'10'
 	
-	subwf	lo,F					; substract value
+	btfss	first_FA				    ; Minus?
+	bra		adjust_cfn_value2	    	; No, Plus
+
+	subwf	lo,F					    ; substract value
 	movlw	d'0'
-	btfsc	divemins+1,7			; 8Bit value
+	btfsc	cf_type,7			        ; 8Bit value
 	subwfb	hi,F
 
 	movlw	b'01111111'
-	btfsc	hi,7					; >32768?
+	btfsc	hi,7				        ; >32768?
 	movwf	hi						
 
 	bra		adjust_cfn_value3
 	
 adjust_cfn_value2:
-	movlw	d'1'
-	btfsc	second_FA				; +10?
-	movlw	d'10'
-	
-	addwf	lo,F					; add value
+	addwf	lo,F					    ; add value
 	movlw	d'0'
-	btfsc	divemins+1,7			; 8Bit value?
+	btfsc	cf_type,7			        ; 8Bit value?
 	addwfc	hi,F
 
-	btfsc	hi,7					; >32768?
+	btfsc	hi,7					    ; >32768?
 	clrf	hi
 
 adjust_cfn_value3:
-	movf	divemins+0,W			; Store current value
+	movf	cf32_x4,W                   ; Store current value
 	addlw	0x82
 	movwf	EEADR
 	movff	lo,EEDATA
-	call	write_eeprom			; Lowbyte
-	movf	divemins+0,W
+	call	write_eeprom			    ; Lowbyte
+	movf	cf32_x4,W
 	addlw	0x83
 	movwf	EEADR
 	movff	hi,EEDATA
-	call	write_eeprom			; Highbyte 
+	call	write_eeprom			    ; Highbyte 
 	movlw	d'5'
 	movwf	menupos
-	bra		menu_custom_functions1	; also debounces switches
-
-getcustom15_default:
-	; # number of requested custom function in wreg
-	movwf	customfunction_temp2
-	
-	movlw	d'31'
-	cpfsgt	customfunction_temp2
-	bra		getcustom15_d2			; Lower bank
-	
-	movlw	d'1'					; Upper Bank
-	movwf	EEADRH
-	movlw	d'32'
-	subwf	customfunction_temp2,F
-	bra		getcustom15_d3
-getcustom15_d2:
-	clrf	EEADRH
-getcustom15_d3:
-	movf	customfunction_temp2,W
-	mullw	d'4'
-	movf	PRODL,W			; x4 for adress
-	addlw	d'128'
-	movwf	EEADR			; +130 for LOW Byte of value
-	call	read_eeprom		; Lowbyte
-	movff	EEDATA,lo
-	incf	EEADR,F
-	call	read_eeprom		; Highbyte
-	movff	EEDATA,hi
-	clrf	EEADRH
-#ifndef NO_CF_TYPES
-	btfss	hi,7			; Is it a 15bit value ?
-	clrf	hi				; NO: clear type flags.
-#endif
-	bcf		hi,7			; Always clear 15bit flag.
-	return					; return
-
-custom_functions_check_divemode:			;displays warning if a critical custom function is not set to default
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf11
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf12
-	return
-
-custom_functions_check_surfmode:			;displays warning if a critical custom function is not set to default
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf11
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf12
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf17
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf18
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf19
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf29
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf32
-	dcfsnz	cf_checker_counter,F			; counts custom functions to check for warning symbol
-	bra		check_cf33
-	return
-
-check_cf11:
-	movlw	d'11'					; saturation factor
-	rcall	custom_function_check_low	; compares current with default value
-	call	test_and_display_warning	; displays the warning if the custom function is not correct
-	movlw	d'2'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf12:
-	movlw	d'12'					; desaturation factor
-	rcall	custom_function_check_high	; compares current with default value
-	call	test_and_display_warning	; displays the warning if the custom function is not correct
-	movlw	d'3'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf17:
-	movlw	d'17'					; lower threshold ppO2
-	rcall	custom_function_check_low	; compares current with default value
-	call	test_and_display_warning	; displays the warning if the custom function is not correct
-	movlw	d'4'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf18:
-	movlw	d'18'					; upper threshold ppO2
-	rcall	custom_function_check_high	; compares current with default value
-	call	test_and_display_warning	; displays the warning if the custom function is not correct
-	movlw	d'5'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf19:
-	movlw	d'19'					; upper threshold ppO2 display
-	rcall	custom_function_check_high	; compares current with default value
-	call	test_and_display_warning	; displays the warning if the custom function is not correct
-	movlw	d'6'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf29:
-	movlw	d'6'
-	movwf	cf_checker_counter		; upper limit for CF29, here: used as a temp variable
-	movlw	d'29'					; last deco stop in [m]
-	rcall	custom_function_check_high_limit	; compares current with default value
-	call	test_and_display_warning			; displays the warning if the custom function is not correct
-	movlw	d'7'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf32:
-	movlw	d'32'					; GF LOW
-	rcall	custom_function_check_high	; compares current with default value
-	call	test_and_display_warning			; displays the warning if the custom function is not correct
-	movlw	d'8'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-check_cf33:
-	movlw	d'33'					; GF HIGH
-	rcall	custom_function_check_high	; compares current with default value
-	call	test_and_display_warning			; displays the warning if the custom function is not correct
-	movlw	d'1'						; next in testing row
-	movwf	cf_checker_counter			; 
-	return
-
-
-test_and_display_warning:
-	movwf	lo						; copy result
-	tstfsz	lo
-	return							; CF OK
-	goto	custom_warn_surfmode
-
-custom_function_check_low:					; Checks CF (#WREG)
-											; Returns WREG=0 if CF is lower then default
-	movwf	temp1							; save for custom value
-	call	getcustom15_1					; Get Current Value stored in hi and lo
-	movff	lo,sub_a+0
-	movff	hi,sub_a+1						; save value
-	
-	movf	temp1,w
-	call	getcustom15_default				; Get Default value stored in hi and lo
-	movff	lo,sub_b+0
-	movff	hi,sub_b+1						; save value
-	call	sub16							; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a
-	btfss	neg_flag						; negative?
-	retlw	.255							; no
-	retlw	.0								; yes
-
-custom_function_check_high:					; Checks CF (#WREG)
-											; Returns WREG=0 if CF is higher then default
-	movwf	temp1							; save for custom value
-	call	getcustom15_1					; Get Current Value stored in hi and lo
-	movff	lo,sub_b+0
-	movff	hi,sub_b+1						; save value
-	
-	movf	temp1,w
-	call	getcustom15_default				; Get Default value stored in hi and lo
-	movff	lo,sub_a+0
-	movff	hi,sub_a+1						; save value
-	call	sub16							; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a
-	btfss	neg_flag						; negative?
-	retlw	.255							; no
-	retlw	.0								; yes
-
-custom_function_check_high_limit:			; Checks if CF (#WREG) is lower then limit (#cf_checker_counter)
-	movwf	temp1							; save for custom value
-	call	getcustom15_1					; Get Current Value stored in hi and lo
-	movff	lo,sub_b+0
-	movff	hi,sub_b+1						; save value
-	movff	cf_checker_counter, sub_a+0
-	clrf	sub_a+1
-	call	sub16							; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a
-	btfss	neg_flag						; negative?
-	retlw	.255							; no
-	retlw	.0								; yes
\ No newline at end of file
+	bra		menu_custom_functions1	    ; also debounces switches