annotate src/options.asm @ 650:bc214815deb2

3.19/10.75 release
author heinrichsweikamp
date Sun, 28 Aug 2022 13:13:38 +0200
parents 070528a88715
children 75e90cd0c2c3
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:
645
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
425 rcall option_check_loaded ; check if new value is valid
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
426 btfss option_value_ok ; value valid?
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
427 bra option_write_serial_invalid ; NO
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
428 movff hi,INDF1 ; YES - take new value
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
429 btfss opt_eeprom_bank,7 ; - volatile option?
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
430 bsf option_changed ; NO - flag that EEPROM needs to be updated
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
431 retlw .0 ; - done
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
432
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
433 option_write_serial_invalid:
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
434 movlw 0x32 ; load serial id of the language option (oLanguage)
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
435 cpfseq lo ; option to write = language option ?
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
436 retlw .2 ; NO - value not valid, abort
070528a88715 3.16 release
heinrichsweikamp
parents: 634
diff changeset
437 retlw .0 ; YES - value not valid, but silently ignore
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
438
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
439
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
440 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
441 ; Increment an Option Value based on Type and min/max Boundary
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
442 ;
0
heinrichsweikamp
parents:
diff changeset
443 ; INPUT: FSR0 = option handle
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
444 ; OUTPUT: incremented option value
0
heinrichsweikamp
parents:
diff changeset
445 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
446 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
447 global option_inc
0
heinrichsweikamp
parents:
diff changeset
448 option_inc:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
449 ; read type, default and register from table
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
450 rcall option_read_definition
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
451
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
452 btfss opt_eeprom_bank,7 ; volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
453 bsf option_changed ; NO - flag that EEPROM needs to be updated
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
454
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
455 ; switch on type
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
456 movf opt_type,W ; get option type
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
457 bz option_inc_uint8 ; type 0: UINT8
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
458 dcfsnz WREG ; decrement
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
459 bra option_inc_enum8 ; type 1: ENUM
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
460 dcfsnz WREG ; decrement
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
461 return ; type 2: STRING - no inc function defined
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
462 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
463 bra option_inc_uint8 ; type 3: UINT8 as meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
464 return ; unknown, do nothing
0
heinrichsweikamp
parents:
diff changeset
465
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
466
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
467 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
468 ; Helper Function - increment UINT8, wrap-around or stop at option max
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
469 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
470 option_inc_uint8:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
471 movf INDF1,W ; get option value
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
472 addwf opt_inc,W ; add increment
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
473 cpfslt opt_max ; option value > max ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
474 bra option_inc_uint8_0 ; NO - new option value ok
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
475 movf opt_min,W ; YES - reset to min value by default
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
476 btfsc option_stop_at_max ; - shall the option value stop at max?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
477 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
478 option_inc_uint8_0:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
479 movwf INDF1 ; store new value
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
480 ; do cross-checks with other option values
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
481 option_inc_uint8_1:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
482 ; 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
483 movlw 0x37 ; serial ID of option CalGasO2
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
484 cpfseq opt_serial ; editing CalGasO2 right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
485 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
486 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
487 decfsz WREG,W ; - in CCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
488 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
489 movlw .26 ; YES -
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
490 cpfseq INDF1 ; - option value = 26 ?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
491 return ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
492 movlw .95 ; YES - advance it to 95
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
493 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
494 return
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
495
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
496 option_inc_uint8_2:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
497 ; check GF low <= GF high
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
498 movlw 0x25 ; serial ID of option opt_GF_low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
499 cpfseq opt_serial ; editing opt_GF_low right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
500 bra option_inc_uint8_3 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
501 movff opt_GF_high,WREG ; get value of associated GF high into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
502 cpfsgt INDF1 ; GF low > GF high?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
503 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
504 movff opt_min,INDF1 ; YES - wrap around to minimum value
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
505 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
506
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
507 option_inc_uint8_3:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
508 ; check GF high >= GF low
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
509 movlw 0x26 ; serial ID of option opt_GF_high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
510 cpfseq opt_serial ; editing opt_GF_high right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
511 bra option_inc_uint8_4 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
512 movff opt_GF_low,WREG ; get value of associated GF low into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
513 cpfslt INDF1 ; GF high < GF low?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
514 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
515 movwf INDF1 ; YES - rise GF high to GF low
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
516 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
517
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
518 option_inc_uint8_4:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
519 ; check aGF low <= aGF high
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
520 movlw 0x27 ; serial ID of option opt_aGF_low
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
521 cpfseq opt_serial ; editing opt_aGF_low right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
522 bra option_inc_uint8_5 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
523 movff opt_aGF_high,WREG ; get value of associated GF high into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
524 cpfsgt INDF1 ; GF low > GF high?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
525 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
526 movff opt_min,INDF1 ; YES - wrap around to minimum value
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
527 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
528
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
529 option_inc_uint8_5:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
530 ; check aGF high >= aGF low
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
531 movlw 0x28 ; serial ID of option opt_aGF_high
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
532 cpfseq opt_serial ; editing opt_aGF_high right now?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
533 bra option_inc_uint8_6 ; NO - check next option
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
534 movff opt_aGF_low,WREG ; get value of associated GF low into WREG
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
535 cpfslt INDF1 ; GF high < GF low?
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
536 return ; NO - setting ok, done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
537 movwf INDF1 ; YES - rise GF high to GF low
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
538 return ; - done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
539
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
540 option_inc_uint8_6:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
541 ; progressive increment for char_I_SAC_work
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
542 movlw 0x3C ; serial ID of option char_I_SAC_work
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
543 cpfseq opt_serial ; editing char_I_SAC_work right now?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
544 bra option_inc_uint8_7 ; NO - check next option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
545 movlw .40 ; YES - set threshold for incrementing in steps of 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
546 cpfsgt INDF1 ; - option value > threshold ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
547 return ; NO - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
548 incf INDF1,F ; YES - increment one more time
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
549 return ; - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
550
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
551 option_inc_uint8_7:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
552 IFDEF _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
553 ; check O2% + He% <= 100%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
554 movlw 0xFA ; serial ID of O2% options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
555 cpfseq opt_serial ; editing a O2% right now?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
556 bra option_inc_uint8_7a ; NO - check for He%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
557 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
558 btfsc opt_eeprom_bank,7 ; - volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
559 movlw .1 ; YES - load offset between O2% and He% for gas 6
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
560 bra option_inc_uint8_7b ; continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
561 option_inc_uint8_7a:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
562 movlw 0xFB ; serial ID of He% options
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
563 cpfseq opt_serial ; editing a He% right now?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
564 bra option_inc_uint8_8 ; NO - check next option
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
565 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
566 btfsc opt_eeprom_bank,7 ; - volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
567 movlw -.1 ; YES - load offset between He% and O2% for gas 6
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
568 option_inc_uint8_7b:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
569 movff PLUSW1,hi ; - copy complementing gas % to hi
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
570 movf INDF1,W ; - copy primary gas % to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
571 addwf hi,F ; - hi = O2% + He%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
572 movlw .101 ; - load max allowed sum + 1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
573 cpfslt hi ; - O2% + He% < 101 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
574 decf INDF1,F ; NO - decrement primary gas% again
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
575 ENDIF ; _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
576
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
577 option_inc_uint8_8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
578 ; add more cross-checks with other option values here
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
579 return ; all done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
580
0
heinrichsweikamp
parents:
diff changeset
581
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
582 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
583 ; Helper Function - increment ENUM, will wrap-around on exceeding option max
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
584 ;
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
585 option_inc_enum8:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
586 incf INDF1,W ; get incremented option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
587 cpfslt opt_max ; option value > max?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
588 bra option_inc_enum8_0 ; NO - new option value ok
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
589 clrf WREG ; YES - reset to 1st option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
590 option_inc_enum8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
591 movwf INDF1 ; store new value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
592 ; do cross-checks with other option values
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
593 option_inc_enum8_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
594 IFDEF _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
595 ; 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
596 movlw 0x1F ; serial ID of option oCCRMode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
597 cpfseq opt_serial ; editing oCCRMode right now?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
598 bra option_inc_enum8_2 ; NO - check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
599 IFDEF _external_sensor
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
600 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
601 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
602 btfsc ext_input_optical ; - optical interface available?
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
603 bra option_inc_enum8_1a ; YES - setting 'sensor' allowed
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
604 ENDIF ; _external_sensor
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
605 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
606 xorlw .1 ; - in sensor mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
607 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
608 incf INDF1,F ; YES - advance option value to AutoSP
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
609 option_inc_enum8_1a:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
610 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
611 xorlw .4 ; in pSCR mode?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
612 bnz option_inc_enum8_1_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
613 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
614 option_inc_enum8_1_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
615 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
616 ENDIF ; _ccr_pscr
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
617
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
618 option_inc_enum8_2:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
619 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
620 ; 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
621 movlw 0x5A ; serial ID of option opt_calc_gasvolume
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
622 cpfseq opt_serial ; editing opt_calc_gasvolume right now?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
623 bra option_inc_enum8_3 ; NO - check next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
624 movf INDF1,W ; YES - get option value
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
625 ;xorlw .0 ; - option value = off ?
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
626 bnz option_inc_enum8_2_exit ; NO - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
627 clrf WREG ; YES - force contingency to be off, too
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
628 movff WREG,opt_gas_contingency_dive ; - ...
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
629 option_inc_enum8_2_exit:
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
630 return
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
631 ENDIF ; _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
632
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
633 option_inc_enum8_3:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
634 ; 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
635 movlw 0x20 ; serial ID of option opt_dive_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
636 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
637 bra option_inc_enum8_4 ; NO - check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
638 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
639 xorlw .1 ; in CCR mode?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
640 bnz option_inc_enum8_3a ; NO - in some other mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
641 IFNDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
642 incf INDF1,f ; YES - no CCR mode compiled in, advance to gauge mode
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
643 bra option_inc_enum8_3a ; - check if gauge mode is available
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
644 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
645 IFDEF _rx_functions
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
646 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
647 option_cleanup_oTrMode_CCR: ; entry point from cleanup during restart
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
648 movff opt_TR_mode,WREG ; get TR mode
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
649 xorlw .2 ; mode = 2 (ind.double)?
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
650 bnz option_inc_enum8_3_exit ; NO - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
651 bra option_inc_enum8_3_reset ; YES - revert mode to 1 (on)
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
652 ENDIF ; _rx_functions
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
653 option_inc_enum8_3a: ; any mode other than CCR
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
654 IFNDEF _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
655 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
656 xorlw .2 ; in Gauge mode?
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
657 bnz option_inc_enum8_3b ; NO - in some other mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
658 incf INDF1,f ; YES - no Gauge mode compiled in, advance to Apnea mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
659 bra option_inc_enum8_3_exit ; - done (Apnea mode is always available)
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
660 ENDIF ; _gauge_mode
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
661 option_inc_enum8_3b:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
662 IFNDEF _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
663 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
664 xorlw .4 ; in pSCR mode?
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
665 bnz option_inc_enum8_3c ; NO - in some other mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
666 clrf INDF1 ; YES - no pSCR mode compiled in, advance to 0 "OC"
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
667 bra option_inc_enum8_3_exit ; - done
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
668 ENDIF ; _ccr_pscr
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
669 option_inc_enum8_3c:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
670 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
671 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
672 movff opt_TR_mode,WREG ; get TR mode
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
673 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
674 bnz option_inc_enum8_3_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
675 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
676 movlw .1 ; load coding of mode "on"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
677 movff WREG,opt_TR_mode ; write to option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
678 option_inc_enum8_3_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
679 return ; done
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
680
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
681 option_inc_enum8_4:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
682 IFDEF _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
683 ; 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
684 movlw 0x7E ; serial ID of option opt_TR_mode
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
685 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
686 bra option_inc_enum8_5 ; NO - check next option
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
687 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
688 decfsz WREG,W ; dive mode = 1 CCR?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
689 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
690 movf INDF1,W ; YES - get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
691 xorlw .2 ; - mode = 2 (ind.double)?
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 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
694 bra option_inc_enum8_4_exit ; - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
695 option_inc_enum8_4a: ; any mode other than CCR
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
696 movf INDF1,W ; get option value (TR mode)
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
697 xorlw .3 ; mode = 3 (CCR Dil+O2)?
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
698 bnz option_inc_enum8_4_exit ; NO - done
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
699 clrf INDF1 ; YES - advance option value to 0 "off"
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
700 option_inc_enum8_4_exit:
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
701 return ; done
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
702 ENDIF ; _rx_functions
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
703
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
704 option_inc_enum8_5:
631
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
705 IFDEF _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
706 ; 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
707 movlw 0x91 ; serial ID of option opt_gas_contingency_dive
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
708 cpfseq opt_serial ; editing opt_gas_contingency_dive right now?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
709 bra option_inc_enum8_6 ; NO - check next option
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
710 movff opt_calc_gasvolume,WREG ; YES - get current setting of gas needs calculation
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
711 tstfsz WREG ; - gas needs calculation switched off?
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
712 return ; NO - done, opt_gas_contingency_dive may be switched on
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
713 clrf INDF1 ; YES - force opt_gas_contingency_dive to off
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
714 return ; - done
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
715 ENDIF ; _gas_contingency
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
716
185ba2f91f59 3.09 beta 1 release
heinrichsweikamp
parents: 628
diff changeset
717 option_inc_enum8_6:
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
718 ; add more cross-checks with other option values here
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 562
diff changeset
719 return
0
heinrichsweikamp
parents:
diff changeset
720
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
721
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
722 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
723 ; Decrement an Option Value based on Type and min/max Boundary
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
724 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
725 ; INPUT: FSR0 = option handle
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
726 ; OUTPUT: decremented option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
727 ; TRASH: TBLPTR, TABLAT, WREG, FSR0, FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
728 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
729 global option_dec
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
730 option_dec:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
731 ; read type, default and register from table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
732 rcall option_read_definition
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
733
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
734 btfss opt_eeprom_bank,7 ; volatile option?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
735 bsf option_changed ; NO - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
736
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
737 ; switch on type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
738 movf opt_type,W ; get option type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
739 bz option_dec_uint8 ; type 0: UINT8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
740 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
741 bra option_dec_enum8 ; type 1: ENUM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
742 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
743 return ; type 2: STRING - no dec function defined
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
744 dcfsnz WREG ; decrement
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
745 bra option_dec_uint8 ; type 3: UINT8 as meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
746 return ; unknown, do nothing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
747
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
748
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
749 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
750 ; Helper Function - decrement UINT8, will stop on reaching option min
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
751 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
752 option_dec_uint8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
753 movf INDF1,W ; get option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
754 bsf STATUS,C ; set carry (= clear borrow)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
755 subfwb opt_inc,W ; subtract increment
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
756 bnc option_dec_uint8_reset ; under-run? -> reset
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
757 cpfsgt opt_min ; option value < min ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
758 bra option_dec_uint8_0 ; NO - new option value ok
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
759 option_dec_uint8_reset:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
760 movf opt_min,W ; YES - reset to min value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
761 option_dec_uint8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
762 movwf INDF1 ; store new value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
763 ; add cross-checks with other option values here
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
764 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
765
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
766
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
767 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
768 ; Helper Function - decrement ENUM, will stop on reaching first option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
769 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
770 option_dec_enum8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
771 tstfsz INDF1 ; option value = 0 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
772 decf INDF1,F ; NO - decrement value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
773 option_dec_enum8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
774 ; add cross-checks with other option values here
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
775 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
776
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
777
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
778 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
779 ; Draw an Option Value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
780 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
781 global option_draw
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
782 option_draw:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
783 ; read type, default and register from table
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
784 rcall option_read_definition
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
785
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
786 ; switch on type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
787 movf opt_type,W ; get option type
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
788 bz option_draw_uint8 ; type0 = INT8
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
789 dcfsnz WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
790 bra option_draw_enum8 ; type1 = ENUM
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
791 dcfsnz WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
792 bra option_draw_string ; type2 = string
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
793 dcfsnz WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
794 bra option_draw_uint8_depth ; type3 = INT8 as meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
795 return ; unknown, do nothing
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
796
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
797
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
798 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
799 ; Helper Function - draw a String
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
800 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
801 option_draw_string:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
802 movff POSTINC1,POSTINC2 ; copy one character
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
803 decfsz opt_max ; decrement remaining string length, became zero?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
804 bra option_draw_string ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
805 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
806
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
807
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
808 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
809 ; Helper Function - draw an INT with automatic display in meters or feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
810 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
811 option_draw_uint8_depth:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
812 TSTOSS opt_units ; using metric units (0=m, 1=ft)?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
813 bra option_draw_uint8 ; YES - handle with standard output
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
814 movff INDF1,lo ; NO - imperial, get value to lo
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
815 call convert_meter_to_feet ; - convert value in lo from meter to feet
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
816 ; bsf leftbind ; - print with left alignment
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
817 output_999 ; - print depth (0-999)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
818 STRCAT_TEXT tFeets ; - append unit and dump to screen
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
819 bra option_draw_uint8_common ; - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
820
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
821
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
822 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
823 ; Helper Function - draw an INT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
824 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
825 option_draw_uint8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
826 movff INDF1,lo ; get option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
827
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
828 movlw .99 ; load a 99
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
829 cpfsgt opt_max ; max value > 99 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
830 bsf hide_digit3 ; NO - do not show digit 3
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
831 movlw .9 ; load a 9
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
832 cpfsgt opt_max ; max value > 9 ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
833 bsf hide_digit2 ; NO - do not show digit 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
834
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
835 output_256 ; print option value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
836
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
837 movf opt_unit+0,W ; is there a unit to append?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
838 iorwf opt_unit+1,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
839 bz option_draw_uint8_common ; NO - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
840 movff opt_unit+0,FSR1L ; YES - pointer to multi-lingual unit text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
841 movff opt_unit+1,FSR1H ; - ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
842 call strcat_text_FSR ; - append unit text to buffer
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
843 ;bra option_draw_uint8_common ; - continue with common part
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
844
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
845
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
846 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
847 ; Helper Function - common Part for INT
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
848 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
849 option_draw_uint8_common:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
850 movf opt_default,W ; get default value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
851 cpfseq lo ; compare with current value, equal?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
852 bra option_draw_uint8_common_1 ; NO - not default, add *
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
853 return ; YES - default, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
854 option_draw_uint8_common_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
855 PUTC "*" ; print "*"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
856 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
857
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
858
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
859 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
860 ; Helper Function - draw an ENUM (set of translated strings)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
861 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
862 option_draw_enum8:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
863 movf INDF1,W ; copy option value to WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
864 movwf lo ; memorize option value, too
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
865 cpfslt opt_max ; option value > maximum permissible value ?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
866 bra option_draw_enum8_0 ; NO - option value allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
867 clrf WREG ; YES - to avoid printing rubbish, use first ENUM item instead
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
868 option_draw_enum8_0:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
869 addwf WREG ; current value *= 2
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
870 addwf opt_inc,W ; base text + 2 * current value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
871 movwf FSR1L ; load FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
872 movlw .0 ; propagate carry...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
873 addwfc opt_min,W ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
874 movwf FSR1H ; ...into FSR1
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
875 call strcat_text_FSR ; print text
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
876 movf opt_default,W ; get default value
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
877 cpfseq lo ; compare with memorized current value, equal?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
878 bra option_draw_enum8_1 ; NO - not default, add *
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
879 return ; YES - default, done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
880 option_draw_enum8_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
881 PUTC "*" ; print "*"
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
882 return ; done
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 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
886 options2 CODE
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
887 ;=============================================================================
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
888
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
889
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
890 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
891 ; Check and Resolve some Interdependencies among Option Values
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
892 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
893 option_crosschecks:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
894 bsf is_diluent_menu ; setup checking diluents
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
895 call gaslist_cleanup_list ; check and correct multiple or none First diluents
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
896
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
897 bcf is_diluent_menu ; setup checking gases
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
898 call gaslist_cleanup_list ; check and correct multiple or none First gases
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
899
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
900 rcall option_cleanup_GF ; check and correct GFlow <= GFhigh
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
901
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
902 IFNDEF _gauge_mode
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
903 rcall option_cleanup_gauge ; check and correct gauge mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
904 ENDIF ; _gauge_mode
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
905
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
906 IFDEF _ccr_pscr
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
907 rcall option_cleanup_oCCRMode ; check and correct CCR / pSCR mode
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
908 ENDIF ; _ccr_pscr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
909
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
910 IFDEF _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
911 rcall option_cleanup_sum_O2_He ; check and correct O2% + He% <= 100 +++
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
912 ENDIF ; _helium
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
913
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
914 return ; done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
915
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
916
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
917 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
918 ; Check and correct GFs so that GF_high >= GF_low
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
919 ;
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
920 option_cleanup_GF:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
921 ; cleanup normal GF
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
922 movff opt_GF_high,WREG ; copy normal GF high to WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
923 movff opt_GF_low,mpr ; copy normal GF low to mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
924 cpfsgt mpr ; GF low > GF high ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
925 bra option_cleanup_GF_2 ; NO - option ok, check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
926 movwf mpr ; YES - copy GF high to mpr
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
927 movlw .100 ; - load GF low limit of 100% into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
928 cpfsgt mpr ; - mpr > 100 ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
929 bra option_cleanup_GF_1 ; NO - correct GF low to GF high
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
930 movwf mpr ; YES - correct GF low to 100%
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
931 option_cleanup_GF_1:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
932 movff mpr,opt_GF_low ; store corrected GF low
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
933 bsf option_changed ; flag that EEPROM needs to be updated
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
934 option_cleanup_GF_2:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
935 ; cleanup alternative GF
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
936 movff opt_aGF_high,WREG ; copy alternative GF high to WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
937 movff opt_aGF_low,mpr ; copy alternative GF low to mpr
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
938 cpfsgt mpr ; GF low > GF high ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
939 bra option_cleanup_GF_4 ; NO - option ok, check next option
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
940 movwf mpr ; YES - copy GF high to mpr
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
941 movlw .100 ; - load GF low limit of 100% into WREG
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
942 cpfsgt mpr ; - mpr > 100 ?
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
943 bra option_cleanup_GF_3 ; NO - correct GF low to GF high
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
944 movwf mpr ; YES - correct GF low to 100%
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
945 option_cleanup_GF_3:
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
946 movff mpr,opt_aGF_low ; store corrected GF low
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
947 bsf option_changed ; flag that EEPROM needs to be updated
608
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
948 option_cleanup_GF_4:
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
949 return ; done
d866684249bd work on 2.99 stable
heinrichsweikamp
parents: 604
diff changeset
950
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
951 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
952 ; 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
953 ;
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
954 IFNDEF _gauge_mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
955 option_cleanup_gauge:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
956 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
957 xorlw .2 ; in Gauge mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
958 bnz option_cleanup_gauge_1 ; NO - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
959 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
960 bsf option_changed ; - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
961 option_cleanup_gauge_1:
604
ca4556fb60b9 bump to 2.99beta, work on 3.00 stable
heinrichsweikamp
parents: 582
diff changeset
962 return ; done
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
963 ENDIF ; _gauge_mode
0
heinrichsweikamp
parents:
diff changeset
964
heinrichsweikamp
parents:
diff changeset
965
634
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
966 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
967 ; Check and correct AutoSP and external Sensor Settings dependent on Modes
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
968 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
969 IFDEF _ccr_pscr
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
970 global option_cleanup_oCCRMode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
971 global option_cleanup_oCCRMode_pSCR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
972 global option_cleanup_oCCRMode_CCR
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
973 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
974 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
975 xorlw .4 ; in pSCR mode?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
976 bnz option_cleanup_oCCRMode_CCR ; NO - check if sensor is available on hosting OSTC
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
977 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
978 banksel opt_ccr_mode ; YES - select options bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
979 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
980 banksel common ; - back to bank common
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
981 bsf option_changed ; - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
982 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
983 IFDEF _external_sensor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
984 btfsc ext_input_s8_ana ; S8/analog interface available?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
985 return ; YES - setting 'sensor' allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
986 btfsc ext_input_optical ; does hosting OSTC have an optical interface?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
987 return ; YES - setting 'sensor' allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
988 ENDIF ; _external_sensor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
989 movff opt_ccr_mode,WREG ; NO to both - get CCR mode
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
990 xorlw .1 ; - coding for sensor
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
991 tstfsz WREG ; - CCR mode = sensor?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
992 return ; NO - setting allowed
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
993 banksel opt_ccr_mode ; YES - setting not allowed, select options bank
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
994 clrf opt_ccr_mode ; - revert setting to 0 (fixed or calculated SP)
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
995 banksel common ; - back to bank common
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
996 bsf option_changed ; - flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
997 return ; - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
998 ENDIF ; _ccr_pscr
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
999
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1000
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1001 ;-----------------------------------------------------------------------------
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1002 ; Check and correct that O2% + He% <= 100%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1003 ;
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1004 IFDEF _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1005 option_cleanup_sum_O2_He:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1006 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
1007 movlw 2*NUM_GAS ; load loop counter
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1008 movwf lo ; ...
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1009 option_cleanup_sum_loop:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1010 movff PREINC1,up ; get He ratio
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1011 movlw -2*NUM_GAS ; address O2 ratio
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1012 movff PLUSW0,hi ; get O2 ratio
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1013 movlw .100 ; load WREG with 100%
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1014 bsf STATUS,C ; set carry = clear borrow
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1015 subfwb hi,W ; subtract O2% from WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1016 subfwb up,W ; subtract He% from WREG
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1017 btfsc STATUS,C ; result negative?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1018 bra option_cleanup_sum_loop_1 ; NO - sum valid
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1019 clrf INDF1 ; YES - heal by setting He% to zero
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1020 bsf option_changed ; flag that EEPROM needs to be updated
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1021 option_cleanup_sum_loop_1:
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1022 decfsz lo ; decrement loop counter, all done?
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1023 bra option_cleanup_sum_loop ; NO - loop
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1024 return ; YES - done
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1025 ENDIF ; _helium
4050675965ea 3.10 stable release
heinrichsweikamp
parents: 631
diff changeset
1026
628
cd58f7fc86db 3.05 stable work
heinrichsweikamp
parents: 623
diff changeset
1027
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1028 ;-----------------------------------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
1029
623
c40025d8e750 3.03 beta released
heinrichsweikamp
parents: 608
diff changeset
1030 END