saleh jaffal / Mbed 2 deprecated SRF02

Dependencies:   N5110 PowerControl beep mbed sensor

Embed: (wiki syntax)

« Back to documentation index

main.h File Reference

main.h File Reference

Header file containing functions prototypes, defines and global variables. More...

Go to the source code of this file.

Namespaces

namespace  buzzer
 

output for status buzzer


namespace  green1
 

GPIO output for status LED.


namespace  green2
 

GPIO output for status LED.


namespace  yellow1
 

GPIO output for status LED.


namespace  yellow2
 

GPIO output for status LED.


namespace  red1
 

GPIO output for status LED.


namespace  red2
 

GPIO output for status LED.


namespace  pot
 

GPIO input for lcd brightness.


namespace  button
 

GPIO input to switch values from the sensor.


Functions

void welcomeMessage ()
 Shows the welcome message when the LCD is on.
void getDistanceCm ()
 gets the distance in cm by dividing 10 read values by 10
void getDistanceIn ()
 gets the distance in inches by dividing 10 read values by 10
void getDistanceUs ()
 gets the distance in us by dividing 10 read values by 10
void buttonPressed ()
 when the button is pressed this action is called
void compDist ()
 looks for where the range of the reading is to set its conditions
void distanceA ()
 compares the cases of each distance to set the Led's values and the buzzer

Variables

int distanceCm
int distanceIn
int distanceUs
int A
int distance1
 All distances used to add the 10 readings from the sensor to get an average of 10 readings per second, so that it will cancel out the noise.
int distance2
int distance3
int distance4
int distance5
int distance6
int distance7
int distance8
int distance9
int distance10
float mypotVal
int sum

Detailed Description

Header file containing functions prototypes, defines and global variables.

Revision 1.0.

Author:
Saleh Jaffal
Date:
April 2015

Definition in file main.h.


Function Documentation

void buttonPressed (  )

when the button is pressed this action is called

when button is pressed it will check if i >1

if it is it will set it to 0

if not it will increment i by one

Definition at line 34 of file main.cpp.

void compDist (  )

looks for where the range of the reading is to set its conditions

calls this action to show the reading

each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)

print formatted data to buffer

if string will fit on display

clears LCD

sets 2 rectangles

prints distance and the reading below it

refreshes LCD screen

compares distances and sets them in their specified range

sets case

sets case

sets case

sets case

sets case

sets case

calls this action to show the reading

each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)

print formatted data to buffer

if string will fit on display

clears LCD

sets 2 rectangles

prints distance and the reading below it

refreshes LCD screen

compares distances and sets them in their specified range

sets case

sets case

sets case

sets case

sets case

sets case

calls this action to show the reading

each character is 6 pixels wide, screen is 84 pixels (84/6 = 14)

print formatted data to buffer

if string will fit on display

clears LCD

sets 2 rectangles

prints distance and the reading below it

refreshes LCD screen

compares distances and sets them in their specified range

sets case

sets case

sets case

sets case

sets case

sets case

Definition at line 202 of file main.cpp.

void distanceA (  )

compares the cases of each distance to set the Led's values and the buzzer

See also:
This code was from a library I found

case 1 would have 2 LED's on

See also:
This code was from a library I found

case 3 would have 4 LED's on

See also:
This code was from a library I found

case 4 would have 5 LED's on

See also:
This code was from a library I found

case 5 would have 6 LED's on

See also:
This code was from a library I found

Definition at line 362 of file main.cpp.

void getDistanceCm (  )

gets the distance in cm by dividing 10 read values by 10

Returns:
the average distance in cm

adds up 10 distances read by the sensor

there is a 70 ms delay between each reading

all of them are added to the sum

the sum is divided by 10 to get the average

Definition at line 132 of file main.cpp.

void getDistanceIn (  )

gets the distance in inches by dividing 10 read values by 10

Returns:
the average distance in inches

adds up 10 distances read by the sensor

there is a 70 ms delay between each reading

all of them are added to the sum

the sum is divided by 10 to get the average

Definition at line 158 of file main.cpp.

void getDistanceUs (  )

gets the distance in us by dividing 10 read values by 10

Returns:
the average distance in us

adds up 10 distances read by the sensor

there is a 70 ms delay between each reading

all of them are added to the sum

the sum is divided by 10 to get the average

Definition at line 180 of file main.cpp.

void welcomeMessage (  )

Shows the welcome message when the LCD is on.

bottom left rectangle is set

bottom right rectangle is set

bottom middle rectangle is set

is set over the bottom rectangles

circle is set on bottom middle box

big middle box is set over everything

top black rectangle is set

left middle black rect is set

middle black rect is set

right middle black rect is set

left bottom black rect is set

middle bottom black rect is set

right bottom black rect is set

rectangle is set over big middle box

left top black rect is set

top black rect is set

right top black rect is set

left bottom black rect is set

middle bottom black rect is set

right bottom black rect is set

rectangle under triangle is set

left line to complete triangle

right line to complete triangle

clears intersecting lines from rectangle

gets the distance after the message

Definition at line 50 of file main.cpp.


Variable Documentation

int A

used to compare the cases after being set in compDist()

Definition at line 120 of file main.h.

int distance1

All distances used to add the 10 readings from the sensor to get an average of 10 readings per second, so that it will cancel out the noise.

distance1 set in ISR

Definition at line 129 of file main.h.

distance10 set in ISR

Definition at line 138 of file main.h.

int distance2

distance2 set in ISR

Definition at line 130 of file main.h.

int distance3

distance3 set in ISR

Definition at line 131 of file main.h.

int distance4

distance4 set in ISR

Definition at line 132 of file main.h.

int distance5

distance5 set in ISR

Definition at line 133 of file main.h.

int distance6

distance6 set in ISR

Definition at line 134 of file main.h.

int distance7

distance7 set in ISR

Definition at line 135 of file main.h.

int distance8

distance8 set in ISR

Definition at line 136 of file main.h.

int distance9

distance9 set in ISR

Definition at line 137 of file main.h.

distanceCm set in ISR

Definition at line 117 of file main.h.

distanceIn set in ISR

Definition at line 118 of file main.h.

distanceUs set in ISR

Definition at line 119 of file main.h.

float mypotVal

mypotVal is used to transfer the vlaue of the pot to lcd brightness

Definition at line 140 of file main.h.

int sum

used to add all the distances together (ie distance 1, distance 2, ...

Definition at line 143 of file main.h.