The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2

Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.

Revision:
18:0696efe39d08
Parent:
7:1add29d51e72
diff -r ca0ce4daf573 -r 0696efe39d08 src/vl53l1_hist_algos_gen4.c
--- a/src/vl53l1_hist_algos_gen4.c	Wed Jun 23 12:57:26 2021 +0000
+++ b/src/vl53l1_hist_algos_gen4.c	Wed Jul 21 17:06:38 2021 +0200
@@ -96,6 +96,8 @@
 
 	uint8_t                       p = 0;
 	VL53L1_histogram_bin_data_t *pB = &(palgo3->VL53L1_p_010);
+	uint16_t enabled_spads_ninety_percent;
+	int32_t amb_threshold_sigma;
 
 	LOG_FUNCTION_START("");
 
@@ -151,9 +153,16 @@
 				&(palgo3->VL53L1_p_038));
 
 
+	amb_threshold_sigma = ppost_cfg->ambient_thresh_sigma1;
+	enabled_spads_ninety_percent =
+		presults->fmt_total_enabled_spads * 230;
+	if ((pbins_input->result__dss_actual_effective_spads <
+		 enabled_spads_ninety_percent) &&
+		(presults->VL53L1_p_002[0].ambient_count_rate_mcps < (5 * 128))){
+		amb_threshold_sigma *= histo_merge_nb;
+	}
 
-	pdmax_cfg->ambient_thresh_sigma =
-		ppost_cfg->ambient_thresh_sigma1;
+	pdmax_cfg->ambient_thresh_sigma = amb_threshold_sigma;
 
 	for (p = 0; p < VL53L1_MAX_AMBIENT_DMAX_VALUES; p++) {
 		if (status == VL53L1_ERROR_NONE) {
@@ -176,7 +185,7 @@
 		status =
 			VL53L1_f_018(
 			ppost_cfg->ambient_thresh_events_scaler,
-			(int32_t)ppost_cfg->ambient_thresh_sigma1,
+			(int32_t)amb_threshold_sigma,
 			(int32_t)ppost_cfg->min_ambient_thresh_events,
 			ppost_cfg->algo__crosstalk_compensation_enable,
 			&(palgo3->VL53L1_p_010),