annotate src/options.asm @ 634:4050675965ea

3.10 stable release
author heinrichsweikamp
date Tue, 28 Apr 2020 17:34:31 +0200
parents 185ba2f91f59
children 070528a88715
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
3 ; File options.asm * next combined generation V3.09.4n
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Manage all options data.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-07-12 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11 ;
heinrichsweikamp
parents:
diff changeset
12
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
13 #include "hwos.inc" ; mandatory header
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
14 #include "strings.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
15 #include "convert.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
16 #include "ghostwriter.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
17 #include "eeprom_rs232.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
18 #include "external_flash.inc"
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
19 #include "wait.inc"
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
20 #include "shared_definitions.h"
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
21 #include "gaslist.inc"
0
heinrichsweikamp
parents:
diff changeset
22
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
23 extern write_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
24 extern read_eeprom
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
25 extern option_table_begin,option_table_end
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
26 extern convert_meter_to_feet
0
heinrichsweikamp
parents:
diff changeset
27
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
28
0
heinrichsweikamp
parents:
diff changeset
29 ;=============================================================================
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
30 options1 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
31 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
32
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
33
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
34 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
35 ; Adjust Address in FSR0 to an Option within an Option Group
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
36 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
37 ; INPUT: FSR0 = base address of the option group
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
38 ; gaslist_gas = offset of the selected option within the group
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
39 ; OUTPUT: FSR0 = pointing to selected option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
40 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
41 global option_adjust_group_member
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
42 option_adjust_group_member:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
43 movf gaslist_gas,W ; get offset in number of options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
44 mullw opt_definition_bytes ; calculate offset in number of bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
45 movf PRODL,W ; get number of bytes, low byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
46 addwf FSR0L,F ; add to FSR0, low byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
47 movf PRODH,W ; get number of bytes, high byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
48 addwfc FSR0H,F ; add to FSR0, high byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
49 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
50
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
51
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
52 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
53 ; Read the Option Definition
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
54 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
55 ; INPUT: FSR0 = option handle
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
56 ; OUTPUT: FSR1 = address of variable.
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
57 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
58 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
59 option_read_definition:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
60 ; option_table_begin is at 0x0|80|00
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
61 clrf TBLPTRU ; TBLPRT upper = 0x00
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
62 movlw HIGH(option_table_begin) ; TBLPRT high = 0x80
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
63 iorwf FSR0H,W ; + 0x0H from FSR0H
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
64 movwf TBLPTRH ; set 0x8H
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
65 movff FSR0L,TBLPTRL ; TBLPRT low = 0xLL from FSR0L
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
66 ; copy option definition from program to data memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
67 lfsr FSR1,opt_type ; load FSR1 with base address of option definition buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
68 movlw opt_definition_bytes ; get number of bytes to copy
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
69 movwf eeprom_loop ; initialize loop counter (using an EEPROM variable here)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
70 option_read_definition_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
71 tblrd*+ ; read one byte from program memory and increment address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
72 movff TABLAT,POSTINC1 ; transfer byte from program memory to memory
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
73 decfsz eeprom_loop,F ; all bytes done?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
74 bra option_read_definition_loop ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
75 tblrd* ; YES - read one byte ahead without incrementing address
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
76 movff TABLAT,POSTINC1 ; - store byte
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
77 movff opt_memory+0,FSR1L ; - load FSR1 with the address of the option value variable
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
78 movff opt_memory+1,FSR1H ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
79 movff TBLPTRL,FSR0L ; - advance handle to the next option definition data set
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
80 movff TBLPTRH,FSR0H ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
81 return ; - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
82
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
83
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
84 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
85 ; Reset all Options to Factory Defaults
0
heinrichsweikamp
parents:
diff changeset
86 ;
heinrichsweikamp
parents:
diff changeset
87 ; INPUT: none
heinrichsweikamp
parents:
diff changeset
88 ; OUTPUT: none
heinrichsweikamp
parents:
diff changeset
89 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, FSR2
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
90 ;
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
91 global option_reset_all ; reset all options to factory default
0
heinrichsweikamp
parents:
diff changeset
92 option_reset_all:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
93 call eeprom_total_dives_read ; read total number of dives
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
94 tstfsz mpr+0 ; number of total dives, low byte = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
95 bra option_reset_all_1 ; NO - skip resetting logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
96 tstfsz mpr+1 ; number of total dives, high byte = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
97 bra option_reset_all_1 ; NO - skip resetting logbook
0
heinrichsweikamp
parents:
diff changeset
98
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
99 ; reset logbook
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
100 call erase_complete_logbook ; erase complete logbook
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
101
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
102 ; reset logbook offset
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
103 CLRI mpr ; set logbook offset to zero
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
104 call eeprom_log_offset_write ; store logbook offset
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
105
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
106 option_reset_all_1:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
107 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
108 option_reset_all_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
109 rcall option_reset ; reset option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
110 incfsz opt_end_token,F ; was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
111 bra option_reset_all_loop ; NO - do next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
112 return ; YES - done
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
113
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 18
diff changeset
114
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
115 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
116 ; Reset an Option to its default Value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
117 ;
0
heinrichsweikamp
parents:
diff changeset
118 ; INPUT: FSR0 = option handle
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
119 ; OUTPUT: option value set to default value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
120 ; option_repaired flag set
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
121 ; option_changed flag set if not a volatile option
0
heinrichsweikamp
parents:
diff changeset
122 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2
heinrichsweikamp
parents:
diff changeset
123 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
124 global option_reset ; reset option value to default
0
heinrichsweikamp
parents:
diff changeset
125 option_reset:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
126 ; read type, default and register from table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
127 rcall option_read_definition ; read option definition
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
128 btfss opt_eeprom_bank,7 ; volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
129 bsf option_changed ; NO - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
130 ;bra option_init_loaded ; continue initializing the option value
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
131
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
132
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
133 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
134 ; Reset an Option to its default Value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
135 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
136 ; INPUT: opt_* option definition vars initialized
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
137 ; OUTPUT: option value set to default value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
138 ; TRASH: TBLPTR, TABLAT, WREG, FSR1, FSR2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
139 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
140 option_init_loaded:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
141 movf opt_type,W ; get option type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
142 xorlw .2 ; type = STRING ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
143 bz opt_init_loaded_string ; YES - string copy
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
144 movff opt_default,INDF1 ; NO - 1 byte copy
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
145 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
146
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
147 opt_init_loaded_string:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
148 movff TBLPTRL,mpr+0 ; back-up TBLPTR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
149 movff TBLPTRH,mpr+1 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
150 movff TBLPTRU,mpr+2 ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
151
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
152 movff FSR1L,FSR2L ; set string destination address
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
153 movff FSR1H,FSR2H ; ...
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
154 movff opt_inc,FSR1L ; get pointer to multi-lingual default text (stored in opt_inc:opt_min)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
155 movff opt_min,FSR1H ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
156 call strcat_text_FSR ; copy translated text to FSR2, hence string option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
157
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
158 movff mpr+0,TBLPTRL ; restore TBLPTR
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
159 movff mpr+1,TBLPTRH ; ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
160 movff mpr+2,TBLPTRU ; ...
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
161
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
162 return ; done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
163
0
heinrichsweikamp
parents:
diff changeset
164
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
165 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
166 ; Check one Option and reset its Value if it is out of its min/max Limits
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
167 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
168 ; INPUT: opt_* vars loaded, FSR1 pointing to option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
169 ; hi value to be checked for validity
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
170 ; OUTPUT: option_value_ok set/not set
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
171 ; TRASH: WREG
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
172 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
173 global option_check_loaded
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
174 option_check_loaded:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
175 ; switch on type
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
176 bsf option_value_ok ; set result to ok by default
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
177 movf opt_type,W ; get type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
178 bz option_check_uint8 ; type 0: INT8
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
179 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
180 bra option_check_enum8 ; type 1: ENUM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
181 dcfsnz WREG ; decrement
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
182 return ; type 2: STRING - nothing to check
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
183 ;bra option_check_uint8 ; type 3: INT8
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
184
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
185 option_check_uint8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
186 tstfsz opt_min ; opt_min = 0 ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
187 bra option_check_min ; NO - check it
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
188 bra option_check_enum8 ; YES - continue with check for maximum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
189
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
190 option_check_min:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
191 decf opt_min,W ; get (minimum permissible value - 1) into WREG
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
192 cpfsgt hi ; option value > (minimum permissible value - 1) ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
193 bra option_check_nok ; NO - value not ok
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
194 ;bra option_check_enum8 ; YES - continue with check for maximum
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
195
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
196 option_check_enum8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
197 infsnz opt_max,W ; get (highest permissible value + 1) into WREG
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
198 return ; highest permissible value is 255, skip check, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
199 cpfslt hi ; option value < (highest permissible value + 1) ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
200 bra option_check_nok ; NO - value not ok
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
201 return ; YES - value ok, done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
202
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
203 option_check_nok:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
204 bcf option_value_ok ; flag option value is invalid
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
205 return ; done
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
206
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
207
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
208 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
209 ; Check and store all Option Values to EEPROM
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
210 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
211 global option_check_and_store_all
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
212 option_check_and_store_all:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
213 bcf PIR3,RC2IE ; disable EUSART interrupts TODO: why???
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
214 call option_crosschecks ; do some crosschecks between option values
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
215 ;bra option_store_all ; continue storing all option values to EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
216
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
217
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
218 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
219 ; Store all Option Values to EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
220 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
221 option_store_all:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
222 ;---- invalidate option version while updating
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
223 CLRI mpr ; set options version number to zero
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
224 EEPROM_II_WRITE mpr,eeprom_options_version ; store options version number in EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
225
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
226 ;---- check and store all option values
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
227 lfsr FSR0,option_table_begin ; point to start of option definition table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
228 option_save_all_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
229 rcall option_check_and_store ; check and store option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
230 incfsz opt_end_token,F ; was this the last option (was opt_end_token = 255) ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
231 bra option_save_all_loop ; NO - do next option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
232
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
233 ;---- store option version
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
234 MOVLI eeprom_opt_version,mpr ; get options version number
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
235 EEPROM_II_WRITE mpr,eeprom_options_version ; store options version number in EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
236
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
237 bcf option_changed ; no pending EEPROM updates any more
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
238 return ; done
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
239
0
heinrichsweikamp
parents:
diff changeset
240
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
241 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
242 ; Check and store one Option Value to EEPROM
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
243 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
244 global option_check_and_store
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
245 option_check_and_store:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
246 rcall option_read_definition ; read the option definition
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
247 movff INDF1,hi ; check current option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
248 rcall option_check_loaded ; check value for validity
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
249 btfss option_value_ok ; value ok (strings are always 'valid') ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
250 movff opt_default,INDF1 ; NO - set value to default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
251 ;bra option_store_loaded ; continue storing value
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
252
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
253
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
254 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
255 ; Store one Option Value to EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
256 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
257 global option_store_loaded
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
258 option_store_loaded:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
259 movf opt_eeprom_bank,W ; get bank
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
260 andlw b'11111110' ; keep only bits 7-1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
261 tstfsz WREG ; bank < 0x02 ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
262 return ; NO - volatile option or illegal address, done/abort
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
263 tstfsz opt_eeprom_bank ; YES - bank = 0 ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
264 bra option_store_execute ; NO - address is valid in any case
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
265 movlw low(eeprom_options_storage-1) ; YES - get start address of options storage minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
266 cpfsgt opt_eeprom_index ; - index >= start address ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
267 return ; NO - illegal address, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
268 ;bra option_store_execute ; YES - address is valid
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
269
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
270 option_store_execute:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
271 movff opt_eeprom_index,EEADR ; set EEPROM index (address low byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
272 movff opt_eeprom_bank, EEADRH ; set EEPROM page (address high byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
273
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
274 movf opt_type,W ; get option type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
275 xorlw .2 ; option type = string ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
276 bz option_store_exec_string ; YES - store string of bytes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
277 ;bnz option_store_exec_byte ; NO - store single byte
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
278
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
279 option_store_exec_byte:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
280 call read_eeprom ; read stored value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
281 movf EEDATA,W ; copy stored value to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
282 xorwf INDF1,W ; xor with current value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
283 btfsc STATUS,Z ; equal?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
284 return ; YES - no need to write to EEPROM, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
285 movff INDF1,EEDATA ; NO - copy current option value to EEPROM write register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
286 goto write_eeprom ; - execute write and return
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
287
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
288 option_store_exec_string:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
289 btfss EEADRH,1 ; current EEPROM address < 512 ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
290 rcall option_store_exec_byte ; YES - store one byte from the string
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
291 movf POSTINC1,W ; increment FSR1 address by a dummy read
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
292 infsnz EEADR,F ; increment EEPROM address, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
293 incf EEADRH,F ; increment EEPROM address, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
294 decfsz opt_max ; decrement string length, done?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
295 bra option_store_exec_string ; NO - loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
296 return ; YES - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
297
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
298
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
299 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
300 ; Restore all Option Values from EEPROM and check them
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
301 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
302 global option_restore_and_check_all
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
303 option_restore_and_check_all:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
304 ;---- Read option version from EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
305 EEPROM_II_READ eeprom_options_version,mpr
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
306
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
307 movlw LOW(eeprom_opt_version) ; get options version from current firmware, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
308 xorwf mpr+0,W ; compare with EEPROM version, do they match?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
309 bnz option_restore_reset ; NO - reset to defaults of current firmware
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
310
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
311 movlw HIGH(eeprom_opt_version) ; get options version from current firmware, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
312 xorwf mpr+1,W ; compare with EEPROM version, do they match?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
313 bnz option_restore_reset ; NO - reset to defaults of current firmware
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
314
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
315 ;---- restore all option values
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
316 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
317 option_restore_all_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
318 rcall option_restore_and_check ; restore and check the option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
319 incfsz opt_end_token,F ; was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
320 bra option_restore_all_loop ; NO - do next option
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
321
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
322 bcf option_changed ; clear flag
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
323 call option_crosschecks ; do some crosschecks between option values
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
324 btfsc option_changed ; found and corrected errors?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
325 bra option_store_all ; YES - write back corrected data to EEPROM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
326 return ; NO - done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
327
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
328 option_restore_reset:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
329 call option_reset_all ; reset all option values to their default
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
330 goto option_check_and_store_all ; write back all option values to EEPROM (and return)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
331
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
332
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
333 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
334 ; Restore one Option Value from EEPROM and check it
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
335 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
336 global option_restore_and_check
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
337 option_restore_and_check:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
338 rcall option_read_definition ; read the option definition
0
heinrichsweikamp
parents:
diff changeset
339
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
340 movf opt_eeprom_bank,W ; get bank
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
341 andlw b'11111110' ; keep only bits 7-1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
342 tstfsz WREG ; bank < 0x02 ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
343 bra option_init_loaded ; NO - volatile option or illegal address, initialize to default
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
344 tstfsz opt_eeprom_bank ; YES - bank = 0 ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
345 bra option_restore_execute ; NO - address is valid in any case
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
346 movlw low(eeprom_options_storage-1) ; YES - get start address of options storage minus 1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
347 cpfsgt opt_eeprom_index ; - index >= start address ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
348 bra option_init_loaded ; NO - illegal address, initialize to default
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
349 ;bra option_restore_execute ; YES - address is valid
0
heinrichsweikamp
parents:
diff changeset
350
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
351 option_restore_execute:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
352 movff opt_eeprom_index,EEADR ; set EEPROM index (address low byte)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
353 movff opt_eeprom_bank, EEADRH ; set EEPROM page (address high byte)
0
heinrichsweikamp
parents:
diff changeset
354
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
355 movf opt_type,W ; get option type
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
356 xorlw .2 ; option type = string ?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
357 bz option_restore_exec_string ; YES - special handling
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
358 call read_eeprom ; NO - execute EEPROM read
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
359 movff EEDATA,INDF1 ; - copy from EEPROM read register to option variable
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
360 movff EEDATA,hi ; - check loaded option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
361 rcall option_check_loaded ; - check if option value is within min/max limits
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
362 btfsc option_value_ok ; - option value ok (strings will always be 'ok') ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
363 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
364 movff opt_default,INDF1 ; NO - set option value to default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
365 movff INDF1,EEDATA ; - copy repaired value to EEPROM write register
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
366 goto write_eeprom ; - execute write and return
0
heinrichsweikamp
parents:
diff changeset
367
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
368 option_restore_exec_string:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
369 call read_eeprom ; read one character from the EEPROM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
370 movff EEDATA,POSTINC1 ; copy it to the option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
371 infsnz EEADR,F ; increment EEPROM address, low byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
372 incf EEADRH,F ; increment EEPROM address, high byte
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
373 decfsz opt_max ; decrement string length, done?
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
374 bra option_restore_exec_string ; NO - loop
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
375 return ; YES - done (nothing to check with strings)
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
376
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
377
0
heinrichsweikamp
parents:
diff changeset
378
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
379 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
380 ; Read an Option Value via serial Index
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
381 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
382 ; INPUT: lo = serial index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
383 ; OUTPUT: hi = option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
384 ; WREG =0: option found and value valid, =1: option not found
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
385 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
386 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
387 global option_read_serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
388 option_read_serial:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
389 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
390 option_read_serial_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
391 rcall option_read_definition ; read option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
392 movf opt_serial,W ; get serial index of the option into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
393 xorwf lo,W ; received index = index of this option ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
394 bz option_read_serial_execute ; YES - read value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
395 incfsz opt_end_token,F ; NO - was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
396 bra option_read_serial_loop ; NO - try next option
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
397 retlw .1 ; YES - option not found, abort
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
398
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
399 option_read_serial_execute:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
400 movff INDF1,hi ; read option value into hi
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
401 retlw .0 ; done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
402
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
403
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
404 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
405 ; Write an Option Value via serial Index
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
406 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
407 ; INPUT: lo = serial index
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
408 ; hi = option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
409 ; OUTPUT: WREG =0: option found and value valid, =1: option not found, =2: value not valid
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
410 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1, up
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
411 ;
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
412 global option_write_serial
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
413 option_write_serial:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
414 lfsr FSR0,option_table_begin ; point to start of option definition table
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
415 option_write_serial_loop:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
416 rcall option_read_definition ; read option definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
417 movf opt_serial,W ; get serial index of the option into WREG
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
418 xorwf lo,W ; received index = index of this option ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
419 bz option_write_serial_execute ; YES - check and update value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
420 incfsz opt_end_token,F ; NO - was this the last option (was opt_end_token = 255) ?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
421 bra option_write_serial_loop ; NO - try next option
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
422 retlw .1 ; YES - option not found, abort
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
423
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
424 option_write_serial_execute:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
425 rcall option_check_loaded ; check if new value is valid
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
426 btfss option_value_ok ; value valid?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
427 retlw .2 ; NO - value not valid, abort
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
428 movff hi,INDF1 ; YES - take new value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
429 btfss opt_eeprom_bank,7 ; - volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
430 bsf option_changed ; NO - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
431 retlw .0 ; - done
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
432
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
433
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
434 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
435 ; Increment an Option Value based on Type and min/max Boundary
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
436 ;
0
heinrichsweikamp
parents:
diff changeset
437 ; INPUT: FSR0 = option handle
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
438 ; OUTPUT: incremented option value
0
heinrichsweikamp
parents:
diff changeset
439 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
440 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
441 global option_inc
0
heinrichsweikamp
parents:
diff changeset
442 option_inc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
443 ; read type, default and register from table
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
444 rcall option_read_definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
445
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
446 btfss opt_eeprom_bank,7 ; volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
447 bsf option_changed ; NO - flag that EEPROM needs to be updated
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
448
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
449 ; switch on type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
450 movf opt_type,W ; get option type
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
451 bz option_inc_uint8 ; type 0: UINT8
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
452 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
453 bra option_inc_enum8 ; type 1: ENUM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
454 dcfsnz WREG ; decrement
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
455 return ; type 2: STRING - no inc function defined
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
456 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
457 bra option_inc_uint8 ; type 3: UINT8 as meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
458 return ; unknown, do nothing
0
heinrichsweikamp
parents:
diff changeset
459
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
460
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
461 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
462 ; Helper Function - increment UINT8, wrap-around or stop at option max
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
463 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
464 option_inc_uint8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
465 movf INDF1,W ; get option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
466 addwf opt_inc,W ; add increment
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
467 cpfslt opt_max ; option value > max ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
468 bra option_inc_uint8_0 ; NO - new option value ok
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
469 movf opt_min,W ; YES - reset to min value by default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
470 btfsc option_stop_at_max ; - shall the option value stop at max?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
471 movf opt_max,W ; YES - keep at max value
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
472 option_inc_uint8_0:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
473 movwf INDF1 ; store new value
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
474 ; do cross-checks with other option values
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
475 option_inc_uint8_1:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
476 ; now some rather crude hack into this routine to make CCR calibration more convenient:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
477 movlw 0x37 ; serial ID of option CalGasO2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
478 cpfseq opt_serial ; editing CalGasO2 right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
479 bra option_inc_uint8_2 ; NO - check next option
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
480 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
481 decfsz WREG,W ; - in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
482 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
483 movlw .26 ; YES -
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
484 cpfseq INDF1 ; - option value = 26 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
485 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
486 movlw .95 ; YES - advance it to 95
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
487 movwf INDF1 ; - store it
533
dfac393b2199 CHANGE: CCR Calibration gas range limited to O2% 21-25 and 95-100 to save button presses
heinrichsweikamp
parents: 418
diff changeset
488 return
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
489
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
490 option_inc_uint8_2:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
491 ; check GF low <= GF high
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
492 movlw 0x25 ; serial ID of option opt_GF_low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
493 cpfseq opt_serial ; editing opt_GF_low right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
494 bra option_inc_uint8_3 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
495 movff opt_GF_high,WREG ; get value of associated GF high into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
496 cpfsgt INDF1 ; GF low > GF high?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
497 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
498 movff opt_min,INDF1 ; YES - wrap around to minimum value
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
499 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
500
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
501 option_inc_uint8_3:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
502 ; check GF high >= GF low
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
503 movlw 0x26 ; serial ID of option opt_GF_high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
504 cpfseq opt_serial ; editing opt_GF_high right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
505 bra option_inc_uint8_4 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
506 movff opt_GF_low,WREG ; get value of associated GF low into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
507 cpfslt INDF1 ; GF high < GF low?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
508 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
509 movwf INDF1 ; YES - rise GF high to GF low
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
510 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
511
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
512 option_inc_uint8_4:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
513 ; check aGF low <= aGF high
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
514 movlw 0x27 ; serial ID of option opt_aGF_low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
515 cpfseq opt_serial ; editing opt_aGF_low right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
516 bra option_inc_uint8_5 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
517 movff opt_aGF_high,WREG ; get value of associated GF high into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
518 cpfsgt INDF1 ; GF low > GF high?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
519 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
520 movff opt_min,INDF1 ; YES - wrap around to minimum value
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
521 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
522
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
523 option_inc_uint8_5:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
524 ; check aGF high >= aGF low
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
525 movlw 0x28 ; serial ID of option opt_aGF_high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
526 cpfseq opt_serial ; editing opt_aGF_high right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
527 bra option_inc_uint8_6 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
528 movff opt_aGF_low,WREG ; get value of associated GF low into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
529 cpfslt INDF1 ; GF high < GF low?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
530 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
531 movwf INDF1 ; YES - rise GF high to GF low
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
532 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
533
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
534 option_inc_uint8_6:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
535 ; progressive increment for char_I_SAC_work
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
536 movlw 0x3C ; serial ID of option char_I_SAC_work
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
537 cpfseq opt_serial ; editing char_I_SAC_work right now?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
538 bra option_inc_uint8_7 ; NO - check next option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
539 movlw .40 ; YES - set threshold for incrementing in steps of 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
540 cpfsgt INDF1 ; - option value > threshold ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
541 return ; NO - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
542 incf INDF1,F ; YES - increment one more time
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
543 return ; - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
544
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
545 option_inc_uint8_7:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
546 IFDEF _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
547 ; check O2% + He% <= 100%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
548 movlw 0xFA ; serial ID of O2% options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
549 cpfseq opt_serial ; editing a O2% right now?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
550 bra option_inc_uint8_7a ; NO - check for He%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
551 movlw .2*NUM_GAS ; YES - load offset between O2% and He% for gas/dil 1-5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
552 btfsc opt_eeprom_bank,7 ; - volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
553 movlw .1 ; YES - load offset between O2% and He% for gas 6
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
554 bra option_inc_uint8_7b ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
555 option_inc_uint8_7a:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
556 movlw 0xFB ; serial ID of He% options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
557 cpfseq opt_serial ; editing a He% right now?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
558 bra option_inc_uint8_8 ; NO - check next option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
559 movlw -.2*NUM_GAS ; YES - load offset between He% and O2% for gas/dil 1-5
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
560 btfsc opt_eeprom_bank,7 ; - volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
561 movlw -.1 ; YES - load offset between He% and O2% for gas 6
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
562 option_inc_uint8_7b:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
563 movff PLUSW1,hi ; - copy complementing gas % to hi
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
564 movf INDF1,W ; - copy primary gas % to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
565 addwf hi,F ; - hi = O2% + He%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
566 movlw .101 ; - load max allowed sum + 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
567 cpfslt hi ; - O2% + He% < 101 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
568 decf INDF1,F ; NO - decrement primary gas% again
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
569 ENDIF ; _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
570
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
571 option_inc_uint8_8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
572 ; add more cross-checks with other option values here
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
573 return ; all done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
574
0
heinrichsweikamp
parents:
diff changeset
575
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
576 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
577 ; Helper Function - increment ENUM, will wrap-around on exceeding option max
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
578 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
579 option_inc_enum8:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
580 incf INDF1,W ; get incremented option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
581 cpfslt opt_max ; option value > max?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
582 bra option_inc_enum8_0 ; NO - new option value ok
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
583 clrf WREG ; YES - reset to 1st option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
584 option_inc_enum8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
585 movwf INDF1 ; store new value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
586 ; do cross-checks with other option values
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
587 option_inc_enum8_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
588 IFDEF _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
589 ; now some rather crude hack into this routine to unify CCR & pSCR mode setting
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
590 movlw 0x1F ; serial ID of option oCCRMode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
591 cpfseq opt_serial ; editing oCCRMode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
592 bra option_inc_enum8_2 ; NO - check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
593 IFDEF _external_sensor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
594 btfsc ext_input_s8_ana ; YES - S8/analog input available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
595 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
596 btfsc ext_input_optical ; - optical interface available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
597 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
598 ENDIF ; _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
599 movf INDF1,W ; NO to both - get mode (=0: fixed SP, =1: Sensor, =2: AutoSP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
600 xorlw .1 ; - in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
601 bnz option_inc_enum8_1a ; NO - continue with next check
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
602 incf INDF1,F ; YES - advance option value to AutoSP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
603 option_inc_enum8_1a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
604 movff opt_dive_mode,WREG ; get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
605 xorlw .4 ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
606 bnz option_inc_enum8_1_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
607 bcf INDF1,1 ; YES - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
608 option_inc_enum8_1_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
609 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
610 ENDIF ; _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
611
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
612 option_inc_enum8_2:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
613 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
614 ; now some rather crude hack to switch off contingency mode if gas needs calculation is switched off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
615 movlw 0x5A ; serial ID of option opt_calc_gasvolume
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
616 cpfseq opt_serial ; editing opt_calc_gasvolume right now?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
617 bra option_inc_enum8_3 ; NO - check next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
618 movf INDF1,W ; YES - get option value
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
619 ;xorlw .0 ; - option value = off ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
620 bnz option_inc_enum8_2_exit ; NO - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
621 clrf WREG ; YES - force contingency to be off, too
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
622 movff WREG,opt_gas_contingency_dive ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
623 option_inc_enum8_2_exit:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
624 return
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
625 ENDIF ; _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
626
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
627 option_inc_enum8_3:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
628 ; now some rather crude hack to correct opt_TR_mode in dependency of opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
629 movlw 0x20 ; serial ID of option opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
630 cpfseq opt_serial ; editing opt_dive_mode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
631 bra option_inc_enum8_4 ; NO - check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
632 movf INDF1,W ; YES - get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
633 xorlw .1 ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
634 bnz option_inc_enum8_3a ; NO - in some other mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
635 IFNDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
636 incf INDF1,f ; YES - no CCR mode compiled in, advance to gauge mode
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
637 bra option_inc_enum8_3a ; - check if gauge mode is available
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
638 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
639 IFDEF _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
640 global option_cleanup_oTrMode_CCR ; embedded clean-up entry-point
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
641 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
642 movff opt_TR_mode,WREG ; get TR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
643 xorlw .2 ; mode = 2 (ind.double)?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
644 bnz option_inc_enum8_3_exit ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
645 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
646 ENDIF ; _rx_functions
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
647 option_inc_enum8_3a: ; any mode other than CCR
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
648 IFNDEF _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
649 movf INDF1,W ; get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
650 xorlw .2 ; in Gauge mode?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
651 bnz option_inc_enum8_3b ; NO - in some other mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
652 incf INDF1,f ; YES - no Gauge mode compiled in, advance to Apnea mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
653 bra option_inc_enum8_3_exit ; - done (Apnea mode is always available)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
654 ENDIF ; _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
655 option_inc_enum8_3b:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
656 IFNDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
657 movf INDF1,W ; get option value: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
658 xorlw .4 ; in pSCR mode?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
659 bnz option_inc_enum8_3c ; NO - in some other mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
660 clrf INDF1 ; YES - no pSCR mode compiled in, advance to 0 "OC"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
661 bra option_inc_enum8_3_exit ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
662 ENDIF ; _ccr_pscr
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
663 option_inc_enum8_3c:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
664 global option_cleanup_oTrMode_no_CCR ; embedded clean-up entry-point
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
665 option_cleanup_oTrMode_no_CCR: ; entry point from cleanup during restart
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
666 movff opt_TR_mode,WREG ; get TR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
667 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
668 bnz option_inc_enum8_3_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
669 option_inc_enum8_3_reset: ; YES - revert to mode 1 (on)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
670 movlw .1 ; load coding of mode "on"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
671 movff WREG,opt_TR_mode ; write to option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
672 option_inc_enum8_3_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
673 return ; done
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
674
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
675 option_inc_enum8_4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
676 IFDEF _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
677 ; now some rather crude hack to advance opt_TR_mode in dependency of opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
678 movlw 0x7E ; serial ID of option opt_TR_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
679 cpfseq opt_serial ; editing opt_TR_mode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
680 bra option_inc_enum8_5 ; NO - check next option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
681 movff opt_dive_mode,WREG ; YES - get dive mode: 0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
682 decfsz WREG,W ; dive mode = 1 CCR?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
683 bra option_inc_enum8_4a ; NO - in any other mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
684 movf INDF1,W ; YES - get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
685 xorlw .2 ; - mode = 2 (ind.double)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
686 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
687 incf INDF1,F ; YES - advance option value to 3 (CCR Dil+O2)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
688 bra option_inc_enum8_4_exit ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
689 option_inc_enum8_4a: ; any mode other than CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
690 movf INDF1,W ; get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
691 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
692 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
693 clrf INDF1 ; YES - advance option value to 0 "off"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
694 option_inc_enum8_4_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
695 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
696 ENDIF ; _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
697
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
698 option_inc_enum8_5:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
699 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
700 ; now some rather crude hack to keep contingency mode switched off if gas needs calculation is switched off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
701 movlw 0x91 ; serial ID of option opt_gas_contingency_dive
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
702 cpfseq opt_serial ; editing opt_gas_contingency_dive right now?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
703 bra option_inc_enum8_6 ; NO - check next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
704 movff opt_calc_gasvolume,WREG ; YES - get current setting of gas needs calculation
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
705 tstfsz WREG ; - gas needs calculation switched off?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
706 return ; NO - done, opt_gas_contingency_dive may be switched on
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
707 clrf INDF1 ; YES - force opt_gas_contingency_dive to off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
708 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
709 ENDIF ; _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
710
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
711 option_inc_enum8_6:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
712 ; add more cross-checks with other option values here
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
713 return
0
heinrichsweikamp
parents:
diff changeset
714
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
715
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
716 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
717 ; Decrement an Option Value based on Type and min/max Boundary
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
718 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
719 ; INPUT: FSR0 = option handle
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
720 ; OUTPUT: decremented option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
721 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
722 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
723 global option_dec
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
724 option_dec:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
725 ; read type, default and register from table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
726 rcall option_read_definition
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
727
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
728 btfss opt_eeprom_bank,7 ; volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
729 bsf option_changed ; NO - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
730
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
731 ; switch on type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
732 movf opt_type,W ; get option type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
733 bz option_dec_uint8 ; type 0: UINT8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
734 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
735 bra option_dec_enum8 ; type 1: ENUM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
736 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
737 return ; type 2: STRING - no dec function defined
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
738 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
739 bra option_dec_uint8 ; type 3: UINT8 as meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
740 return ; unknown, do nothing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
741
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
742
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
743 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
744 ; Helper Function - decrement UINT8, will stop on reaching option min
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
745 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
746 option_dec_uint8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
747 movf INDF1,W ; get option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
748 bsf STATUS,C ; set carry (= clear borrow)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
749 subfwb opt_inc,W ; subtract increment
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
750 bnc option_dec_uint8_reset ; under-run? -> reset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
751 cpfsgt opt_min ; option value < min ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
752 bra option_dec_uint8_0 ; NO - new option value ok
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
753 option_dec_uint8_reset:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
754 movf opt_min,W ; YES - reset to min value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
755 option_dec_uint8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
756 movwf INDF1 ; store new value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
757 ; add cross-checks with other option values here
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
758 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
759
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
760
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
761 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
762 ; Helper Function - decrement ENUM, will stop on reaching first option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
763 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
764 option_dec_enum8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
765 tstfsz INDF1 ; option value = 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
766 decf INDF1,F ; NO - decrement value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
767 option_dec_enum8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
768 ; add cross-checks with other option values here
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
769 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
770
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
771
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
772 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
773 ; Draw an Option Value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
774 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
775 global option_draw
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
776 option_draw:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
777 ; read type, default and register from table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
778 rcall option_read_definition
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
779
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
780 ; switch on type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
781 movf opt_type,W ; get option type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
782 bz option_draw_uint8 ; type0 = INT8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
783 dcfsnz WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
784 bra option_draw_enum8 ; type1 = ENUM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
785 dcfsnz WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
786 bra option_draw_string ; type2 = string
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
787 dcfsnz WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
788 bra option_draw_uint8_depth ; type3 = INT8 as meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
789 return ; unknown, do nothing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
790
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
791
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
792 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
793 ; Helper Function - draw a String
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
794 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
795 option_draw_string:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
796 movff POSTINC1,POSTINC2 ; copy one character
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
797 decfsz opt_max ; decrement remaining string length, became zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
798 bra option_draw_string ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
799 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
800
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
801
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
802 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
803 ; Helper Function - draw an INT with automatic display in meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
804 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
805 option_draw_uint8_depth:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
806 TSTOSS opt_units ; using metric units (0=m, 1=ft)?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
807 bra option_draw_uint8 ; YES - handle with standard output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
808 movff INDF1,lo ; NO - imperial, get value to lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
809 call convert_meter_to_feet ; - convert value in lo from meter to feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
810 ; bsf leftbind ; - print with left alignment
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
811 output_999 ; - print depth (0-999)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
812 STRCAT_TEXT tFeets ; - append unit and dump to screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
813 bra option_draw_uint8_common ; - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
814
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
815
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
816 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
817 ; Helper Function - draw an INT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
818 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
819 option_draw_uint8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
820 movff INDF1,lo ; get option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
821
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
822 movlw .99 ; load a 99
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
823 cpfsgt opt_max ; max value > 99 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
824 bsf hide_digit3 ; NO - do not show digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
825 movlw .9 ; load a 9
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
826 cpfsgt opt_max ; max value > 9 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
827 bsf hide_digit2 ; NO - do not show digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
828
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
829 output_256 ; print option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
830
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
831 movf opt_unit+0,W ; is there a unit to append?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
832 iorwf opt_unit+1,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
833 bz option_draw_uint8_common ; NO - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
834 movff opt_unit+0,FSR1L ; YES - pointer to multi-lingual unit text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
835 movff opt_unit+1,FSR1H ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
836 call strcat_text_FSR ; - append unit text to buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
837 ;bra option_draw_uint8_common ; - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
838
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
839
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
840 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
841 ; Helper Function - common Part for INT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
842 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
843 option_draw_uint8_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
844 movf opt_default,W ; get default value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
845 cpfseq lo ; compare with current value, equal?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
846 bra option_draw_uint8_common_1 ; NO - not default, add *
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
847 return ; YES - default, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
848 option_draw_uint8_common_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
849 PUTC "*" ; print "*"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
850 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
851
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
852
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
853 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
854 ; Helper Function - draw an ENUM (set of translated strings)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
855 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
856 option_draw_enum8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
857 movf INDF1,W ; copy option value to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
858 movwf lo ; memorize option value, too
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
859 cpfslt opt_max ; option value > maximum permissible value ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
860 bra option_draw_enum8_0 ; NO - option value allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
861 clrf WREG ; YES - to avoid printing rubbish, use first ENUM item instead
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
862 option_draw_enum8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
863 addwf WREG ; current value *= 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
864 addwf opt_inc,W ; base text + 2 * current value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
865 movwf FSR1L ; load FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
866 movlw .0 ; propagate carry...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
867 addwfc opt_min,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
868 movwf FSR1H ; ...into FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
869 call strcat_text_FSR ; print text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
870 movf opt_default,W ; get default value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
871 cpfseq lo ; compare with memorized current value, equal?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
872 bra option_draw_enum8_1 ; NO - not default, add *
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
873 return ; YES - default, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
874 option_draw_enum8_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
875 PUTC "*" ; print "*"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
876 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
877
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
878
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
879 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
880 options2 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
881 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
882
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
883
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
884 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
885 ; Check and Resolve some Interdependencies among Option Values
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
886 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
887 option_crosschecks:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
888 bsf is_diluent_menu ; setup checking diluents
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
889 call gaslist_cleanup_list ; check and correct multiple or none First diluents
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
890
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
891 bcf is_diluent_menu ; setup checking gases
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
892 call gaslist_cleanup_list ; check and correct multiple or none First gases
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
893
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
894 rcall option_cleanup_GF ; check and correct GFlow <= GFhigh
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
895
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
896 IFNDEF _gauge_mode
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
897 rcall option_cleanup_gauge ; check and correct gauge mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
898 ENDIF ; _gauge_mode
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
899
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
900 IFDEF _ccr_pscr
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
901 rcall option_cleanup_oCCRMode ; check and correct CCR / pSCR mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
902 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
903
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
904 IFDEF _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
905 rcall option_cleanup_sum_O2_He ; check and correct O2% + He% <= 100 +++
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
906 ENDIF ; _helium
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
907
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
908 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
909
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
910
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
911 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
912 ; Check and correct GFs so that GF_high >= GF_low
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
913 ;
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
914 option_cleanup_GF:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
915 ; cleanup normal GF
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
916 movff opt_GF_high,WREG ; copy normal GF high to WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
917 movff opt_GF_low,mpr ; copy normal GF low to mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
918 cpfsgt mpr ; GF low > GF high ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
919 bra option_cleanup_GF_2 ; NO - option ok, check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
920 movwf mpr ; YES - copy GF high to mpr
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
921 movlw .100 ; - load GF low limit of 100% into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
922 cpfsgt mpr ; - mpr > 100 ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
923 bra option_cleanup_GF_1 ; NO - correct GF low to GF high
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
924 movwf mpr ; YES - correct GF low to 100%
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
925 option_cleanup_GF_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
926 movff mpr,opt_GF_low ; store corrected GF low
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
927 bsf option_changed ; flag that EEPROM needs to be updated
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
928 option_cleanup_GF_2:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
929 ; cleanup alternative GF
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
930 movff opt_aGF_high,WREG ; copy alternative GF high to WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
931 movff opt_aGF_low,mpr ; copy alternative GF low to mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
932 cpfsgt mpr ; GF low > GF high ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
933 bra option_cleanup_GF_4 ; NO - option ok, check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
934 movwf mpr ; YES - copy GF high to mpr
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
935 movlw .100 ; - load GF low limit of 100% into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
936 cpfsgt mpr ; - mpr > 100 ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
937 bra option_cleanup_GF_3 ; NO - correct GF low to GF high
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
938 movwf mpr ; YES - correct GF low to 100%
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
939 option_cleanup_GF_3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
940 movff mpr,opt_aGF_low ; store corrected GF low
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
941 bsf option_changed ; flag that EEPROM needs to be updated
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
942 option_cleanup_GF_4:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
943 return ; done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
944
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
945 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
946 ; Check and correct Dive Mode if Gauge Mode is not allowed
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
947 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
948 IFNDEF _gauge_mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
949 option_cleanup_gauge:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
950 movff opt_dive_mode,WREG ; get dive mode into WREG (0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
951 xorlw .2 ; in Gauge mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
952 bnz option_cleanup_gauge_1 ; NO - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
953 movff WREG,opt_dive_mode ; YES - setting not allowed, WREG is zero -> reset to OC mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
954 bsf option_changed ; - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
955 option_cleanup_gauge_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
956 return ; done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
957 ENDIF ; _gauge_mode
0
heinrichsweikamp
parents:
diff changeset
958
heinrichsweikamp
parents:
diff changeset
959
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
960 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
961 ; Check and correct AutoSP and external Sensor Settings dependent on Modes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
962 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
963 IFDEF _ccr_pscr
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
964 global option_cleanup_oCCRMode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
965 global option_cleanup_oCCRMode_pSCR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
966 global option_cleanup_oCCRMode_CCR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
967 option_cleanup_oCCRMode: ; in pSCR mode, revert AutoSP (2) to calculated SP (0), in pSCR and CCR revert Sensor to fixed SP if no sensor interface available
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
968 movff opt_dive_mode,WREG ; get dive mode into WREG (0=OC, 1=CCR, 2=Gauge, 3=Apnea, 4=pSCR)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
969 xorlw .4 ; in pSCR mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
970 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
971 option_cleanup_oCCRMode_pSCR: ; jump-in from start.asm if known to be in pSCR mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
972 banksel opt_ccr_mode ; YES - select options bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
973 bcf opt_ccr_mode,1 ; - clear bit 1 because opt_ccr_mode may only be 0 or 1 (reverts AutoSP to calculated SP, keeps sensor)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
974 banksel common ; - back to bank common
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
975 bsf option_changed ; - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
976 option_cleanup_oCCRMode_CCR: ; continue from above & jump-in from start.asm if known to be in CCR mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
977 IFDEF _external_sensor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
978 btfsc ext_input_s8_ana ; S8/analog interface available?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
979 return ; YES - setting 'sensor' allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
980 btfsc ext_input_optical ; does hosting OSTC have an optical interface?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
981 return ; YES - setting 'sensor' allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
982 ENDIF ; _external_sensor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
983 movff opt_ccr_mode,WREG ; NO to both - get CCR mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
984 xorlw .1 ; - coding for sensor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
985 tstfsz WREG ; - CCR mode = sensor?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
986 return ; NO - setting allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
987 banksel opt_ccr_mode ; YES - setting not allowed, select options bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
988 clrf opt_ccr_mode ; - revert setting to 0 (fixed or calculated SP)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
989 banksel common ; - back to bank common
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
990 bsf option_changed ; - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
991 return ; - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
992 ENDIF ; _ccr_pscr
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
993
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
994
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
995 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
996 ; Check and correct that O2% + He% <= 100%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
997 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
998 IFDEF _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
999 option_cleanup_sum_O2_He:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1000 lfsr FSR0,opt_gas_He_ratio-1 ; load (base address of He% array - 1) because of PREINC
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1001 movlw 2*NUM_GAS ; load loop counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1002 movwf lo ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1003 option_cleanup_sum_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1004 movff PREINC1,up ; get He ratio
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1005 movlw -2*NUM_GAS ; address O2 ratio
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1006 movff PLUSW0,hi ; get O2 ratio
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1007 movlw .100 ; load WREG with 100%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1008 bsf STATUS,C ; set carry = clear borrow
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1009 subfwb hi,W ; subtract O2% from WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1010 subfwb up,W ; subtract He% from WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1011 btfsc STATUS,C ; result negative?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1012 bra option_cleanup_sum_loop_1 ; NO - sum valid
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1013 clrf INDF1 ; YES - heal by setting He% to zero
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1014 bsf option_changed ; flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1015 option_cleanup_sum_loop_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1016 decfsz lo ; decrement loop counter, all done?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1017 bra option_cleanup_sum_loop ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1018 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1019 ENDIF ; _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1020
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1021
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1022 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
1023
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1024 END