Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 203:dd9b167e82dc
1.64 (Fix ambient light for cR)
author | heinrichsweikamp |
---|---|
date | Fri, 21 Nov 2014 11:51:53 +0100 |
parents | 82faedf8fd58 |
children | 93085f540746 |
comparison
equal
deleted
inserted
replaced
202:34b8de21146c | 203:dd9b167e82dc |
---|---|
220 btfsc adc_running ; ADC in use? | 220 btfsc adc_running ; ADC in use? |
221 return ; Yes, return | 221 return ; Yes, return |
222 | 222 |
223 btfss cr_hardware | 223 btfss cr_hardware |
224 bra get_ambient_level1 ; Normal ostc3 hardware | 224 bra get_ambient_level1 ; Normal ostc3 hardware |
225 movlw .250 | 225 |
226 movwf ambient_light+0 | 226 banksel isr_backup ; Back to Bank0 ISR data |
227 clrf ambient_light+1 ; Set to max | 227 movff opt_brightness,isr1_temp |
228 bra get_ambient_level2 ; Continue as normal | 228 incf isr1_temp,F ; adjust 0-2 to 1-3 |
229 movlw ambient_light_max_high_cr; cR hardware brightest setting | |
230 dcfsnz isr1_temp,F | |
231 movlw ambient_light_max_eco ; brightest setting | |
232 dcfsnz isr1_temp,F | |
233 movlw ambient_light_max_medium; brightest setting | |
234 | |
235 movff WREG,ambient_light+0 ; Set to max. | |
236 movff ambient_light+0,max_CCPR1L ; Store value for dimming in TMR7 interrupt | |
237 return | |
229 | 238 |
230 get_ambient_level1: | 239 get_ambient_level1: |
231 movlw b'00000000' ; Vref+ = Vdd | 240 movlw b'00000000' ; Vref+ = Vdd |
232 movwf ADCON1 | 241 movwf ADCON1 |
233 movlw b'00011101' ; power on ADC, select AN7 | 242 movlw b'00011101' ; power on ADC, select AN7 |
267 get_ambient_level2: | 276 get_ambient_level2: |
268 movlw .10 | 277 movlw .10 |
269 subwf ambient_light+0,F ; Subtract 10 (ADC Offset) | 278 subwf ambient_light+0,F ; Subtract 10 (ADC Offset) |
270 btfsc STATUS,N | 279 btfsc STATUS,N |
271 movwf ambient_light+0 ; avoid clipping | 280 movwf ambient_light+0 ; avoid clipping |
272 | |
273 | 281 |
274 banksel isr_backup ; Back to Bank0 ISR data | 282 banksel isr_backup ; Back to Bank0 ISR data |
275 movff opt_brightness,isr1_temp | 283 movff opt_brightness,isr1_temp |
276 | 284 |
277 btfsc RCSTA1,7 ; UART module on? | 285 btfsc RCSTA1,7 ; UART module on? |