comparison code_part1/OSTC_code_asm_part1/menu_reset.asm @ 79:69c462400279

Making CF edition esier
author JeanDo
date Mon, 06 Dec 2010 18:00:13 +0100
parents df2d3b28947f
children 3e351e25f5d1
comparison
equal deleted inserted replaced
78:bd16d5830b06 79:69c462400279
24 ; ToDo: 24 ; ToDo:
25 25
26 ; routines to reset external EEPROM (currently inactvated!) 26 ; routines to reset external EEPROM (currently inactvated!)
27 ; routines to reset custom function, gases and decompression values 27 ; routines to reset custom function, gases and decompression values
28 ; does not reset clock 28 ; does not reset clock
29
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 ;=============================================================================
29 141
30 menu_reset: 142 menu_reset:
31 movlw d'1' 143 movlw d'1'
32 movwf menupos 144 movwf menupos
33 145
164 rcall reset_customfunction ; saves default and current value for gas #5 276 rcall reset_customfunction ; saves default and current value for gas #5
165 movlw d'21' ; O2 part (21%) 277 movlw d'21' ; O2 part (21%)
166 rcall reset_customfunction ; saves default and current value for gas #6 278 rcall reset_customfunction ; saves default and current value for gas #6
167 279
168 reset_all_cf: 280 reset_all_cf:
169 ; resets all customfunctions to the following default values
170 movlw d'1' 281 movlw d'1'
171 movwf EEDATA 282 movwf EEDATA
172 write_int_eeprom d'33' ; reset start gas 283 write_int_eeprom d'33' ; reset start gas
173 clrf EEDATA 284 clrf EEDATA
174 write_int_eeprom d'34' ; reset deco model to ZH-L16 285 write_int_eeprom d'34' ; reset deco model to ZH-L16
209 320
210 movlw d'1' 321 movlw d'1'
211 movwf nofly_time+0 ; Clear nofly time 322 movwf nofly_time+0 ; Clear nofly time
212 clrf nofly_time+1 ; Clear nofly time 323 clrf nofly_time+1 ; Clear nofly time
213 324
214 #DEFINE dive_threshold d'100' ; 8BIT 100cm 325 reset_all_cf_bank0:
215 #DEFINE surf_threshold d'30' ; 8BIT 30cm 326 clrf EEADRH
216 #DEFINE diveloop_timeout d'240' ; 8BIT 240s
217 #DEFINE surfloop_timeout d'120' ; 8BIT 120s
218 #DEFINE premenu_timeout d'5' ; 8BIT 5s
219
220 #DEFINE minimum_velocity d'7' ; 8BIT 7min/min
221 #DEFINE pressure_offset_divemode d'1160' ; 15BIT 1160mBar
222 #DEFINE max_surfpressure d'1100' ; 15BIT 1100mBar
223 #DEFINE min_gradient_factor d'20' ; 8Bit 20%
224 #DEFINE oxygen_threshold d'20' ; 8Bit 20%
225
226 #DEFINE dive_menu_timeout d'30' ; 8BIT 30s
227 #DEFINE saturation_multiplier d'110' ; 8BIT x1.1
228 #DEFINE desaturation_multiplier d'90' ; 8BIT x0.9
229 #DEFINE nofly_time_ratio d'60' ; 8BIT 60%
230 #DEFINE gradient_factor_alarm1 d'100' ; 8Bit 100%
231
232 #DEFINE cns_display_surface d'10' ; 8Bit 10%
233 #DEFINE deco_distance_for_sim d'10' ; 8Bit 1m
234 #DEFINE ppo2_warning_low d'019' ; 8Bit 0.19 Bar
235 #DEFINE ppo2_warning_high d'160' ; 8Bit 1.60 Bar
236 #DEFINE ppo2_display_high d'150' ; 8Bit 1.50 Bar
237
238 #DEFINE sampling_rate d'10' ; 8Bit 10s
239 #DEFINE sampling_divisor_temp d'6' ; 8Bit /6
240 #DEFINE sampling_divisor_deco d'6' ; 8Bit /6
241 #DEFINE sampling_divisor_tank d'0' ; 8Bit never
242 #DEFINE sampling_divisor_ppo2 d'0' ; 8Bit never
243
244 #DEFINE sampling_divisor_deco2 d'0' ; 8Bit never
245 #DEFINE sampling_divisor_nyu2 d'0' ; 8Bit never
246 #DEFINE cns_display_high d'20' ; 8Bit 20%
247 #DEFINE logbook_offset d'0' ; 15Bit No Offset, but 15Bit value
248 #DEFINE last_deco_depth d'3' ; 8Bit 3m
249 #DEFINE timeout_apnoe_mode d'10' ; 8Bit 10min
250 #DEFINE show_voltage_value d'0' ; 1Bit =1 Show value instead of symbol, =0 Show Symbol
251
252 #DEFINE GF_low_default d'30' ; 8Bit 30%
253 #DEFINE GF_high_default d'90' ; 8Bit 90%
254 #DEFINE color_battery_surface d'199' ; 8Bit Color Battery sign: Deep blue
255 #DEFINE color_standard1 d'255' ; 8Bit Color Standard: White
256 #DEFINE color_divemask d'62' ; 8Bit Color Divemask: Light green
257 #DEFINE color_warnings d'224' ; 8Bit Color Warnings: Red
258
259 #DEFINE show_seconds_divemode d'0' ; 1Bit =1 Show the seconds in Divemode
260 #DEFINE show_clock_divemode d'0' ; 1Bit =1 Show the clock in Divemode
261 #DEFINE warn_ceiling_divemode d'1' ; 1Bit =1 Warn ceiling violation in divemode
262 #DEFINE start_with_stopwatch d'0' ; 1Bit =1 start with stopwatch
263 #DEFINE blink_gas_divemode d'0' ; 1Bit =1 Show (resetable) average Depth instead of temperature
264
265 #DEFINE color_warn_depth_mBar d'13000' ; 15Bit Warn depths
266 #DEFINE color_warn_cns_percent d'101' ; 8Bit Warn-%
267 #DEFINE color_warn_gf_percent d'101' ; 8Bit Warn-%
268 #DEFINE color_warn_ppo2_cbar d'161' ; 8Bit ppO2 warn
269 #DEFINE color_warn_celocity_mmin d'15' ; 8Bit warn at xx m/min
270
271 #DEFINE time_correction_value_default d'42' ; 8Bit Adds to Seconds on Midnight
272
273 movlw d'127' ; address of low byte of first custom function 327 movlw d'127' ; address of low byte of first custom function
274 movwf EEADR 328 movwf EEADR
275 clrf hi ; only required once 329
276 movlw LOW dive_threshold ; 8Bit value 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
336
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
342
343 tblrd*+
344 movf TABLAT, W ; Low byte in WREG,
345 tblrd*+
346 movff TABLAT, hi ; High byte in hi
277 rcall reset_customfunction ; saves default and current value 347 rcall reset_customfunction ; saves default and current value
278 348 bra cf_bank0_loop
279 movlw LOW surf_threshold
280 rcall reset_customfunction ; saves default and current value
281
282 movlw LOW diveloop_timeout
283 rcall reset_customfunction ; saves default and current value
284
285 movlw LOW surfloop_timeout
286 rcall reset_customfunction ; saves default and current value
287
288 movlw LOW premenu_timeout
289 rcall reset_customfunction ; saves default and current value
290
291 movlw LOW minimum_velocity
292 rcall reset_customfunction ; saves default and current value
293
294 movlw HIGH pressure_offset_divemode
295 movwf hi
296 bsf hi,7 ; 15Bit value
297 movlw LOW pressure_offset_divemode
298 rcall reset_customfunction ; saves default and current value
299
300 movlw HIGH max_surfpressure
301 movwf hi
302 bsf hi,7 ; 15Bit value
303 movlw LOW max_surfpressure
304 rcall reset_customfunction ; saves default and current value
305
306 movlw LOW min_gradient_factor
307 rcall reset_customfunction ; saves default and current value
308
309 movlw LOW oxygen_threshold
310 rcall reset_customfunction ; saves default and current value
311
312 movlw LOW dive_menu_timeout
313 rcall reset_customfunction ; saves default and current value
314
315 movlw LOW saturation_multiplier
316 rcall reset_customfunction ; saves default and current value
317
318 movlw LOW desaturation_multiplier
319 rcall reset_customfunction ; saves default and current value
320
321 movlw LOW nofly_time_ratio
322 rcall reset_customfunction ; saves default and current value
323
324 movlw LOW gradient_factor_alarm1
325 rcall reset_customfunction ; saves default and current value
326
327 movlw LOW cns_display_surface
328 rcall reset_customfunction ; saves default and current value
329
330 movlw LOW deco_distance_for_sim
331 rcall reset_customfunction ; saves default and current value
332
333 movlw LOW ppo2_warning_low
334 rcall reset_customfunction ; saves default and current value
335
336 movlw LOW ppo2_warning_high
337 rcall reset_customfunction ; saves default and current value
338
339 movlw LOW ppo2_display_high
340 rcall reset_customfunction ; saves default and current value
341
342 movlw LOW sampling_rate
343 rcall reset_customfunction ; saves default and current value
344
345 movlw LOW sampling_divisor_temp
346 rcall reset_customfunction ; saves default and current value
347
348 movlw LOW sampling_divisor_deco
349 rcall reset_customfunction ; saves default and current value
350
351 movlw LOW sampling_divisor_tank
352 rcall reset_customfunction ; saves default and current value
353
354 movlw LOW sampling_divisor_ppo2
355 rcall reset_customfunction ; saves default and current value
356
357 movlw LOW sampling_divisor_deco2
358 rcall reset_customfunction ; saves default and current value
359
360 movlw LOW sampling_divisor_nyu2
361 rcall reset_customfunction ; saves default and current value
362
363 movlw LOW cns_display_high
364 rcall reset_customfunction ; saves default and current value
365
366 clrf hi
367 bsf hi,7 ; 15Bit value
368 movlw LOW logbook_offset
369 rcall reset_customfunction ; saves default and current value
370
371 movlw LOW last_deco_depth
372 rcall reset_customfunction ; saves default and current value
373
374 movlw LOW timeout_apnoe_mode
375 rcall reset_customfunction ; saves default and current value
376
377 movlw LOW show_voltage_value
378 rcall reset_customfunction ; saves default and current value
379 349
380 reset_all_cf_bank1: 350 reset_all_cf_bank1:
381 movlw d'1' 351 movlw d'1'
382 movwf EEADRH ; EEPROM BANK 1 !! 352 movwf EEADRH ; EEPROM BANK 1 !!
383 movlw d'127' ; address of low byte of first custom function 353 movlw d'127' ; address of low byte of first custom function
384 movwf EEADR 354 movwf EEADR
385 clrf hi ; only required once/bank
386 355
387 movlw LOW GF_low_default 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
361
362 tblrd*+
363 movf TABLAT, W ; Low byte in WREG,
364 tblrd*+
365 movff TABLAT, hi ; High byte in hi
388 rcall reset_customfunction ; saves default and current value 366 rcall reset_customfunction ; saves default and current value
389 367 bra cf_bank1_loop
390 movlw LOW GF_high_default 368
391 rcall reset_customfunction ; saves default and current value 369 cf_bank1_end:
392
393 movlw color_battery_surface
394 rcall reset_customfunction ; saves default and current value
395
396 movlw color_standard1
397 rcall reset_customfunction ; saves default and current value
398
399 movlw color_divemask
400 rcall reset_customfunction ; saves default and current value
401
402 movlw color_warnings
403 rcall reset_customfunction ; saves default and current value
404
405 movlw show_seconds_divemode
406 rcall reset_customfunction ; saves default and current value
407
408 movlw show_clock_divemode
409 rcall reset_customfunction ; saves default and current value
410
411 movlw warn_ceiling_divemode
412 rcall reset_customfunction ; saves default and current value
413
414 movlw start_with_stopwatch
415 rcall reset_customfunction ; saves default and current value
416
417 movlw blink_gas_divemode
418 rcall reset_customfunction ; saves default and current value
419
420 movlw HIGH color_warn_depth_mBar
421 movwf hi
422 bsf hi,7 ; 15Bit value
423 movlw LOW color_warn_depth_mBar
424 rcall reset_customfunction ; saves default and current value
425
426 movlw color_warn_cns_percent
427 rcall reset_customfunction ; saves default and current value
428
429 movlw color_warn_gf_percent
430 rcall reset_customfunction ; saves default and current value
431
432 movlw color_warn_ppo2_cbar
433 rcall reset_customfunction ; saves default and current value
434
435 movlw color_warn_celocity_mmin
436 rcall reset_customfunction ; saves default and current value
437
438 movlw time_correction_value_default
439 rcall reset_customfunction ; saves default and current value
440
441 movlw d'0'
442 rcall reset_customfunction ; saves default and current value
443 movlw d'0'
444 rcall reset_customfunction ; saves default and current value
445 movlw d'0'
446 rcall reset_customfunction ; saves default and current value
447 movlw d'0'
448 rcall reset_customfunction ; saves default and current value
449 movlw d'0'
450 rcall reset_customfunction ; saves default and current value
451 movlw d'0'
452 rcall reset_customfunction ; saves default and current value
453 movlw d'0'
454 rcall reset_customfunction ; saves default and current value
455 movlw d'0'
456 rcall reset_customfunction ; saves default and current value
457 movlw d'0'
458 rcall reset_customfunction ; saves default and current value
459 movlw d'0'
460 rcall reset_customfunction ; saves default and current value
461 movlw d'0'
462 rcall reset_customfunction ; saves default and current value
463 movlw d'0'
464 rcall reset_customfunction ; saves default and current value
465 movlw d'0'
466 rcall reset_customfunction ; saves default and current value
467 movlw d'0'
468 rcall reset_customfunction ; saves default and current value
469 movlw d'0'
470 rcall reset_customfunction ; saves default and current value
471
472 clrf EEADRH ; EEPROM BANK 0 ! 370 clrf EEADRH ; EEPROM BANK 0 !
473 371
474
475 ;call reset_external_eeprom ; delete profile memory 372 ;call reset_external_eeprom ; delete profile memory
476 goto restart ; all reset, quit to surfmode 373 goto restart ; all reset, quit to surfmode
477 374
375 ; Write the four bytes lo:hi:lo:(hi w/o type flags) into EEPROM
376 ; Don't change hi:lo values...
478 reset_customfunction: 377 reset_customfunction:
479 movwf lo 378 movwf lo
480 incf EEADR,F 379 incf EEADR,F
481 movff lo, EEDATA ; Lowbyte Defaul value 380 movff lo, EEDATA ; Lowbyte Defaul value
482 call write_eeprom 381 call write_eeprom
485 call write_eeprom 384 call write_eeprom
486 incf EEADR,F 385 incf EEADR,F
487 movff lo, EEDATA ; Lowbyte current value 386 movff lo, EEDATA ; Lowbyte current value
488 call write_eeprom 387 call write_eeprom
489 incf EEADR,F 388 incf EEADR,F
490 bcf hi,7 ; This bit will only be written for the default value
491 movff hi, EEDATA ; Highbyte current value 389 movff hi, EEDATA ; Highbyte current value
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
492 call write_eeprom 396 call write_eeprom
493 clrf hi
494 return 397 return
495 398
496 399
497 reset_external_eeprom: ; deletes complete external eeprom! 400 reset_external_eeprom: ; deletes complete external eeprom!
498 clrf eeprom_address+0 401 clrf eeprom_address+0