comparison src/divemode.asm @ 646:5b7fe7777425

3.16 release
author heinrichs weikamp
date Thu, 14 Oct 2021 12:03:24 +0200
parents 8c1f1f334275
children 357341239438
comparison
equal deleted inserted replaced
642:a9a0188091e4 646:5b7fe7777425
231 231
232 ;----------------------------------------------------------------------------- 232 ;-----------------------------------------------------------------------------
233 ; Dive Mode Mail Loop 233 ; Dive Mode Mail Loop
234 ; 234 ;
235 diveloop_loop: 235 diveloop_loop:
236 btfsc trigger_full_second ; new 1/1 second? 236 btfss trigger_quarter_second ; new 1/4 second?
237 bra diveloop_loop_0 ; No - continue
238
239 ;---- tasks any new 1/4 second -----
240 bcf trigger_quarter_second ; YES - clear flag
241
242 movlw .4 ; 62,5ms * 4 = 1/4 second
243 movff WREG,isr_tmr7_helper ; to make sure at least 1/4 will pass before trigger_quarter_second is re-set
244
245 btfss press_sensor_type ; New sensor found?
246 bra diveloop_loop_0 ; No - continue
247
248 ; Handle new pressure sensor every 1/4 second
249 btfsc ms5837_state ; =0: result of temperature is in the ADC
250 bra diveloop_loop_quarter_2
251 call I2C_get_temp_val_MS5837 ; (Will set ms5837_state)
252 bra diveloop_loop_0 ; Done.
253 diveloop_loop_quarter_2:
254 call I2C_get_press_val_MS5837 ; (Will clear ms5837_state)
255 ;---- tasks any new 1/4 second done -----
256
257 diveloop_loop_0:
258 btfsc trigger_full_second ; new 1/1 second?
237 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second 259 bra diveloop_loop_2 ; YES - continue with tasks every 1/1 second
238 btfsc trigger_half_second ; NO - new 1/2 second? 260 btfsc trigger_half_second ; NO - new 1/2 second?
239 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second 261 bra diveloop_loop_1 ; YES - continue with tasks every 1/2 second
240 262
241 ; tasks every round except every 1/1 or 1/2 second 263 ; tasks every round except every 1/1 or 1/2 second
463 call divemenu_cleanup ; clean up menu area and restore dive data 485 call divemenu_cleanup ; clean up menu area and restore dive data
464 ;bra diveloop_loop_12 ; continue the dive loop 486 ;bra diveloop_loop_12 ; continue the dive loop
465 487
466 488
467 diveloop_loop_12: 489 diveloop_loop_12:
468 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text) 490 bsf FLAG_TFT_active_gas_divemode; redraw gas and setpoint (eventually needed to restore the "Bailout" text)
469 491
470 btfsc request_next_custview ; shall show next custom view? 492 btfsc request_next_custview ; shall show next custom view?
471 call dive_customview_toggle ; YES - show next custom view 493 call dive_customview_toggle ; YES - show next custom view
472 494
473 btfsc request_gas_change ; shall change gas? 495 btfsc request_gas_change ; shall change gas?
530 bra update_divemode60_1 ; NO - skip next 552 bra update_divemode60_1 ; NO - skip next
531 movlw d'7' ; YES - set type of alarm = battery low 553 movlw d'7' ; YES - set type of alarm = battery low
532 movwf alarm_type ; - copy to alarm register 554 movwf alarm_type ; - copy to alarm register
533 bsf event_occured ; - set event flag 555 bsf event_occured ; - set event flag
534 movlw .0 ; - coding of brightness level ECO 556 movlw .0 ; - coding of brightness level ECO
535 movff WREG,opt_brightness ; - set brightness to ECO 557 movff WREG,opt_brightness_divemode ; - set brightness to ECO
536 558
537 update_divemode60_1: 559 update_divemode60_1:
538 ; max allowed runtime in simulator is 254 minutes in 560 ; max allowed runtime in simulator is 254 minutes in
539 ; order for the tissue calculation catch-up to work! 561 ; order for the tissue calculation catch-up to work!
540 562
1949 call cmpU16 ; sub_a - sub_b = pressure_rel_cur - start-dive threshold 1971 call cmpU16 ; sub_a - sub_b = pressure_rel_cur - start-dive threshold
1950 btfsc neg_flag ; pressure_rel_cur > dive_threshold, i.e. deeper than threshold? 1972 btfsc neg_flag ; pressure_rel_cur > dive_threshold, i.e. deeper than threshold?
1951 bra check_dive_modes_shallow ; NO - shallower than threshold 1973 bra check_dive_modes_shallow ; NO - shallower than threshold
1952 btfsc divetime_longer_1min ; YES - diving > one minute? 1974 btfsc divetime_longer_1min ; YES - diving > one minute?
1953 CLRI dive_timeout_timer ; YES - reset timeout counter 1975 CLRI dive_timeout_timer ; YES - reset timeout counter
1976 decfsz dive_threshold_debounce,F ; debounce counter
1977 return
1978 incf dive_threshold_debounce,F
1954 bsf divemode ; - set dive mode flag 1979 bsf divemode ; - set dive mode flag
1955 bsf count_divetime ; - count dive time 1980 bsf count_divetime ; - count dive time
1956 return ; - done 1981 return ; - done
1957 1982
1958 check_dive_modes_shallow: 1983 check_dive_modes_shallow:
1984 movlw .5 ; load debounce counter
1985 movwf dive_threshold_debounce
1959 bcf count_divetime ; stop counting dive time 1986 bcf count_divetime ; stop counting dive time
1960 ; btfss divetime_longer_1min ; diving > one minute? 1987 ; btfss divetime_longer_1min ; diving > one minute?
1961 ; bcf divemode ; NO - quit dive mode as this was no real dive 1988 ; bcf divemode ; NO - quit dive mode as this was no real dive
1962 return ; done mH 1989 return ; done mH
1963 1990