Mercurial > public > hwos_code
comparison src/divemode.asm @ 216:973a0969e0ac
NEW: On-board simulator can increase divetime in 5min steps
author | heinrichsweikamp |
---|---|
date | Mon, 15 Dec 2014 19:50:51 +0100 |
parents | 031d875200ca |
children | 8fbd8c5ac51f |
comparison
equal
deleted
inserted
replaced
215:8636efc5c6c5 | 216:973a0969e0ac |
---|---|
22 #include "start.inc" | 22 #include "start.inc" |
23 #include "adc_lightsensor.inc" | 23 #include "adc_lightsensor.inc" |
24 #include "ghostwriter.inc" | 24 #include "ghostwriter.inc" |
25 #include "i2c.inc" | 25 #include "i2c.inc" |
26 #include "calibrate.inc" | 26 #include "calibrate.inc" |
27 #include "convert.inc" | |
27 | 28 |
28 gui CODE | 29 gui CODE |
29 | 30 |
30 global diveloop | 31 global diveloop |
31 diveloop: | 32 diveloop: |
723 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) | 724 bra set_dive_modes2 ; too shallow (rel_pressure<dive_threshold) |
724 | 725 |
725 btfsc realdive ; Dive longer than one minute? | 726 btfsc realdive ; Dive longer than one minute? |
726 clrf timeout_counter ; Yes, reset timout counter | 727 clrf timeout_counter ; Yes, reset timout counter |
727 | 728 |
728 set_dive_modes_common: | |
729 bsf divemode ; (Re-)Set divemode flag | 729 bsf divemode ; (Re-)Set divemode flag |
730 bsf divemode2 ; displayed divetime is running | 730 bsf divemode2 ; displayed divetime is running |
731 return | 731 return |
732 | 732 |
733 set_dive_modes2: | 733 set_dive_modes2: |
864 | 864 |
865 test_switches_divemode1: | 865 test_switches_divemode1: |
866 bcf switch_right | 866 bcf switch_right |
867 movlw divemode_menuview_timeout | 867 movlw divemode_menuview_timeout |
868 movwf timeout_counter3 ; Reload timeout | 868 movwf timeout_counter3 ; Reload timeout |
869 movff menupos2,WREG ; Menupos3 holds number of customview/divemode menu function | 869 movff menupos2,WREG ; menupos2 holds number of customview/divemode menu function |
870 dcfsnz WREG,F | 870 dcfsnz WREG,F |
871 bra divemode_option_gaschange ; Switch to the indicated "better gas" | 871 bra divemode_option_gaschange ; Switch to the indicated "better gas" |
872 dcfsnz WREG,F | 872 dcfsnz WREG,F |
873 bra divemode_option0 ; Start/Setup Divemode menu | 873 bra divemode_option0 ; Start/Setup Divemode menu |
874 dcfsnz WREG,F | 874 dcfsnz WREG,F |
879 bra divemode_option3 ; Ascend 1m | 879 bra divemode_option3 ; Ascend 1m |
880 dcfsnz WREG,F | 880 dcfsnz WREG,F |
881 bra divemode_option4 ; Quit Apnoe mode | 881 bra divemode_option4 ; Quit Apnoe mode |
882 dcfsnz WREG,F | 882 dcfsnz WREG,F |
883 bra divemode_option5 ; Reset Stopwatch (In Gauge mode) | 883 bra divemode_option5 ; Reset Stopwatch (In Gauge mode) |
884 dcfsnz WREG,F | |
885 bra divemode_option6 ; +5mins simulation | |
884 return | 886 return |
885 | 887 |
886 test_switches_divemode2: | 888 test_switches_divemode2: |
887 bcf switch_left | 889 bcf switch_left |
888 call menuview_toggle ; Menu or Simulator tasks | 890 call menuview_toggle ; Menu or Simulator tasks |
1019 | 1021 |
1020 divemode_option5: | 1022 divemode_option5: |
1021 call menuview_toggle_reset ; Reset to zero (Zero=no menuview) | 1023 call menuview_toggle_reset ; Reset to zero (Zero=no menuview) |
1022 bsf reset_average_depth ; Set Flag | 1024 bsf reset_average_depth ; Set Flag |
1023 return | 1025 return |
1026 | |
1027 divemode_option6: | |
1028 bcf divemode2 ; Stop divetime | |
1029 movlw .5 | |
1030 addwf divemins+0,F | |
1031 movlw .0 | |
1032 addwfc divemins+1,F | |
1033 movlw .5 | |
1034 movwf up | |
1035 ; 1min mode | |
1036 divemode_option6_2: | |
1037 movlw .1 | |
1038 movff WREG,char_I_step_is_1min ; Force 1min mode | |
1039 clrf TMR5L | |
1040 clrf TMR5H ; 30,51757813µs/bit in TMR5L:TMR5H | |
1041 call deco_calc_hauptroutine ; calc_tissue | |
1042 movlb .1 | |
1043 decfsz up,F ; Done? | |
1044 bra divemode_option6_2 ; Not yet | |
1045 bsf divemode2 ; continue divetime | |
1046 call menuview_toggle_reset | |
1047 return | |
1048 | |
1049 ; 2sec mode | |
1050 ; #DEFINE divemode_simtext_row .164 | |
1051 ; #DEFINE divemode_simtext_column .32 | |
1052 ; | |
1053 ; rcall divemode_option6_divetime | |
1054 ; rcall divemode_option6_divetime ; 2 times | |
1055 ; | |
1056 ; bsf win_invert ; Set invert flag | |
1057 ; movlw color_yellow | |
1058 ; call TFT_set_color | |
1059 ; bsf leftbind | |
1060 ; WIN_SMALL divemode_simtext_column,divemode_simtext_row | |
1061 ; lfsr FSR2,buffer | |
1062 ; movlw .2 | |
1063 ; mulwf up | |
1064 ; movff PRODL,lo | |
1065 ; movff PRODH,hi | |
1066 ; output_16 | |
1067 ; STRCAT_PRINT "s " ; Show 300s delay countdown | |
1068 ; call TFT_standard_color | |
1069 ; bcf win_invert | |
1070 ; bcf leftbind | |
1071 ; rcall calc_deko_divemode2a ; Calc 150*2 seconds = 300secs = 5mins | |
1072 ; decfsz up,F ; Done? | |
1073 ; bra divemode_option6_2 ; Not yet | |
1074 ; bsf divemode2 ; continue divetime | |
1075 ; call menuview_toggle_reset | |
1076 ; return | |
1077 | |
1078 divemode_option6_divetime: | |
1079 incf divesecs,F | |
1080 movlw d'59' | |
1081 cpfsgt divesecs | |
1082 bra divemode_option6_divetime2 | |
1083 clrf divesecs | |
1084 infsnz divemins+0,F | |
1085 incf divemins+1,F ; increase divemins | |
1086 divemode_option6_divetime2: | |
1087 return | |
1088 | |
1024 | 1089 |
1025 divemode_simulator_check_limits: | 1090 divemode_simulator_check_limits: |
1026 ; Check limits (150m and 0m) | 1091 ; Check limits (150m and 0m) |
1027 movlw LOW d'16000' ; Compare to 16bar=16000mbar (150m). | 1092 movlw LOW d'16000' ; Compare to 16bar=16000mbar (150m). |
1028 subwf sim_pressure+0,W | 1093 subwf sim_pressure+0,W |