changeset 99:39d325b2a5f9

FIX bad warning for 15bits CF values
author JeanDo
date Sun, 12 Dec 2010 16:47:32 +0100
parents 6f8e3a08011e
children db4a20b413df
files code_part1/OSTC_code_asm_part1/divemode_menu.asm code_part1/OSTC_code_asm_part1/menu_custom.asm code_part1/OSTC_code_asm_part1/menu_reset.asm
diffstat 3 files changed, 38 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sun Dec 12 15:01:05 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sun Dec 12 16:47:32 2010 +0100
@@ -543,7 +543,7 @@
 	movff	EEDATA, char_I_N2_ratio		; = N2!
 	bsf		manual_gas_changed			; set event flag
 	bsf		event_occured				; set global event flag
-bsf		is_bailout					;=1: CC mode, but bailout active!		
+    bsf		is_bailout					;=1: CC mode, but bailout active!		
 	clrf	lo							; clear Setpoint, PLED_const_ppO2_value now displayes "Bail"
 	movff	lo,char_I_const_ppO2		
 	bra		timeout_divemenu2			; quit underwater menu!
--- a/code_part1/OSTC_code_asm_part1/menu_custom.asm	Sun Dec 12 15:01:05 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm	Sun Dec 12 16:47:32 2010 +0100
@@ -1,4 +1,3 @@
-
 ; OSTC - diving computer code
 ; Copyright (C) 2008 HeinrichsWeikamp GbR
 
@@ -423,6 +422,10 @@
 ; 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:
+; Min/max unsupported for 15bit values yet...
+    btfsc   cf_type,7           ; A 15bit value ?
+    return
+
 	movff	EEADRH, FSR1H		; Backup...
 
 ; Display min line
@@ -756,6 +759,13 @@
 ; Trashes: TBLPTR, EEADR, PROD
 
 check_customfunctions:
+;   rcall   check_next_cf               ; Check 5 at a time...
+;   rcall   check_next_cf
+;   rcall   check_next_cf
+;   rcall   check_next_cf
+;
+;check_next_cf:
+
     movf    cf_checker_counter,W        ; Get current CF to ckeck
 
     ; Setup cf32_x4 and cf page bit:
@@ -805,12 +815,13 @@
     btfss   cf_type,7                   ; 15 or 8 bit value ?
     bra     cf_check_8bit
     
-; Do a 15bit check
+; Implement the 15bit check, even if not displayed...
     rcall   getcustom15_1               ; Read into hi:lo
 
     movf    cf_min,W                    ; Compute (bound-value) -> hi:lo
     subwf   lo,F
     movf    cf_max,W
+    bcf     WREG,7                      ; Clear min or max bit
     subwfb  hi,F
 
     movf    lo,W                        ; Is it a 0 result ?
@@ -819,7 +830,7 @@
     retlw   -1                          ; YES: then it is ok.
 
 cf_15_not_equal:
-    btfss   cf_type,CF_MIN_BIT          ; Checking min or max ?
+    btfss   cf_max,7                    ; Checking min or max ?
     btg     hi,6                        ; exchange wanted sign
     
     setf    WREG                        ; -1 for return w/o error
--- a/code_part1/OSTC_code_asm_part1/menu_reset.asm	Sun Dec 12 15:01:05 2010 +0100
+++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm	Sun Dec 12 16:47:32 2010 +0100
@@ -35,40 +35,47 @@
 ; If in types mode, set flags into hi. If not, clear it.
 CF_DEFAULT	macro	type, default, min, max
     noexpand
+CFn set 1+CFn
     if (type) == CF_INT15
-    	if (HIGH (default)) > .127
-    		error "CF# 15bit default too big:", value
+    	if HIGH (default) > .127
+    		error CF#v(CFn) "15bit default too big: ", default
     	endif
     	if (min)>0 && (max>min)
-    	    error "CF# 15bit defaults cannot have both MIN & MAX flags"
+    	    error CF#v(CFn) "15bit defaults cannot have both MIN & MAX flags"
+    	endif
+    	if HIGH(min) > .127
+    	    error CF#v(CFn) "15bit MIN value too big: ", min
+    	endif
+    	if HIGH(max) > .127
+    	    error CF#v(CFn) "15bit MAX value too big: ", max
     	endif
     
         ifdef NO_CF_TYPES
     		DB  LOW (default), HIGH(default) + 0x80
     	else
     		DB  LOW (default), HIGH(default) + 0x80
-    		if (min) > 0
+    		if (max) > (min)
+        		DB  LOW(max), HIGH(max) + 0x80
+        	else
         		DB  LOW(min), HIGH(min)
-        	else
-        		DB  LOW(min), HIGH(min) + 0x80
         	endif
     	endif
     else
         ; Basic sanity check for 8bit values:
     	if HIGH(default) > 0
-    		error "CF# 8bit default too big:", (default)
+    		error CF#v(CFn) "8bit default too big: ", default
     	endif
     	if HIGH(min) > 0
-    		error "CF# 8bit min too big:", (min)
+    		error CF#v(CFn) "8bit min too big: ", min
     	endif
     	if HIGH(max) > 0
-    		error "CF# 8bit max too big:", (max)
+    		error CF#v(CFn) "8bit max too big: ", max
     	endif
     	if ((type)==CF_BOOL) && ( (default)>1 )
-    		error "CF# BOOL default too big:", (default)
+    		error CF#v(CFn) "BOOL default too big: ", default
     	endif
     	if ((type)==CF_BOOL) && ( (min)>0 || (max)>0 )
-    		error "CF# BOOL cannot have min/max"
+    		error CF#v(CFn) "BOOL cannot have min/max"
     	endif
     
         ifdef NO_CF_TYPES
@@ -89,7 +96,7 @@
     endm
 
 ; Starting at CF0
-CF_NUMBER   set     -1
+CFn set     -1
 
 ; resets all customfunctions to the following default values
 cf_default_table0:
@@ -142,25 +149,24 @@
 	CF_DEFAULT    CF_COLOR,     d'199', 0,      0 		; color_battery_surface		Color Battery sign: Deep blue
 	CF_DEFAULT    CF_COLOR,     d'255', 0,      0 		; color_standard1			Color Standard: White
 	CF_DEFAULT    CF_COLOR,     d'62',  0,      0 		; color_divemask			Color Divemask: Light green
+    
 	CF_DEFAULT    CF_COLOR,     d'224', 0,      0 		; color_warnings			Color Warnings: Red
-    
 	CF_DEFAULT    CF_BOOL,	    d'0',   0,      0       ; show_seconds_divemode		=1 Show the seconds in Divemode
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	CF_DEFAULT    CF_BOOL,	    d'1',   0,      0       ; warn_ceiling_divemode		=1 Warn ceiling violation in divemode
 	CF_DEFAULT    CF_BOOL, 	    d'0',   0,      0       ; start_with_stopwatch		=1 start with stopwatch
+    
 	CF_DEFAULT    CF_BOOL,	    d'0',   0,      0       ; blink_gas_divemode 		=1 Show (resetable) average Depth instead of temperature
-    
 	CF_DEFAULT    CF_INT15,     d'13000', 0,    0		; color_warn_depth_mBar		Warn depths
 	CF_DEFAULT    CF_PERCENT,	d'101', d'50',  d'101'	; color_warn_cns_percent    Warn-%
 	CF_DEFAULT    CF_PERCENT,	d'101', d'50',  d'101'  ; color_warn_gf_percent		Warn-%
 	CF_DEFAULT    CF_CENTI,     d'161', d'100', d'161'  ; color_warn_ppo2_cbar		ppO2 warn
+    
 	CF_DEFAULT    CF_INT8,	    d'15',  d'7',   d'20'	; color_warn_celocity_mmin	warn at xx m/min
-    
 	CF_DEFAULT    CF_SEC,	    d'42',  d'0',   d'240'  ; time_correction_value_default	Adds to Seconds on Midnight
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	CF_DEFAULT    CF_INT15,     0,      0,      0       ; UNUSED
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
-	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	                
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
@@ -176,6 +182,7 @@
 	                
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
+	CF_DEFAULT    CF_INT15,     0,      0,      0 		; UNUSED
 cf_default_table2:
 
 ;=============================================================================