Mercurial > public > hwos_code
comparison src/tft_outputs.asm @ 480:ad8acade5567
NEW: PSCR mode (Passive semi-closed rebreather)
author | heinrichsweikamp |
---|---|
date | Mon, 06 Feb 2017 16:26:36 +0100 |
parents | 44b8a826b314 |
children | c0ee33f1f399 |
comparison
equal
deleted
inserted
replaced
479:34e73dc68799 | 480:ad8acade5567 |
---|---|
1944 | 1944 |
1945 global TFT_display_decotype_surface | 1945 global TFT_display_decotype_surface |
1946 TFT_display_decotype_surface: | 1946 TFT_display_decotype_surface: |
1947 WIN_STD surf_decotype_column,surf_decotype_row | 1947 WIN_STD surf_decotype_column,surf_decotype_row |
1948 WIN_COLOR color_lightblue | 1948 WIN_COLOR color_lightblue |
1949 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea | 1949 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea, 4=PSCR |
1950 tstfsz lo | 1950 tstfsz lo |
1951 bra TFT_display_decotype_surface2 | 1951 bra TFT_display_decotype_surface2 |
1952 TFT_display_decotype_surface0: | 1952 TFT_display_decotype_surface0: |
1953 STRCAT_TEXT_PRINT tDvOC ; OC | 1953 STRCAT_TEXT_PRINT tDvOC ; OC |
1954 bra TFT_display_decotype_exit | 1954 bra TFT_display_decotype_exit |
1981 bra TFT_display_decotype_surface4 | 1981 bra TFT_display_decotype_surface4 |
1982 TFT_display_decotype_surface3_1: | 1982 TFT_display_decotype_surface3_1: |
1983 STRCAT_TEXT_PRINT tDvGauge ; Gauge | 1983 STRCAT_TEXT_PRINT tDvGauge ; Gauge |
1984 bra TFT_display_decotype_exit | 1984 bra TFT_display_decotype_exit |
1985 TFT_display_decotype_surface4: | 1985 TFT_display_decotype_surface4: |
1986 decfsz lo,F | |
1987 bra TFT_display_decotype_surface5 | |
1988 TFT_display_decotype_surface4_1: | |
1986 STRCAT_TEXT_PRINT tDvApnea ; Apnea | 1989 STRCAT_TEXT_PRINT tDvApnea ; Apnea |
1990 bra TFT_display_decotype_exit | |
1991 TFT_display_decotype_surface5: | |
1992 STRCAT_TEXT_PRINT tDvPSCR ; PSCR | |
1987 TFT_display_decotype_exit: | 1993 TFT_display_decotype_exit: |
1988 goto TFT_standard_color ; and return... | 1994 goto TFT_standard_color ; and return... |
1989 | 1995 |
1990 global TFT_display_decotype_surface1 ; Used from logbook! | 1996 global TFT_display_decotype_surface1 ; Used from logbook! |
1991 TFT_display_decotype_surface1: ; Used from logbook! | 1997 TFT_display_decotype_surface1: ; Used from logbook! |
1996 decfsz lo,F | 2002 decfsz lo,F |
1997 bra TFT_display_decotype_surface1_3 | 2003 bra TFT_display_decotype_surface1_3 |
1998 STRCAT_TEXT_PRINT tDvCC ; CC (w/o Sensor/Fixed Display) | 2004 STRCAT_TEXT_PRINT tDvCC ; CC (w/o Sensor/Fixed Display) |
1999 TFT_display_decotype_surface1_3: | 2005 TFT_display_decotype_surface1_3: |
2000 decfsz lo,F | 2006 decfsz lo,F |
2001 bra TFT_display_decotype_surface4 ; Apnea | 2007 bra TFT_display_decotype_surface1_4 |
2002 bra TFT_display_decotype_surface3_1 ; Gauge | 2008 bra TFT_display_decotype_surface3_1 ; Gauge |
2009 TFT_display_decotype_surface1_4: | |
2010 decfsz lo,F | |
2011 bra TFT_display_decotype_surface4_1 ; Apnea | |
2012 bra TFT_display_decotype_surface5 ; PSCR | |
2003 | 2013 |
2004 ;============================================================================= | 2014 ;============================================================================= |
2005 | 2015 |
2006 global TFT_splist_surfmode ; Show Setpoint list | 2016 global TFT_splist_surfmode ; Show Setpoint list |
2007 extern gaslist_strcat_setpoint | 2017 extern gaslist_strcat_setpoint |
3663 STRCPY_TEXT_PRINT tppO2 | 3673 STRCPY_TEXT_PRINT tppO2 |
3664 goto TFT_standard_color; and return... | 3674 goto TFT_standard_color; and return... |
3665 | 3675 |
3666 global TFT_display_ppo2_val | 3676 global TFT_display_ppo2_val |
3667 TFT_display_ppo2_val: | 3677 TFT_display_ppo2_val: |
3678 btfss FLAG_pscr_mode | |
3679 bra TFT_display_ppo2_val_non_pscr ; Non-PSCR modes... | |
3680 ; in PSCR mode | |
3681 call compute_pscr_ppo2 ; pSCR ppO2 into sub_c:2 | |
3682 movff sub_c+0,xA+0 | |
3683 movff sub_c+1,xA+1 | |
3684 movlw d'100' | |
3685 movwf xB+0 | |
3686 clrf xB+1 | |
3687 call div16x16 ; /100 | |
3688 tstfsz xC+1 ; Is ppO2 > 2.55bar ? | |
3689 setf xC+0 ; yes: bound to 2.55... better than wrap around. | |
3690 movff xC+0,char_I_actual_ppO2 ; copy last ppO2 to buffer register (for pSCR CNS) | |
3691 clrf xC+2 | |
3692 clrf xC+3 | |
3693 movff sub_c+0,xC+0 | |
3694 movff sub_c+1,xC+1 ; copy for comptibility | |
3695 bra TFT_display_ppo2_val_com | |
3696 | |
3697 TFT_display_ppo2_val_non_pscr: | |
3668 SAFE_2BYTE_COPY amb_pressure, xA | 3698 SAFE_2BYTE_COPY amb_pressure, xA |
3669 movlw d'10' | 3699 movlw d'10' |
3670 movwf xB+0 | 3700 movwf xB+0 |
3671 clrf xB+1 | 3701 clrf xB+1 |
3672 call div16x16 ; xC=p_amb/10 | 3702 call div16x16 ; xC=p_amb/10 |
3674 movff xC+1,xA+1 | 3704 movff xC+1,xA+1 |
3675 movff char_I_O2_ratio,xB+0 ; =O2 ratio | 3705 movff char_I_O2_ratio,xB+0 ; =O2 ratio |
3676 clrf xB+1 | 3706 clrf xB+1 |
3677 call mult16x16 ; char_I_O2_ratio * p_amb/10 | 3707 call mult16x16 ; char_I_O2_ratio * p_amb/10 |
3678 | 3708 |
3709 TFT_display_ppo2_val_com: | |
3679 call TFT_standard_color | 3710 call TFT_standard_color |
3680 TFT_color_code warn_ppo2 ; Color-code output (ppO2 stored in xC) | 3711 TFT_color_code warn_ppo2 ; Color-code output (ppO2 stored in xC) |
3681 WIN_MEDIUM dm_custom_ceiling_ppo2_val_col, dm_custom_ceiling_value_row | 3712 WIN_MEDIUM dm_custom_ceiling_ppo2_val_col, dm_custom_ceiling_value_row |
3682 ; hijacking neg_flag_velocity to know where the value is displayed | 3713 ; hijacking neg_flag_velocity to know where the value is displayed |
3683 bsf neg_flag_velocity | 3714 bsf neg_flag_velocity |
3830 | 3861 |
3831 movff xC+0,lo | 3862 movff xC+0,lo |
3832 movff xC+1,hi ; restore lo and hi with updated value | 3863 movff xC+1,hi ; restore lo and hi with updated value |
3833 return | 3864 return |
3834 | 3865 |
3866 ;============================================================================= | |
3867 global compute_pscr_ppo2 | |
3868 compute_pscr_ppo2: | |
3869 ; (Pressure[mbar]*char_I_O2_ratio)-(100-char_I_O2_ratio)*CF61*CF62*10 | |
3870 movff char_I_O2_ratio,WREG | |
3871 sublw .100 ; 100-char_I_O2_ratio -> WREG | |
3872 mullw .10 ; (100-char_I_O2_ratio)*10 -> PROD:2 | |
3873 movff PRODL,xA+0 | |
3874 movff PRODH,xA+1 | |
3875 movff opt_PSCR_drop,xB+0 ; O2 Drop | |
3876 clrf xB+1 | |
3877 call mult16x16 ;xA*xB=xC -> (100-char_I_O2_ratio)*10*CF61 | |
3878 movff xC+0,xA+0 | |
3879 movff xC+1,xA+1 | |
3880 movff opt_PSCR_lungratio,xB+0 ; Lung ratio | |
3881 clrf xB+1 | |
3882 call mult16x16 ;xA*xB=xC -> (100-char_I_O2_ratio)*10*CF61*CF62 | |
3883 | |
3884 movlw .10 | |
3885 movwf xB+0 | |
3886 clrf xB+1 | |
3887 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3888 ; store xC:2 in lo:hi | |
3889 movff xC+0,lo | |
3890 movff xC+1,hi | |
3891 | |
3892 SAFE_2BYTE_COPY amb_pressure, xA | |
3893 movff char_I_O2_ratio,xB+0 | |
3894 clrf xB+1 | |
3895 call mult16x16 ;xA*xB=xC -> xC:4 = Pressure[mbar]*char_I_O2_ratio | |
3896 | |
3897 movlw .10 | |
3898 movwf xB+0 | |
3899 clrf xB+1 | |
3900 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
3901 | |
3902 ; store xC:2 in sub_a | |
3903 movff xC+0,sub_a+0 | |
3904 movff xC+1,sub_a+1 | |
3905 ; reload result from lo:hi | |
3906 movff lo,sub_b+0 | |
3907 movff hi,sub_b+1 | |
3908 | |
3909 call subU16 ;sub_c = sub_a - sub_b (with UNSIGNED values) | |
3910 return | |
3911 | |
3912 | |
3835 END | 3913 END |