Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 217:ce6f16711567
BUGFIX gas switch
+ Make sure not to pass gas switch
+ Don't clobber ratio N2/He when canceling ascent passing gas switch.
+ Build-up GF_low history during the whole dive.
author | JeanDo |
---|---|
date | Thu, 24 Feb 2011 23:22:32 +0100 |
parents | f5e9db793dd3 |
children | 8dbcc26878d3 |
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 ; Gas Setup menu | |
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
21 ; written: 10/08/07 | |
22 ; last updated: 080906 | |
23 ; known bugs: | |
24 ; ToDo: | |
25 | |
26 menu_gassetup: | |
27 movlw d'1' | |
28 movwf menupos | |
29 | |
30 menu_gassetup_prelist: | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
31 call PLED_ClearScreen |
47 | 32 call gassetup_sort_gaslist ; Sorts Gaslist according to change depth |
0 | 33 clrf timeout_counter2 |
34 bcf sleepmode | |
35 bcf menubit2 | |
36 bcf menubit3 | |
37 call PLED_topline_box | |
38 WIN_INVERT .1 ; Init new Wordprocessor | |
39 DISPLAYTEXT .106 ; Gas List | |
40 WIN_INVERT .0 ; Init new Wordprocessor | |
41 clrf decodata+0 ; Here: # of gas 0-4 | |
42 clrf divemins+0 ; Here: # of Gas * 4 | |
43 movlw d'5' | |
44 movwf waitms_temp ; here: stores row for gas list | |
45 movlw d'2' | |
46 movwf wait_temp ; here: stores eeprom address for gas list | |
47 | |
48 ; Changed v1.44se | |
49 menu_gassetup_list: | |
50 WIN_LEFT .20 | |
51 movlw d'4' | |
52 addwf wait_temp,F ; Increase eeprom address for gas list | |
53 movlw d'30' | |
54 addwf waitms_temp,F ; Increase row | |
55 movf waitms_temp,W ; Load row into WREG | |
56 movff WREG,win_top | |
57 lfsr FSR2,letter | |
123 | 58 PUTC 'G' |
0 | 59 movff decodata+0,lo |
60 incf lo,F | |
61 bsf leftbind | |
62 output_99 | |
123 | 63 PUTC ':' |
0 | 64 |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
65 movf decodata+0,W |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
66 call PLED_grey_inactive_gas ; Sets Greyvalue for inactive gases |
0 | 67 call word_processor |
68 WIN_LEFT .40 | |
69 movf waitms_temp,W ; Load row into WREG | |
70 movff WREG,win_top | |
71 lfsr FSR2,letter | |
72 | |
73 movlw d'33' | |
74 movwf EEADR | |
75 call read_eeprom ; Get current startgas 1-5 # into EEDATA | |
76 decf EEDATA,W ; 0-4 | |
77 cpfseq decodata+0 ; =current displayed gas #? | |
78 bra menu_gassetup_Tx ; no, do not display * | |
123 | 79 PUTC '*' ; display * |
0 | 80 |
81 ; New v1.44se | |
82 menu_gassetup_Tx: | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
83 movf decodata+0,W |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
84 call PLED_grey_inactive_gas ; Sets Greyvalue for inactive gases |
0 | 85 call word_processor |
86 | |
87 WIN_LEFT .48 | |
88 movf waitms_temp,W ; Load row into WREG | |
89 movff WREG,win_top | |
90 lfsr FSR2,letter | |
91 | |
92 movff wait_temp, EEADR ; Gas %He - Set address in internal EEPROM | |
93 incf EEADR,F ; Gas %He - Set address in internal EEPROM | |
94 call read_eeprom ; Read He value from EEPROM | |
95 movff EEDATA,lo ; Move EEDATA -> lo | |
96 movf lo,f ; Move lo -> f | |
97 movlw d'0' ; Move 0 -> WREG | |
98 cpfsgt lo ; He > 0? | |
99 bra menu_gassetup_Nx ; NO check o2 | |
100 | |
101 ; YES Write TX 15/55 | |
102 call gassetup_write_Tx | |
103 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM | |
104 call read_eeprom ; O2 value | |
105 movff EEDATA,lo | |
106 output_8 | |
123 | 107 PUTC '/' |
0 | 108 incf EEADR,F ; Gas #hi: %He - Set address in internal EEPROM |
109 call read_eeprom ; He value | |
110 movff EEDATA,lo | |
111 output_8 | |
112 bra menu_gassetup_list0 | |
113 | |
114 ; New v1.44se | |
115 menu_gassetup_Nx: | |
116 movff wait_temp, EEADR ; Gas %O2 - Set address in internal EEPROM | |
117 call read_eeprom ; Read O2 value from EEPROM | |
118 movff EEDATA,lo ; Move EEDATA -> lo | |
119 movf lo,f ; Move lo -> f | |
120 movlw d'21' ; Move 21 -> WREG | |
121 cpfsgt lo ; o2 > 21% | |
122 bra menu_gassetup_Air ; NO AIR | |
123 movlw d'100' ; Move 100 -> WREG | |
124 cpfslt lo ; o2 < 100% | |
125 bra menu_gassetup_O2 ; NO write O2 | |
126 | |
127 ; YES Write NX 32 | |
128 call gassetup_write_Nx | |
129 output_8 | |
130 bra menu_gassetup_list0 | |
131 | |
132 ; New v1.44se | |
133 menu_gassetup_O2: | |
123 | 134 STRCAT "O2 " |
0 | 135 output_8 |
136 bra menu_gassetup_list0 | |
137 | |
138 ; New v1.44se | |
139 menu_gassetup_Air: | |
140 cpfseq lo ; o2 = 21% | |
141 call menu_gassetup_Err | |
142 | |
123 | 143 STRCAT "AIR " |
0 | 144 output_8 |
145 bra menu_gassetup_list0 | |
146 | |
147 ; New v1.44se | |
148 menu_gassetup_Err: | |
123 | 149 STRCAT "ERR " |
0 | 150 output_8 |
151 | |
152 ; Changed v1.44se | |
153 menu_gassetup_list0: | |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
154 movf decodata+0,W |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
155 call PLED_grey_inactive_gas ; Sets Greyvalue for inactive gases |
0 | 156 call word_processor |
157 | |
158 WIN_LEFT .105 | |
159 movf waitms_temp,W ; Load row into WREG | |
160 movff WREG,win_top | |
161 lfsr FSR2,letter | |
162 | |
123 | 163 STRCAT " in " |
0 | 164 movf decodata+0,W ; read current value |
165 addlw d'28' ; offset in memory | |
166 movwf EEADR | |
167 call read_eeprom ; Low-value | |
168 movff EEDATA,lo | |
169 output_8 | |
123 | 170 PUTC 'm' |
121
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
171 movf decodata+0,W |
e0f29e20bd24
Mix-type icons: check apnoe/gauge/CF#41, depth=0, and first gas. Changed colors.
JeanDo
parents:
115
diff
changeset
|
172 call PLED_grey_inactive_gas ; Sets Greyvalue for inactive gases |
0 | 173 call word_processor |
174 | |
3 | 175 call PLED_standard_color |
0 | 176 |
177 incf decodata+0,F | |
178 movlw d'5' | |
179 cpfseq decodata+0 | |
180 goto menu_gassetup_list | |
181 | |
182 DISPLAYTEXT .11 ; Exit | |
183 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
184 call PLED_menu_cursor | |
185 | |
186 gassetup_list_loop: | |
187 call check_switches_logbook | |
188 | |
189 btfsc menubit3 | |
190 bra gassetup_list2 ; move cursor | |
191 | |
192 btfsc menubit2 | |
193 bra do_gassetup_list; call gas-specific submenu | |
194 | |
195 btfsc divemode | |
196 goto restart ; dive started! | |
197 | |
198 btfsc onesecupdate | |
199 call timeout_surfmode | |
200 | |
201 btfsc onesecupdate | |
202 call set_dive_modes | |
203 | |
204 bcf onesecupdate ; 1 sec. functions done | |
205 | |
206 btfsc sleepmode | |
207 bra exit_gassetup_list | |
208 | |
209 bra gassetup_list_loop | |
210 | |
211 gassetup_list2: | |
212 incf menupos,F | |
213 movlw d'7' | |
214 cpfseq menupos ; =7? | |
215 bra gassetup_list3 ; No | |
216 movlw d'1' | |
217 movwf menupos | |
218 | |
219 gassetup_list3: | |
220 clrf timeout_counter2 | |
221 call PLED_menu_cursor | |
222 | |
223 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
224 | |
225 bcf menubit3 ; clear flag | |
226 bra gassetup_list_loop | |
227 | |
228 exit_gassetup_list: ; exit... | |
229 movlw d'2' | |
230 movwf menupos | |
231 goto menu2 | |
232 | |
233 do_gassetup_list: | |
234 dcfsnz menupos,F | |
235 bra gassetup_list_edit_gas1 | |
236 dcfsnz menupos,F | |
237 bra gassetup_list_edit_gas2 | |
238 dcfsnz menupos,F | |
239 bra gassetup_list_edit_gas3 | |
240 dcfsnz menupos,F | |
241 bra gassetup_list_edit_gas4 | |
242 dcfsnz menupos,F | |
243 bra gassetup_list_edit_gas5 | |
244 bra exit_gassetup_list ; Exit List | |
245 | |
246 gassetup_list_edit_gas1: | |
247 movlw d'0' | |
248 movwf decodata+0 | |
249 movlw d'0' | |
250 movwf divemins+0 | |
251 bra menu_gassetup_page1 | |
252 | |
253 gassetup_list_edit_gas2: | |
254 movlw d'1' | |
255 movwf decodata+0 | |
256 movlw d'4' | |
257 movwf divemins+0 | |
258 bra menu_gassetup_page1 | |
259 | |
260 gassetup_list_edit_gas3: | |
261 movlw d'2' | |
262 movwf decodata+0 | |
263 movlw d'8' | |
264 movwf divemins+0 | |
265 bra menu_gassetup_page1 | |
266 | |
267 gassetup_list_edit_gas4: | |
268 movlw d'3' | |
269 movwf decodata+0 | |
270 movlw d'12' | |
271 movwf divemins+0 | |
272 bra menu_gassetup_page1 | |
273 | |
274 gassetup_list_edit_gas5: | |
275 movlw d'4' | |
276 movwf decodata+0 | |
277 movlw d'16' | |
278 movwf divemins+0 | |
279 bra menu_gassetup_page1 | |
280 | |
281 menu_gassetup_page1: | |
282 movlw d'1' | |
283 movwf menupos | |
284 bcf gas_setup_page2 ; Page 1 of gassetup | |
285 bcf menubit4 | |
286 bcf cursor | |
287 bcf sleepmode | |
288 bcf first_FA ; Here: =1: -, =0: + | |
289 | |
290 menu_gassetup0: | |
291 call PLED_ClearScreen | |
98
6f8e3a08011e
1.73beta rc1 (Added new customview for divemode)
heinrichsweikamp
parents:
50
diff
changeset
|
292 DISPLAYTEXT .147 ; More... |
0 | 293 DISPLAYTEXT .11 ; Exit |
294 | |
295 menu_gassetup1: | |
296 clrf timeout_counter2 | |
297 bcf menubit2 | |
298 bcf menubit3 | |
299 | |
300 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info | |
301 | |
302 WIN_LEFT .20 | |
199 | 303 WIN_TOP .65 |
123 | 304 STRCPY "O2: " |
0 | 305 |
306 movf divemins+0,W | |
307 addlw 0x06 | |
308 movwf EEADR | |
199 | 309 call read_eeprom ; O2 value |
0 | 310 movff EEDATA,lo |
311 output_8 | |
199 | 312 STRCAT_PRINT "% " |
0 | 313 |
314 ; Show MOD in m | |
199 | 315 WIN_LEFT .90 |
316 lfsr FSR2, letter | |
317 OUTPUTTEXTH .297 ; MOD: | |
318 | |
319 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
0 | 320 mullw d'10' |
321 movff PRODL,xA+0 | |
199 | 322 movff PRODH,xA+1 ; ppO2 in [0.01Bar] * 10 |
0 | 323 |
324 movf divemins+0,W | |
325 addlw 0x06 | |
326 movwf EEADR | |
199 | 327 call read_eeprom ; O2 value |
0 | 328 movff EEDATA,xB+0 |
329 clrf xB+1 | |
199 | 330 call div16x16 ; xA/xB=xC with xA as remainder |
0 | 331 movlw d'10' |
199 | 332 subwf xC+0,F ; Subtract 10m... |
0 | 333 movff xC+0,lo |
334 movlw d'0' | |
335 subwfb xC+1,F | |
336 movff xC+1,hi | |
337 output_16 | |
199 | 338 STRCAT_PRINT "m " |
0 | 339 |
199 | 340 WIN_LEFT .20 |
0 | 341 WIN_TOP .95 |
123 | 342 STRCPY "He: " |
0 | 343 movf divemins+0,W |
344 addlw 0x07 | |
345 movwf EEADR | |
199 | 346 call read_eeprom ; He value |
0 | 347 movff EEDATA,lo |
348 output_8 | |
199 | 349 STRCAT_PRINT "% " |
105 | 350 |
351 ; Show END in m | |
199 | 352 lfsr FSR2, letter |
353 WIN_LEFT .90 | |
354 OUTPUTTEXTH .298 ; END: | |
355 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
105 | 356 mullw d'10' |
357 movff PRODL,xA+0 | |
199 | 358 movff PRODH,xA+1 ; ppO2 in [0.01Bar] * 10 |
105 | 359 movf divemins+0,W |
360 addlw 0x06 | |
361 movwf EEADR | |
199 | 362 call read_eeprom ; O2 value |
105 | 363 movff EEDATA,xB+0 |
364 clrf xB+1 | |
199 | 365 call div16x16 ; xA/xB=xC with xA as remainder |
105 | 366 movlw d'10' |
199 | 367 subwf xC+0,F ; Subtract 10m... |
105 | 368 movff xC+0,lo |
369 movlw d'0' | |
370 subwfb xC+1,F | |
199 | 371 movff xC+1,hi ; lo:hi holding MOD in meters |
105 | 372 movlw d'10' |
373 addwf lo,F | |
374 movlw d'0' | |
199 | 375 addwfc hi,F ; lo:hi holding MOD+10m |
105 | 376 |
377 movf divemins+0,W | |
378 addlw 0x07 | |
379 movwf EEADR | |
199 | 380 call read_eeprom ; He value in % -> EEDATA |
105 | 381 movlw d'100' |
382 movwf xA+0 | |
199 | 383 movf EEDATA,W ; He value in % -> EEDATA |
384 subwf xA+0,F ; xA+0 = 100 - He Value in % | |
105 | 385 clrf xA+1 |
386 movff lo,xB+0 | |
199 | 387 movff hi,xB+1 ; Copy MOD+10 |
388 call mult16x16 ; xA*xB=xC | |
105 | 389 movff xC+0,xA+0 |
390 movff xC+1,xA+1 | |
391 movlw d'100' | |
392 movwf xB+0 | |
393 clrf xB+1 | |
199 | 394 call div16x16 ; xA/xB=xC with xA as remainder |
105 | 395 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 |
396 movlw d'10' | |
199 | 397 subwf xC+0,F ; Subtract 10m... |
105 | 398 movff xC+0,lo |
399 movlw d'0' | |
400 subwfb xC+1,F | |
401 movff xC+1,hi | |
402 output_16 | |
199 | 403 STRCAT_PRINT "m " |
0 | 404 |
199 | 405 WIN_LEFT .20 |
0 | 406 WIN_TOP .125 |
123 | 407 STRCPY "+/-: " |
0 | 408 movlw '+' |
409 btfsc first_FA | |
410 movlw '-' | |
411 movwf POSTINC2 | |
412 call word_processor | |
413 | |
414 WIN_TOP .155 | |
415 lfsr FSR2,letter | |
199 | 416 OUTPUTTEXT .89 ; Default: |
0 | 417 movf divemins+0,W |
418 addlw 0x04 | |
419 movwf EEADR | |
199 | 420 call read_eeprom ; Default O2 value |
0 | 421 movff EEDATA,lo |
422 output_8 | |
123 | 423 PUTC '/' |
0 | 424 movf divemins+0,W |
425 addlw 0x05 | |
426 movwf EEADR | |
199 | 427 call read_eeprom ; Default He value |
0 | 428 movff EEDATA,lo |
429 output_8 | |
123 | 430 STRCAT_PRINT " " |
0 | 431 |
432 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
433 call PLED_menu_cursor | |
434 | |
435 gassetup_loop: | |
436 call check_switches_logbook | |
437 | |
438 btfsc menubit3 | |
439 bra gassetup2 ; move cursor | |
440 | |
441 btfsc menubit2 | |
442 bra do_gassetup ; call submenu | |
443 | |
444 btfsc divemode | |
445 goto restart ; dive started! | |
446 | |
447 btfsc onesecupdate | |
448 call timeout_surfmode | |
449 | |
450 btfsc onesecupdate | |
451 call set_dive_modes | |
452 | |
453 bcf onesecupdate ; 1 sec. functions done | |
454 | |
455 btfsc sleepmode | |
456 bra exit_gassetup | |
457 | |
458 bra gassetup_loop | |
459 | |
460 gassetup2: | |
461 incf menupos,F | |
462 movlw d'7' | |
463 cpfseq menupos ; =7? | |
464 bra gassetup3 ; No | |
465 movlw d'1' | |
466 movwf menupos | |
467 | |
468 gassetup3: | |
469 | |
470 clrf timeout_counter2 | |
471 call PLED_menu_cursor | |
472 | |
473 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
474 | |
475 bcf menubit3 ; clear flag | |
476 bra gassetup_loop | |
477 | |
478 do_gassetup: | |
479 dcfsnz menupos,F | |
480 bra next_gas_page | |
481 dcfsnz menupos,F | |
482 bra adjust_o2 | |
483 dcfsnz menupos,F | |
484 bra adjust_he | |
485 dcfsnz menupos,F | |
486 bra toggle_plus_minus_gassetup | |
487 dcfsnz menupos,F | |
488 bra restore_gas | |
489 exit_gassetup: ; exit... | |
490 movff decodata+0,menupos | |
491 incf menupos,F | |
492 bra menu_gassetup_prelist | |
493 | |
494 toggle_plus_minus_gassetup: | |
495 btg first_FA | |
496 movlw d'4' | |
497 movwf menupos | |
498 bra menu_gassetup1 ; return | |
499 | |
500 next_gas: | |
501 movlw d'1' | |
502 movwf menupos | |
503 bra menu_gassetup0 ; incl. clear screen | |
504 | |
505 adjust_o2: | |
506 movf divemins+0,W ; read current value | |
507 addlw 0x06 | |
508 movwf EEADR | |
509 call read_eeprom ; Low-value | |
510 movff EEDATA,lo | |
511 | |
512 btfsc first_FA ; Minus? | |
513 bra adjust_o2_1 ; yes, minus! | |
514 | |
515 incf lo,F ; increase O2 | |
516 movlw d'101' | |
517 cpfseq lo | |
518 bra adjust_o2_2 | |
519 movlw d'4' ; LOWER O2 Limit | |
520 movwf lo | |
521 bra adjust_o2_2 | |
522 | |
523 adjust_o2_1: | |
524 decf lo,F ; decrease O2 | |
525 movlw d'3' | |
526 cpfseq lo | |
527 bra adjust_o2_2 | |
528 | |
529 movf divemins+0,W | |
530 addlw 0x07 | |
531 movwf EEADR | |
532 call read_eeprom ; read He value | |
533 | |
534 movlw d'100' | |
535 movwf lo | |
536 movf EEDATA,W ; He value | |
537 subwf lo,F ; lo=100% - He% | |
538 | |
539 adjust_o2_2: ; test if O2+He>100... | |
540 movf divemins+0,W | |
541 addlw 0x07 | |
542 movwf EEADR | |
543 call read_eeprom ; read He value | |
544 movf EEDATA,W ; He value | |
545 addwf lo,W ; add O2 value | |
546 movwf hi ; store in temp | |
547 movlw d'101' | |
548 cpfseq hi ; O2 and He > 100? | |
549 bra adjust_o2_3 ; No! | |
550 | |
551 movlw d'4' ; LOWER O2 Limit | |
552 movwf lo | |
553 | |
554 adjust_o2_3: | |
555 movf divemins+0,W ; save current value | |
556 addlw 0x06 | |
557 movwf EEADR | |
558 movff lo,EEDATA | |
559 call write_eeprom ; Low-value | |
560 | |
561 movlw d'2' | |
562 movwf menupos | |
563 bra menu_gassetup1 | |
564 | |
565 adjust_he: | |
566 movf divemins+0,W ; read current value | |
567 addlw 0x07 | |
568 movwf EEADR | |
569 call read_eeprom ; Low-value | |
570 movff EEDATA,lo | |
571 | |
572 btfsc first_FA ; Minus? | |
573 bra adjust_he_1 ; yes, minus! | |
574 | |
575 incf lo,F | |
576 movlw d'92' ; He limited to (useless) 90% | |
577 cpfseq lo | |
578 bra adjust_he_2 | |
579 clrf lo | |
580 bra adjust_he_2 | |
581 | |
582 adjust_he_1: | |
583 decf lo,F ; decrease He | |
584 movlw d'255' | |
585 cpfseq lo | |
586 bra adjust_he_2 | |
587 clrf lo | |
588 | |
589 adjust_he_2: ; test if O2+He>100... | |
590 movf divemins+0,W | |
591 addlw 0x06 | |
592 movwf EEADR | |
593 call read_eeprom ; read He value | |
594 movf EEDATA,W ; He value | |
595 addwf lo,W ; add O2 value | |
596 movwf hi ; store in temp | |
597 movlw d'101' | |
598 cpfseq hi ; O2 and He > 100? | |
599 bra adjust_he_3 ; No! | |
600 ; clrf lo ; Yes, clear He to zero | |
601 decf lo,F ; reduce He again = unchanged after operation | |
602 | |
603 adjust_he_3: | |
604 movf divemins+0,W ; save current value | |
605 addlw 0x07 | |
606 movwf EEADR | |
607 movff lo,EEDATA | |
608 call write_eeprom ; Low-value | |
609 | |
610 movlw d'3' | |
611 movwf menupos | |
612 bra menu_gassetup1 ; | |
613 | |
614 restore_gas: | |
615 movf divemins+0,W ; read Default value | |
616 addlw 0x04 | |
617 movwf EEADR | |
618 call read_eeprom ; Low-value | |
619 movff EEDATA,lo | |
620 movf divemins+0,W | |
621 addlw 0x05 | |
622 movwf EEADR | |
623 call read_eeprom ; High-value | |
624 movff EEDATA,hi | |
625 | |
626 movf divemins+0,W ; save Default value | |
627 addlw 0x06 | |
628 movwf EEADR | |
629 movff lo,EEDATA | |
630 call write_eeprom ; Low-value | |
631 movf divemins+0,W | |
632 addlw 0x07 | |
633 movwf EEADR | |
634 movff hi,EEDATA | |
635 call write_eeprom ; High-value | |
636 | |
637 movlw d'5' | |
638 movwf menupos | |
639 bra menu_gassetup1 ; | |
640 | |
641 | |
642 next_gas_page: | |
643 call PLED_ClearScreen | |
644 movlw d'1' | |
645 movwf menupos | |
646 DISPLAYTEXT .109 ; Back | |
647 | |
648 DISPLAYTEXT .11 ; Exit | |
649 | |
650 next_gas_page1: | |
651 clrf timeout_counter2 | |
652 bcf menubit2 | |
653 bcf menubit3 | |
654 | |
655 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info | |
656 rcall gassetup_show_ppO2 ; Display the ppO2 of the change depth with the current gas | |
657 | |
658 WIN_TOP .65 | |
659 WIN_LEFT .20 | |
660 lfsr FSR2,letter | |
661 OUTPUTTEXT .105 ; "Active Gas? " | |
662 read_int_eeprom d'27' ; read flag register | |
663 | |
664 ; hi contains active gas flags in BIT0:4 .... | |
665 | |
666 movff decodata+0,lo ; Gas 0-4 | |
667 incf lo,F ; Gas 1-5 | |
668 | |
669 active_gas_display: | |
670 rrcf EEDATA ; roll flags into carry | |
671 decfsz lo,F ; max. 5 times... | |
672 bra active_gas_display | |
673 | |
674 btfss STATUS,C ; test carry | |
675 bra active_gas_display_no | |
676 | |
677 OUTPUTTEXT .96 ; Yes | |
678 bra active_gas_display_end | |
679 | |
680 active_gas_display_no: | |
123 | 681 STRCAT " " ; three spaces instead of "Yes" |
0 | 682 |
683 active_gas_display_end: | |
684 call word_processor | |
685 | |
686 WIN_TOP .95 | |
687 WIN_LEFT .20 | |
688 lfsr FSR2,letter | |
689 OUTPUTTEXT .88 ; First Gas? | |
123 | 690 PUTC ' ' |
0 | 691 |
692 movlw d'33' | |
693 movwf EEADR | |
694 call read_eeprom ; Get current startgas 1-5 # into EEDATA | |
695 decf EEDATA,W ; 0-4 | |
696 cpfseq decodata+0 ; =current displayed gas #? | |
697 bra menu_firstgas0 ; no, display three spaces | |
698 | |
699 OUTPUTTEXT .96 ; Yes | |
700 bra menu_firstgas1 | |
701 | |
702 menu_firstgas0: | |
123 | 703 STRCAT " " ; 3 spaces. |
0 | 704 |
705 menu_firstgas1: | |
706 call word_processor | |
707 | |
708 WIN_TOP .125 | |
709 WIN_LEFT .20 | |
710 lfsr FSR2,letter | |
711 OUTPUTTEXT .107 ; Change+ | |
712 call word_processor | |
713 | |
714 WIN_TOP .155 | |
715 WIN_LEFT .20 | |
716 lfsr FSR2,letter | |
717 OUTPUTTEXT .108 ; Change- | |
718 call word_processor | |
719 | |
720 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
721 call PLED_menu_cursor | |
722 | |
723 next_gas_page_loop: | |
724 call check_switches_logbook | |
725 | |
726 btfsc menubit3 | |
727 bra next_gas_page2 ; move cursor | |
728 | |
729 btfsc menubit2 | |
730 bra do_next_gas_page ; call submenu | |
731 | |
732 btfsc divemode | |
733 goto restart ; dive started! | |
734 | |
735 btfsc onesecupdate | |
736 call timeout_surfmode | |
737 | |
738 btfsc onesecupdate | |
739 call set_dive_modes | |
740 | |
741 bcf onesecupdate ; 1 sec. functions done | |
742 | |
743 btfsc sleepmode | |
744 bra exit_gassetup | |
745 | |
746 bra next_gas_page_loop | |
747 | |
748 next_gas_page2: | |
749 incf menupos,F | |
750 | |
751 movlw d'7' | |
752 cpfseq menupos ; =7? | |
753 bra next_gas_page3 ; No | |
754 movlw d'1' | |
755 movwf menupos | |
756 | |
757 next_gas_page3: | |
758 clrf timeout_counter2 | |
759 call PLED_menu_cursor | |
760 | |
761 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
762 | |
763 bcf menubit3 ; clear flag | |
764 bra next_gas_page_loop | |
765 | |
766 do_next_gas_page: | |
767 dcfsnz menupos,F | |
768 bra next_gas | |
769 dcfsnz menupos,F | |
770 bra toggle_active_gas | |
771 dcfsnz menupos,F | |
772 bra make_first_gas | |
773 dcfsnz menupos,F | |
774 bra change_gas_depth_plus | |
775 dcfsnz menupos,F | |
776 bra change_gas_depth_minus | |
777 bra exit_gassetup ; Exit menu | |
778 | |
779 make_first_gas: | |
780 movff decodata+0,EEDATA ; current gas (0-4) into EEDATA | |
781 incf EEDATA,F ; current gas (1-5) into EEDATA | |
782 movlw d'33' | |
783 movwf EEADR | |
784 call write_eeprom ; store in internal EEPROM | |
115 | 785 |
786 ; Set First gas to "Active" | |
787 read_int_eeprom d'27' ; read flag register | |
788 movff decodata+0,lo ; selected gas 0-4 | |
789 incf lo,F | |
790 dcfsnz lo,F | |
791 bsf EEDATA,0 | |
792 dcfsnz lo,F | |
793 bsf EEDATA,1 | |
794 dcfsnz lo,F | |
795 bsf EEDATA,2 | |
796 dcfsnz lo,F | |
797 bsf EEDATA,3 | |
798 dcfsnz lo,F | |
799 bsf EEDATA,4 | |
800 write_int_eeprom d'27' ; write flag register | |
801 | |
0 | 802 movlw d'3' |
803 movwf menupos | |
804 bra next_gas_page1 | |
805 | |
806 toggle_active_gas: | |
807 read_int_eeprom d'27' ; read flag register | |
808 movff decodata+0,lo ; selected gas 0-4 | |
809 incf lo,F | |
810 dcfsnz lo,F | |
811 btg EEDATA,0 | |
812 dcfsnz lo,F | |
813 btg EEDATA,1 | |
814 dcfsnz lo,F | |
815 btg EEDATA,2 | |
816 dcfsnz lo,F | |
817 btg EEDATA,3 | |
818 dcfsnz lo,F | |
819 btg EEDATA,4 | |
820 write_int_eeprom d'27' ; write flag register | |
821 movlw d'2' | |
822 movwf menupos | |
823 bra next_gas_page1 | |
824 | |
825 change_gas_depth_plus: | |
826 movf decodata+0,W ; read current value | |
827 addlw d'28' ; offset in memory | |
828 movwf EEADR | |
829 call read_eeprom ; Low-value | |
830 movff EEDATA,lo | |
831 | |
832 incf lo,F ; increase depth | |
833 movlw d'100' ; Change depth limit + 1 | |
834 cpfseq lo | |
835 bra change_gas_depth_plus2 | |
836 movlw d'99' ; Change depth limit | |
837 movwf lo | |
838 change_gas_depth_plus2: | |
839 movff lo,EEDATA ; write result | |
840 call write_eeprom ; save result in EEPROM | |
841 | |
842 movlw d'4' | |
843 movwf menupos | |
844 bra next_gas_page1 | |
845 | |
846 | |
847 change_gas_depth_minus: | |
848 movf decodata+0,W ; read current value | |
849 addlw d'28' ; offset in memory | |
850 movwf EEADR | |
851 call read_eeprom ; Low-value | |
852 movff EEDATA,lo | |
853 | |
854 decf lo,F ; decrease depth | |
855 movlw d'255' | |
856 cpfseq lo | |
857 bra change_gas_depth_minus2 | |
858 movlw d'0' | |
859 movwf lo | |
860 | |
861 change_gas_depth_minus2: | |
862 movff lo,EEDATA ; write result | |
863 call write_eeprom ; save result in EEPROM | |
864 | |
865 movlw d'5' | |
866 movwf menupos | |
867 bra next_gas_page1 | |
868 | |
869 ; Changed v1.44se | |
870 gassetup_title_bar2: | |
871 call PLED_topline_box | |
872 WIN_INVERT .1 ; Init new Wordprocessor | |
873 WIN_TOP .2 | |
874 WIN_LEFT .0 | |
875 lfsr FSR2,letter | |
876 OUTPUTTEXT .95 ; Gas# | |
877 movff decodata+0,lo | |
878 incf lo,F | |
879 bsf leftbind | |
880 output_99 | |
123 | 881 STRCAT_PRINT ": " |
0 | 882 |
883 WIN_TOP .2 | |
884 WIN_LEFT .50 | |
885 lfsr FSR2,letter | |
886 | |
887 ;He check | |
888 movf divemins+0,W | |
889 addlw 0x07 | |
890 movwf EEADR | |
891 call read_eeprom ; He value | |
892 movff EEDATA,lo ; Move EEData -> lo | |
893 movf lo,f ; Move lo -> f | |
894 movlw d'0' ; Move 0 -> WREG | |
895 cpfsgt lo ; He > 0? | |
896 bra gassetup_title_bar3 ; NO check o2 | |
897 | |
898 ; YES Write TX 15/55 | |
899 call gassetup_write_Tx ; Write TX | |
900 movf divemins+0,W | |
901 addlw 0x06 | |
902 movwf EEADR | |
903 call read_eeprom ; O2 value | |
904 movff EEDATA,lo | |
905 output_8 ; Write O2 | |
123 | 906 PUTC '/' |
0 | 907 movf divemins+0,W |
908 addlw 0x07 | |
909 movwf EEADR | |
910 call read_eeprom ; He value | |
911 movff EEDATA,lo | |
912 output_8 ; Write He | |
913 bra gassetup_title_bar7 | |
914 | |
915 ; New v1.44se | |
916 gassetup_title_bar3: ; O2 Check | |
917 movf divemins+0,W | |
918 addlw 0x06 | |
919 movwf EEADR | |
920 call read_eeprom ; O2 value | |
921 movff EEDATA,lo | |
922 movf lo,f ; Move lo -> f | |
923 movlw d'21' ; Move 21 -> WREG | |
924 cpfseq lo ; o2 = 21 | |
925 cpfsgt lo ; o2 > 21% | |
926 bra gassetup_title_bar5 ; NO AIR | |
927 movlw d'100' ; Move 100 -> WREG | |
928 cpfslt lo ; o2 < 100% | |
929 bra gassetup_title_bar4 ; NO write O2 | |
930 | |
931 ; YES Write NX 32 | |
932 call gassetup_write_Nx | |
933 output_8 | |
934 bra gassetup_title_bar7 | |
935 | |
936 ; New v1.44se | |
937 gassetup_title_bar4: | |
123 | 938 STRCAT "O2 " |
0 | 939 output_8 |
940 bra gassetup_title_bar7 | |
941 | |
942 ; New v1.44se | |
943 gassetup_title_bar5: | |
944 cpfseq lo ; o2 = 21% | |
945 bra gassetup_title_bar6 | |
946 | |
123 | 947 STRCAT "AIR " |
0 | 948 output_8 |
949 bra gassetup_title_bar7 | |
950 | |
951 ; New v1.44se | |
952 gassetup_title_bar6: ; ERROR | |
123 | 953 STRCAT "ERR " |
0 | 954 output_8 |
955 bra gassetup_title_bar7 | |
956 | |
957 gassetup_title_bar7: | |
123 | 958 STRCAT " in " |
0 | 959 movf decodata+0,W ; read current value |
960 addlw d'28' ; offset in memory | |
961 movwf EEADR | |
962 call read_eeprom ; Low-value | |
963 movff EEDATA,lo | |
964 output_8 | |
123 | 965 STRCAT_PRINT "m " |
0 | 966 |
967 WIN_INVERT .0 ; Init new Wordprocessor | |
968 return | |
969 | |
970 ; New v1.44se | |
971 gassetup_write_Nx: | |
123 | 972 STRCAT "NX " |
0 | 973 return |
974 | |
975 ; New v1.44se | |
976 gassetup_write_Tx: | |
123 | 977 STRCAT "TX " |
0 | 978 return |
979 | |
980 gassetup_show_ppO2: | |
981 movf divemins+0,W | |
982 addlw 0x06 | |
983 movwf EEADR | |
984 call read_eeprom ; O2 value | |
985 movff EEDATA,hi | |
986 | |
987 movf decodata+0,W ; read current value | |
988 addlw d'28' ; offset in memory | |
989 movwf EEADR | |
990 call read_eeprom ; Change depth in m | |
991 movff EEDATA,lo | |
992 movlw d'10' | |
993 addwf lo,F ; Depth+10m=lo | |
994 movf hi,W | |
995 mulwf lo ; (Depth+10m)*O2 | |
996 movff PRODL,xA+0 | |
997 movff PRODH,xA+1 | |
998 movlw d'10' | |
999 movwf xB+0 | |
1000 clrf xB+1 | |
1001 call div16x16 ;xA/xB=xC with xA as remainder | |
1002 movff xC+0,lo ; ((Depth+10m)*O2)/10 = [0.01Bar] ppO2 | |
1003 movff xC+1,hi | |
1004 | |
1005 WIN_LEFT .55 | |
1006 WIN_TOP .35 | |
1007 lfsr FSR2,letter | |
50 | 1008 OUTPUTTEXT d'149' ; (ppO2: |
0 | 1009 output_16dp d'3' |
50 | 1010 OUTPUTTEXT d'150' ; Bar: |
0 | 1011 call word_processor |
35 | 1012 return |
1013 | |
1014 | |
1015 gassetup_sort_gaslist: ; Sorts Gaslist according to change depth | |
1016 ; EEPROM Locations of Gaslist | |
1017 ; Gas1: | |
1018 ; O2 Default:4 | |
1019 ; He Default:5 | |
1020 ; O2 Current:6 | |
1021 ; He Current:7 | |
1022 ; Change: 28 | |
1023 ; Active: 27,0 | |
1024 | |
1025 ; Gas2: | |
1026 ; O2 Default:8 | |
1027 ; He Default:9 | |
1028 ; O2 Current:10 | |
1029 ; He Current:11 | |
1030 ; Change: 29 | |
1031 ; Active: 27,1 | |
1032 | |
1033 ; Gas3: | |
1034 ; O2 Default:12 | |
1035 ; He Default:13 | |
1036 ; O2 Current:14 | |
1037 ; He Current:15 | |
1038 ; Change: 30 | |
1039 ; Active: 27,2 | |
1040 | |
1041 ; Gas4: | |
1042 ; O2 Default:16 | |
1043 ; He Default:17 | |
1044 ; O2 Current:18 | |
1045 ; He Current:19 | |
1046 ; Change: 31 | |
1047 ; Active: 27,3 | |
1048 | |
1049 ; Gas5: | |
1050 ; O2 Default:20 | |
1051 ; He Default:21 | |
1052 ; O2 Current:22 | |
1053 ; He Current:23 | |
1054 ; Change: 32 | |
1055 ; Active: 27,4 | |
1056 | |
47 | 1057 ; reset Change depths (Important for all users who upgrade from <1.60!) |
1058 clrf EEADRH | |
1059 clrf EEDATA | |
1060 write_int_eeprom d'118' ; | |
1061 write_int_eeprom d'119' ; | |
1062 write_int_eeprom d'120' ; | |
1063 write_int_eeprom d'121' ; | |
1064 write_int_eeprom d'122' ; | |
1065 movlw d'21' ; O2 Current | |
1066 movwf EEDATA | |
1067 write_int_eeprom d'96' ; | |
1068 write_int_eeprom d'100' ; | |
1069 write_int_eeprom d'104' ; | |
1070 write_int_eeprom d'108' ; | |
1071 write_int_eeprom d'112' ; | |
1072 | |
1073 clrf EEDATA ; He Current | |
1074 write_int_eeprom d'97' ; | |
1075 write_int_eeprom d'101' ; | |
1076 write_int_eeprom d'105' ; | |
1077 write_int_eeprom d'109' ; | |
1078 write_int_eeprom d'113' ; | |
1079 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1080 ; Find deepest Gas |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1081 ; Copy all to RAM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1082 movlw d'3' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1083 movwf EEADR |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1084 clrf EEADRH |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1085 lfsr FSR2,letter ; Store gases in Letter buffer (max. 26Byte!) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1086 gassetup_sort_gaslist1: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1087 incf EEADR,F ; Next Adress |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1088 call read_eeprom ; Read byte |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1089 movff EEDATA,POSTINC2 ; Copy into RAM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1090 movlw d'23' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1091 cpfseq EEADR ; All done? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1092 bra gassetup_sort_gaslist1 ; No, not yet |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1093 ; Letter+0 = EEPROM 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1094 ; ... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1095 ; Letter+20 = EEPROM 23 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1096 read_int_eeprom d'28' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1097 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+21 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1098 read_int_eeprom d'29' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1099 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+22 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1100 read_int_eeprom d'30' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1101 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+23 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1102 read_int_eeprom d'31' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1103 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+24 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1104 read_int_eeprom d'32' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1105 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+25 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1106 read_int_eeprom d'27' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1107 movff EEDATA,POSTINC2 ; Active Byte -> Letter+26 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1108 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1109 ; All change depths = 0? -> Skip sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1110 lfsr FSR2,letter+.20 ; Change depths... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1111 movlw d'5' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1112 movwf logbook_temp3 ; Gas (0-4) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1113 clrf logbook_temp1 ; counter |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1114 gassetup_sort_gaslist1a: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1115 movf POSTINC2,W |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1116 addwf logbook_temp1,F ; sum |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1117 decfsz logbook_temp3,F ; Loop |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1118 bra gassetup_sort_gaslist1a |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1119 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1120 tstfsz logbook_temp1 ; All depths = 0? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1121 bra gassetup_sort_gaslist1b ; No |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1122 return ; Yes, skip all! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1123 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1124 gassetup_sort_gaslist1b: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1125 ; Initialize sorting... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1126 bcf menubit2 ; Change Start gas only 1x |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1127 movlw d'99' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1128 movwf logbook_temp4 ; Last Gas change depth |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1129 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1130 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1131 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1132 movlw d'5' ; Gas 5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1133 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1134 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1135 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1136 write_int_eeprom d'122' ; Write Change Depth Gas 5 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1137 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1138 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1139 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1140 movlw d'4' ; Gas 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1141 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1142 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1143 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1144 write_int_eeprom d'121' ; Write Change Depth Gas 4 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1145 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1146 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1147 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 3 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1148 movlw d'3' ; Gas 3 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1149 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1150 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1151 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1152 write_int_eeprom d'120' ; Write Change Depth Gas 3 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1153 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1154 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1155 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 2 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1156 movlw d'2' ; Gas 2 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1157 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1158 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1159 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1160 write_int_eeprom d'119' ; Write Change Depth Gas 2 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1161 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1162 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1163 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1164 movlw d'1' ; Gas 1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1165 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1166 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1167 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1168 write_int_eeprom d'118' ; Write Change Depth Gas 1 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1169 return |
35 | 1170 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1171 gassetup_sort_sort: |
41 | 1172 clrf logbook_temp2 ; Gas (0-4) |
1173 clrf logbook_temp1 ; Here: Change depth in m | |
1174 clrf logbook_temp3 ; Gas (0-4) | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1175 |
41 | 1176 lfsr FSR2,letter+.20 ; Change depths... |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1177 gassetup_sort_gaslist2: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1178 movf POSTINC2,W ; Get Change depth into WREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1179 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1180 cpfsgt logbook_temp4 ; logbook_temp4 < W? Here: Change depth of last sort run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1181 bra gassetup_sort_gaslist3 ; Skip, tested depth > max. Depth from last run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1182 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1183 cpfslt logbook_temp1 ; logbook_temp1 < W? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1184 bra gassetup_sort_gaslist3 ; Skip, tested depth < max. Depth from this run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1185 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1186 movwf logbook_temp1 ; copy new depth (current run) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1187 movff logbook_temp2,logbook_temp3 ; Holds deepest Gas 0-4 of this run |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1188 gassetup_sort_gaslist3: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1189 incf logbook_temp2,F ; Check next Gas |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1190 movlw d'5' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1191 cpfseq logbook_temp2 ; All done? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1192 bra gassetup_sort_gaslist2 ; No |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1193 gassetup_sort_gaslist4: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1194 movff logbook_temp1,logbook_temp4 ; copy new depth (Store for next run) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1195 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1196 ; Debugger |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1197 ;call enable_rs232 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1198 ; movff logbook_temp1,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1199 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1200 ; movff logbook_temp2,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1201 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1202 ; movff logbook_temp3,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1203 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1204 ; movff logbook_temp4,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1205 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1206 ; movff logbook_temp5,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1207 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1208 ; WAITMS d'255' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1209 return |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1210 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1211 gassetup_sort_store: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1212 lfsr FSR2,letter ; Point to Gas0 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1213 movf logbook_temp3,W |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1214 mullw d'4' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1215 movf PRODL,W ; x4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1216 addwf FSR2L,F |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1217 movlw d'0' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1218 addwfc FSR2H,F ; Point to Gas #logbook_temp3 (0-4) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1219 |
50 | 1220 ; btfsc menubit2 ; Change Start gas only 1x |
1221 ; bra gassetup_sort_store2 ; Skip | |
1222 ;; First Gas: 33 (1-5) | |
1223 ;; Was gas #logbook_temp3 first gas? | |
1224 ; read_int_eeprom d'33' ; Get old first gas (1-5) | |
1225 ; incf logbook_temp3,W ; Gas 1-5 -> WREG | |
1226 ; cpfseq EEDATA ; Compare with EEDATA d'33' | |
1227 ; bra gassetup_sort_store2 ; Was not first gas! | |
1228 ; movff logbook_temp5,EEDATA ; Copy new first gas | |
1229 ; write_int_eeprom d'123' ; Store | |
1230 ; bsf menubit2 ; Done. Do not change again. | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1231 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1232 gassetup_sort_store2: |
45 | 1233 ; Was Gas #logbook_temp3 active? |
1234 ; Letter+26 holds active bits 25? | |
1235 movff logbook_temp3,logbook_temp6 ; Counter 0-4 | |
1236 incf logbook_temp6,F ; Counter 1-5 | |
1237 movff letter+.25, logbook_temp2 ; No longer used | |
1238 read_int_eeprom d'27' ; Active flag register | |
1239 gassetup_sort_store3: | |
1240 rrcf logbook_temp2,F ; Shift into Carry | |
1241 decfsz logbook_temp6,F ; 1-5 x | |
1242 bra gassetup_sort_store3 ; Loop | |
1243 ; Carry now holds active bit of gas #logbook_temp3 (0-4) | |
1244 | |
1245 btfss STATUS,C ; Was Gas active? | |
1246 clrf logbook_temp1 ; No!, Clear change Depth to make it inactive for sorted list! | |
1247 | |
49 | 1248 ;call enable_rs232 |
1249 ;movff logbook_temp1,TXREG | |
1250 ;call rs232_wait_tx ; wait for UART | |
1251 | |
1252 movf logbook_temp5,W ; 1-5 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1253 mullw d'4' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1254 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5 |
45 | 1255 movlw d'90' ; +90 Offset to new... |
1256 addwf EEADR,F ; ..sorted list! | |
1257 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1258 movff POSTINC2,EEDATA ; O2 Default |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1259 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1260 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1261 movff POSTINC2,EEDATA ; He Default |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1262 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1263 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1264 movff POSTINC2,EEDATA ; O2 Current |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1265 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1266 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1267 movff POSTINC2,EEDATA ; He Current |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1268 call write_eeprom ; store in internal EEPROM |
0 | 1269 return |