comparison src/i2c.asm @ 616:935e20e16dff

work on new battery menu
author heinrichsweikamp
date Sat, 02 Feb 2019 19:22:16 +0100
parents b87f23fae743
children 7b3903536213
comparison
equal deleted inserted replaced
615:b87f23fae743 616:935e20e16dff
920 movwf i2c_temp1 920 movwf i2c_temp1
921 lt2942_get_temperature2: 921 lt2942_get_temperature2:
922 bcf STATUS,C 922 bcf STATUS,C
923 rrcf xC+3,F 923 rrcf xC+3,F
924 rrcf xC+2,F 924 rrcf xC+2,F
925 rrcf xC+1,F 925 rrcf xC+1,F ; Result in 0.1K
926 rrcf xC+0,F 926 rrcf xC+0,F ; Result in 0.1K
927 decfsz i2c_temp1,F 927 decfsz i2c_temp1,F
928 bra lt2942_get_temperature2 928 bra lt2942_get_temperature2
929 929
930 movff xC+1,sub_a+1 930 movlw LOW max_allowed_battery_temp ; in 0.1K
931 movff xC+0,sub_a+0
932 movlw LOW .2731 ; Kelvin to Celcius offset
933 movwf sub_b+0
934 movlw HIGH .2731 ; Kelvin to Celcius offset
935 movwf sub_b+1
936 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values)
937
938 ; Update battery_temperature in 0.1°C
939 movff sub_c+1,battery_temperature+1
940 movff sub_c+0,battery_temperature+0
941
942 movlw LOW max_allowed_battery_temp ; in 0.1°C
943 movwf sub_a+0 931 movwf sub_a+0
944 movlw HIGH max_allowed_battery_temp 932 movlw HIGH max_allowed_battery_temp
945 movwf sub_a+1 933 movwf sub_a+1
946 movff battery_temperature+0,sub_b+0 934 movff xC+1,sub_b+1
947 movff battery_temperature+1,sub_b+1 935 movff xC+0,sub_b+0
948 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) 936 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values)
949 btfss neg_flag 937 btfss neg_flag
950 return ; temp ok, return 938 return ; temp ok, return
951 ; too hot, disable charge if currently charging 939 ; too hot, disable charge if currently charging
952 btfss cc_active 940 btfss cc_active