EasyManua.ls Logo

ST VD6283 - Parallel als and Flicker Measure Using an External Adc

ST VD6283
27 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
A.4 Parallel ALS and flicker measure using an external adc
CustomerPrivate client;
void *hdl;
int als_started = 0;
int start_flk = 0;
// sensor initialization
Error = STALS_Init("VD6283", &client, &hdl);
// First configure device settings
Error = STALS_SetInterMeasurementTime(hdl, 0, &current_inter_measurement);
Error = STALS_SetExposureTime(hdl, 50000, &current_exposure);
Error = STALS_SetGain(hdl, STALS_CHANNEL_1, 0x0100, &current_gain);
Error = STALS_SetGain(hdl, STALS_CHANNEL_6, 0x0a00, &current_gain);
Error = STALS_SetFlickerOutputType(hdl, STALS_FLICKER_OUTPUT_ANALOG);
// start platform adc capture
Platform_capture_adc_start();
// main loop
do {
update_display = 0;
if (!als_started) {
Error = STALS_Start(hdl, STALS_MODE_ALS_SINGLE_SHOT, STALS_CHANNEL_1);
als_started = 1;
}
// Flicker must be started after als
if (!start_flk) {
Error = STALS_Start(hdl, STALS_MODE_FLICKER, STALS_CHANNEL_6);
start_flk = 1;
}
// ALS acquisition
Error = STALS_GetAlsValues(hdl, STALS_CHANNEL_1, &meas, &is_valid);
if (is_valid) {
als_value = meas.CountValue[0];
update_display = 1;
Error = STALS_Stop(hdl, STALS_MODE_ALS_SINGLE_SHOT);
als_started = 0;
}
// Check if adc data are ready to update the flicker frequency
Platform_capture_adc_frame(data, &is_flk_valid);
if (is_flk_valid) {
Platform_fft(data, data_fft);
flk_frequency = Platform_flk_detect(data_fft);
update_display = 1;
}
// update display if we have new als or flicker data
if (update_display)
display(als_value, flk_frequency);
} while(!exit_loop);
// stop platform adc capture
Platform_capture_adc_stop();
// stop ALS acquisition and flicker sampling
Error = STALS_Stop(hdl, STALS_MODE_FLICKER);
if (als_started)
Error = STALS_Stop(hdl, STALS_MODE_ALS_SINGLE_SHOT);
// Release sensor
Error = STALS_Term(&hdl);
UM2878
Parallel ALS and flicker measure using an external adc
UM2878 - Rev 1
page 23/27

Related product manuals