static void display_result(RANGING_SENSOR_Result_t *Result)
{
uint8_t i;
uint8_t j;
char message[50];
for (i = 0; i < RANGING_SENSOR_MAX_NB_ZONES; i++)
{
OLED_NewFrame();
sprintf(message, "Targets = %lu", (unsigned long)Result->ZoneResult[i].NumberOfTargets);
OLED_PrintString(0, 0, message, &font12x12, OLED_COLOR_NORMAL);
for (j = 0; j < Result->ZoneResult[i].NumberOfTargets; j++)
{
sprintf(message, "Status = %ld", (long)Result->ZoneResult[i].Status[j]);
OLED_PrintString(0, 20, message, &font12x12, OLED_COLOR_NORMAL);
sprintf(message, "Distance = %ld mm", (long)Result->ZoneResult[i].Distance[j]);
OLED_PrintString(0, 35, message, &font12x12, OLED_COLOR_NORMAL);
}
OLED_ShowFrame();
}
}
static void MX_VL53L4ED_SimpleRanging_Process(void)
{
uint32_t Id;
CUSTOM_RANGING_SENSOR_ReadID(CUSTOM_VL53L4ED, &Id);
CUSTOM_RANGING_SENSOR_GetCapabilities(CUSTOM_VL53L4ED, &Cap);
Profile.RangingProfile = VL53L4ED_PROFILE_CONTINUOUS;
Profile.TimingBudget = TIMING_BUDGET;
Profile.Frequency = 0; /* Induces intermeasurement period, NOT USED for normal ranging */
Profile.EnableAmbient = 1; /* Enable: 1, Disable: 0 */
Profile.EnableSignal = 1; /* Enable: 1, Disable: 0 */
/* set the profile if different from default one */
CUSTOM_RANGING_SENSOR_ConfigProfile(CUSTOM_VL53L4ED, &Profile);
status = CUSTOM_RANGING_SENSOR_Start(CUSTOM_VL53L4ED, RS_MODE_BLOCKING_CONTINUOUS);
while (1)
{
/* polling mode */
status = CUSTOM_RANGING_SENSOR_GetDistance(CUSTOM_VL53L4ED, &Result);
if (status == BSP_ERROR_NONE)
{
print_result(&Result);
display_result(&Result);
}
HAL_Delay(POLLING_PERIOD);
}
}