
1 sensory wired directly to the F401. Uses Ayoub's Custom library. Mb6
Revision 2:28f78024d00a, committed 2021-07-21
- Comitter:
- charlesmn
- Date:
- Wed Jul 21 12:09:20 2021 +0000
- Parent:
- 1:8cfb1799974f
- Child:
- 3:ba1ee6cac90d
- Commit message:
- Fix NumberOfZones issue. Fix printing of results
Changed in this revision
53L3A2_Ranging.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/53L3A2_Ranging.lib Tue Jul 20 16:04:57 2021 +0000 +++ b/53L3A2_Ranging.lib Wed Jul 21 12:09:20 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/charlesmn/code/53L3A2_Ranging/#7b331e34f358 +https://os.mbed.com/users/charlesmn/code/53L3A2_Ranging/#2316b88a9c5c
--- a/main.cpp Tue Jul 20 16:04:57 2021 +0000 +++ b/main.cpp Wed Jul 21 12:09:20 2021 +0000 @@ -72,6 +72,8 @@ RANGING_SENSOR_Result_t Result; RANGING_SENSOR_ProfileConfig_t Profile; + uint16_t zone = 0; + uint16_t target = 0; printf("MX_53L3A2_MultiSensorRanging_Process\n"); Profile.RangingProfile = RS_MULTI_TARGET_LONG_RANGE; @@ -100,24 +102,53 @@ // repeatedly read data and start next measurement while (1) { status = sensor->CUSTOM_RANGING_GetDistance(ToF_sensor, &Result); - - if ((status == BSP_ERROR_NONE) && ( Result.NumberOfZones != 0)) - + // print results if ((status == BSP_ERROR_NONE) && - (Result.NumberOfZones != 0) && - (Result.ZoneResult[0].Status[0] == BSP_ERROR_NONE )) + ( Result.ZoneResult[zone].NumberOfTargets != 0)) // is there data { - printf("\n |---> "); - printf("Status = %d, Distance = %5d mm", - Result.ZoneResult[0].Status[0], - Result.ZoneResult[0].Distance[0]); + for ( target = 0 ; target < Result.ZoneResult[zone].NumberOfTargets; target++) + { + if (Result.ZoneResult[zone].Status[target] == VL53LX_RANGESTATUS_RANGE_VALID ) + { + printf("\n |---> "); + printf("Status = %d, Target %d, Distance = %5d mm", + Result.ZoneResult[zone].Status[target], + target, + Result.ZoneResult[zone].Distance[target]); + } + } + } + + wait_ms(POLLING_PERIOD); + } +} +/* + // repeatedly read data and start next measurement + // Note in VL53L3CX there is only one Zone so NumberOfZones is not used and is always assumed to be 1 + while (1) { + memset( &Result, 0x0,sizeof(RANGING_SENSOR_Result_t)); + status = sensor->VL53L3A2_RANGING_GetDistance(ToF_sensor, &Result); + if ((status == BSP_ERROR_NONE) && + ( Result.ZoneResult[zone].NumberOfTargets != 0)) + { + for ( target = 0 ; target < Result.ZoneResult[0].NumberOfTargets; target++) + { + if (Result.ZoneResult[zone].Status[target] == VL53LX_RANGESTATUS_RANGE_VALID ) + { + printf("\n |---> "); + printf("Status = %d, Target %d, Distance = %5d mm", + Result.ZoneResult[zone].Status[target], + target, + Result.ZoneResult[zone].Distance[target]); + } + } } wait_ms(POLLING_PERIOD); } } - +*/ /*=================================== Main ================================== =============================================================================*/