ELEC2645 (2015/16) / Mbed 2 deprecated Year2SensorProject

Dependencies:   N5110 SRF02 TMP102 mbed

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  SRF02
 

Ultra sonic distance sensor I2C mode SDA and SCL clock lines (no pull-up resitors required)


namespace  TMP102
 

Temperature sensor I2C mode SDA and SCL clock lines (no pull-up resitors required)


namespace  Upper_Button
 

Interrupt button (top button)


namespace  Lower_Button
 

Interrupt button (bottom button)


namespace  sw2
 

sw2 on the K64F


namespace  sw3
 

sw3 on the K64F


namespace  Potentiometer
 

An analogue input.


namespace  LCD
 

LCD screen outputs.


namespace  Screens_LED
 

onboard LED on the nokia N5110 screen


namespace  Buzzer
 

PWM controlled buzzer that serves as sound alert.


namespace  Warning_LED
 

LED that will warn the user.


namespace  red_led
 

red LED on the K64F


namespace  green_led
 

green LED on the K64F


namespace  blue_led
 

blue LED on the K64F


namespace  serial
 

output serial for USB communication (debugging)


namespace  sensorTicker
 

Sensor ticker that will periodically call for distance and temperature measurements.


namespace  buttonsDebounce
 

Button Debounce ticker that will periodically call everytime a button has been pressed and will prevent multiple inputs from being recognised.


namespace  potTicker
 

Potetiometer ticker that will periodically call to check the position of the potentiometer.


Functions

float getDistance ()
 method that will get the average of 10 distance measurements
void drawCar ()
 Method that draws the car on the screen.
void reallyCloseDistance ()
 Method that lets the user know the car is really close to an object.
void closeDistance ()
 Method that lets the user know the car is close to an object.
void mediuDistance ()
 Method that lets the user know the car is almost close to an object.
void farDistance ()
 Method that lets the user know the car far from an object.
void printBars ()
 Method that prints the bars to show the user the obstacles distance.
void numericMode ()
 Method that prints the distance and the temperature on the screen.
void init_serial ()
 Initialises serial communication.
void init_K64F ()
 Initialises all the K64F's on board peripherals.
void buzzerOFF ()
 Sets the buzzers duty cycle to 0.
void buzzerON ()
 Sets the buzzers duty cycle to 50%.
Interrupt Service Routine Functions

Sets the functions of the ISR

void timer_isr ()
 Time triggered interrupt method.
void timer1_isr ()
 Time triggered interrupt method.
void timer2_isr ()
 Time triggered interrupt method.
void botButton_isr ()
 Event triggered interrupt method.
void topButton_isr ()
 Event triggered interrupt method.
Menu related functions

All the functions that set up the menus of the project

void MenuLine1 ()
 Scans the second bank of 6 and inverts all the pixels.
void MenuLine1Short ()
 Scans the second bank of 6 and inverts some of the pixels.
void MenuLine2 ()
 Scans the third bank of 6 and inverts all the pixels.
void MenuLine2Short ()
 Scans the third bank of 6 and inverts some of the pixels.
void MenuLine3 ()
 Scans the fourth bank of 6 and inverts all the pixels.
void MenuLine3Short ()
 Scans the fourth bank of 6 and inverts some of the pixels.
void MenuLine4 ()
 Scans the fifth bank of 6 and inverts all the pixels.
void MenuLine4Short ()
 Scans the fifth bank of 6 and inverts some of the pixels.
void MenuLine5 ()
 Scans the sixth bank of 6 and inverts all the pixels.
void MenuLine5Short ()
 Scans the sixth bank of 6 and inverts some of the pixels.
void introScreen ()
 Sets up the intro screen.
void mainMenu ()
 Sets up the main menu.
void goToMainMenu ()
 Simple function that will send the user back to the main menu whenever the bottom button is pressed.
void goToSelectedOption ()
 Simple function that will send the user to a certain screen depending on what state it is.
void peripheralsMenu ()
 Sets up the peripherals menu.
void modesMenu ()
 Sets up the modes menu.
void soundMenu ()
 Sets up the sound menu.
void LEDMenu ()
 Sets up the LED menu.
void brightnessMenu ()
 Sets up the brightness menu.
void nightMenu ()
 Sets up the day/night menu.

Variables

float distance
 Float that stores the average distance measurement from the getDistance function.
float dist
 Float that stores the average distance measurement to be used in the modes functions.
float T
 Float that stores the temperature measurement to be used in the modes functions.
int emptyVariable
 Integer that serves as an empty variable to store the distance average measurements.
int realDistance
 Integer that stores the distance measurements in cm from the distance sensor.
int temp
 Integer that stores the floored temperature measurement to be used in the parking mode function [printBars()].
int current_screen
 Integer that serves as an empty variable to store the current screen state.
int selected_option
 Integer that serves as an empty variable to store the selected option once an interrupt has occurred.
int led_state
 Integer that serves as an empty variable to store the LED state (either on or off)
int buzzer_state
 Integer that serves as an empty variable to store the buzzer state (either on or off)
int circle_position_SOUND = 27
 Integer that stores the initial y value for the circles in the sound menu.
int circle_position_LED = 27
 Integer that stores the initial y value for the circles in the LED menu.
int circle_position_brightness = 43
 Integer that stores the initial y value for the circles in the brightness menu.
int circle_position_NIGHT = 27
 Integer that stores the initial y value for the circles in the night menu.
int length1
 Integer that stores the length of the distance string to be printed in the numeric mode.
int length2
 Integer that stores the length of the temperature string to be printed in the numeric mode.
char buffer [14]
 Char that stores an array of characters to print the distance in the numeric mode.
char buffer2 [14]
 Char that stores an array of characters to print the temperature in the numeric mode and parking mode.
Constant integers

Constant integers used as unchangeable states for menu navigation and states of LED and buzzer

const int menu_state = 0
 Constant integer that signals the menu state.
const int peripherals_state = 1
 Constant integer that signals the peripherals state.
const int brightness_state = 2
 Constant integer that signals the brightness state.
const int sound_state = 3
 Constant integer that signals the sound menu state.
const int ledMenu_state = 4
 Constant integer that signals the LED menu state.
const int nightMenu_state = 5
 Constant integer that signals the night menu state.
const int modes_state = 6
 Constant integer that signals the modes state state.
const int parkingMode_state = 7
 Constant integer that signals the parking mode state.
const int numericMode_state = 8
 Constant integer that signals the numeric mode state.
const int LEDON_state = 9
 Constant integer that signals the LED is ON state.
const int LEDOFF_state = 10
 Constant integer that signals the LED is OFF state.
const int buzzerON_state = 11
 Constant integer that signals the buzzer is ON state.
const int buzzerOFF_state = 12
 Constant integer that signals the buzzer is OFF state.
Interrupt Service Routine Flags

Set flags in ISR

volatile int g_timer_flag = 0
 Volatile integer that serves as a time triggered ISR for the sensor ticker.
volatile int g_timer1_flag = 0
 Volatile integer that serves as a time triggered ISR for the button debouncer ticker.
volatile int g_timer2_flag = 0
 Volatile integer that serves as a time triggered ISR for the potentiometer reading ticker.
volatile int g_topButton_flag = 0
 Volatile integer that serves as an event triggered ISR for when the top button is pressed.
volatile int g_botButton_flag = 0
 Volatile integer that serves as an event triggered ISR for when the bottom button is pressed.

Detailed Description

Header file containing functions prototypes, defines and global variables.

Parking Sensor Project (Year 2) ELEC 2645

Author:
Arnau Segura Doncel
Date:
March 2016

Definition in file main.h.


Function Documentation

void botButton_isr (  )

Event triggered interrupt method.

Definition at line 690 of file main.cpp.

void brightnessMenu (  )

Sets up the brightness menu.

The backlight led will go from a range of 0% to 100% brightness.

Definition at line 382 of file main.cpp.

void buzzerOFF (  )

Sets the buzzers duty cycle to 0.

Definition at line 343 of file main.cpp.

void buzzerON (  )

Sets the buzzers duty cycle to 50%.

Definition at line 338 of file main.cpp.

void closeDistance (  )

Method that lets the user know the car is close to an object.

Definition at line 75 of file main.cpp.

void drawCar (  )

Method that draws the car on the screen.

Definition at line 55 of file main.cpp.

void farDistance (  )

Method that lets the user know the car far from an object.

Definition at line 88 of file main.cpp.

float getDistance (  )

method that will get the average of 10 distance measurements

Returns:
Average of 10 distance measurements

Definition at line 39 of file main.cpp.

void goToMainMenu (  )

Simple function that will send the user back to the main menu whenever the bottom button is pressed.

Definition at line 466 of file main.cpp.

void goToSelectedOption (  )

Simple function that will send the user to a certain screen depending on what state it is.

Definition at line 475 of file main.cpp.

void init_K64F (  )

Initialises all the K64F's on board peripherals.

Definition at line 650 of file main.cpp.

void init_serial (  )

Initialises serial communication.

Definition at line 644 of file main.cpp.

void introScreen (  )

Sets up the intro screen.

Displays the intro message

Definition at line 219 of file main.cpp.

void LEDMenu (  )

Sets up the LED menu.

The led will either turn on at critical distances from an object or it won't

Definition at line 348 of file main.cpp.

void mainMenu (  )

Sets up the main menu.

Normalises potentiometer values to the highlighted bank of text in order to navigate the menus more easily

Definition at line 241 of file main.cpp.

void mediuDistance (  )

Method that lets the user know the car is almost close to an object.

void MenuLine1 (  )

Scans the second bank of 6 and inverts all the pixels.

Definition at line 485 of file main.cpp.

void MenuLine1Short (  )

Scans the second bank of 6 and inverts some of the pixels.

Definition at line 501 of file main.cpp.

void MenuLine2 (  )

Scans the third bank of 6 and inverts all the pixels.

Definition at line 516 of file main.cpp.

void MenuLine2Short (  )

Scans the third bank of 6 and inverts some of the pixels.

Definition at line 532 of file main.cpp.

void MenuLine3 (  )

Scans the fourth bank of 6 and inverts all the pixels.

Definition at line 548 of file main.cpp.

void MenuLine3Short (  )

Scans the fourth bank of 6 and inverts some of the pixels.

Definition at line 564 of file main.cpp.

void MenuLine4 (  )

Scans the fifth bank of 6 and inverts all the pixels.

Definition at line 580 of file main.cpp.

void MenuLine4Short (  )

Scans the fifth bank of 6 and inverts some of the pixels.

Definition at line 596 of file main.cpp.

void MenuLine5 (  )

Scans the sixth bank of 6 and inverts all the pixels.

Definition at line 612 of file main.cpp.

void MenuLine5Short (  )

Scans the sixth bank of 6 and inverts some of the pixels.

Definition at line 628 of file main.cpp.

void modesMenu (  )

Sets up the modes menu.

The user will be able to use the parking sensor or a numerical value sensor that will indicate both temperature and distance.

Definition at line 288 of file main.cpp.

void nightMenu (  )

Sets up the day/night menu.

The lcd will change from normal mode to inverse mode when the user desires so

Definition at line 435 of file main.cpp.

void numericMode (  )

Method that prints the distance and the temperature on the screen.

Definition at line 174 of file main.cpp.

void peripheralsMenu (  )

Sets up the peripherals menu.

The peripherals are the LED and the buzzer

Definition at line 262 of file main.cpp.

void printBars (  )

Method that prints the bars to show the user the obstacles distance.

Definition at line 93 of file main.cpp.

void reallyCloseDistance (  )

Method that lets the user know the car is really close to an object.

Definition at line 67 of file main.cpp.

void soundMenu (  )

Sets up the sound menu.

Either turn sound off or on

Definition at line 307 of file main.cpp.

void timer1_isr (  )

Time triggered interrupt method.

Definition at line 676 of file main.cpp.

void timer2_isr (  )

Time triggered interrupt method.

Definition at line 684 of file main.cpp.

void timer_isr (  )

Time triggered interrupt method.

Definition at line 670 of file main.cpp.

void topButton_isr (  )

Event triggered interrupt method.

Definition at line 705 of file main.cpp.


Variable Documentation

const int brightness_state = 2

Constant integer that signals the brightness state.

Definition at line 376 of file main.h.

char buffer[14]

Char that stores an array of characters to print the distance in the numeric mode.

Definition at line 399 of file main.h.

char buffer2[14]

Char that stores an array of characters to print the temperature in the numeric mode and parking mode.

Definition at line 401 of file main.h.

Integer that serves as an empty variable to store the buzzer state (either on or off)

Definition at line 353 of file main.h.

const int buzzerOFF_state = 12

Constant integer that signals the buzzer is OFF state.

Definition at line 396 of file main.h.

const int buzzerON_state = 11

Constant integer that signals the buzzer is ON state.

Definition at line 394 of file main.h.

Integer that stores the initial y value for the circles in the brightness menu.

Definition at line 359 of file main.h.

Integer that stores the initial y value for the circles in the LED menu.

Definition at line 357 of file main.h.

Integer that stores the initial y value for the circles in the night menu.

Definition at line 361 of file main.h.

Integer that stores the initial y value for the circles in the sound menu.

Definition at line 355 of file main.h.

Integer that serves as an empty variable to store the current screen state.

Definition at line 347 of file main.h.

float dist

Float that stores the average distance measurement to be used in the modes functions.

Definition at line 337 of file main.h.

float distance

Float that stores the average distance measurement from the getDistance function.

Definition at line 335 of file main.h.

Integer that serves as an empty variable to store the distance average measurements.

Definition at line 341 of file main.h.

volatile int g_botButton_flag = 0

Volatile integer that serves as an event triggered ISR for when the bottom button is pressed.

Definition at line 416 of file main.h.

volatile int g_timer1_flag = 0

Volatile integer that serves as a time triggered ISR for the button debouncer ticker.

Definition at line 410 of file main.h.

volatile int g_timer2_flag = 0

Volatile integer that serves as a time triggered ISR for the potentiometer reading ticker.

Definition at line 412 of file main.h.

volatile int g_timer_flag = 0

Volatile integer that serves as a time triggered ISR for the sensor ticker.

Definition at line 408 of file main.h.

volatile int g_topButton_flag = 0

Volatile integer that serves as an event triggered ISR for when the top button is pressed.

Definition at line 414 of file main.h.

int led_state

Integer that serves as an empty variable to store the LED state (either on or off)

Definition at line 351 of file main.h.

const int ledMenu_state = 4

Constant integer that signals the LED menu state.

Definition at line 380 of file main.h.

const int LEDOFF_state = 10

Constant integer that signals the LED is OFF state.

Definition at line 392 of file main.h.

const int LEDON_state = 9

Constant integer that signals the LED is ON state.

Definition at line 390 of file main.h.

int length1

Integer that stores the length of the distance string to be printed in the numeric mode.

Definition at line 363 of file main.h.

int length2

Integer that stores the length of the temperature string to be printed in the numeric mode.

Definition at line 365 of file main.h.

const int menu_state = 0

Constant integer that signals the menu state.

Definition at line 372 of file main.h.

const int modes_state = 6

Constant integer that signals the modes state state.

Definition at line 384 of file main.h.

const int nightMenu_state = 5

Constant integer that signals the night menu state.

Definition at line 382 of file main.h.

const int numericMode_state = 8

Constant integer that signals the numeric mode state.

Definition at line 388 of file main.h.

const int parkingMode_state = 7

Constant integer that signals the parking mode state.

Definition at line 386 of file main.h.

const int peripherals_state = 1

Constant integer that signals the peripherals state.

Definition at line 374 of file main.h.

Integer that stores the distance measurements in cm from the distance sensor.

Definition at line 343 of file main.h.

Integer that serves as an empty variable to store the selected option once an interrupt has occurred.

Definition at line 349 of file main.h.

const int sound_state = 3

Constant integer that signals the sound menu state.

Definition at line 378 of file main.h.

float T

Float that stores the temperature measurement to be used in the modes functions.

Definition at line 339 of file main.h.

int temp

Integer that stores the floored temperature measurement to be used in the parking mode function [printBars()].

Definition at line 345 of file main.h.