Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 296:2986e7cdb68c
Apply salinity for ceiling warning
author | Heinrichsweikamp |
---|---|
date | Thu, 28 Apr 2011 18:51:48 +0200 |
parents | 4dbff2aa31ee |
children | ceedf078b2d8 |
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 | |
287 | 663 ; Active gas flags in BIT0:4 .... |
0 | 664 movff decodata+0,lo ; Gas 0-4 |
665 incf lo,F ; Gas 1-5 | |
666 | |
287 | 667 read_int_eeprom d'27' ; read flag register |
0 | 668 active_gas_display: |
669 rrcf EEDATA ; roll flags into carry | |
670 decfsz lo,F ; max. 5 times... | |
671 bra active_gas_display | |
672 | |
673 btfss STATUS,C ; test carry | |
674 bra active_gas_display_no | |
675 | |
676 OUTPUTTEXT .96 ; Yes | |
677 bra active_gas_display_end | |
678 | |
679 active_gas_display_no: | |
123 | 680 STRCAT " " ; three spaces instead of "Yes" |
0 | 681 |
682 active_gas_display_end: | |
683 call word_processor | |
684 | |
685 WIN_TOP .95 | |
686 WIN_LEFT .20 | |
687 lfsr FSR2,letter | |
688 OUTPUTTEXT .88 ; First Gas? | |
123 | 689 PUTC ' ' |
0 | 690 |
691 movlw d'33' | |
692 movwf EEADR | |
693 call read_eeprom ; Get current startgas 1-5 # into EEDATA | |
694 decf EEDATA,W ; 0-4 | |
695 cpfseq decodata+0 ; =current displayed gas #? | |
696 bra menu_firstgas0 ; no, display three spaces | |
697 | |
698 OUTPUTTEXT .96 ; Yes | |
699 bra menu_firstgas1 | |
700 | |
701 menu_firstgas0: | |
123 | 702 STRCAT " " ; 3 spaces. |
0 | 703 |
704 menu_firstgas1: | |
705 call word_processor | |
706 | |
707 WIN_TOP .125 | |
708 WIN_LEFT .20 | |
709 lfsr FSR2,letter | |
710 OUTPUTTEXT .107 ; Change+ | |
711 call word_processor | |
712 | |
713 WIN_TOP .155 | |
714 WIN_LEFT .20 | |
715 lfsr FSR2,letter | |
716 OUTPUTTEXT .108 ; Change- | |
717 call word_processor | |
718 | |
719 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
720 call PLED_menu_cursor | |
721 | |
722 next_gas_page_loop: | |
723 call check_switches_logbook | |
724 | |
725 btfsc menubit3 | |
726 bra next_gas_page2 ; move cursor | |
727 | |
728 btfsc menubit2 | |
729 bra do_next_gas_page ; call submenu | |
730 | |
731 btfsc divemode | |
732 goto restart ; dive started! | |
733 | |
734 btfsc onesecupdate | |
735 call timeout_surfmode | |
736 | |
737 btfsc onesecupdate | |
738 call set_dive_modes | |
739 | |
740 bcf onesecupdate ; 1 sec. functions done | |
741 | |
742 btfsc sleepmode | |
743 bra exit_gassetup | |
744 | |
745 bra next_gas_page_loop | |
746 | |
747 next_gas_page2: | |
748 incf menupos,F | |
749 | |
750 movlw d'7' | |
751 cpfseq menupos ; =7? | |
752 bra next_gas_page3 ; No | |
753 movlw d'1' | |
754 movwf menupos | |
755 | |
756 next_gas_page3: | |
757 clrf timeout_counter2 | |
758 call PLED_menu_cursor | |
759 | |
760 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | |
761 | |
762 bcf menubit3 ; clear flag | |
763 bra next_gas_page_loop | |
764 | |
765 do_next_gas_page: | |
766 dcfsnz menupos,F | |
767 bra next_gas | |
768 dcfsnz menupos,F | |
769 bra toggle_active_gas | |
770 dcfsnz menupos,F | |
771 bra make_first_gas | |
772 dcfsnz menupos,F | |
773 bra change_gas_depth_plus | |
774 dcfsnz menupos,F | |
775 bra change_gas_depth_minus | |
776 bra exit_gassetup ; Exit menu | |
777 | |
778 make_first_gas: | |
779 movff decodata+0,EEDATA ; current gas (0-4) into EEDATA | |
780 incf EEDATA,F ; current gas (1-5) into EEDATA | |
781 movlw d'33' | |
782 movwf EEADR | |
783 call write_eeprom ; store in internal EEPROM | |
115 | 784 |
785 ; Set First gas to "Active" | |
786 read_int_eeprom d'27' ; read flag register | |
787 movff decodata+0,lo ; selected gas 0-4 | |
788 incf lo,F | |
789 dcfsnz lo,F | |
790 bsf EEDATA,0 | |
791 dcfsnz lo,F | |
792 bsf EEDATA,1 | |
793 dcfsnz lo,F | |
794 bsf EEDATA,2 | |
795 dcfsnz lo,F | |
796 bsf EEDATA,3 | |
797 dcfsnz lo,F | |
798 bsf EEDATA,4 | |
799 write_int_eeprom d'27' ; write flag register | |
800 | |
0 | 801 movlw d'3' |
802 movwf menupos | |
803 bra next_gas_page1 | |
804 | |
805 toggle_active_gas: | |
806 read_int_eeprom d'27' ; read flag register | |
807 movff decodata+0,lo ; selected gas 0-4 | |
808 incf lo,F | |
809 dcfsnz lo,F | |
810 btg EEDATA,0 | |
811 dcfsnz lo,F | |
812 btg EEDATA,1 | |
813 dcfsnz lo,F | |
814 btg EEDATA,2 | |
815 dcfsnz lo,F | |
816 btg EEDATA,3 | |
817 dcfsnz lo,F | |
818 btg EEDATA,4 | |
819 write_int_eeprom d'27' ; write flag register | |
820 movlw d'2' | |
821 movwf menupos | |
822 bra next_gas_page1 | |
823 | |
824 change_gas_depth_plus: | |
825 movf decodata+0,W ; read current value | |
826 addlw d'28' ; offset in memory | |
827 movwf EEADR | |
828 call read_eeprom ; Low-value | |
829 movff EEDATA,lo | |
830 | |
831 incf lo,F ; increase depth | |
832 movlw d'100' ; Change depth limit + 1 | |
833 cpfseq lo | |
834 bra change_gas_depth_plus2 | |
835 movlw d'99' ; Change depth limit | |
836 movwf lo | |
837 change_gas_depth_plus2: | |
838 movff lo,EEDATA ; write result | |
839 call write_eeprom ; save result in EEPROM | |
840 | |
841 movlw d'4' | |
842 movwf menupos | |
843 bra next_gas_page1 | |
844 | |
845 | |
846 change_gas_depth_minus: | |
847 movf decodata+0,W ; read current value | |
848 addlw d'28' ; offset in memory | |
849 movwf EEADR | |
850 call read_eeprom ; Low-value | |
851 movff EEDATA,lo | |
852 | |
853 decf lo,F ; decrease depth | |
854 movlw d'255' | |
855 cpfseq lo | |
856 bra change_gas_depth_minus2 | |
857 movlw d'0' | |
858 movwf lo | |
859 | |
860 change_gas_depth_minus2: | |
861 movff lo,EEDATA ; write result | |
862 call write_eeprom ; save result in EEPROM | |
863 | |
864 movlw d'5' | |
865 movwf menupos | |
866 bra next_gas_page1 | |
867 | |
868 ; Changed v1.44se | |
869 gassetup_title_bar2: | |
870 call PLED_topline_box | |
871 WIN_INVERT .1 ; Init new Wordprocessor | |
872 WIN_TOP .2 | |
873 WIN_LEFT .0 | |
874 lfsr FSR2,letter | |
875 OUTPUTTEXT .95 ; Gas# | |
876 movff decodata+0,lo | |
877 incf lo,F | |
878 bsf leftbind | |
879 output_99 | |
123 | 880 STRCAT_PRINT ": " |
0 | 881 |
882 WIN_TOP .2 | |
883 WIN_LEFT .50 | |
884 lfsr FSR2,letter | |
885 | |
886 ;He check | |
887 movf divemins+0,W | |
888 addlw 0x07 | |
889 movwf EEADR | |
890 call read_eeprom ; He value | |
891 movff EEDATA,lo ; Move EEData -> lo | |
892 movf lo,f ; Move lo -> f | |
893 movlw d'0' ; Move 0 -> WREG | |
894 cpfsgt lo ; He > 0? | |
895 bra gassetup_title_bar3 ; NO check o2 | |
896 | |
897 ; YES Write TX 15/55 | |
898 call gassetup_write_Tx ; Write TX | |
899 movf divemins+0,W | |
900 addlw 0x06 | |
901 movwf EEADR | |
902 call read_eeprom ; O2 value | |
903 movff EEDATA,lo | |
904 output_8 ; Write O2 | |
123 | 905 PUTC '/' |
0 | 906 movf divemins+0,W |
907 addlw 0x07 | |
908 movwf EEADR | |
909 call read_eeprom ; He value | |
910 movff EEDATA,lo | |
911 output_8 ; Write He | |
912 bra gassetup_title_bar7 | |
913 | |
914 ; New v1.44se | |
915 gassetup_title_bar3: ; O2 Check | |
916 movf divemins+0,W | |
917 addlw 0x06 | |
918 movwf EEADR | |
919 call read_eeprom ; O2 value | |
920 movff EEDATA,lo | |
921 movf lo,f ; Move lo -> f | |
922 movlw d'21' ; Move 21 -> WREG | |
923 cpfseq lo ; o2 = 21 | |
924 cpfsgt lo ; o2 > 21% | |
925 bra gassetup_title_bar5 ; NO AIR | |
926 movlw d'100' ; Move 100 -> WREG | |
927 cpfslt lo ; o2 < 100% | |
928 bra gassetup_title_bar4 ; NO write O2 | |
929 | |
930 ; YES Write NX 32 | |
931 call gassetup_write_Nx | |
932 output_8 | |
933 bra gassetup_title_bar7 | |
934 | |
935 ; New v1.44se | |
936 gassetup_title_bar4: | |
123 | 937 STRCAT "O2 " |
0 | 938 output_8 |
939 bra gassetup_title_bar7 | |
940 | |
941 ; New v1.44se | |
942 gassetup_title_bar5: | |
943 cpfseq lo ; o2 = 21% | |
944 bra gassetup_title_bar6 | |
945 | |
123 | 946 STRCAT "AIR " |
0 | 947 output_8 |
948 bra gassetup_title_bar7 | |
949 | |
950 ; New v1.44se | |
951 gassetup_title_bar6: ; ERROR | |
123 | 952 STRCAT "ERR " |
0 | 953 output_8 |
954 bra gassetup_title_bar7 | |
955 | |
956 gassetup_title_bar7: | |
123 | 957 STRCAT " in " |
0 | 958 movf decodata+0,W ; read current value |
959 addlw d'28' ; offset in memory | |
960 movwf EEADR | |
961 call read_eeprom ; Low-value | |
962 movff EEDATA,lo | |
963 output_8 | |
123 | 964 STRCAT_PRINT "m " |
0 | 965 |
966 WIN_INVERT .0 ; Init new Wordprocessor | |
967 return | |
968 | |
969 ; New v1.44se | |
970 gassetup_write_Nx: | |
123 | 971 STRCAT "NX " |
0 | 972 return |
973 | |
974 ; New v1.44se | |
975 gassetup_write_Tx: | |
123 | 976 STRCAT "TX " |
0 | 977 return |
978 | |
979 gassetup_show_ppO2: | |
980 movf divemins+0,W | |
981 addlw 0x06 | |
982 movwf EEADR | |
983 call read_eeprom ; O2 value | |
984 movff EEDATA,hi | |
985 | |
986 movf decodata+0,W ; read current value | |
987 addlw d'28' ; offset in memory | |
988 movwf EEADR | |
989 call read_eeprom ; Change depth in m | |
990 movff EEDATA,lo | |
991 movlw d'10' | |
992 addwf lo,F ; Depth+10m=lo | |
993 movf hi,W | |
994 mulwf lo ; (Depth+10m)*O2 | |
995 movff PRODL,xA+0 | |
996 movff PRODH,xA+1 | |
997 movlw d'10' | |
998 movwf xB+0 | |
999 clrf xB+1 | |
1000 call div16x16 ;xA/xB=xC with xA as remainder | |
1001 movff xC+0,lo ; ((Depth+10m)*O2)/10 = [0.01Bar] ppO2 | |
1002 movff xC+1,hi | |
1003 | |
1004 WIN_LEFT .55 | |
1005 WIN_TOP .35 | |
1006 lfsr FSR2,letter | |
50 | 1007 OUTPUTTEXT d'149' ; (ppO2: |
0 | 1008 output_16dp d'3' |
50 | 1009 OUTPUTTEXT d'150' ; Bar: |
0 | 1010 call word_processor |
35 | 1011 return |
1012 | |
227 | 1013 ;============================================================================= |
287 | 1014 ; Make sure first gas is marked active. |
1015 ; Note: - Gas are not soted anymore. | |
1016 ; - Gas with a depth>0 should not be forced active, or it is impossible | |
1017 ; to de-activate them. | |
1018 gassetup_sort_gaslist: | |
286 | 1019 |
287 | 1020 clrf EEADRH ; Select EEPROM lower page. |
1021 read_int_eeprom d'33' ; Get First gas (1-5) | |
1022 movff EEDATA,lo ; into register lo | |
286 | 1023 |
287 | 1024 read_int_eeprom d'27' ; Read selected gases |
286 | 1025 |
287 | 1026 dcfsnz lo,F ; If lo==1 |
1027 bsf EEDATA,0 ; Select Gas1 | |
1028 dcfsnz lo,F ; If lo==2 | |
1029 bsf EEDATA,1 ; Select Gas2 | |
1030 dcfsnz lo,F | |
1031 bsf EEDATA,2 | |
1032 dcfsnz lo,F | |
1033 bsf EEDATA,3 | |
1034 dcfsnz lo,F | |
1035 bsf EEDATA,4 | |
1036 | |
1037 ; Copy result to register: | |
290
4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
JeanDo
parents:
287
diff
changeset
|
1038 movff EEDATA,gaslist_active |
287 | 1039 |
1040 ; And write to EEPROM too, to survive next reboot: | |
1041 write_int_eeprom d'27' | |
286 | 1042 |
1043 return | |
281 | 1044 |
287 | 1045 ;============================================================================= |
35 | 1046 ; EEPROM Locations of Gaslist |
1047 ; Gas1: | |
1048 ; O2 Default:4 | |
1049 ; He Default:5 | |
1050 ; O2 Current:6 | |
1051 ; He Current:7 | |
1052 ; Change: 28 | |
1053 ; Active: 27,0 | |
1054 | |
1055 ; Gas2: | |
1056 ; O2 Default:8 | |
1057 ; He Default:9 | |
1058 ; O2 Current:10 | |
1059 ; He Current:11 | |
1060 ; Change: 29 | |
1061 ; Active: 27,1 | |
1062 | |
1063 ; Gas3: | |
1064 ; O2 Default:12 | |
1065 ; He Default:13 | |
1066 ; O2 Current:14 | |
1067 ; He Current:15 | |
1068 ; Change: 30 | |
1069 ; Active: 27,2 | |
1070 | |
1071 ; Gas4: | |
1072 ; O2 Default:16 | |
1073 ; He Default:17 | |
1074 ; O2 Current:18 | |
1075 ; He Current:19 | |
1076 ; Change: 31 | |
1077 ; Active: 27,3 | |
1078 | |
1079 ; Gas5: | |
1080 ; O2 Default:20 | |
1081 ; He Default:21 | |
1082 ; O2 Current:22 | |
1083 ; He Current:23 | |
1084 ; Change: 32 | |
1085 ; Active: 27,4 |