People Counter / Mbed 2 deprecated person_counter

Dependencies:   mbed mbed-rtos 4DGL-uLCD-SE HC_SR04_Ultrasonic_Library

Revision:
4:7d02b3f3bee6
Parent:
3:b5cdd40e99e9
Child:
5:3ff2acbd08ab
--- a/main.cpp	Wed Apr 22 04:00:14 2020 +0000
+++ b/main.cpp	Wed Apr 22 04:26:37 2020 +0000
@@ -1,18 +1,71 @@
 #include "mbed.h"
+#include "rtos.h"
 #include "SDFileSystem.h"
 #include "uLCD_4DGL.h"
 #include "XNucleo53L0A1.h"
+#include "ultrasonic.h"
+
 //#include <stdio.h>
 #include <string>
 
+//I2C sensor pins
+#define VL53L0_I2C_SDA   p28
+#define VL53L0_I2C_SCL   p27
+
 uLCD_4DGL uLCD(p13, p14, p12); // serial tx, serial rx, reset pin;
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
 DigitalOut shdn(p26);
+RawSerial BT(p9,p10);
+//Serial BT(p9,p10);
+
+
 DigitalOut MyLED(LED1);
 
+//needed for TOF
+static XNucleo53L0A1 *board=NULL;
 
+void dist(int distance)
+{
+    //put code here to execute when the sonar distance has changed
+    
+}
+
+ultrasonic mu(p30, p29, .1, 1, &dist);    //Set the trigger pin to p30 and the echo pin to p29
+                                        //have updates every .1 seconds and a timeout after 1
+                                        //second, and call dist when the distance changes
+
+void TOF(void const *arguments) {
+    //initialize the TOF
+    int status;
+    uint32_t distance;
+    DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
+    /* creates the 53L0A1 expansion board singleton obj */
+    board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2);
+    shdn = 0; //must reset sensor for an mbed reset to work
+    wait(0.1);
+    shdn = 1;
+    wait(0.1);
+    /* init the 53L0A1 board with default values */
+    status = board->init_board();
+    while (status) {
+        //pc.printf("Failed to init board! \r\n");
+        status = board->init_board();
+    }
+    
+    /*
+    How you would print TOF to pc serial
+    
+    status = board->sensor_centre->get_distance(&distance);
+    if (status == VL53L0X_ERROR_NONE) {
+        pc.printf("D=%ld mm\r\n", distance);
+    }
+        
+    */
+}
 
 int main()
 {
+    
     MyLED = 0;
     while(1){
         MyLED = !MyLED;