EasyManua.ls Logo

ST VD6283 - Appendix A Examples; ALS Measure in Single Shot Mode; ALS Measure in Synchronous Mode

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...
Appendix A Examples
A.1 ALS measure in single shot mode
CustomerPrivate client;
void *hdl;
// sensor initialization
Error = STALS_Init("VD6283", &client, &hdl);
// First configure device settings
Error = STALS_SetExposureTime(hdl, 10000, &current_exposure);
Error = STALS_SetGain(hdl, STALS_CHANNEL_1, 0x0100, &current_gain);
// Start ALS acquisition
Error = STALS_Start(hdl, STALS_MODE_ALS_SINGLE_SHOT, STALS_CHANNEL_1);
// poll until acquisition is completed
do {
Error = STALS_GetAlsValues(hdl, STALS_CHANNEL_1, &meas, &is_valid);
} while(!is_valid);
// display acquisition
printf("channel 1 count = %d\n", meas.CountValue[0]);
// stop acquisition
Error = STALS_Stop(hdl, STALS_MODE_ALS_SINGLE_SHOT);
// Release sensor
Error = STALS_Term(&hdl);
A.2 ALS measure in synchronous mode
CustomerPrivate client;
void *hdl;
// sensor initialization
Error = STALS_Init("VD6283", &client, &hdl);
// First configure sensor settings
Error = STALS_SetInterMeasurementTime(hdl, 1000000, &current_inter_measurement);
Error = STALS_SetExposureTime(hdl, 100000, &current_exposure);
Error = STALS_SetGain(hdl, STALS_CHANNEL_1, 0x0100, &current_gain);
Error = STALS_SetGain(hdl, STALS_CHANNEL_2, 0x0100, &current_gain);
// Start ALS acquisition
Error = STALS_Start(hdl, STALS_MODE_ALS_SYNCHRONOUS, STALS_CHANNEL_1 | STALS_CHANNEL_2);
// poll until acquisition is completed
for(loop = 0; loop < 10; loop++) {
do {
Error = STALS_GetAlsValues(hdl, STALS_CHANNEL_1 | STALS_CHANNEL_2, &meas, &is_valid);
} while(!is_valid);
// display acquisition
printf("loop measure %d %6d / %6d\n", loop, meas.CountValue[0], meas.CountValue[1]);
}
// stop acquisition
Error = STALS_Stop(hdl, STALS_MODE_ALS_SYNCHRONOUS);
// Release sensor
Error = STALS_Term(&hdl);
UM2878
Examples
UM2878 - Rev 1
page 21/27

Related product manuals