comparison src/adc_lightsensor.asm @ 44:18fe4e668baa

BUGFIX: Percent display with 1,5V batteries
author heinrichsweikamp
date Wed, 28 Aug 2013 15:44:11 +0200
parents 0e1723f2761e
children f3062a611eef
comparison
equal deleted inserted replaced
43:83794355f927 44:18fe4e668baa
148 btfsc neg_flag 148 btfsc neg_flag
149 bra get_battery_voltage3d 149 bra get_battery_voltage3d
150 movlw .10 150 movlw .10
151 movwf lo 151 movwf lo
152 get_battery_voltage3d: 152 get_battery_voltage3d:
153 movlw .100
154 cpfslt lo
155 movwf lo
156 ; lo will be between 100 (Full) and 0 (empty)
153 movf batt_percent,W 157 movf batt_percent,W
154 cpfsgt lo ; keep batt_percent on the lowest value found 158 cpfsgt lo ; keep batt_percent on the lowest value found
155 movff lo,batt_percent ; store value 159 movff lo,batt_percent ; store value
156 ; btfsc battery_is_36v ; but always use computed value for 3,6V battery 160 ; btfsc battery_is_36v ; but always use computed value for 3,6V battery
157 ; movff lo,batt_percent ; store value 161 ; movff lo,batt_percent ; store value
173 rrcf sub_c+0 ; /2 177 rrcf sub_c+0 ; /2
174 bcf STATUS,C 178 bcf STATUS,C
175 rrcf sub_c+1 179 rrcf sub_c+1
176 rrcf sub_c+0 ; /4 180 rrcf sub_c+0 ; /4
177 movff sub_c+0,lo 181 movff sub_c+0,lo
178 bra get_battery_voltage3 ; Check limits and return 182 bra get_battery_voltage3d ; Check limits and return
179 183
180 global get_ambient_level 184 global get_ambient_level
181 get_ambient_level: ; starts ADC and waits until finished 185 get_ambient_level: ; starts ADC and waits until finished
182 btfsc adc_running ; ADC in use? 186 btfsc adc_running ; ADC in use?
183 return ; Yes, return 187 return ; Yes, return