Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_reset.asm @ 85:8b813f67220f
renaming "Max Depth" to "max."
author | heinrichsweikamp |
---|---|
date | Wed, 08 Dec 2010 08:37:03 +0100 |
parents | 3e351e25f5d1 |
children | b40a0a6284da |
rev | line source |
---|---|
0 | 1 |
2 ; OSTC - diving computer code | |
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
4 | |
5 ; This program is free software: you can redistribute it and/or modify | |
6 ; it under the terms of the GNU General Public License as published by | |
7 ; the Free Software Foundation, either version 3 of the License, or | |
8 ; (at your option) any later version. | |
9 | |
10 ; This program is distributed in the hope that it will be useful, | |
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ; GNU General Public License for more details. | |
14 | |
15 ; You should have received a copy of the GNU General Public License | |
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 | |
19 ; Menu "Reset all" | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 10/30/05 | |
22 ; last updated: 08/08/31 | |
23 ; known bugs: | |
24 ; ToDo: | |
25 | |
26 ; routines to reset external EEPROM (currently inactvated!) | |
27 ; routines to reset custom function, gases and decompression values | |
28 ; does not reset clock | |
29 | |
79 | 30 ;============================================================================= |
31 ; CF default values | |
32 ; | |
33 | |
34 ; Macro to check values, and construct PROM CF default table. | |
35 ; If in types mode, set flags into hi. If not, clear it. | |
36 CF_DEFAULT macro type, value | |
37 if ( type == CF_INT15 ) | |
38 if (HIGH value) > .127 | |
39 error "15bit default too big:", value | |
40 endif | |
41 DB LOW value, 0x80 + (HIGH value) | |
42 else | |
43 ; Basic sanity check for 8bit values: | |
44 if ( HIGH value ) > 0 | |
45 error "8bit default too big:", value | |
46 endif | |
47 if (type==CF_BOOL) && (value > 1) | |
48 error "BOOL default too big:", value | |
49 endif | |
50 ifdef NO_CF_TYPES | |
51 DB LOW value, HIGH value | |
52 else | |
53 DB LOW value, type | |
54 endif | |
55 endif | |
56 endm | |
57 | |
58 ; resets all customfunctions to the following default values | |
59 cf_default_table: | |
60 ;---- BANK0 custom function defaults ------------------------------------- | |
61 CF_DEFAULT CF_CENTI, d'100' ; dive_threshold 100cm | |
62 CF_DEFAULT CF_CENTI, d'30' ; surf_threshold 30cm | |
63 CF_DEFAULT CF_SEC, d'240' ; diveloop_timeout 240s | |
64 CF_DEFAULT CF_SEC, d'120' ; surfloop_timeout 120s | |
65 CF_DEFAULT CF_SEC, d'5' ; premenu_timeout 5s | |
66 | |
67 CF_DEFAULT CF_INT8, d'7' ; minimum_velocity 7min/min | |
68 CF_DEFAULT CF_INT15, d'1160' ; pressure_offset_divemode 1160mBar | |
69 CF_DEFAULT CF_INT15, d'1100' ; max_surfpressure 1100mBar | |
70 CF_DEFAULT CF_PERCENT, d'20' ; min_gradient_factor 20% | |
71 CF_DEFAULT CF_PERCENT, d'20' ; oxygen_threshold 20% | |
72 | |
73 CF_DEFAULT CF_SEC, d'30' ; dive_menu_timeout 30s | |
74 CF_DEFAULT CF_PERCENT, d'110' ; saturation_multiplier x1.10 | |
75 CF_DEFAULT CF_PERCENT, d'90' ; desaturation_multiplier x0.90 | |
76 CF_DEFAULT CF_PERCENT, d'60' ; nofly_time_ratio 60% | |
77 CF_DEFAULT CF_PERCENT, d'100' ; gradient_factor_alarm1 100% | |
78 | |
79 CF_DEFAULT CF_PERCENT, d'10' ; cns_display_surface 10% | |
80 CF_DEFAULT CF_INT8, d'10' ; deco_distance_for_sim 1m | |
81 CF_DEFAULT CF_CENTI, d'019' ; ppo2_warning_low 0.19 Bar | |
82 CF_DEFAULT CF_CENTI, d'160' ; ppo2_warning_high 1.60 Bar | |
83 CF_DEFAULT CF_CENTI, d'150' ; ppo2_display_high 1.50 Bar | |
84 | |
85 CF_DEFAULT CF_INT8, d'10' ; sampling_rate 10s | |
86 CF_DEFAULT CF_INT8, d'6' ; sampling_divisor_temp /6 | |
87 CF_DEFAULT CF_INT8, d'6' ; sampling_divisor_deco /6 | |
88 CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_tank never | |
89 CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_ppo2 never | |
90 | |
91 CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_deco2 never | |
92 CF_DEFAULT CF_INT8, d'0' ; sampling_divisor_nyu2 never | |
93 CF_DEFAULT CF_PERCENT, d'20' ; cns_display_high 20% | |
94 CF_DEFAULT CF_INT8, d'0' ; logbook_offset No Offset, but 15Bit value | |
95 CF_DEFAULT CF_INT8, d'3' ; last_deco_depth 3m | |
96 | |
97 CF_DEFAULT CF_SEC, d'10' ; timeout_apnoe_mode 10min | |
98 CF_DEFAULT CF_BOOL, d'0' ; show_voltage_value =1 Show value instead of symbol, =0 Show Symbol | |
99 | |
100 ;---- BANK1 custom function defaults ------------------------------------- | |
101 CF_DEFAULT CF_PERCENT, d'30' ; GF_low_default 30% | |
102 CF_DEFAULT CF_PERCENT, d'90' ; GF_high_default 90% | |
103 CF_DEFAULT CF_COLOR, d'199' ; color_battery_surface Color Battery sign: Deep blue | |
104 CF_DEFAULT CF_COLOR, d'255' ; color_standard1 Color Standard: White | |
105 CF_DEFAULT CF_COLOR, d'62' ; color_divemask Color Divemask: Light green | |
106 CF_DEFAULT CF_COLOR, d'224' ; color_warnings Color Warnings: Red | |
107 | |
108 CF_DEFAULT CF_BOOL, d'0' ; show_seconds_divemode =1 Show the seconds in Divemode | |
109 CF_DEFAULT CF_BOOL, d'0' ; show_clock_divemode =1 Show the clock in Divemode | |
110 CF_DEFAULT CF_BOOL, d'1' ; warn_ceiling_divemode =1 Warn ceiling violation in divemode | |
111 CF_DEFAULT CF_BOOL, d'0' ; start_with_stopwatch =1 start with stopwatch | |
112 CF_DEFAULT CF_BOOL, d'0' ; blink_gas_divemode =1 Show (resetable) average Depth instead of temperature | |
113 | |
114 CF_DEFAULT CF_INT15, d'13000' ; color_warn_depth_mBar Warn depths | |
115 CF_DEFAULT CF_PERCENT, d'101' ; color_warn_cns_percent Warn-% | |
116 CF_DEFAULT CF_PERCENT, d'101' ; color_warn_gf_percent Warn-% | |
117 CF_DEFAULT CF_CENTI, d'161' ; color_warn_ppo2_cbar ppO2 warn | |
118 CF_DEFAULT CF_INT8, d'15' ; color_warn_celocity_mmin warn at xx m/min | |
119 | |
120 CF_DEFAULT CF_SEC, d'42' ; time_correction_value_default Adds to Seconds on Midnight | |
121 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
122 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
123 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
124 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
125 | |
126 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
127 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
128 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
129 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
130 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
131 | |
132 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
133 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
134 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
135 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
136 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
137 | |
138 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
139 CF_DEFAULT CF_INT15, 0 ; UNUSED | |
140 ;============================================================================= | |
141 | |
0 | 142 menu_reset: |
143 movlw d'1' | |
144 movwf menupos | |
145 | |
146 call PLED_ClearScreen | |
147 call PLED_reset_menu_mask | |
148 | |
149 menu_reset2: | |
150 clrf timeout_counter2 | |
151 bcf sleepmode | |
152 bcf menubit2 | |
153 bcf menubit3 | |
154 bsf menubit | |
155 bsf cursor | |
156 call PLED_reset_menu_mask | |
157 call PLED_menu_cursor | |
158 bcf switch_left | |
159 bcf switch_right | |
160 menu_reset_loop: | |
161 call check_switches_menu | |
162 btfsc menubit2 | |
163 bra do_menu_reset ; call submenu | |
164 btfss menubit | |
165 bra menu ; exit setup menu and return to main menu | |
166 btfsc onesecupdate | |
167 call timeout_surfmode | |
168 btfsc onesecupdate | |
169 call set_dive_modes | |
170 btfsc onesecupdate | |
171 call test_charger ; check if charger IC is active | |
172 btfsc onesecupdate | |
173 call get_battery_voltage ; get battery voltage | |
174 bcf onesecupdate ; End of one second tasks | |
175 btfsc sleepmode | |
176 goto menu | |
177 btfsc divemode | |
178 goto restart ; exit menu, restart and enter divemode | |
179 bra menu_reset_loop | |
180 do_menu_reset: ; calls submenu | |
181 dcfsnz menupos,F | |
182 bra do_menu_reset_exit ; Cancel, exit | |
183 dcfsnz menupos,F | |
184 bra do_menu_reset_all ; Reset all settings | |
185 dcfsnz menupos,F | |
186 bra do_menu_reset_logbook ; Reset Logbook Memory! | |
187 dcfsnz menupos,F | |
188 bra do_menu_reset_reboot ; Reboot OSTC | |
189 dcfsnz menupos,F | |
190 bra do_menu_reset_decodata ; Reset Decodata | |
191 do_menu_reset_exit: | |
192 movlw d'3' | |
193 movwf menupos | |
194 bra menu2 ; exit... | |
195 | |
196 | |
197 do_menu_reset_reboot: | |
198 call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! | |
199 movwf menupos ; Used as temp | |
200 tstfsz menupos | |
201 bra do_menu_reset_reboot2 ; Delete now! | |
202 bra do_menu_reset_exit ; Cancel! | |
203 | |
204 do_menu_reset_reboot2: | |
205 call PLED_DisplayOff ; Power-down OLED | |
206 movlw b'00000000' ; Bit6: PPL Disable | |
207 movwf OSCTUNE | |
208 movlw b'01111110' ; 8MHz | |
209 movwf OSCCON | |
210 reset | |
211 goto 0x00000 ; restart to 0x00000 | |
212 | |
213 do_menu_reset_logbook: | |
214 call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! | |
215 movwf menupos ; Used as temp | |
216 tstfsz menupos | |
217 bra do_menu_reset_logbook2 ; Delete Logbook now! | |
218 bra do_menu_reset_exit ; Cancel! | |
219 | |
220 do_menu_reset_logbook2: | |
221 call PLED_ClearScreen | |
222 DISPLAYTEXT .25 ; "Reset..." | |
223 call reset_external_eeprom ; delete profile memory | |
224 bra do_menu_reset_exit | |
225 | |
226 do_menu_reset_decodata: | |
227 call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! | |
228 movwf menupos ; Used as temp | |
229 tstfsz menupos | |
230 bra do_menu_reset_decodata2 ; Reset Deco Data now! | |
231 bra do_menu_reset_exit ; Cancel! | |
232 | |
233 do_menu_reset_decodata2: | |
234 ; reset deco data | |
235 call PLED_ClearScreen | |
236 DISPLAYTEXT .25 ; "Reset..." | |
237 movff amb_pressure+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | |
238 movff amb_pressure+1,int_I_pres_respiration+1 | |
239 call deco_main_clear_tissue ; | |
240 movlb b'00000001' ; RAM Bank1 selected | |
241 goto restart ; done. quit to surfmode | |
242 | |
243 do_menu_reset_all: | |
244 call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! | |
245 movwf menupos ; Used as temp | |
246 tstfsz menupos | |
247 bra do_menu_reset_all2 ; Reset all now! | |
248 bra do_menu_reset_exit ; Cancel! | |
249 | |
250 do_menu_reset_all2: | |
251 call PLED_ClearScreen | |
252 DISPLAYTEXT .25 ; "Reset..." | |
253 | |
254 reset_start: | |
255 ; reset deco data | |
256 movff amb_pressure+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | |
257 movff amb_pressure+1,int_I_pres_respiration+1 | |
258 call deco_main_clear_tissue ; | |
259 movlb b'00000001' ; RAM Bank1 selected | |
260 | |
261 ; reset gases | |
262 clrf EEADRH ; EEPROM BANK 0 ! | |
263 | |
264 movlw d'3' ; address of first gas-1 | |
265 movwf EEADR | |
266 clrf hi ; He part (default for all gases: 0%) | |
267 movlw d'21' ; O2 part (21%) | |
268 rcall reset_customfunction ; saves default and current value for gas #1 | |
269 movlw d'21' ; O2 part (21%) | |
270 rcall reset_customfunction ; saves default and current value for gas #2 | |
271 movlw d'21' ; O2 part (21%) | |
272 rcall reset_customfunction ; saves default and current value for gas #3 | |
273 movlw d'21' ; O2 part (21%) | |
274 rcall reset_customfunction ; saves default and current value for gas #4 | |
275 movlw d'21' ; O2 part (21%) | |
276 rcall reset_customfunction ; saves default and current value for gas #5 | |
277 movlw d'21' ; O2 part (21%) | |
278 rcall reset_customfunction ; saves default and current value for gas #6 | |
279 | |
280 reset_all_cf: | |
281 movlw d'1' | |
282 movwf EEDATA | |
283 write_int_eeprom d'33' ; reset start gas | |
284 clrf EEDATA | |
285 write_int_eeprom d'34' ; reset deco model to ZH-L16 | |
286 clrf EEDATA | |
287 write_int_eeprom d'35' ; Do not use O2 Sensor in CC Modes | |
288 | |
289 movlw d'0' | |
290 clrf EEDATA | |
291 write_int_eeprom d'39' ; Disable Debugbode | |
292 clrf EEDATA | |
293 write_int_eeprom d'90' ; Disable Brightness offset? (Dim=1, Normal = 0) | |
294 clrf EEDATA | |
295 write_int_eeprom d'91' ; Reset Date format to MM/DD/YY | |
296 | |
297 movlw d'100' | |
298 write_int_eeprom d'26' ; Salinity default: 1.00 kg/l | |
299 | |
300 movlw b'00011111' | |
301 movwf EEDATA | |
302 write_int_eeprom d'27' ; reset active gas flags | |
303 | |
304 clrf EEDATA | |
305 write_int_eeprom d'28' ; reset change depth gas #1 | |
306 clrf EEDATA | |
307 write_int_eeprom d'29' ; reset change depth gas #2 | |
308 clrf EEDATA | |
309 write_int_eeprom d'30' ; reset change depth gas #3 | |
310 clrf EEDATA | |
311 write_int_eeprom d'31' ; reset change depth gas #4 | |
312 clrf EEDATA | |
313 write_int_eeprom d'32' ; reset change depth gas #5 | |
314 | |
315 movlw d'100' | |
316 movwf EEDATA | |
317 write_int_eeprom d'36' ; reset mix1 to ppO2=1.00Bar | |
318 write_int_eeprom d'37' ; reset mix2 to ppO2=1.00Bar | |
319 write_int_eeprom d'38' ; reset mix3 to ppO2=1.00Bar | |
320 | |
321 movlw d'1' | |
322 movwf nofly_time+0 ; Clear nofly time | |
323 clrf nofly_time+1 ; Clear nofly time | |
324 | |
79 | 325 reset_all_cf_bank0: |
326 clrf EEADRH | |
0 | 327 movlw d'127' ; address of low byte of first custom function |
328 movwf EEADR | |
329 | |
79 | 330 movlw LOW cf_default_table ; Load PROM pointer. |
331 movwf TBLPTRL,A | |
332 movlw HIGH cf_default_table | |
333 movwf TBLPTRH,A | |
334 movlw UPPER cf_default_table | |
335 movwf TBLPTRU,A | |
0 | 336 |
79 | 337 cf_bank0_loop: |
338 ; Did we already read 32 (decimal) bytes ? | |
339 movf TBLPTRL,W | |
340 sublw LOW (cf_default_table+.64) | |
341 bz reset_all_cf_bank1 | |
0 | 342 |
79 | 343 tblrd*+ |
344 movf TABLAT, W ; Low byte in WREG, | |
345 tblrd*+ | |
346 movff TABLAT, hi ; High byte in hi | |
0 | 347 rcall reset_customfunction ; saves default and current value |
79 | 348 bra cf_bank0_loop |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
349 |
0 | 350 reset_all_cf_bank1: |
351 movlw d'1' | |
352 movwf EEADRH ; EEPROM BANK 1 !! | |
353 movlw d'127' ; address of low byte of first custom function | |
354 movwf EEADR | |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
355 |
79 | 356 cf_bank1_loop: |
357 ; Did we already read another 32 (decimal) bytes ? | |
358 movf TBLPTRL,W | |
359 sublw LOW (cf_default_table+.128) | |
360 bz cf_bank1_end | |
27
29341afd2060
NEW: Depth, CNS, GF, ppO2 and Velocity are Color-coded
heinrichsweikamp
parents:
25
diff
changeset
|
361 |
79 | 362 tblrd*+ |
363 movf TABLAT, W ; Low byte in WREG, | |
364 tblrd*+ | |
365 movff TABLAT, hi ; High byte in hi | |
0 | 366 rcall reset_customfunction ; saves default and current value |
79 | 367 bra cf_bank1_loop |
0 | 368 |
79 | 369 cf_bank1_end: |
0 | 370 clrf EEADRH ; EEPROM BANK 0 ! |
83
3e351e25f5d1
adding anti-aliased fonts frame and merging some patches from Jeando
heinrichsweikamp
parents:
79
diff
changeset
|
371 |
0 | 372 ;call reset_external_eeprom ; delete profile memory |
373 goto restart ; all reset, quit to surfmode | |
374 | |
79 | 375 ; Write the four bytes lo:hi:lo:(hi w/o type flags) into EEPROM |
376 ; Don't change hi:lo values... | |
0 | 377 reset_customfunction: |
378 movwf lo | |
379 incf EEADR,F | |
380 movff lo, EEDATA ; Lowbyte Defaul value | |
381 call write_eeprom | |
382 incf EEADR,F | |
383 movff hi, EEDATA ; Highbyte default value | |
384 call write_eeprom | |
385 incf EEADR,F | |
386 movff lo, EEDATA ; Lowbyte current value | |
387 call write_eeprom | |
388 incf EEADR,F | |
389 movff hi, EEDATA ; Highbyte current value | |
79 | 390 #ifdef NO_CF_TYPES |
391 bcf EEDATA,7 ; This bit will only be written for the default value | |
392 #else | |
393 btfss EEDATA,7 ; A 15bit value ? | |
394 clrf EEDATA ; Nope: clear type flag. | |
395 #endif | |
0 | 396 call write_eeprom |
397 return | |
398 | |
399 | |
400 reset_external_eeprom: ; deletes complete external eeprom! | |
401 clrf eeprom_address+0 | |
402 clrf eeprom_address+1 | |
403 | |
404 movlw d'2' | |
405 movwf temp3 | |
406 reset_eeprom02: | |
407 clrf temp4 | |
408 reset_eeprom01: | |
409 movlw d'64' | |
410 movwf temp2 | |
411 bcf eeprom_blockwrite ; Blockwrite start | |
412 reset_eeprom1: | |
413 setf ext_ee_temp1 ; byte for Blockwrite.... | |
414 movf ext_ee_temp1,W ; So, 1st. Byte of block is fine, too | |
415 call write_external_eeprom_block | |
416 decfsz temp2,F ; 64 Byte done | |
417 bra reset_eeprom1 | |
418 bsf SSPCON2,PEN ; Stop condition | |
419 call WaitMSSP | |
420 WAITMS d'7' | |
421 decfsz temp4,F | |
422 bra reset_eeprom01 ; do this 256 times | |
423 decfsz temp3,F | |
424 bra reset_eeprom02 ; and this all 2 times -> 512 *64Bytes = 32KB | |
425 | |
426 bcf eeprom_blockwrite ; clear blockwrite flag | |
427 | |
428 clrf eeprom_address+0 | |
429 clrf eeprom_address+1 | |
430 | |
431 movlw 0xFD ; With these three bytes the OSTC will find the free area in the EEPROM faster | |
432 call write_external_eeprom | |
433 movlw 0xFD | |
434 call write_external_eeprom | |
435 movlw 0xFE | |
436 call write_external_eeprom | |
437 | |
438 clrf eeprom_address+0 | |
439 clrf eeprom_address+1 | |
440 return | |
441 |