Reverse Parking sensor

Dependencies:   N5110 SRF02 buzzer mbed

Fork of ParkingSENSOR by Renosi Momoh

main.h

Committer:
Reniboy
Date:
2016-05-05
Revision:
0:e1ae1b9889a3
Child:
1:775f6e8071a2

File content as of revision 0:e1ae1b9889a3:

/**
@file main.h
@brief Header file containg functions, variables and prototypes
@brief Revision 1.0
@brief Reverse Parking sensor
@date March 2015 **/


#include "mbed.h"
#include "N5110.h"
#include "SRF02/SRF02.h"
#include "buzzer.h"
#include "SDFileSystem.h"

/** INPUTS AND OUTPUTS  **/

N5110 lcd (PTE26, PTA0, PTC4, PTD0, PTD2, PTD1, PTC3);
/** @brief Connections for the LCD Display **/
SRF02 sensor(I2C_SDA,I2C_SCL);
/** @brief Ultrasonic distance sensor connected in I2C mode**/
Beep buzzer(PTA2); 
/** 
@brief Piezo type buzzer that can produce notes and vary the frequency as well. Connected to Pwm signal 
**/

InterruptIn button(PTB18);
/**
@Brief Button connected to mbed with the use of InterruptIn class**/
InterruptIn sw2(SW2);


InterruptIn sw3(SW3);
DigitalOut r_led(PTC2);

SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
 /** Defining pins for SD card file system **/
Serial serial(USBTX, USBRX);  // for PC debugging purposes
AnalogIn pot(PTB2);   /* Potentiometer middle pin connected to PTB3, other two ends connected to GND and 3.3V */



/** Create objects for timeout using flipper **/
Timeout flipper;
Timeout flipper2;
Ticker ticker;
Ticker ticker2;
Ticker ticker3;
void button_isr();
void init_serial(); /** function to activate onboard switches and LEDs **/
void timer_isr();
void timer2_isr();
void timer1_isr();
void mainProg();
void inActiveState();
/** 
@namespace Main Function
@brief The function containing the main menu to choose functions from 
**/
   
void classicMode(); /**
@Brief Allow the screen to refresh when the potentiometer is set to reflect output mode.
**/

void delete_file(char filename[]); // Function to call for deletion of file.

/** Flags and Interrupt Service Routines **/

volatile int g_timer_flag = 0; /** @Brief G flag makes things easier to distinguish as this is a global variable **/
volatile int g_timer2_flag = 0;
volatile int g_sw3_flag = 0;
volatile int g_button_flag = 0;
volatile int g_timer1_flag = 0;
void sw2_isr();
void sw3_isr();

/** Misc **/
float averageDistance(); 
/**
@namespace Average Distance
@Brief This function allows us to take ten sensor readings and find the average to improve accuracy 
**/
float averageDistanceIn();

int distance;
float distanceIn;


/** Functions **/

void introTune();
/**
@namespace Introductory Tune  
@brief Provides and audible indication that the system is on
**/
void beeping(); 
/**
@namespace Beeping function,
@brief This function allows the sensor to detect the distance and make the speaker beep accordingly
**/
void sensingImage(); 
/**
@Brief This function shows the distance in bars depending on how close an object is
**/
void sensingImageIn();
/**
@namespace Shows the parking sensor distances in inches
@brief Converts the distance into inches
**/
void classicMode1();
void radarMode(); 
/**
Function allows the data to be saved on to an SD card including the time and distance
**/
void saveData();
 /**
 Function will be concurrent with readings and will be intrinsically tied to the actions of the SD card. 
 **/
void loadData(); /** 
Creating a function to allow the data to be loaded when and show the records of all the distances and and times 
**/
void active(); 
/** 
@Brief Main functionality that essentially reads the distance from the sensor and conveys the information via The display and buzzer
**/
void radar();
/**
@namespace Radar
@brief Fucntion calling radar mode so as to allow for use of interrupts 
**/
void sweepSpeed(); 
/** @namespace Sweep Speed
    @Brief Function that varies the rate at which the radar sweeps with the sensor distance 
**/
void sweep();
/**@namespace Sweeping Functions
   @Brief  Each of these functions will read the distance from the sensor and set the radar arrow speed across the screen appropriately
**/
void sweepOne();
void sweepTwo();
void sweepThree();
void sweepFour();
void sweepFive();
void sweepSix();
void sweepSeven();
void sweepEight();
void sweepNine();



/** Variables **/

     
float i;  /**
@brief Variable used to vary frequency of the buzzer
 **/
float t; 
/** 
@brief Variable used to vary frequency of the radar sweep 
**/