@@ -79,13 +79,13 @@ void mt9v034_context_configuration(void)
7979 uint16_t new_height_context_b = FULL_IMAGE_COLUMN_SIZE * 4 ;
8080
8181 /* blanking settings */
82- uint16_t new_hor_blanking_context_a = 709 + MINIMUM_HORIZONTAL_BLANKING ;// 709 is minimum value without distortions
82+ uint16_t new_hor_blanking_context_a = 425 + MINIMUM_HORIZONTAL_BLANKING ;// 709 is minimum value without distortions
8383 uint16_t new_ver_blanking_context_a = 10 ; // this value is the first without image errors (dark lines)
8484 uint16_t new_hor_blanking_context_b = MAX_IMAGE_WIDTH - new_width_context_b + MINIMUM_HORIZONTAL_BLANKING ;
8585 if (new_hor_blanking_context_b < 800 ) {
8686 new_hor_blanking_context_b = 800 ;
8787 }
88- uint16_t new_ver_blanking_context_b = 10 ;
88+ uint16_t new_ver_blanking_context_b = 5 ;
8989
9090
9191 /* Read Mode
@@ -109,51 +109,38 @@ void mt9v034_context_configuration(void)
109109 * so we set max on 64 (lines) = 0x40
110110 */
111111 uint16_t min_exposure = 0x0001 ; // default
112- uint16_t max_exposure = 0x01E0 ; // default
113- uint16_t new_max_gain = 64 ; // VALID RANGE: 16-64 (default)
114112 uint16_t pixel_count = 4096 ; //64x64 take all pixels to estimate exposure time // VALID RANGE: 1-65535
115-
116- uint16_t desired_brightness = 58 ; // default
117- uint16_t resolution_ctrl = 0x0203 ; // default
118- uint16_t hdr_enabled = 0x0100 ; // default
119- uint16_t aec_agc_enabled = 0x0003 ; // default
120- uint16_t coarse_sw1 = 0x01BB ; // default from context A
121- uint16_t coarse_sw2 = 0x01D9 ; // default from context A
122113 uint16_t shutter_width_ctrl = 0x0164 ; // default from context A
123- uint16_t total_shutter_width = 0x01E0 ; // default from context A
124114 uint16_t aec_update_freq = 0x02 ; // default Number of frames to skip between changes in AEC VALID RANGE: 0-15
125115 uint16_t aec_low_pass = 0x01 ; // default VALID RANGE: 0-2
126116 uint16_t agc_update_freq = 0x02 ; // default Number of frames to skip between changes in AGC VALID RANGE: 0-15
127117 uint16_t agc_low_pass = 0x02 ; // default VALID RANGE: 0-2
128118
119+ uint16_t resolution_ctrl = 0x0303 ; // 12 bit adc for low light
120+ uint16_t max_gain = global_data .param [PARAM_GAIN_MAX ];
121+ uint16_t max_exposure = global_data .param [PARAM_EXPOSURE_MAX ];
122+ uint16_t coarse_sw1 = global_data .param [PARAM_SHTR_W_1 ];
123+ uint16_t coarse_sw2 = global_data .param [PARAM_SHTR_W_2 ];
124+ uint16_t total_shutter_width = global_data .param [PARAM_SHTR_W_TOT ];
125+ uint16_t hdr_enabled = 0x0000 ;
126+ bool hdr_enable_flag = global_data .param [PARAM_HDR ] > 0 ;
127+ if (hdr_enable_flag ) {
128+ hdr_enabled = 0x0100 ;
129+ }
129130
130- if (FLOAT_AS_BOOL (global_data .param [PARAM_IMAGE_LOW_LIGHT ]))
131- {
132- min_exposure = 0x0001 ;
133- max_exposure = 0x0040 ;
134- desired_brightness = 58 ; // VALID RANGE: 8-64
135- resolution_ctrl = 0x0202 ;//10 bit linear
136- hdr_enabled = 0x0000 ; // off
137- aec_agc_enabled = 0x0303 ; // on
138- coarse_sw1 = 0x01BB ; // default from context A
139- coarse_sw2 = 0x01D9 ; // default from context A
140- shutter_width_ctrl = 0x0164 ; // default from context A
141- total_shutter_width = 0x01E0 ; // default from context A
131+ bool aec_enable_flag = global_data .param [PARAM_AEC ] > 0 ;
132+ uint16_t aec_agc_enabled = 0x0000 ;
133+ if (aec_enable_flag ) {
134+ aec_agc_enabled |= (1 << 0 );
142135 }
143- else
144- {
145- min_exposure = 0x0001 ;
146- max_exposure = 0x0080 ;
147- desired_brightness = 16 ; // VALID RANGE: 8-64
148- resolution_ctrl = 0x0202 ;//10bit linear
149- hdr_enabled = 0x0000 ; // off
150- aec_agc_enabled = 0x0303 ; // on
151- coarse_sw1 = 0x01BB ; // default from context A
152- coarse_sw2 = 0x01D9 ; // default from context A
153- shutter_width_ctrl = 0x0164 ; // default from context A
154- total_shutter_width = 0x01E0 ; // default from context A
136+
137+ bool agc_enable_flag = global_data .param [PARAM_AGC ] > 0 ;
138+ if (agc_enable_flag ) {
139+ aec_agc_enabled |= (1 << 1 );
155140 }
156141
142+ uint16_t desired_brightness = global_data .param [PARAM_BRIGHT ];
143+
157144 uint16_t row_noise_correction = 0x0000 ; // default
158145 uint16_t test_data = 0x0000 ; // default
159146
@@ -216,7 +203,7 @@ void mt9v034_context_configuration(void)
216203 mt9v034_WriteReg16 (MTV_HDR_ENABLE_REG , hdr_enabled ); // disable HDR on both contexts
217204 mt9v034_WriteReg16 (MTV_MIN_EXPOSURE_REG , min_exposure );
218205 mt9v034_WriteReg16 (MTV_MAX_EXPOSURE_REG , max_exposure );
219- mt9v034_WriteReg16 (MTV_MAX_GAIN_REG , new_max_gain );
206+ mt9v034_WriteReg16 (MTV_MAX_GAIN_REG , max_gain );
220207 mt9v034_WriteReg16 (MTV_AGC_AEC_PIXEL_COUNT_REG , pixel_count );
221208 mt9v034_WriteReg16 (MTV_AGC_AEC_DESIRED_BIN_REG , desired_brightness );
222209 mt9v034_WriteReg16 (MTV_ADC_RES_CTRL_REG , resolution_ctrl ); // here is the way to regulate darkness :)
0 commit comments