People Counter / Mbed 2 deprecated person_counter

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

main.cpp

Committer:
rmalik8
Date:
2020-04-22
Revision:
5:3ff2acbd08ab
Parent:
4:7d02b3f3bee6
Child:
6:068146497fe6

File content as of revision 5:3ff2acbd08ab:

#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 to get distance value
    status = board->sensor_centre->get_distance(&distance);
    
    How you would print TOF to pc serial
    if (status == VL53L0X_ERROR_NONE) {
        pc.printf("D=%ld mm\r\n", distance);
    }
        
    */
}

int main()
{
    
    MyLED = 0;
    while(1){
        MyLED = !MyLED;
        wait(.1);
    }
}