comparison code_part1/OSTC_code_asm_part1/divemode.asm @ 681:6e456a6398e0

Hardware4 support
author heinrichsweikamp
date Fri, 25 Jan 2013 18:00:49 +0100
parents 0211d9b9f0ca
children aebb6d039249
comparison
equal deleted inserted replaced
680:c6220d340684 681:6e456a6398e0
30 movlw b'00000011' 30 movlw b'00000011'
31 movwf T3CON ; Timer3 with 32768Hz clock running 31 movwf T3CON ; Timer3 with 32768Hz clock running
32 32
33 ; Startup Tasks for all modes 33 ; Startup Tasks for all modes
34 ostc_debug 'R' ; Sends debug-information to screen if debugmode active 34 ostc_debug 'R' ; Sends debug-information to screen if debugmode active
35 call PLED_ClearScreen ; clean up OLED 35 call DISP_ClearScreen ; clean up DISPLAY
36 call PLED_divemode_mask ; Display mask 36 call DISP_divemode_mask ; Display mask
37 call PLED_temp_divemode ; Displays temperature 37 call DISP_temp_divemode ; Displays temperature
38 call PLED_active_gas_divemode ; Display gas 38 call DISP_active_gas_divemode ; Display gas
39 39
40 ; Reload last customview 40 ; Reload last customview
41 read_int_eeprom d'94' ; Read last selected customview dive mode into EEDATA 41 read_int_eeprom d'94' ; Read last selected customview dive mode into EEDATA
42 movff EEDATA,menupos3 ; Copy to menupos3 42 movff EEDATA,menupos3 ; Copy to menupos3
43 call customview_toggle2 ; Show customview 43 call customview_toggle2 ; Show customview
49 bra diveloop_loop ; Skip in gauge mode 49 bra diveloop_loop ; Skip in gauge mode
50 btfsc FLAG_apnoe_mode 50 btfsc FLAG_apnoe_mode
51 bra diveloop_loop ; Skip in apnoe mode 51 bra diveloop_loop ; Skip in apnoe mode
52 52
53 ; Startup Tasks for deco modes 53 ; Startup Tasks for deco modes
54 call PLED_display_ndl_mask ; display "no stop" if not in gauge or apnoe mode 54 call DISP_display_ndl_mask ; display "no stop" if not in gauge or apnoe mode
55 55
56 btfss FLAG_const_ppO2_mode ; only in const_ppO2_mode 56 btfss FLAG_const_ppO2_mode ; only in const_ppO2_mode
57 bra diveloop_loop ; OC modes, skip 57 bra diveloop_loop ; OC modes, skip
58 bsf setpoint_changed ; Add a setpoint change to the first depth sample in CC mode 58 bsf setpoint_changed ; Add a setpoint change to the first depth sample in CC mode
59 bsf event_occured ; set global event flag 59 bsf event_occured ; set global event flag
78 diveloop_loop1y: 78 diveloop_loop1y:
79 btfss update_divetime ; display new divetime? 79 btfss update_divetime ; display new divetime?
80 bra diveloop_loop1z ; No 80 bra diveloop_loop1z ; No
81 btfsc premenu ; Is the divemode menu active? 81 btfsc premenu ; Is the divemode menu active?
82 bra diveloop_loop1z ; Yes 82 bra diveloop_loop1z ; Yes
83 call PLED_divemins ; Display (new) divetime! 83 call DISP_divemins ; Display (new) divetime!
84 diveloop_loop1z: 84 diveloop_loop1z:
85 bcf update_divetime ; clear flag 85 bcf update_divetime ; clear flag
86 86
87 btfsc FLAG_const_ppO2_mode ; only in const_ppO2_mode 87 btfsc FLAG_const_ppO2_mode ; only in const_ppO2_mode
88 bra diveloop_loop1c ; One Second Tasks in const_ppO2 mode 88 bra diveloop_loop1c ; One Second Tasks in const_ppO2 mode
89 89
90 ; Tasks only for OC modes 90 ; Tasks only for OC modes
91 btfsc show_safety_stop ; Show the safety stop? 91 btfsc show_safety_stop ; Show the safety stop?
92 call PLED_show_safety_stop ; Yes, show/delete if done. 92 call DISP_show_safety_stop ; Yes, show/delete if done.
93 call check_ppO2 ; check ppO2 and displays warning if required 93 call check_ppO2 ; check ppO2 and displays warning if required
94 call calc_deko_divemode ; calculate decompression and display result (any two seconds) 94 call calc_deko_divemode ; calculate decompression and display result (any two seconds)
95 bra diveloop_loop1x ; Common Tasks 95 bra diveloop_loop1x ; Common Tasks
96 96
97 ; Tasks only for Gauge mode 97 ; Tasks only for Gauge mode
98 diveloop_loop1a: 98 diveloop_loop1a:
99 btfss premenu ; Is the divemode menu active? 99 btfss premenu ; Is the divemode menu active?
100 call PLED_divemins ; display (new) divetime! 100 call DISP_divemins ; display (new) divetime!
101 call customview_second ; Do every-second tasks for the custom view area 101 call customview_second ; Do every-second tasks for the custom view area
102 call timeout_divemode ; dive finished? This routine sets the required flags 102 call timeout_divemode ; dive finished? This routine sets the required flags
103 103
104 btfsc twosecupdate ; two seconds after the last call 104 btfsc twosecupdate ; two seconds after the last call
105 bra diveloop_loop1a2 ; Common Tasks 105 bra diveloop_loop1a2 ; Common Tasks
120 bra diveloop_loop1x ; Common Tasks 120 bra diveloop_loop1x ; Common Tasks
121 121
122 ; Tasks only for ppO2 mode 122 ; Tasks only for ppO2 mode
123 diveloop_loop1c: 123 diveloop_loop1c:
124 btfsc show_safety_stop ; Show the safety stop? 124 btfsc show_safety_stop ; Show the safety stop?
125 call PLED_show_safety_stop ; Yes, show/delete if done. 125 call DISP_show_safety_stop ; Yes, show/delete if done.
126 call PLED_const_ppO2_value ; display const ppO2 setting in [bar] 126 call DISP_const_ppO2_value ; display const ppO2 setting in [bar]
127 call calc_deko_divemode ; calculate decompression and display result (any two seconds) 127 call calc_deko_divemode ; calculate decompression and display result (any two seconds)
128 btfsc is_bailout ; Are we in Bailout mode? 128 btfsc is_bailout ; Are we in Bailout mode?
129 call check_ppO2_bail ; Yes, display ppO2 (If required) 129 call check_ppO2_bail ; Yes, display ppO2 (If required)
130 130
131 bra diveloop_loop1x ; Common Tasks 131 bra diveloop_loop1x ; Common Tasks
143 ;diveloop_loop1y: 143 ;diveloop_loop1y:
144 ; btfss update_divetime ; display new divetime? 144 ; btfss update_divetime ; display new divetime?
145 ; bra diveloop_loop1z ; No 145 ; bra diveloop_loop1z ; No
146 ; btfsc premenu ; Is the divemode menu active? 146 ; btfsc premenu ; Is the divemode menu active?
147 ; bra diveloop_loop1z ; Yes 147 ; bra diveloop_loop1z ; Yes
148 ; call PLED_divemins ; Display (new) divetime! 148 ; call DISP_divemins ; Display (new) divetime!
149 ; 149 ;
150 ;diveloop_loop1z: 150 ;diveloop_loop1z:
151 ; bcf update_divetime ; clear flag 151 ; bcf update_divetime ; clear flag
152 152
153 btfsc ppO2_show_value ; show ppO2? 153 btfsc ppO2_show_value ; show ppO2?
211 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG 211 GETCUSTOM8 d'4' ; loads premenu_timeout into WREG
212 cpfsgt timeout_counter3 ; ... longer then premenu_timeout 212 cpfsgt timeout_counter3 ; ... longer then premenu_timeout
213 return ; No! 213 return ; No!
214 214
215 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit 215 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit
216 call PLED_menu_clear ; Remove "Menu?" 216 call DISP_menu_clear ; Remove "Menu?"
217 call PLED_divemode_mask ; And redraw mask (Redraw missing "T" from "Tauchzeit" in german text version) 217 call DISP_divemode_mask ; And redraw mask (Redraw missing "T" from "Tauchzeit" in german text version)
218 call PLED_divemins ; Redraw divetime 218 call DISP_divemins ; Redraw divetime
219 return 219 return
220 220
221 divemode_apnoe_tasks: ; 1 sec. Apnoe tasks 221 divemode_apnoe_tasks: ; 1 sec. Apnoe tasks
222 call PLED_divemins ; display (new) divetime! 222 call DISP_divemins ; display (new) divetime!
223 call PLED_display_apnoe_descent ; Show descent timer 223 call DISP_display_apnoe_descent ; Show descent timer
224 224
225 btfsc divemode2 ; Time running? 225 btfsc divemode2 ; Time running?
226 bra divemode_apnoe_tasks2 ; New descent, reset data if flag is set 226 bra divemode_apnoe_tasks2 ; New descent, reset data if flag is set
227 227
228 call PLED_display_apnoe_surface 228 call DISP_display_apnoe_surface
229 incf apnoe_surface_secs,F 229 incf apnoe_surface_secs,F
230 movlw d'60' 230 movlw d'60'
231 cpfseq apnoe_surface_secs 231 cpfseq apnoe_surface_secs
232 bra divemode_apnoe_tasks1 232 bra divemode_apnoe_tasks1
233 clrf apnoe_surface_secs 233 clrf apnoe_surface_secs
245 btfss FLAG_active_descent ; Are descending? 245 btfss FLAG_active_descent ; Are descending?
246 return ; No, We are at the surface 246 return ; No, We are at the surface
247 call apnoe_calc_maxdepth ; Yes! 247 call apnoe_calc_maxdepth ; Yes!
248 248
249 divemode_apnoe_tasks3: 249 divemode_apnoe_tasks3:
250 call PLED_apnoe_clear_surface ; Clear Surface timer 250 call DISP_apnoe_clear_surface ; Clear Surface timer
251 251
252 clrf apnoe_timeout_counter ; Delete timeout 252 clrf apnoe_timeout_counter ; Delete timeout
253 clrf apnoe_surface_secs 253 clrf apnoe_surface_secs
254 clrf apnoe_surface_mins 254 clrf apnoe_surface_mins
255 clrf apnoe_secs 255 clrf apnoe_secs
317 ; Check if CNS should be displayed 317 ; Check if CNS should be displayed
318 movff char_O_CNS_fraction,lo ; copy into bank1 318 movff char_O_CNS_fraction,lo ; copy into bank1
319 GETCUSTOM8 d'27' ; cns_display_high 319 GETCUSTOM8 d'27' ; cns_display_high
320 subwf lo,W 320 subwf lo,W
321 btfsc STATUS,C 321 btfsc STATUS,C
322 call PLED_display_cns ; Show CNS 322 call DISP_display_cns ; Show CNS
323 call check_gas_change ; Checks if a better gas should be selected (by user) 323 call check_gas_change ; Checks if a better gas should be selected (by user)
324 324
325 ;NOTE: always set full gas list, because the user can switch gas, 325 ;NOTE: always set full gas list, because the user can switch gas,
326 ; even in NDL mode... 326 ; even in NDL mode...
327 327
464 reset_safety_stop2: 464 reset_safety_stop2:
465 btfss safety_stop_active ; Safety stop shown 465 btfss safety_stop_active ; Safety stop shown
466 return ; No, don't delete it 466 return ; No, don't delete it
467 bcf show_safety_stop ; Clear flag 467 bcf show_safety_stop ; Clear flag
468 bcf safety_stop_active ; Clear flag 468 bcf safety_stop_active ; Clear flag
469 call PLED_clear_decoarea ; Yes, Clear stop 469 call DISP_clear_decoarea ; Yes, Clear stop
470 goto PLED_display_ndl_mask ; Show NDL again (And return) 470 goto DISP_display_ndl_mask ; Show NDL again (And return)
471 471
472 ;----------------------------------------------------------------------------- 472 ;-----------------------------------------------------------------------------
473 ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2) 473 ; calculate ppO2 in 0.01bar (e.g. 150 = 1.50 bar ppO2)
474 set_actual_ppo2: 474 set_actual_ppo2:
475 SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in millibar (1000 = 1.00 bar). 475 SAFE_2BYTE_COPY amb_pressure, xA ; P_amb in millibar (1000 = 1.00 bar).
608 movff char_O_first_deco_depth,wait_temp ; copy ceiling to temp register 608 movff char_O_first_deco_depth,wait_temp ; copy ceiling to temp register
609 tstfsz wait_temp ; Ceiling<0m? 609 tstfsz wait_temp ; Ceiling<0m?
610 bra calc_deko_divemode3 ; Yes! 610 bra calc_deko_divemode3 ; Yes!
611 611
612 btfsc dekostop_active ; Already in nodeco mode ? 612 btfsc dekostop_active ; Already in nodeco mode ?
613 call PLED_display_ndl_mask ; Clear deco data, display nostop time 613 call DISP_display_ndl_mask ; Clear deco data, display nostop time
614 bcf dekostop_active ; clear flag 614 bcf dekostop_active ; clear flag
615 615
616 clrf decodata+0 ; for profile memory 616 clrf decodata+0 ; for profile memory
617 movff char_O_nullzeit,decodata+1 ; nostop time 617 movff char_O_nullzeit,decodata+1 ; nostop time
618 618
619 call PLED_display_ndl ; display no deco limit 619 call DISP_display_ndl ; display no deco limit
620 620
621 calc_deko_divemode5: 621 calc_deko_divemode5:
622 ; Check if extra cycles are needed to compute @5 variant: 622 ; Check if extra cycles are needed to compute @5 variant:
623 btfss tts_extra_time ; Is @5 displayed ? 623 btfss tts_extra_time ; Is @5 displayed ?
624 return ; No: don't compute it. 624 return ; No: don't compute it.
633 movwf apnoe_mins 633 movwf apnoe_mins
634 return 634 return
635 635
636 calc_deko_divemode3: 636 calc_deko_divemode3:
637 btfss dekostop_active ; Already in deco mode ? 637 btfss dekostop_active ; Already in deco mode ?
638 call PLED_display_deko_mask ; clear nostop time, display decodata 638 call DISP_display_deko_mask ; clear nostop time, display decodata
639 bsf dekostop_active ; Set flag 639 bsf dekostop_active ; Set flag
640 640
641 movff char_O_first_deco_depth,decodata+0 ; ceiling 641 movff char_O_first_deco_depth,decodata+0 ; ceiling
642 movff char_O_first_deco_time,decodata+1 ; length of first stop in minues 642 movff char_O_first_deco_time,decodata+1 ; length of first stop in minues
643 643
644 call PLED_display_deko ; display decodata 644 call DISP_display_deko ; display decodata
645 bra calc_deko_divemode5 645 bra calc_deko_divemode5
646 646
647 ;----------------------------------------------------------------------------- 647 ;-----------------------------------------------------------------------------
648 648
649 divemode_prepare_flags_for_deco: 649 divemode_prepare_flags_for_deco:
968 movwf lo 968 movwf lo
969 movlw d'1' 969 movlw d'1'
970 cpfseq lo ; =1? 970 cpfseq lo ; =1?
971 bra update_velocity1 ; No 971 bra update_velocity1 ; No
972 972
973 call PLED_display_velocity_graphical 973 call DISP_display_velocity_graphical
974 return 974 return
975 975
976 update_velocity1: 976 update_velocity1:
977 call PLED_display_velocity 977 call DISP_display_velocity
978 return 978 return
979 979
980 do_not_display_velocity: 980 do_not_display_velocity:
981 btfss display_velocity ; Velocity was not displayed, do not delete 981 btfss display_velocity ; Velocity was not displayed, do not delete
982 return 982 return
983 983
984 bcf display_velocity ; Velocity was displayed, delete velocity now 984 bcf display_velocity ; Velocity was displayed, delete velocity now
985 call PLED_display_velocity_clear 985 call DISP_display_velocity_clear
986 return 986 return
987 987
988 check_ppO2: ; check current ppO2 and display warning if required 988 check_ppO2: ; check current ppO2 and display warning if required
989 btfsc FLAG_const_ppO2_mode ; ignore in ppO2 mode.... 989 btfsc FLAG_const_ppO2_mode ; ignore in ppO2 mode....
990 return 990 return
1078 bra check_ppO2_2 ; yes! 1078 bra check_ppO2_2 ; yes!
1079 1079
1080 btfss ppO2_display_active ; is the value displayed? 1080 btfss ppO2_display_active ; is the value displayed?
1081 bra check_ppO2_3 ; No, so clear not required 1081 bra check_ppO2_3 ; No, so clear not required
1082 1082
1083 call PLED_show_ppO2_clear; Clear ppO2 value 1083 call DISP_show_ppO2_clear; Clear ppO2 value
1084 bcf ppO2_display_active ; clear flag 1084 bcf ppO2_display_active ; clear flag
1085 bra check_ppO2_3 ; done 1085 bra check_ppO2_3 ; done
1086 1086
1087 check_ppO2_2: 1087 check_ppO2_2:
1088 call PLED_show_ppO2 ; Display ppO2 (stored in xC) 1088 call DISP_show_ppO2 ; Display ppO2 (stored in xC)
1089 bsf ppO2_display_active ; Set flag 1089 bsf ppO2_display_active ; Set flag
1090 1090
1091 check_ppO2_3: 1091 check_ppO2_3:
1092 return ; done 1092 return ; done
1093 1093
1224 1224
1225 btfsc FLAG_const_ppO2_mode ; in ppO2 mode? 1225 btfsc FLAG_const_ppO2_mode ; in ppO2 mode?
1226 bcf better_gas_available ; Yes, do not blink better gas 1226 bcf better_gas_available ; Yes, do not blink better gas
1227 1227
1228 check_gas_change7: 1228 check_gas_change7:
1229 call PLED_active_gas_divemode; Display gas, if required (and with "*" if required...) 1229 call DISP_active_gas_divemode; Display gas, if required (and with "*" if required...)
1230 return 1230 return
1231 1231
1232 ;============================================================================= 1232 ;=============================================================================
1233 1233
1234 calculate_noflytime: 1234 calculate_noflytime:
1705 bsf temp_changed ; Yes 1705 bsf temp_changed ; Yes
1706 movf hi,W 1706 movf hi,W
1707 cpfseq last_temperature+1 1707 cpfseq last_temperature+1
1708 bsf temp_changed ; Yes 1708 bsf temp_changed ; Yes
1709 btfsc temp_changed 1709 btfsc temp_changed
1710 call PLED_temp_divemode ; Displays temperature 1710 call DISP_temp_divemode ; Displays temperature
1711 1711
1712 bcf pres_changed ; Display new depth? 1712 bcf pres_changed ; Display new depth?
1713 SAFE_2BYTE_COPY amb_pressure, lo 1713 SAFE_2BYTE_COPY amb_pressure, lo
1714 movf lo,W 1714 movf lo,W
1715 cpfseq last_pressure+0 1715 cpfseq last_pressure+0
1720 1720
1721 btfsc simulatormode_active ; always update depth when in simulator mode 1721 btfsc simulatormode_active ; always update depth when in simulator mode
1722 bsf pres_changed 1722 bsf pres_changed
1723 1723
1724 btfsc pres_changed 1724 btfsc pres_changed
1725 call PLED_depth ; Displays new depth 1725 call DISP_depth ; Displays new depth
1726 return 1726 return
1727 1727
1728 update_divemode60: ; update any minute 1728 update_divemode60: ; update any minute
1729 call get_battery_voltage ; gets battery voltage 1729 call get_battery_voltage ; gets battery voltage
1730 call set_powersafe ; red LED blinking if battery is low 1730 call set_powersafe ; red LED blinking if battery is low
1731 call PLED_max_pressure ; No, use normal max. depth 1731 call DISP_max_pressure ; No, use normal max. depth
1732 call check_temp_extrema ; check for new temperature extremas 1732 call check_temp_extrema ; check for new temperature extremas
1733 call customview_minute ; Do every-minute tasks for the custom view area 1733 call customview_minute ; Do every-minute tasks for the custom view area
1734 bcf oneminupdate 1734 bcf oneminupdate
1735 return 1735 return
1736 1736
1744 btfss neg_flag 1744 btfss neg_flag
1745 return 1745 return
1746 ;max_pressure<rel_pressure 1746 ;max_pressure<rel_pressure
1747 movff sub_b+0,max_pressure+0 1747 movff sub_b+0,max_pressure+0
1748 movff sub_b+1,max_pressure+1 1748 movff sub_b+1,max_pressure+1
1749 call PLED_max_pressure ; No, use normal max. depth 1749 call DISP_max_pressure ; No, use normal max. depth
1750 return 1750 return
1751 1751
1752 set_min_temp: 1752 set_min_temp:
1753 movff mintemp+0,sub_a+0 1753 movff mintemp+0,sub_a+0
1754 movff mintemp+1,sub_a+1 1754 movff mintemp+1,sub_a+1
1796 1796
1797 set_dive_modes_common: 1797 set_dive_modes_common:
1798 bsf divemode ; (Re-)Set divemode flag 1798 bsf divemode ; (Re-)Set divemode flag
1799 bsf divemode2 ; displayed divetime is running 1799 bsf divemode2 ; displayed divetime is running
1800 btfsc timeout_display ; Was the timeout displayed? 1800 btfsc timeout_display ; Was the timeout displayed?
1801 call PLED_divemode_timeout_clear ; Yes, Clear (once) 1801 call DISP_divemode_timeout_clear ; Yes, Clear (once)
1802 return 1802 return
1803 1803
1804 set_dive_modes2: 1804 set_dive_modes2:
1805 bcf divemode2 ; Stop time 1805 bcf divemode2 ; Stop time
1806 btfss realdive ; dive longer then one minute? 1806 btfss realdive ; dive longer then one minute?
1817 btfsc gauge_mode ; In Gauge mode? 1817 btfsc gauge_mode ; In Gauge mode?
1818 return ; Yes, return 1818 return ; Yes, return
1819 1819
1820 1820
1821 btfss dekostop_active ; Is a deco stop displayed? 1821 btfss dekostop_active ; Is a deco stop displayed?
1822 call PLED_divemode_timeout ; No, show the divemode timeout here... 1822 call DISP_divemode_timeout ; No, show the divemode timeout here...
1823 btfsc dekostop_active ; Is a deco stop displayed? 1823 btfsc dekostop_active ; Is a deco stop displayed?
1824 call PLED_divemode_timeout2 ; Yes, show red warning divemode counter 1824 call DISP_divemode_timeout2 ; Yes, show red warning divemode counter
1825 return 1825 return
1826 1826
1827 set_dive_modes3: ; High-altitude mode 1827 set_dive_modes3: ; High-altitude mode
1828 btfsc realdive ; dive longer then one minute? 1828 btfsc realdive ; dive longer then one minute?
1829 bra set_dive_modes0 ; Yes -> this is a real dive -> Use CF00 threshold for ascend 1829 bra set_dive_modes0 ; Yes -> this is a real dive -> Use CF00 threshold for ascend
1973 clrf total_divetime_seconds+0 1973 clrf total_divetime_seconds+0
1974 clrf total_divetime_seconds+1 1974 clrf total_divetime_seconds+1
1975 bsf divemode2 ; displayed divetime is running (Divetime starts HERE) 1975 bsf divemode2 ; displayed divetime is running (Divetime starts HERE)
1976 1976
1977 clrf EEADRH ; Make sure to select eeprom bank 0 1977 clrf EEADRH ; Make sure to select eeprom bank 0
1978 call PLED_brightness_low 1978 call DISP_brightness_low
1979 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0) 1979 read_int_eeprom d'90' ; Brightness offset? (Dim>0, Normal = 0)
1980 movlw d'0' 1980 movlw d'0'
1981 cpfsgt EEDATA 1981 cpfsgt EEDATA
1982 call PLED_brightness_full 1982 call DISP_brightness_full
1983 1983
1984 bcf use_aGF 1984 bcf use_aGF
1985 bcf timeout_display 1985 bcf timeout_display
1986 bcf menu3_active 1986 bcf menu3_active
1987 clrf divesecs 1987 clrf divesecs