Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 134:48f12271eb18
divingmode graphs
small fix in altimeter menu
author | heinrichsweikamp |
---|---|
date | Wed, 05 Jan 2011 12:40:06 +0100 |
parents | 6a94f96e9cea |
children | f5e9db793dd3 |
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_TOP .65 | |
303 WIN_LEFT .20 | |
123 | 304 |
305 STRCPY "O2: " | |
0 | 306 |
307 movf divemins+0,W | |
308 addlw 0x06 | |
309 movwf EEADR | |
310 call read_eeprom ; O2 value | |
311 movff EEDATA,lo | |
312 output_8 | |
123 | 313 STRCAT "% (MOD:" |
0 | 314 |
315 ; Show MOD in m | |
316 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
317 mullw d'10' | |
318 movff PRODL,xA+0 | |
319 movff PRODH,xA+1 ; ppO2 in [0.01Bar] * 10 | |
320 | |
321 movf divemins+0,W | |
322 addlw 0x06 | |
323 movwf EEADR | |
324 call read_eeprom ; O2 value | |
325 movff EEDATA,xB+0 | |
326 clrf xB+1 | |
327 call div16x16 ;xA/xB=xC with xA as remainder | |
328 movlw d'10' | |
329 subwf xC+0,F ; Subtract 10m... | |
330 movff xC+0,lo | |
331 movlw d'0' | |
332 subwfb xC+1,F | |
333 movff xC+1,hi | |
334 output_16 | |
123 | 335 STRCAT_PRINT "m) " |
0 | 336 |
337 WIN_TOP .95 | |
123 | 338 STRCPY "He: " |
0 | 339 movf divemins+0,W |
340 addlw 0x07 | |
341 movwf EEADR | |
342 call read_eeprom ; He value | |
343 movff EEDATA,lo | |
344 output_8 | |
123 | 345 STRCAT "% (END:" |
105 | 346 |
347 ; Show END in m | |
348 GETCUSTOM8 .18 ; ppO2 warnvalue in WREG | |
349 mullw d'10' | |
350 movff PRODL,xA+0 | |
351 movff PRODH,xA+1 ; ppO2 in [0.01Bar] * 10 | |
352 movf divemins+0,W | |
353 addlw 0x06 | |
354 movwf EEADR | |
355 call read_eeprom ; O2 value | |
356 movff EEDATA,xB+0 | |
357 clrf xB+1 | |
358 call div16x16 ;xA/xB=xC with xA as remainder | |
359 movlw d'10' | |
360 subwf xC+0,F ; Subtract 10m... | |
361 movff xC+0,lo | |
362 movlw d'0' | |
363 subwfb xC+1,F | |
364 movff xC+1,hi ; lo:hi holding MOD in meters | |
365 movlw d'10' | |
366 addwf lo,F | |
367 movlw d'0' | |
368 addwfc hi,F ; lo:hi holding MOD+10m | |
369 | |
370 movf divemins+0,W | |
371 addlw 0x07 | |
372 movwf EEADR | |
373 call read_eeprom ; He value in % -> EEDATA | |
374 movlw d'100' | |
375 movwf xA+0 | |
376 movf EEDATA,W ; He value in % -> EEDATA | |
377 subwf xA+0,F ; xA+0 = 100 - He Value in % | |
378 clrf xA+1 | |
379 movff lo,xB+0 | |
380 movff hi,xB+1 ; Copy MOD+10 | |
381 call mult16x16 ;xA*xB=xC | |
382 movff xC+0,xA+0 | |
383 movff xC+1,xA+1 | |
384 movlw d'100' | |
385 movwf xB+0 | |
386 clrf xB+1 | |
387 call div16x16 ;xA/xB=xC with xA as remainder | |
388 ; xC:2 = ((MOD+10) * 100 - HE Value in %) / 100 | |
389 movlw d'10' | |
390 subwf xC+0,F ; Subtract 10m... | |
391 movff xC+0,lo | |
392 movlw d'0' | |
393 subwfb xC+1,F | |
394 movff xC+1,hi | |
395 output_16 | |
123 | 396 STRCAT_PRINT "m) " |
0 | 397 |
398 WIN_TOP .125 | |
123 | 399 STRCPY "+/-: " |
0 | 400 movlw '+' |
401 btfsc first_FA | |
402 movlw '-' | |
403 movwf POSTINC2 | |
404 call word_processor | |
405 | |
406 WIN_TOP .155 | |
407 lfsr FSR2,letter | |
408 OUTPUTTEXT .89 ; Default: | |
409 movf divemins+0,W | |
410 addlw 0x04 | |
411 movwf EEADR | |
412 call read_eeprom ; Default O2 value | |
413 movff EEDATA,lo | |
414 output_8 | |
123 | 415 PUTC '/' |
0 | 416 movf divemins+0,W |
417 addlw 0x05 | |
418 movwf EEADR | |
419 call read_eeprom ; Default He value | |
420 movff EEDATA,lo | |
421 output_8 | |
123 | 422 STRCAT_PRINT " " |
0 | 423 |
424 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
425 call PLED_menu_cursor | |
426 | |
427 gassetup_loop: | |
428 call check_switches_logbook | |
429 | |
430 btfsc menubit3 | |
431 bra gassetup2 ; move cursor | |
432 | |
433 btfsc menubit2 | |
434 bra do_gassetup ; call submenu | |
435 | |
436 btfsc divemode | |
437 goto restart ; dive started! | |
438 | |
439 btfsc onesecupdate | |
440 call timeout_surfmode | |
441 | |
442 btfsc onesecupdate | |
443 call set_dive_modes | |
444 | |
445 bcf onesecupdate ; 1 sec. functions done | |
446 | |
447 btfsc sleepmode | |
448 bra exit_gassetup | |
449 | |
450 bra gassetup_loop | |
451 | |
452 gassetup2: | |
453 incf menupos,F | |
454 movlw d'7' | |
455 cpfseq menupos ; =7? | |
456 bra gassetup3 ; No | |
457 movlw d'1' | |
458 movwf menupos | |
459 | |
460 gassetup3: | |
461 | |
462 clrf timeout_counter2 | |
463 call PLED_menu_cursor | |
464 | |
465 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
466 | |
467 bcf menubit3 ; clear flag | |
468 bra gassetup_loop | |
469 | |
470 do_gassetup: | |
471 dcfsnz menupos,F | |
472 bra next_gas_page | |
473 dcfsnz menupos,F | |
474 bra adjust_o2 | |
475 dcfsnz menupos,F | |
476 bra adjust_he | |
477 dcfsnz menupos,F | |
478 bra toggle_plus_minus_gassetup | |
479 dcfsnz menupos,F | |
480 bra restore_gas | |
481 exit_gassetup: ; exit... | |
482 movff decodata+0,menupos | |
483 incf menupos,F | |
484 bra menu_gassetup_prelist | |
485 | |
486 toggle_plus_minus_gassetup: | |
487 btg first_FA | |
488 movlw d'4' | |
489 movwf menupos | |
490 bra menu_gassetup1 ; return | |
491 | |
492 next_gas: | |
493 movlw d'1' | |
494 movwf menupos | |
495 bra menu_gassetup0 ; incl. clear screen | |
496 | |
497 adjust_o2: | |
498 movf divemins+0,W ; read current value | |
499 addlw 0x06 | |
500 movwf EEADR | |
501 call read_eeprom ; Low-value | |
502 movff EEDATA,lo | |
503 | |
504 btfsc first_FA ; Minus? | |
505 bra adjust_o2_1 ; yes, minus! | |
506 | |
507 incf lo,F ; increase O2 | |
508 movlw d'101' | |
509 cpfseq lo | |
510 bra adjust_o2_2 | |
511 movlw d'4' ; LOWER O2 Limit | |
512 movwf lo | |
513 bra adjust_o2_2 | |
514 | |
515 adjust_o2_1: | |
516 decf lo,F ; decrease O2 | |
517 movlw d'3' | |
518 cpfseq lo | |
519 bra adjust_o2_2 | |
520 | |
521 movf divemins+0,W | |
522 addlw 0x07 | |
523 movwf EEADR | |
524 call read_eeprom ; read He value | |
525 | |
526 movlw d'100' | |
527 movwf lo | |
528 movf EEDATA,W ; He value | |
529 subwf lo,F ; lo=100% - He% | |
530 | |
531 adjust_o2_2: ; test if O2+He>100... | |
532 movf divemins+0,W | |
533 addlw 0x07 | |
534 movwf EEADR | |
535 call read_eeprom ; read He value | |
536 movf EEDATA,W ; He value | |
537 addwf lo,W ; add O2 value | |
538 movwf hi ; store in temp | |
539 movlw d'101' | |
540 cpfseq hi ; O2 and He > 100? | |
541 bra adjust_o2_3 ; No! | |
542 | |
543 movlw d'4' ; LOWER O2 Limit | |
544 movwf lo | |
545 | |
546 adjust_o2_3: | |
547 movf divemins+0,W ; save current value | |
548 addlw 0x06 | |
549 movwf EEADR | |
550 movff lo,EEDATA | |
551 call write_eeprom ; Low-value | |
552 | |
553 movlw d'2' | |
554 movwf menupos | |
555 bra menu_gassetup1 | |
556 | |
557 adjust_he: | |
558 movf divemins+0,W ; read current value | |
559 addlw 0x07 | |
560 movwf EEADR | |
561 call read_eeprom ; Low-value | |
562 movff EEDATA,lo | |
563 | |
564 btfsc first_FA ; Minus? | |
565 bra adjust_he_1 ; yes, minus! | |
566 | |
567 incf lo,F | |
568 movlw d'92' ; He limited to (useless) 90% | |
569 cpfseq lo | |
570 bra adjust_he_2 | |
571 clrf lo | |
572 bra adjust_he_2 | |
573 | |
574 adjust_he_1: | |
575 decf lo,F ; decrease He | |
576 movlw d'255' | |
577 cpfseq lo | |
578 bra adjust_he_2 | |
579 clrf lo | |
580 | |
581 adjust_he_2: ; test if O2+He>100... | |
582 movf divemins+0,W | |
583 addlw 0x06 | |
584 movwf EEADR | |
585 call read_eeprom ; read He value | |
586 movf EEDATA,W ; He value | |
587 addwf lo,W ; add O2 value | |
588 movwf hi ; store in temp | |
589 movlw d'101' | |
590 cpfseq hi ; O2 and He > 100? | |
591 bra adjust_he_3 ; No! | |
592 ; clrf lo ; Yes, clear He to zero | |
593 decf lo,F ; reduce He again = unchanged after operation | |
594 | |
595 adjust_he_3: | |
596 movf divemins+0,W ; save current value | |
597 addlw 0x07 | |
598 movwf EEADR | |
599 movff lo,EEDATA | |
600 call write_eeprom ; Low-value | |
601 | |
602 movlw d'3' | |
603 movwf menupos | |
604 bra menu_gassetup1 ; | |
605 | |
606 restore_gas: | |
607 movf divemins+0,W ; read Default value | |
608 addlw 0x04 | |
609 movwf EEADR | |
610 call read_eeprom ; Low-value | |
611 movff EEDATA,lo | |
612 movf divemins+0,W | |
613 addlw 0x05 | |
614 movwf EEADR | |
615 call read_eeprom ; High-value | |
616 movff EEDATA,hi | |
617 | |
618 movf divemins+0,W ; save Default value | |
619 addlw 0x06 | |
620 movwf EEADR | |
621 movff lo,EEDATA | |
622 call write_eeprom ; Low-value | |
623 movf divemins+0,W | |
624 addlw 0x07 | |
625 movwf EEADR | |
626 movff hi,EEDATA | |
627 call write_eeprom ; High-value | |
628 | |
629 movlw d'5' | |
630 movwf menupos | |
631 bra menu_gassetup1 ; | |
632 | |
633 | |
634 next_gas_page: | |
635 call PLED_ClearScreen | |
636 movlw d'1' | |
637 movwf menupos | |
638 DISPLAYTEXT .109 ; Back | |
639 | |
640 DISPLAYTEXT .11 ; Exit | |
641 | |
642 next_gas_page1: | |
643 clrf timeout_counter2 | |
644 bcf menubit2 | |
645 bcf menubit3 | |
646 | |
647 rcall gassetup_title_bar2 ; Displays the title bar with the current Gas info | |
648 rcall gassetup_show_ppO2 ; Display the ppO2 of the change depth with the current gas | |
649 | |
650 WIN_TOP .65 | |
651 WIN_LEFT .20 | |
652 lfsr FSR2,letter | |
653 OUTPUTTEXT .105 ; "Active Gas? " | |
654 read_int_eeprom d'27' ; read flag register | |
655 | |
656 ; hi contains active gas flags in BIT0:4 .... | |
657 | |
658 movff decodata+0,lo ; Gas 0-4 | |
659 incf lo,F ; Gas 1-5 | |
660 | |
661 active_gas_display: | |
662 rrcf EEDATA ; roll flags into carry | |
663 decfsz lo,F ; max. 5 times... | |
664 bra active_gas_display | |
665 | |
666 btfss STATUS,C ; test carry | |
667 bra active_gas_display_no | |
668 | |
669 OUTPUTTEXT .96 ; Yes | |
670 bra active_gas_display_end | |
671 | |
672 active_gas_display_no: | |
123 | 673 STRCAT " " ; three spaces instead of "Yes" |
0 | 674 |
675 active_gas_display_end: | |
676 call word_processor | |
677 | |
678 WIN_TOP .95 | |
679 WIN_LEFT .20 | |
680 lfsr FSR2,letter | |
681 OUTPUTTEXT .88 ; First Gas? | |
123 | 682 PUTC ' ' |
0 | 683 |
684 movlw d'33' | |
685 movwf EEADR | |
686 call read_eeprom ; Get current startgas 1-5 # into EEDATA | |
687 decf EEDATA,W ; 0-4 | |
688 cpfseq decodata+0 ; =current displayed gas #? | |
689 bra menu_firstgas0 ; no, display three spaces | |
690 | |
691 OUTPUTTEXT .96 ; Yes | |
692 bra menu_firstgas1 | |
693 | |
694 menu_firstgas0: | |
123 | 695 STRCAT " " ; 3 spaces. |
0 | 696 |
697 menu_firstgas1: | |
698 call word_processor | |
699 | |
700 WIN_TOP .125 | |
701 WIN_LEFT .20 | |
702 lfsr FSR2,letter | |
703 OUTPUTTEXT .107 ; Change+ | |
704 call word_processor | |
705 | |
706 WIN_TOP .155 | |
707 WIN_LEFT .20 | |
708 lfsr FSR2,letter | |
709 OUTPUTTEXT .108 ; Change- | |
710 call word_processor | |
711 | |
712 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
713 call PLED_menu_cursor | |
714 | |
715 next_gas_page_loop: | |
716 call check_switches_logbook | |
717 | |
718 btfsc menubit3 | |
719 bra next_gas_page2 ; move cursor | |
720 | |
721 btfsc menubit2 | |
722 bra do_next_gas_page ; call submenu | |
723 | |
724 btfsc divemode | |
725 goto restart ; dive started! | |
726 | |
727 btfsc onesecupdate | |
728 call timeout_surfmode | |
729 | |
730 btfsc onesecupdate | |
731 call set_dive_modes | |
732 | |
733 bcf onesecupdate ; 1 sec. functions done | |
734 | |
735 btfsc sleepmode | |
736 bra exit_gassetup | |
737 | |
738 bra next_gas_page_loop | |
739 | |
740 next_gas_page2: | |
741 incf menupos,F | |
742 | |
743 movlw d'7' | |
744 cpfseq menupos ; =7? | |
745 bra next_gas_page3 ; No | |
746 movlw d'1' | |
747 movwf menupos | |
748 | |
749 next_gas_page3: | |
750 clrf timeout_counter2 | |
751 call PLED_menu_cursor | |
752 | |
753 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
754 | |
755 bcf menubit3 ; clear flag | |
756 bra next_gas_page_loop | |
757 | |
758 do_next_gas_page: | |
759 dcfsnz menupos,F | |
760 bra next_gas | |
761 dcfsnz menupos,F | |
762 bra toggle_active_gas | |
763 dcfsnz menupos,F | |
764 bra make_first_gas | |
765 dcfsnz menupos,F | |
766 bra change_gas_depth_plus | |
767 dcfsnz menupos,F | |
768 bra change_gas_depth_minus | |
769 bra exit_gassetup ; Exit menu | |
770 | |
771 make_first_gas: | |
772 movff decodata+0,EEDATA ; current gas (0-4) into EEDATA | |
773 incf EEDATA,F ; current gas (1-5) into EEDATA | |
774 movlw d'33' | |
775 movwf EEADR | |
776 call write_eeprom ; store in internal EEPROM | |
115 | 777 |
778 ; Set First gas to "Active" | |
779 read_int_eeprom d'27' ; read flag register | |
780 movff decodata+0,lo ; selected gas 0-4 | |
781 incf lo,F | |
782 dcfsnz lo,F | |
783 bsf EEDATA,0 | |
784 dcfsnz lo,F | |
785 bsf EEDATA,1 | |
786 dcfsnz lo,F | |
787 bsf EEDATA,2 | |
788 dcfsnz lo,F | |
789 bsf EEDATA,3 | |
790 dcfsnz lo,F | |
791 bsf EEDATA,4 | |
792 write_int_eeprom d'27' ; write flag register | |
793 | |
0 | 794 movlw d'3' |
795 movwf menupos | |
796 bra next_gas_page1 | |
797 | |
798 toggle_active_gas: | |
799 read_int_eeprom d'27' ; read flag register | |
800 movff decodata+0,lo ; selected gas 0-4 | |
801 incf lo,F | |
802 dcfsnz lo,F | |
803 btg EEDATA,0 | |
804 dcfsnz lo,F | |
805 btg EEDATA,1 | |
806 dcfsnz lo,F | |
807 btg EEDATA,2 | |
808 dcfsnz lo,F | |
809 btg EEDATA,3 | |
810 dcfsnz lo,F | |
811 btg EEDATA,4 | |
812 write_int_eeprom d'27' ; write flag register | |
813 movlw d'2' | |
814 movwf menupos | |
815 bra next_gas_page1 | |
816 | |
817 change_gas_depth_plus: | |
818 movf decodata+0,W ; read current value | |
819 addlw d'28' ; offset in memory | |
820 movwf EEADR | |
821 call read_eeprom ; Low-value | |
822 movff EEDATA,lo | |
823 | |
824 incf lo,F ; increase depth | |
825 movlw d'100' ; Change depth limit + 1 | |
826 cpfseq lo | |
827 bra change_gas_depth_plus2 | |
828 movlw d'99' ; Change depth limit | |
829 movwf lo | |
830 change_gas_depth_plus2: | |
831 movff lo,EEDATA ; write result | |
832 call write_eeprom ; save result in EEPROM | |
833 | |
834 movlw d'4' | |
835 movwf menupos | |
836 bra next_gas_page1 | |
837 | |
838 | |
839 change_gas_depth_minus: | |
840 movf decodata+0,W ; read current value | |
841 addlw d'28' ; offset in memory | |
842 movwf EEADR | |
843 call read_eeprom ; Low-value | |
844 movff EEDATA,lo | |
845 | |
846 decf lo,F ; decrease depth | |
847 movlw d'255' | |
848 cpfseq lo | |
849 bra change_gas_depth_minus2 | |
850 movlw d'0' | |
851 movwf lo | |
852 | |
853 change_gas_depth_minus2: | |
854 movff lo,EEDATA ; write result | |
855 call write_eeprom ; save result in EEPROM | |
856 | |
857 movlw d'5' | |
858 movwf menupos | |
859 bra next_gas_page1 | |
860 | |
861 ; Changed v1.44se | |
862 gassetup_title_bar2: | |
863 call PLED_topline_box | |
864 WIN_INVERT .1 ; Init new Wordprocessor | |
865 WIN_TOP .2 | |
866 WIN_LEFT .0 | |
867 lfsr FSR2,letter | |
868 OUTPUTTEXT .95 ; Gas# | |
869 movff decodata+0,lo | |
870 incf lo,F | |
871 bsf leftbind | |
872 output_99 | |
123 | 873 STRCAT_PRINT ": " |
0 | 874 |
875 WIN_TOP .2 | |
876 WIN_LEFT .50 | |
877 lfsr FSR2,letter | |
878 | |
879 ;He check | |
880 movf divemins+0,W | |
881 addlw 0x07 | |
882 movwf EEADR | |
883 call read_eeprom ; He value | |
884 movff EEDATA,lo ; Move EEData -> lo | |
885 movf lo,f ; Move lo -> f | |
886 movlw d'0' ; Move 0 -> WREG | |
887 cpfsgt lo ; He > 0? | |
888 bra gassetup_title_bar3 ; NO check o2 | |
889 | |
890 ; YES Write TX 15/55 | |
891 call gassetup_write_Tx ; Write TX | |
892 movf divemins+0,W | |
893 addlw 0x06 | |
894 movwf EEADR | |
895 call read_eeprom ; O2 value | |
896 movff EEDATA,lo | |
897 output_8 ; Write O2 | |
123 | 898 PUTC '/' |
0 | 899 movf divemins+0,W |
900 addlw 0x07 | |
901 movwf EEADR | |
902 call read_eeprom ; He value | |
903 movff EEDATA,lo | |
904 output_8 ; Write He | |
905 bra gassetup_title_bar7 | |
906 | |
907 ; New v1.44se | |
908 gassetup_title_bar3: ; O2 Check | |
909 movf divemins+0,W | |
910 addlw 0x06 | |
911 movwf EEADR | |
912 call read_eeprom ; O2 value | |
913 movff EEDATA,lo | |
914 movf lo,f ; Move lo -> f | |
915 movlw d'21' ; Move 21 -> WREG | |
916 cpfseq lo ; o2 = 21 | |
917 cpfsgt lo ; o2 > 21% | |
918 bra gassetup_title_bar5 ; NO AIR | |
919 movlw d'100' ; Move 100 -> WREG | |
920 cpfslt lo ; o2 < 100% | |
921 bra gassetup_title_bar4 ; NO write O2 | |
922 | |
923 ; YES Write NX 32 | |
924 call gassetup_write_Nx | |
925 output_8 | |
926 bra gassetup_title_bar7 | |
927 | |
928 ; New v1.44se | |
929 gassetup_title_bar4: | |
123 | 930 STRCAT "O2 " |
0 | 931 output_8 |
932 bra gassetup_title_bar7 | |
933 | |
934 ; New v1.44se | |
935 gassetup_title_bar5: | |
936 cpfseq lo ; o2 = 21% | |
937 bra gassetup_title_bar6 | |
938 | |
123 | 939 STRCAT "AIR " |
0 | 940 output_8 |
941 bra gassetup_title_bar7 | |
942 | |
943 ; New v1.44se | |
944 gassetup_title_bar6: ; ERROR | |
123 | 945 STRCAT "ERR " |
0 | 946 output_8 |
947 bra gassetup_title_bar7 | |
948 | |
949 gassetup_title_bar7: | |
123 | 950 STRCAT " in " |
0 | 951 movf decodata+0,W ; read current value |
952 addlw d'28' ; offset in memory | |
953 movwf EEADR | |
954 call read_eeprom ; Low-value | |
955 movff EEDATA,lo | |
956 output_8 | |
123 | 957 STRCAT_PRINT "m " |
0 | 958 |
959 WIN_INVERT .0 ; Init new Wordprocessor | |
960 return | |
961 | |
962 ; New v1.44se | |
963 gassetup_write_Nx: | |
123 | 964 STRCAT "NX " |
0 | 965 return |
966 | |
967 ; New v1.44se | |
968 gassetup_write_Tx: | |
123 | 969 STRCAT "TX " |
0 | 970 return |
971 | |
972 gassetup_show_ppO2: | |
973 movf divemins+0,W | |
974 addlw 0x06 | |
975 movwf EEADR | |
976 call read_eeprom ; O2 value | |
977 movff EEDATA,hi | |
978 | |
979 movf decodata+0,W ; read current value | |
980 addlw d'28' ; offset in memory | |
981 movwf EEADR | |
982 call read_eeprom ; Change depth in m | |
983 movff EEDATA,lo | |
984 movlw d'10' | |
985 addwf lo,F ; Depth+10m=lo | |
986 movf hi,W | |
987 mulwf lo ; (Depth+10m)*O2 | |
988 movff PRODL,xA+0 | |
989 movff PRODH,xA+1 | |
990 movlw d'10' | |
991 movwf xB+0 | |
992 clrf xB+1 | |
993 call div16x16 ;xA/xB=xC with xA as remainder | |
994 movff xC+0,lo ; ((Depth+10m)*O2)/10 = [0.01Bar] ppO2 | |
995 movff xC+1,hi | |
996 | |
997 WIN_LEFT .55 | |
998 WIN_TOP .35 | |
999 lfsr FSR2,letter | |
50 | 1000 OUTPUTTEXT d'149' ; (ppO2: |
0 | 1001 output_16dp d'3' |
50 | 1002 OUTPUTTEXT d'150' ; Bar: |
0 | 1003 call word_processor |
35 | 1004 return |
1005 | |
1006 | |
1007 gassetup_sort_gaslist: ; Sorts Gaslist according to change depth | |
1008 ; EEPROM Locations of Gaslist | |
1009 ; Gas1: | |
1010 ; O2 Default:4 | |
1011 ; He Default:5 | |
1012 ; O2 Current:6 | |
1013 ; He Current:7 | |
1014 ; Change: 28 | |
1015 ; Active: 27,0 | |
1016 | |
1017 ; Gas2: | |
1018 ; O2 Default:8 | |
1019 ; He Default:9 | |
1020 ; O2 Current:10 | |
1021 ; He Current:11 | |
1022 ; Change: 29 | |
1023 ; Active: 27,1 | |
1024 | |
1025 ; Gas3: | |
1026 ; O2 Default:12 | |
1027 ; He Default:13 | |
1028 ; O2 Current:14 | |
1029 ; He Current:15 | |
1030 ; Change: 30 | |
1031 ; Active: 27,2 | |
1032 | |
1033 ; Gas4: | |
1034 ; O2 Default:16 | |
1035 ; He Default:17 | |
1036 ; O2 Current:18 | |
1037 ; He Current:19 | |
1038 ; Change: 31 | |
1039 ; Active: 27,3 | |
1040 | |
1041 ; Gas5: | |
1042 ; O2 Default:20 | |
1043 ; He Default:21 | |
1044 ; O2 Current:22 | |
1045 ; He Current:23 | |
1046 ; Change: 32 | |
1047 ; Active: 27,4 | |
1048 | |
47 | 1049 ; reset Change depths (Important for all users who upgrade from <1.60!) |
1050 clrf EEADRH | |
1051 clrf EEDATA | |
1052 write_int_eeprom d'118' ; | |
1053 write_int_eeprom d'119' ; | |
1054 write_int_eeprom d'120' ; | |
1055 write_int_eeprom d'121' ; | |
1056 write_int_eeprom d'122' ; | |
1057 movlw d'21' ; O2 Current | |
1058 movwf EEDATA | |
1059 write_int_eeprom d'96' ; | |
1060 write_int_eeprom d'100' ; | |
1061 write_int_eeprom d'104' ; | |
1062 write_int_eeprom d'108' ; | |
1063 write_int_eeprom d'112' ; | |
1064 | |
1065 clrf EEDATA ; He Current | |
1066 write_int_eeprom d'97' ; | |
1067 write_int_eeprom d'101' ; | |
1068 write_int_eeprom d'105' ; | |
1069 write_int_eeprom d'109' ; | |
1070 write_int_eeprom d'113' ; | |
1071 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1072 ; Find deepest Gas |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1073 ; Copy all to RAM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1074 movlw d'3' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1075 movwf EEADR |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1076 clrf EEADRH |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1077 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
|
1078 gassetup_sort_gaslist1: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1079 incf EEADR,F ; Next Adress |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1080 call read_eeprom ; Read byte |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1081 movff EEDATA,POSTINC2 ; Copy into RAM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1082 movlw d'23' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1083 cpfseq EEADR ; All done? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1084 bra gassetup_sort_gaslist1 ; No, not yet |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1085 ; Letter+0 = EEPROM 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1086 ; ... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1087 ; Letter+20 = EEPROM 23 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1088 read_int_eeprom d'28' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1089 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+21 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1090 read_int_eeprom d'29' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1091 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+22 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1092 read_int_eeprom d'30' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1093 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+23 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1094 read_int_eeprom d'31' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1095 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+24 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1096 read_int_eeprom d'32' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1097 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+25 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1098 read_int_eeprom d'27' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1099 movff EEDATA,POSTINC2 ; Active Byte -> Letter+26 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1100 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1101 ; All change depths = 0? -> Skip sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1102 lfsr FSR2,letter+.20 ; Change depths... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1103 movlw d'5' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1104 movwf logbook_temp3 ; Gas (0-4) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1105 clrf logbook_temp1 ; counter |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1106 gassetup_sort_gaslist1a: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1107 movf POSTINC2,W |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1108 addwf logbook_temp1,F ; sum |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1109 decfsz logbook_temp3,F ; Loop |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1110 bra gassetup_sort_gaslist1a |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1111 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1112 tstfsz logbook_temp1 ; All depths = 0? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1113 bra gassetup_sort_gaslist1b ; No |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1114 return ; Yes, skip all! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1115 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1116 gassetup_sort_gaslist1b: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1117 ; Initialize sorting... |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1118 bcf menubit2 ; Change Start gas only 1x |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1119 movlw d'99' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1120 movwf logbook_temp4 ; Last Gas change depth |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1121 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1122 rcall gassetup_sort_sort ; Sort! |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1123 ; 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
|
1124 movlw d'5' ; Gas 5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1125 movwf logbook_temp5 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1126 rcall gassetup_sort_store |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1127 movff logbook_temp1,EEDATA ; Change depth -> EEDATA |
45 | 1128 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
|
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 4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1132 movlw d'4' ; Gas 4 |
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'121' ; Write Change Depth Gas 4 |
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 3 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1140 movlw d'3' ; Gas 3 |
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'120' ; Write Change Depth Gas 3 |
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 2 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1148 movlw d'2' ; Gas 2 |
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'119' ; Write Change Depth Gas 2 |
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 1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1156 movlw d'1' ; Gas 1 |
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'118' ; Write Change Depth Gas 1 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1161 return |
35 | 1162 |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1163 gassetup_sort_sort: |
41 | 1164 clrf logbook_temp2 ; Gas (0-4) |
1165 clrf logbook_temp1 ; Here: Change depth in m | |
1166 clrf logbook_temp3 ; Gas (0-4) | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1167 |
41 | 1168 lfsr FSR2,letter+.20 ; Change depths... |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1169 gassetup_sort_gaslist2: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1170 movf POSTINC2,W ; Get Change depth into WREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1171 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1172 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
|
1173 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
|
1174 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1175 cpfslt logbook_temp1 ; logbook_temp1 < W? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1176 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
|
1177 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1178 movwf logbook_temp1 ; copy new depth (current run) |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1179 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
|
1180 gassetup_sort_gaslist3: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1181 incf logbook_temp2,F ; Check next Gas |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1182 movlw d'5' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1183 cpfseq logbook_temp2 ; All done? |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1184 bra gassetup_sort_gaslist2 ; No |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1185 gassetup_sort_gaslist4: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1186 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
|
1187 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1188 ; Debugger |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1189 ;call enable_rs232 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1190 ; movff logbook_temp1,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1191 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1192 ; movff logbook_temp2,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1193 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1194 ; movff logbook_temp3,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1195 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1196 ; movff logbook_temp4,TXREG |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1197 ; call rs232_wait_tx ; wait for UART |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1198 ; movff logbook_temp5,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 ; WAITMS d'255' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1201 return |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1202 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1203 gassetup_sort_store: |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1204 lfsr FSR2,letter ; Point to Gas0 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1205 movf logbook_temp3,W |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1206 mullw d'4' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1207 movf PRODL,W ; x4 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1208 addwf FSR2L,F |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1209 movlw d'0' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1210 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
|
1211 |
50 | 1212 ; btfsc menubit2 ; Change Start gas only 1x |
1213 ; bra gassetup_sort_store2 ; Skip | |
1214 ;; First Gas: 33 (1-5) | |
1215 ;; Was gas #logbook_temp3 first gas? | |
1216 ; read_int_eeprom d'33' ; Get old first gas (1-5) | |
1217 ; incf logbook_temp3,W ; Gas 1-5 -> WREG | |
1218 ; cpfseq EEDATA ; Compare with EEDATA d'33' | |
1219 ; bra gassetup_sort_store2 ; Was not first gas! | |
1220 ; movff logbook_temp5,EEDATA ; Copy new first gas | |
1221 ; write_int_eeprom d'123' ; Store | |
1222 ; bsf menubit2 ; Done. Do not change again. | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1223 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1224 gassetup_sort_store2: |
45 | 1225 ; Was Gas #logbook_temp3 active? |
1226 ; Letter+26 holds active bits 25? | |
1227 movff logbook_temp3,logbook_temp6 ; Counter 0-4 | |
1228 incf logbook_temp6,F ; Counter 1-5 | |
1229 movff letter+.25, logbook_temp2 ; No longer used | |
1230 read_int_eeprom d'27' ; Active flag register | |
1231 gassetup_sort_store3: | |
1232 rrcf logbook_temp2,F ; Shift into Carry | |
1233 decfsz logbook_temp6,F ; 1-5 x | |
1234 bra gassetup_sort_store3 ; Loop | |
1235 ; Carry now holds active bit of gas #logbook_temp3 (0-4) | |
1236 | |
1237 btfss STATUS,C ; Was Gas active? | |
1238 clrf logbook_temp1 ; No!, Clear change Depth to make it inactive for sorted list! | |
1239 | |
49 | 1240 ;call enable_rs232 |
1241 ;movff logbook_temp1,TXREG | |
1242 ;call rs232_wait_tx ; wait for UART | |
1243 | |
1244 movf logbook_temp5,W ; 1-5 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1245 mullw d'4' |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1246 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5 |
45 | 1247 movlw d'90' ; +90 Offset to new... |
1248 addwf EEADR,F ; ..sorted list! | |
1249 | |
36
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1250 movff POSTINC2,EEDATA ; O2 Default |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1251 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1252 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1253 movff POSTINC2,EEDATA ; He Default |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1254 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1255 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1256 movff POSTINC2,EEDATA ; O2 Current |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1257 call write_eeprom ; store in internal EEPROM |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1258 incf EEADR,F ; +1 |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1259 movff POSTINC2,EEDATA ; He Current |
3c38ba950dfb
Gas Setup now sorts Gases for new Deco code
heinrichsweikamp
parents:
35
diff
changeset
|
1260 call write_eeprom ; store in internal EEPROM |
0 | 1261 return |