diff 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
line wrap: on
line diff
--- a/src/adc_lightsensor.asm	Fri Nov 21 11:10:07 2014 +0100
+++ b/src/adc_lightsensor.asm	Fri Nov 21 11:51:53 2014 +0100
@@ -222,10 +222,19 @@
 
     btfss   cr_hardware
     bra     get_ambient_level1  ; Normal ostc3 hardware
-    movlw   .250
-    movwf   ambient_light+0
-    clrf    ambient_light+1     ; Set to max
-    bra     get_ambient_level2  ; Continue as normal
+
+  	banksel isr_backup              ; Back to Bank0 ISR data
+	movff	opt_brightness,isr1_temp
+	incf	isr1_temp,F				; adjust 0-2 to 1-3
+	movlw	ambient_light_max_high_cr; cR hardware brightest setting
+	dcfsnz	isr1_temp,F
+	movlw	ambient_light_max_eco	; brightest setting
+	dcfsnz	isr1_temp,F
+	movlw	ambient_light_max_medium; brightest setting
+
+	movff	WREG,ambient_light+0		; Set to max.
+	movff	ambient_light+0,max_CCPR1L	; Store value for dimming in TMR7 interrupt
+	return
 
 get_ambient_level1:
 	movlw	b'00000000'         ; Vref+ = Vdd
@@ -270,7 +279,6 @@
     btfsc   STATUS,N
     movwf   ambient_light+0         ; avoid clipping
 
-
   	banksel isr_backup              ; Back to Bank0 ISR data
 	movff	opt_brightness,isr1_temp