Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 290:4dbff2aa31ee
Hunting for refusing to ignore disabled gas in list...
+ Keep gaslist in order.
author | JeanDo |
---|---|
date | Fri, 22 Apr 2011 00:13:39 +0200 |
parents | 5f2fe81fde9f |
children | 916df3161d52 |
comparison
equal
deleted
inserted
replaced
289:6d8a2550c9ea | 290:4dbff2aa31ee |
---|---|
331 | 331 |
332 ; Check for decompression gases if in decomode | 332 ; Check for decompression gases if in decomode |
333 btfss dekostop_active | 333 btfss dekostop_active |
334 bra reset_decompression_gases ; While in NDL, do not set deompression gas | 334 bra reset_decompression_gases ; While in NDL, do not set deompression gas |
335 | 335 |
336 divemode_check_decogases: ; CALLed from Simulator | |
337 ; Copy all gases to char_I_deco_N2_ratio and char_I_deco_He_ratio | 336 ; Copy all gases to char_I_deco_N2_ratio and char_I_deco_He_ratio |
337 divemode_check_decogases: ; CALLed from Simulator, too | |
338 | |
339 clrf EEADRH, ; Make sure to select eeprom bank 0 | |
338 read_int_eeprom d'5' ; Read He ratio | 340 read_int_eeprom d'5' ; Read He ratio |
339 movff EEDATA,char_I_deco_He_ratio+4 ; And copy into hold register | 341 movff EEDATA,char_I_deco_He_ratio+0 ; And copy into hold register |
340 read_int_eeprom d'4' ; Read O2 ratio | 342 read_int_eeprom d'4' ; Read O2 ratio |
341 movff char_I_deco_He_ratio+4, wait_temp ; copy into bank1 register | 343 movff char_I_deco_He_ratio+0, wait_temp ; copy into bank1 register |
342 bsf STATUS,C ; | 344 bsf STATUS,C ; |
343 movlw d'100' ; 100% | 345 movlw d'100' ; 100% |
344 subfwb wait_temp,W ; minus He | 346 subfwb wait_temp,W ; minus He |
345 subfwb EEDATA,F ; minus O2 | 347 subfwb EEDATA,F ; minus O2 |
346 movff EEDATA, char_I_deco_N2_ratio+4; = N2! | 348 movff EEDATA, char_I_deco_N2_ratio+0; = N2! |
347 | 349 |
348 read_int_eeprom d'9' ; Read He ratio | 350 read_int_eeprom d'9' ; Read He ratio |
349 movff EEDATA,char_I_deco_He_ratio+3 ; And copy into hold register | 351 movff EEDATA,char_I_deco_He_ratio+1 ; And copy into hold register |
350 read_int_eeprom d'8' ; Read O2 ratio | 352 read_int_eeprom d'8' ; Read O2 ratio |
351 movff char_I_deco_He_ratio+3, wait_temp ; copy into bank1 register | 353 movff char_I_deco_He_ratio+1, wait_temp ; copy into bank1 register |
352 bsf STATUS,C ; | 354 bsf STATUS,C ; |
353 movlw d'100' ; 100% | 355 movlw d'100' ; 100% |
354 subfwb wait_temp,W ; minus He | 356 subfwb wait_temp,W ; minus He |
355 subfwb EEDATA,F ; minus O2 | 357 subfwb EEDATA,F ; minus O2 |
356 movff EEDATA, char_I_deco_N2_ratio+3; = N2! | 358 movff EEDATA, char_I_deco_N2_ratio+1; = N2! |
357 | 359 |
358 read_int_eeprom d'13' ; Read He ratio | 360 read_int_eeprom d'13' ; Read He ratio |
359 movff EEDATA,char_I_deco_He_ratio+2 ; And copy into hold register | 361 movff EEDATA,char_I_deco_He_ratio+2 ; And copy into hold register |
360 read_int_eeprom d'12' ; Read O2 ratio | 362 read_int_eeprom d'12' ; Read O2 ratio |
361 movff char_I_deco_He_ratio+2, wait_temp ; copy into bank1 register | 363 movff char_I_deco_He_ratio+2, wait_temp ; copy into bank1 register |
364 subfwb wait_temp,W ; minus He | 366 subfwb wait_temp,W ; minus He |
365 subfwb EEDATA,F ; minus O2 | 367 subfwb EEDATA,F ; minus O2 |
366 movff EEDATA, char_I_deco_N2_ratio+2; = N2! | 368 movff EEDATA, char_I_deco_N2_ratio+2; = N2! |
367 | 369 |
368 read_int_eeprom d'17' ; Read He ratio | 370 read_int_eeprom d'17' ; Read He ratio |
369 movff EEDATA,char_I_deco_He_ratio+1 ; And copy into hold register | 371 movff EEDATA,char_I_deco_He_ratio+3 ; And copy into hold register |
370 read_int_eeprom d'16' ; Read O2 ratio | 372 read_int_eeprom d'16' ; Read O2 ratio |
371 movff char_I_deco_He_ratio+1, wait_temp ; copy into bank1 register | 373 movff char_I_deco_He_ratio+3, wait_temp ; copy into bank1 register |
372 bsf STATUS,C ; | 374 bsf STATUS,C ; |
373 movlw d'100' ; 100% | 375 movlw d'100' ; 100% |
374 subfwb wait_temp,W ; minus He | 376 subfwb wait_temp,W ; minus He |
375 subfwb EEDATA,F ; minus O2 | 377 subfwb EEDATA,F ; minus O2 |
376 movff EEDATA, char_I_deco_N2_ratio+1; = N2! | 378 movff EEDATA, char_I_deco_N2_ratio+3; = N2! |
377 | 379 |
378 read_int_eeprom d'21' ; Read He ratio | 380 read_int_eeprom d'21' ; Read He ratio |
379 movff EEDATA,char_I_deco_He_ratio+0; And copy into hold register | 381 movff EEDATA,char_I_deco_He_ratio+4; And copy into hold register |
380 read_int_eeprom d'20' ; Read O2 ratio | 382 read_int_eeprom d'20' ; Read O2 ratio |
381 movff char_I_deco_He_ratio+0, wait_temp ; copy into bank1 register | 383 movff char_I_deco_He_ratio+4, wait_temp ; copy into bank1 register |
382 bsf STATUS,C ; | 384 bsf STATUS,C ; |
383 movlw d'100' ; 100% | 385 movlw d'100' ; 100% |
384 subfwb wait_temp,W ; minus He | 386 subfwb wait_temp,W ; minus He |
385 subfwb EEDATA,F ; minus O2 | 387 subfwb EEDATA,F ; minus O2 |
386 movff EEDATA, char_I_deco_N2_ratio+0; = N2! | 388 movff EEDATA, char_I_deco_N2_ratio+4; = N2! |
389 | |
390 ; Copy depth of enabled gas into char_I_deco_gas_change | |
391 ; Note gaslist_active is inited in diveloop_boot, and edited by | |
392 ; the de-activation menu. So don't reread it from eeprom here. | |
387 | 393 |
388 read_int_eeprom d'28' ; read gas_change_depth Gas1 | 394 read_int_eeprom d'28' ; read gas_change_depth Gas1 |
389 btfss sorted_gaslist_active,0 ; Apply depth? | 395 btfss gaslist_active,0 ; Apply depth? |
396 clrf EEDATA ; No, clear! | |
397 movff EEDATA,char_I_deco_gas_change+0 ; Yes! | |
398 | |
399 read_int_eeprom d'29' ; read gas_change_depth Gas2 | |
400 btfss gaslist_active,1 ; Apply depth? | |
401 clrf EEDATA ; No, clear! | |
402 movff EEDATA,char_I_deco_gas_change+1 ; Yes! | |
403 | |
404 read_int_eeprom d'30' ; read gas_change_depth Gas3 | |
405 btfss gaslist_active,2 ; Apply depth? | |
406 clrf EEDATA ; No, clear! | |
407 movff EEDATA,char_I_deco_gas_change+2 ; Yes! | |
408 | |
409 read_int_eeprom d'31' ; read gas_change_depth Gas4 | |
410 btfss gaslist_active,3 ; Apply depth? | |
411 clrf EEDATA ; No, clear! | |
412 movff EEDATA,char_I_deco_gas_change+3 ; Yes! | |
413 | |
414 read_int_eeprom d'32' ; read gas_change_depth Gas5 | |
415 btfss gaslist_active,4 ; Apply depth? | |
390 clrf EEDATA ; No, clear! | 416 clrf EEDATA ; No, clear! |
391 movff EEDATA,char_I_deco_gas_change+4 ; Yes! | 417 movff EEDATA,char_I_deco_gas_change+4 ; Yes! |
392 | |
393 read_int_eeprom d'29' ; read gas_change_depth Gas2 | |
394 btfss sorted_gaslist_active,1 ; Apply depth? | |
395 clrf EEDATA ; No, clear! | |
396 movff EEDATA,char_I_deco_gas_change+3 ; Yes! | |
397 | |
398 read_int_eeprom d'30' ; read gas_change_depth Gas3 | |
399 btfss sorted_gaslist_active,2 ; Apply depth? | |
400 clrf EEDATA ; No, clear! | |
401 movff EEDATA,char_I_deco_gas_change+2 ; Yes! | |
402 | |
403 read_int_eeprom d'31' ; read gas_change_depth Gas4 | |
404 btfss sorted_gaslist_active,3 ; Apply depth? | |
405 clrf EEDATA ; No, clear! | |
406 movff EEDATA,char_I_deco_gas_change+1 ; Yes! | |
407 | |
408 read_int_eeprom d'32' ; read gas_change_depth Gas5 | |
409 btfss sorted_gaslist_active,4 ; Apply depth? | |
410 clrf EEDATA ; No, clear! | |
411 movff EEDATA,char_I_deco_gas_change+0 ; Yes! | |
412 | 418 |
413 ; Debugger | 419 ; Debugger |
414 ; call enable_rs232 | 420 ; call enable_rs232 |
415 ; movff char_I_deco_He_ratio+4,TXREG | 421 ; movff char_I_deco_He_ratio+4,TXREG |
416 ; call rs232_wait_tx ; wait for UART | 422 ; call rs232_wait_tx ; wait for UART |
445 | 451 |
446 return | 452 return |
447 | 453 |
448 reset_decompression_gases: ; reset the deco gas while in NDL | 454 reset_decompression_gases: ; reset the deco gas while in NDL |
449 ostc_debug 'F' ; Sends debug-information to screen if debugmode active | 455 ostc_debug 'F' ; Sends debug-information to screen if debugmode active |
450 clrf lo | 456 lfsr FSR2,char_I_deco_gas_change |
451 movff lo,char_I_deco_gas_change+4 | 457 clrf POSTINC2 ; Clear Gas1 |
452 movff lo,char_I_deco_gas_change+3 | 458 clrf POSTINC2 |
453 movff lo,char_I_deco_gas_change+2 | 459 clrf POSTINC2 |
454 movff lo,char_I_deco_gas_change+1 | 460 clrf POSTINC2 |
455 movff lo,char_I_deco_gas_change+0 ; clear | 461 clrf POSTINC2 ; Clear Gas5 |
456 return | 462 return |
457 | 463 |
458 calc_deko_divemode2: | 464 calc_deko_divemode2: |
459 bcf twosecupdate | 465 bcf twosecupdate |
460 | 466 |
931 bsf ppO2_display_active ; Set flag | 937 bsf ppO2_display_active ; Set flag |
932 | 938 |
933 check_ppO2_3: | 939 check_ppO2_3: |
934 return ; done | 940 return ; done |
935 | 941 |
936 | 942 ;============================================================================= |
943 ; Compare all enabled gas in list, to see if a better one is available. | |
944 ; | |
945 ; Output: better_gas_available | |
946 ; | |
937 check_gas_change: ; Checks if a better gas should be selected (by user) | 947 check_gas_change: ; Checks if a better gas should be selected (by user) |
938 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 948 bcf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
939 | 949 |
940 movff rel_pressure+0,xA+0 | 950 movff rel_pressure+0,xA+0 |
941 movff rel_pressure+1,xA+1 | 951 movff rel_pressure+1,xA+1 |
943 movwf xB+0 | 953 movwf xB+0 |
944 clrf xB+1 | 954 clrf xB+1 |
945 call div16x16 ; compute depth in full m -> result in xC+0 | 955 call div16x16 ; compute depth in full m -> result in xC+0 |
946 | 956 |
947 check_gas_change1: ; check gas1 | 957 check_gas_change1: ; check gas1 |
948 btfss sorted_gaslist_active,0 ; check active flag | 958 btfss gaslist_active,0 ; check active flag |
949 bra check_gas_change2 ; skip inactive gases! | 959 bra check_gas_change2 ; skip inactive gases! |
950 movlw d'1' | 960 movlw d'1' |
951 cpfseq active_gas ; is this gas currently selected? | 961 cpfseq active_gas ; is this gas currently selected? |
952 bra check_gas_change1x ; No... | 962 bra check_gas_change1x ; No... |
953 bra check_gas_change2 ; Yes, skip depth check | 963 bra check_gas_change2 ; Yes, skip depth check |
963 subwf EEDATA,W ; Change depth-3m | 973 subwf EEDATA,W ; Change depth-3m |
964 cpfslt xC+0 ; current depth<Change depth-3m? | 974 cpfslt xC+0 ; current depth<Change depth-3m? |
965 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 975 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
966 | 976 |
967 check_gas_change2: ; check gas2 | 977 check_gas_change2: ; check gas2 |
968 btfss sorted_gaslist_active,1 ; check active flag | 978 btfss gaslist_active,1 ; check active flag |
969 bra check_gas_change3 ; skip inactive gases! | 979 bra check_gas_change3 ; skip inactive gases! |
970 movlw d'2' | 980 movlw d'2' |
971 cpfseq active_gas ; is this gas currently selected? | 981 cpfseq active_gas ; is this gas currently selected? |
972 bra check_gas_change2x ; No... | 982 bra check_gas_change2x ; No... |
973 bra check_gas_change3 ; Yes, skip depth check | 983 bra check_gas_change3 ; Yes, skip depth check |
983 subwf EEDATA,W ; Change depth-3m | 993 subwf EEDATA,W ; Change depth-3m |
984 cpfslt xC+0 ; current depth<Change depth-3m? | 994 cpfslt xC+0 ; current depth<Change depth-3m? |
985 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 995 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
986 | 996 |
987 check_gas_change3: ; check gas3 | 997 check_gas_change3: ; check gas3 |
988 btfss sorted_gaslist_active,2 ; check active flag | 998 btfss gaslist_active,2 ; check active flag |
989 bra check_gas_change4 ; skip inactive gases! | 999 bra check_gas_change4 ; skip inactive gases! |
990 movlw d'3' | 1000 movlw d'3' |
991 cpfseq active_gas ; is this gas currently selected? | 1001 cpfseq active_gas ; is this gas currently selected? |
992 bra check_gas_change3x ; No... | 1002 bra check_gas_change3x ; No... |
993 bra check_gas_change4 ; Yes, skip depth check | 1003 bra check_gas_change4 ; Yes, skip depth check |
1003 subwf EEDATA,W ; Change depth-3m | 1013 subwf EEDATA,W ; Change depth-3m |
1004 cpfslt xC+0 ; current depth<Change depth-3m? | 1014 cpfslt xC+0 ; current depth<Change depth-3m? |
1005 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1015 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1006 | 1016 |
1007 check_gas_change4: ; check gas4 | 1017 check_gas_change4: ; check gas4 |
1008 btfss sorted_gaslist_active,3 ; check active flag | 1018 btfss gaslist_active,3 ; check active flag |
1009 bra check_gas_change5 ; skip inactive gases! | 1019 bra check_gas_change5 ; skip inactive gases! |
1010 movlw d'4' | 1020 movlw d'4' |
1011 cpfseq active_gas ; is this gas currently selected? | 1021 cpfseq active_gas ; is this gas currently selected? |
1012 bra check_gas_change4x ; No... | 1022 bra check_gas_change4x ; No... |
1013 bra check_gas_change5 ; Yes, skip depth check | 1023 bra check_gas_change5 ; Yes, skip depth check |
1023 subwf EEDATA,W ; Change depth-3m | 1033 subwf EEDATA,W ; Change depth-3m |
1024 cpfslt xC+0 ; current depth<Change depth-3m? | 1034 cpfslt xC+0 ; current depth<Change depth-3m? |
1025 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1035 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1026 | 1036 |
1027 check_gas_change5: ; check gas5 | 1037 check_gas_change5: ; check gas5 |
1028 btfss sorted_gaslist_active,4 ; check active flag | 1038 btfss gaslist_active,4 ; check active flag |
1029 bra check_gas_change6 ; skip inactive gases! | 1039 bra check_gas_change6 ; skip inactive gases! |
1030 movlw d'5' | 1040 movlw d'5' |
1031 cpfseq active_gas ; is this gas currently selected? | 1041 cpfseq active_gas ; is this gas currently selected? |
1032 bra check_gas_change5x ; No... | 1042 bra check_gas_change5x ; No... |
1033 bra check_gas_change6 ; Yes, skip depth check | 1043 bra check_gas_change6 ; Yes, skip depth check |
1045 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode | 1055 bsf better_gas_available ;=1: A better gas is available and a gas change is advised in divemode |
1046 | 1056 |
1047 check_gas_change6: ;Done | 1057 check_gas_change6: ;Done |
1048 call PLED_active_gas_divemode; Display gas, if required (and with "*" if irequired...) | 1058 call PLED_active_gas_divemode; Display gas, if required (and with "*" if irequired...) |
1049 return | 1059 return |
1060 | |
1061 ;============================================================================= | |
1050 | 1062 |
1051 calculate_noflytime: | 1063 calculate_noflytime: |
1052 ; calculate nofly time | 1064 ; calculate nofly time |
1053 movff int_O_desaturation_time+0,xA+0 | 1065 movff int_O_desaturation_time+0,xA+0 |
1054 movff int_O_desaturation_time+1,xA+1 | 1066 movff int_O_desaturation_time+1,xA+1 |
1639 movwf average_divesecs+0 | 1651 movwf average_divesecs+0 |
1640 clrf average_divesecs+1 | 1652 clrf average_divesecs+1 |
1641 bcf reset_average_depth ; Clear flag | 1653 bcf reset_average_depth ; Clear flag |
1642 return | 1654 return |
1643 | 1655 |
1656 ;============================================================================= | |
1657 ; Setup everything to enter divemode. | |
1658 ; | |
1644 diveloop_boot: | 1659 diveloop_boot: |
1645 ostc_debug 'Q' ; Sends debug-information to screen if debugmode active | 1660 ostc_debug 'Q' ; Sends debug-information to screen if debugmode active |
1646 clrf max_pressure+0 ; clear some variables | 1661 clrf max_pressure+0 ; clear some variables |
1647 clrf max_pressure+1 | 1662 clrf max_pressure+1 |
1648 | 1663 |
1649 clrf avr_rel_pressure+0 | 1664 clrf avr_rel_pressure+0 |
1650 clrf avr_rel_pressure+1 | 1665 clrf avr_rel_pressure+1 |
1651 | 1666 |
1667 clrf EEADRH ; Make sure to select eeprom bank 0 | |
1652 call PLED_brightness_low | 1668 call PLED_brightness_low |
1653 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) | 1669 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) |
1654 movlw d'0' | 1670 movlw d'0' |
1655 cpfsgt EEDATA | 1671 cpfsgt EEDATA |
1656 call PLED_brightness_full | 1672 call PLED_brightness_full |
1766 subfwb wait_temp,W ; minus He | 1782 subfwb wait_temp,W ; minus He |
1767 bsf STATUS,C ; Borrow bit | 1783 bsf STATUS,C ; Borrow bit |
1768 subfwb EEDATA,F ; minus O2 | 1784 subfwb EEDATA,F ; minus O2 |
1769 movff EEDATA, char_I_N2_ratio ; = N2! | 1785 movff EEDATA, char_I_N2_ratio ; = N2! |
1770 | 1786 |
1771 ; Configure sorted_gaslist_active flag register | 1787 ; Configure gaslist_active flag register |
1772 read_int_eeprom d'27' | 1788 read_int_eeprom d'27' |
1773 movff EEDATA, sorted_gaslist_active | 1789 movff EEDATA, gaslist_active |
1774 return | 1790 return |