refine output format for average measure

This commit is contained in:
Yunhorn 2024-10-16 12:06:16 +08:00
parent 2716d737ce
commit 353deb7e48
1 changed files with 14 additions and 4 deletions

View File

@ -140,19 +140,29 @@ uint16_t MX_TOF_Ranging_Process(void)
uint8_t center_roi[4] = {27,28,35,36}; uint8_t center_roi[4] = {27,28,35,36};
uint8_t range_mode = 2; //STS_TOF_LONG_RANGE; uint8_t range_mode = 2; //STS_TOF_LONG_RANGE;
int status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result); int status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
#if 1
printf("\r| 27 | 28 | 35 | 36 |\r\n");
for (uint8_t zone_nbr = 0; zone_nbr < 4; zone_nbr++) for (uint8_t zone_nbr = 0; zone_nbr < 4; zone_nbr++)
{ {
/* Print distance and status */ /* Print distance and status */
if (Result.ZoneResult[center_roi[zone_nbr]].NumberOfTargets > 0) if (Result.ZoneResult[center_roi[zone_nbr]].NumberOfTargets > 0)
printf("\n\r%2d distance = %4d mm status =%2d\n\r",center_roi[zone_nbr], {
printf("| %04ld %2ld",
(long)Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1], (long)Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1],
(long)Result.ZoneResult[center_roi[zone_nbr]].Status[RANGING_SENSOR_NB_TARGET_PER_ZONE-1]); (long)Result.ZoneResult[center_roi[zone_nbr]].Status[RANGING_SENSOR_NB_TARGET_PER_ZONE-1]);
}
else {
printf("| -- ");
}
range_distance += Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1]; range_distance += Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1];
} }
#endif //printf("\n\r");
range_distance /=4; range_distance /=4;
APP_LOG(TS_OFF, VLEVEL_M, "\n VL53L1 Range distance =%u mm \n\r", (uint16_t)range_distance); printf("| %u mm\r\n", (uint16_t)range_distance);
return (uint16_t) range_distance; return (uint16_t) range_distance;
#endif #endif