Simple ranging example, using polling, with only the X-Nucleo_53L1A1 expansion board.
Dependencies: X_NUCLEO_53L1A1_mbed
Revision 3:a3a863902994, committed 2019-10-14
- Comitter:
- johnAlexander
- Date:
- Mon Oct 14 10:12:25 2019 +0000
- Parent:
- 2:819f8323b02d
- Commit message:
- Simple ranging example, using polling, with only the X-Nucleo-53L1A1 expansion board.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 14 10:02:40 2019 +0000 +++ b/main.cpp Mon Oct 14 10:12:25 2019 +0000 @@ -1,6 +1,6 @@ /* * This VL53L1X Expansion board test application performs range measurements - * using the onboard embedded centre sensor, and 2 Satellite boards. + * using the onboard embedded centre sensor. * * Measured ranges are ouput on the Serial Port, running at 115200 baud. * @@ -47,11 +47,7 @@ { int status = 0; uint8_t ready_centre = 0; - uint8_t ready_left = 0; - uint8_t ready_right = 0; uint16_t distance_centre = 0; - uint16_t distance_left = 0; - uint16_t distance_right = 0; printf("Hello world!\r\n"); @@ -81,24 +77,6 @@ } } - /* Start ranging on the left sensor */ - if (board->sensor_left != NULL) { - status = board->sensor_left->VL53L1X_StartRanging(); - if (status != 0) { - printf("Left sensor failed to start ranging!\r\n"); - return status; - } - } - - /* Start ranging on the right sensor */ - if (board->sensor_right != NULL) { - status = board->sensor_right->VL53L1X_StartRanging(); - if (status != 0) { - printf("Right sensor failed to start ranging!\r\n"); - return status; - } - } - /* Ranging loop * Checks each sensor for data ready */ @@ -112,33 +90,13 @@ if (board->sensor_centre != NULL) { board->sensor_centre->VL53L1X_CheckForDataReady(&ready_centre); } - if (board->sensor_left != NULL) { - board->sensor_left->VL53L1X_CheckForDataReady(&ready_left); - } - if (board->sensor_right != NULL) { - board->sensor_right->VL53L1X_CheckForDataReady(&ready_right); - } if (ready_centre) { board->sensor_centre->VL53L1X_GetRangeStatus(&ready_centre); board->sensor_centre->VL53L1X_GetDistance(&distance_centre); } - if (ready_left) { - board->sensor_left->VL53L1X_GetRangeStatus(&ready_left); - board->sensor_left->VL53L1X_GetDistance(&distance_left); - } - if (ready_right) { - board->sensor_right->VL53L1X_GetRangeStatus(&ready_right); - board->sensor_right->VL53L1X_GetDistance(&distance_right); - } if (board->sensor_centre != NULL) { - printf("Distance read by centre sensor is : %d\r\n", distance_centre); - } - if (board->sensor_left != NULL) { - printf("Distance read by left satellite sensor is : %d\r\n", distance_left); - } - if (board->sensor_right != NULL) { - printf("Distance read by right satellite sensor is : %d\r\n", distance_right); + printf("Distance read by sensor is : %d\r\n", distance_centre); } }