Sample ranging example. Suporting up to 3 sensors. Sending result from X-NUCLEO-53L0A1 both on com port and on digit display. User button IRQ used for switching displayed sensor

Dependencies:   mbed X_NUCLEO_53L0A1

Fork of Display_53L0A1_WithSatelites by ST Expansion SW Team

Revision:
2:a3bc0a0af780
Parent:
1:9d5c48d409b6
Child:
3:ff6e42401073
diff -r 9d5c48d409b6 -r a3bc0a0af780 main.cpp
--- a/main.cpp	Wed Jun 14 09:14:13 2017 +0000
+++ b/main.cpp	Mon Aug 07 15:38:43 2017 +0000
@@ -6,7 +6,7 @@
 #include <assert.h>
 
 /* This VL53L0X Expansion board test application performs a range measurement in polling mode
-   on the sensors. The demo supports the centre sensor and up to 2 satelites boards. 
+   on the sensors. The demo supports the centre sensor and up to 2 satellites boards.
    
    The User Blue button controls the selected sensor. Measurements from this sensor are displayed 
    on the 4-digit display.
@@ -34,7 +34,7 @@
     VL53L0X *sensorPtr;
 } installedSensors[3];
 
-int InitSensorsArray()
+int init_sensors_array()
 {
    int status = 1;
    /* start the measure on sensor top */
@@ -43,7 +43,7 @@
        installedSensors[sensorCnt].prefix = 'C';
        installedSensors[sensorCnt].sensorPtr = board->sensor_centre;
        ++sensorCnt;
-       status=board->sensor_centre->StartMeasurement(operating_mode, NULL);
+       status=board->sensor_centre->start_measurement(operating_mode, NULL);
    }
    /* start the measure on sensor left if present */
    if (NULL != board->sensor_left)
@@ -51,7 +51,7 @@
         installedSensors[sensorCnt].prefix='L';
         installedSensors[sensorCnt].sensorPtr = board->sensor_left;
         ++sensorCnt;    
-        status=board->sensor_left->StartMeasurement(operating_mode, NULL);
+        status=board->sensor_left->start_measurement(operating_mode, NULL);
    }
    /* start the measure on sensor right if present */
    if (NULL != board->sensor_right)
@@ -59,7 +59,7 @@
         installedSensors[sensorCnt].prefix = 'R';
         installedSensors[sensorCnt].sensorPtr = board->sensor_right;
         ++sensorCnt;
-        status=board->sensor_right->StartMeasurement(operating_mode, NULL);
+        status=board->sensor_right->start_measurement(operating_mode, NULL);
    }
    /* set first displayed sensor to embedded top */
    currentSensor = 0;
@@ -67,7 +67,7 @@
 }
 
 /* ISR callback function of the user blue button to switch measuring sensor. */
-void SwitchMeasuringSensorIRQ(void)
+void switch_measuring_sensor_irq(void)
 {
     ++currentSensor;
     if (currentSensor == sensorCnt)
@@ -76,13 +76,13 @@
 }
 
 /* On board 4 digit local display refresh*/
-void DisplayRefresh(OperatingMode op_mode)
+void display_refresh(OperatingMode op_mode)
 {   
   char str[4];
    
   for (int t=0; t < sensorCnt; t++)
   {
-     installedSensors[t].sensorPtr->GetMeasurement(op_mode, &data_sensor);
+     installedSensors[t].sensorPtr->get_measurement(op_mode, &data_sensor);
      if (data_sensor.RangeStatus == 0) // we have a valid range.
      {
       printf("%c %4d; ", installedSensors[t].prefix,data_sensor.RangeMilliMeter);
@@ -101,32 +101,32 @@
      } 
   }
   printf("\r\n");
-  board->display->DisplayString(str);
+  board->display->display_string(str);
 }
 
-void RangeMeasure(DevI2C *device_i2c) {
+void range_measure(DevI2C *device_i2c) {
    int status;
 
    /* creates the 53L0A1 expansion board singleton obj */
-   board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
+   board=X_NUCLEO_53L0A1::instance(device_i2c, A2, D8, D2);
     
-   board->display->DisplayString("53L0");
+   board->display->display_string("53L0");
    /* init the 53L0A1 expansion board with default values */
-   status=board->InitBoard();
+   status=board->init_board();
    if(status)
       printf("Failed to init board!\n\r");   
    operating_mode=range_single_shot_polling;
 
-   status = InitSensorsArray();
+   status = init_sensors_array();
    
    if(!status)
    {
       while(1)
       {
-         DisplayRefresh(operating_mode);
+         display_refresh(operating_mode);
       }
    }
-   board->display->DisplayString("BYE");
+   board->display->display_string("BYE");
    delete board;        
 }    
 
@@ -137,9 +137,9 @@
 {   
 #if USER_BUTTON==PC_13  // we are cross compiling for Nucleo-f401 
    InterruptIn stop_button (USER_BUTTON);
-   stop_button.rise (&SwitchMeasuringSensorIRQ);  
+   stop_button.rise (&switch_measuring_sensor_irq);
 #endif   
    DevI2C *device_i2c =new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);        
-   RangeMeasure(device_i2c);  // start continuous measures
+   range_measure(device_i2c);  // start continuous measures
 }