People Counter / Mbed 2 deprecated person_counter

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

Committer:
rmalik8
Date:
Wed Apr 22 04:29:28 2020 +0000
Revision:
5:3ff2acbd08ab
Parent:
4:7d02b3f3bee6
Child:
6:068146497fe6
corrected typo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mmarine3 2:1ec843c95914 1 #include "mbed.h"
rmalik8 4:7d02b3f3bee6 2 #include "rtos.h"
mmarine3 2:1ec843c95914 3 #include "SDFileSystem.h"
mmarine3 2:1ec843c95914 4 #include "uLCD_4DGL.h"
rmalik8 3:b5cdd40e99e9 5 #include "XNucleo53L0A1.h"
rmalik8 4:7d02b3f3bee6 6 #include "ultrasonic.h"
rmalik8 4:7d02b3f3bee6 7
rmalik8 3:b5cdd40e99e9 8 //#include <stdio.h>
mmarine3 2:1ec843c95914 9 #include <string>
mmarine3 2:1ec843c95914 10
rmalik8 4:7d02b3f3bee6 11 //I2C sensor pins
rmalik8 4:7d02b3f3bee6 12 #define VL53L0_I2C_SDA p28
rmalik8 4:7d02b3f3bee6 13 #define VL53L0_I2C_SCL p27
rmalik8 4:7d02b3f3bee6 14
rmalik8 3:b5cdd40e99e9 15 uLCD_4DGL uLCD(p13, p14, p12); // serial tx, serial rx, reset pin;
rmalik8 4:7d02b3f3bee6 16 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
rmalik8 3:b5cdd40e99e9 17 DigitalOut shdn(p26);
rmalik8 4:7d02b3f3bee6 18 RawSerial BT(p9,p10);
rmalik8 4:7d02b3f3bee6 19 //Serial BT(p9,p10);
rmalik8 4:7d02b3f3bee6 20
rmalik8 4:7d02b3f3bee6 21
mmarine3 2:1ec843c95914 22 DigitalOut MyLED(LED1);
mmarine3 2:1ec843c95914 23
rmalik8 4:7d02b3f3bee6 24 //needed for TOF
rmalik8 4:7d02b3f3bee6 25 static XNucleo53L0A1 *board=NULL;
mmarine3 2:1ec843c95914 26
rmalik8 4:7d02b3f3bee6 27 void dist(int distance)
rmalik8 4:7d02b3f3bee6 28 {
rmalik8 4:7d02b3f3bee6 29 //put code here to execute when the sonar distance has changed
rmalik8 4:7d02b3f3bee6 30
rmalik8 4:7d02b3f3bee6 31 }
rmalik8 4:7d02b3f3bee6 32
rmalik8 4:7d02b3f3bee6 33 ultrasonic mu(p30, p29, .1, 1, &dist); //Set the trigger pin to p30 and the echo pin to p29
rmalik8 4:7d02b3f3bee6 34 //have updates every .1 seconds and a timeout after 1
rmalik8 4:7d02b3f3bee6 35 //second, and call dist when the distance changes
rmalik8 4:7d02b3f3bee6 36
rmalik8 4:7d02b3f3bee6 37 void TOF(void const *arguments) {
rmalik8 4:7d02b3f3bee6 38 //initialize the TOF
rmalik8 4:7d02b3f3bee6 39 int status;
rmalik8 4:7d02b3f3bee6 40 uint32_t distance;
rmalik8 4:7d02b3f3bee6 41 DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
rmalik8 4:7d02b3f3bee6 42 /* creates the 53L0A1 expansion board singleton obj */
rmalik8 4:7d02b3f3bee6 43 board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2);
rmalik8 4:7d02b3f3bee6 44 shdn = 0; //must reset sensor for an mbed reset to work
rmalik8 4:7d02b3f3bee6 45 wait(0.1);
rmalik8 4:7d02b3f3bee6 46 shdn = 1;
rmalik8 4:7d02b3f3bee6 47 wait(0.1);
rmalik8 4:7d02b3f3bee6 48 /* init the 53L0A1 board with default values */
rmalik8 4:7d02b3f3bee6 49 status = board->init_board();
rmalik8 4:7d02b3f3bee6 50 while (status) {
rmalik8 4:7d02b3f3bee6 51 //pc.printf("Failed to init board! \r\n");
rmalik8 4:7d02b3f3bee6 52 status = board->init_board();
rmalik8 4:7d02b3f3bee6 53 }
rmalik8 4:7d02b3f3bee6 54
rmalik8 4:7d02b3f3bee6 55 /*
rmalik8 4:7d02b3f3bee6 56
rmalik8 5:3ff2acbd08ab 57 How to get distance value
rmalik8 4:7d02b3f3bee6 58 status = board->sensor_centre->get_distance(&distance);
rmalik8 5:3ff2acbd08ab 59
rmalik8 5:3ff2acbd08ab 60 How you would print TOF to pc serial
rmalik8 4:7d02b3f3bee6 61 if (status == VL53L0X_ERROR_NONE) {
rmalik8 4:7d02b3f3bee6 62 pc.printf("D=%ld mm\r\n", distance);
rmalik8 4:7d02b3f3bee6 63 }
rmalik8 4:7d02b3f3bee6 64
rmalik8 4:7d02b3f3bee6 65 */
rmalik8 4:7d02b3f3bee6 66 }
mmarine3 2:1ec843c95914 67
mmarine3 2:1ec843c95914 68 int main()
mmarine3 2:1ec843c95914 69 {
rmalik8 4:7d02b3f3bee6 70
mmarine3 2:1ec843c95914 71 MyLED = 0;
mmarine3 2:1ec843c95914 72 while(1){
mmarine3 2:1ec843c95914 73 MyLED = !MyLED;
mmarine3 2:1ec843c95914 74 wait(.1);
mmarine3 2:1ec843c95914 75 }
mmarine3 2:1ec843c95914 76 }