ELEC2645 (2015/16) / Mbed 2 deprecated SensorMatic_Project

Dependencies:   N5110-JDB SRF02 SoftPWM-JDB TMP102 mbed

Embed: (wiki syntax)

« Back to documentation index

main.h File Reference

main.h File Reference

Header File containing Defines, Function Prototypes and Global Variables. More...

Go to the source code of this file.

Data Structures

struct  AverageValues
 Takes the average over 10 reading from each sensor. More...

Namespaces

namespace  screen
 

Object to Class for Nokia N5110 Library.


namespace  srf02
 

Object to Class for SRF02 Distance Sensor.


namespace  tmp102
 

Object to Class for TMP102 Temperature Sensor.


namespace  pc
 

Object to Class for Serial Library.


namespace  systemTicker
 

Object for a Ticker which keeps the whole system in time.


namespace  controller
 

Potentiometer connected to AnalogIn Pin PTB10 (Used to Select Menu Items).


namespace  backward
 

Push Button connected to InterruptIn Pin PTB19 (Used to Return to Main Menu).


namespace  forward
 

Push Button connected to InterruptIn Pin PTB18 (Various Uses - Menu Selection & Toggling Options...).


namespace  piezo
 

Piezo Buzzer connected to PwmOut Pin PTA2 (Used w/ Distance Sensor for Audible Warning).


namespace  red_led
 

Red LED connected to DigitalOut Pin PTC9 (Used w/ Distance and Temperature Sensor for Visual Warning).


namespace  yellow_led
 

Yellow LED connected to DigitalOut Pin PTC0 (Used w/ Distance and Temperature Sensor for Visual Warning).


namespace  green_led
 

Green LED connected to DigitalOut Pin PTC7 (Used w/ Distance and Temperature Sensor for Visual Warning).


namespace  redPWM
 

Red LED connected to DigitalOut Pin PTC9 (BUT used with 'SoftPWM' so it can flash periodically).


namespace  yellowPWM
 

Yelow LED connected to DigitalOut Pin PTC0 (BUT used with 'SoftPWM' so it can flash periodically).


namespace  greenPWM
 

Green LED connected to DigitalOut Pin PTC7 (BUT used with 'SoftPWM' so it can flash periodically).


namespace  r_led
 

Object for the K64F On-Board Red LED - Never used but necessary to turn it off.


namespace  g_led
 

Object for the K64F On-Board Green LED - Never used but necessary to turn it off.


namespace  b_led
 

Object for the K64F On-Board Blue LED - Never used but necessary to turn it off.


Functions

void system_isr ()
 ISR Function for the 'systemTicker' Flag (ISR = Interrupt Service Routine).
void forward_isr ()
 ISR Function for the 'forward' Button InterruptIn (ISR = Interrupt Service Routine).
void backward_isr ()
 ISR Function for the 'backward' Button InterruptIn (ISR = Interrupt Service Routine).
void clearAll ()
 Function clears the buffer - Any text or set pixels on the screen.
void init_K64F ()
 Initialises the Nokia Screen by setting various parameters (i.e Button Pull-Ups/Downs and RGB LEDs).
void init_buzzer ()
 Initialises the Piezo Buzzer by setting various parameters (i.e Initial Period and Duty Cycle).
void init_program ()
 Initialises all other aspects surrounding the programme.
void welcomeScreen ()
 Contains strings which display an introductory message on the screen before the programme begins.
void mainMenu ()
 Function for displaying text and navigating around the Main Menu (Sensors/Options).
void sensorMenu ()
 Function for displaying text and navigating around the Sensor Menu (Distance/Temperature).
void optionsMenu ()
 Function for displaying text and navigating around the Options Menu (LEDs/Sound/Colour).
void distanceDisplay ()
 Function for displaying the output from the distance sensor numerically and graphically.
void temperatureDisplay ()
 Function for displaying the output from the temperature sensor numerically and graphically.
void returnToMenu ()
 Returns the programme back to the Main Menu from any screen when the 'backward' Button is pressed.
void printCursorPositionMain (int cursor)
 Prints the Position of the Cursor - Used in the Main and Sensor Menus Only.
void printCursorPositionOptions (int cursor, int stateOfLEDTrigger, int stateOfSoundTrigger)
 Prints the Position of the Cursor - Used in the OptionsOnly.
int getCursorPosition ()
 Reads value of Potentiometer ('controller') and assigns it to a Bank (0-5) through Multiplication.
void LEDs_Flashing ()
 Uses Software PWM to cause the Red/Yellow/Green LEDs to flash at a specified period.
void cancel_LEDs_Flashing ()
 Uses Software PWM to cause the Red/Yellow/Green LEDs to stop flashing.
void LEDs_Distance (int d)
 Function for turning ON/OFF LEDs depending on the distance from the SRF02 Sensor.
void LEDs_Temperature (int t)
 Function for turning ON/OFF LEDs depending on the temperature from the TMP102 Sensor.
void allLEDOn ()
 Turns all LEDs ON.
void allLEDOff ()
 Turns all LEDs OFF.
void buzzerOn ()
 Turns ON the Piezo and its outputs a constant noise.
void buzzerFar ()
 Turns ON the Piezo and uses a period that simulates being 'far away' - Less frequent bleeps.
void buzzerNormal ()
 Turns ON the Piezo and uses a period that simulates being a 'safe, normal' distance - Moderately frequent bleeps.
void buzzerClose ()
 Turns ON the Piezo and uses a period that simulates being 'close' to an object - Highly freqeuent bleeps.
bool toggleLEDs ()
 After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerLEDs).
bool toggleSound ()
 After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerSound).
void toggleColour ()
 After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerColour).

Variables

int screenNumber = 0
 Each Screen Number denotes a different navigation menu.
int y_axis_rect_main
 Converts value of cursor into a pixel number (0-48) - Main Menu or Sensor Menu Only.
int y_axis_rect_options
 Converts value of cursor into a pixel number (0-48) - Options Menu Only.
volatile int g_system_flag = 0
 Sets the Flag for 'systemTicker' initially to zero.
volatile int g_forward_flag = 0
 Sets the Flag for 'forward' Button Interrupt initially to zero.
volatile int g_backward_flag = 0
 Sets the Flag for 'backward' Button Interrupt initially to zero.
bool stateOfLED = 0
 Sets the status of the variable from the 'ToggleLED()' function.
bool stateOfSound = 0
 Sets the status of the variable from the 'ToggleSound()' function.
volatile bool triggerLEDs = 0
 Trigger is used for enable/disable LED option.
volatile bool triggerSound = 0
 Trigger is used for enable/disable Sound option.
volatile bool triggerColour = 0
 Trigger is used for enable/disable Colour option.

Detailed Description

Header File containing Defines, Function Prototypes and Global Variables.

Revision 1.0.

Author:
Jack David Berriman - 200836574
Date:
Summer 2016

Definition in file main.h.


Function Documentation

void allLEDOff (  )

Turns all LEDs OFF.

Definition at line 514 of file main.cpp.

void allLEDOn (  )

Turns all LEDs ON.

Definition at line 506 of file main.cpp.

void backward_isr (  )

ISR Function for the 'backward' Button InterruptIn (ISR = Interrupt Service Routine).

Definition at line 671 of file main.cpp.

void buzzerClose (  )

Turns ON the Piezo and uses a period that simulates being 'close' to an object - Highly freqeuent bleeps.

Definition at line 618 of file main.cpp.

void buzzerFar (  )

Turns ON the Piezo and uses a period that simulates being 'far away' - Less frequent bleeps.

Definition at line 634 of file main.cpp.

void buzzerNormal (  )

Turns ON the Piezo and uses a period that simulates being a 'safe, normal' distance - Moderately frequent bleeps.

Definition at line 626 of file main.cpp.

void buzzerOn (  )

Turns ON the Piezo and its outputs a constant noise.

Definition at line 611 of file main.cpp.

void cancel_LEDs_Flashing (  )

Uses Software PWM to cause the Red/Yellow/Green LEDs to stop flashing.

Called in order to explicitly tell the K64F to stop using SoftPWM.

Definition at line 534 of file main.cpp.

void clearAll (  )

Function clears the buffer - Any text or set pixels on the screen.

Definition at line 71 of file main.cpp.

void distanceDisplay (  )

Function for displaying the output from the distance sensor numerically and graphically.

Definition at line 344 of file main.cpp.

void forward_isr (  )

ISR Function for the 'forward' Button InterruptIn (ISR = Interrupt Service Routine).

Definition at line 665 of file main.cpp.

int getCursorPosition (  )

Reads value of Potentiometer ('controller') and assigns it to a Bank (0-5) through Multiplication.

Ensures that cursor is always set to a Bank - Anything greater than 5 is set to Bank 5.

Definition at line 155 of file main.cpp.

void init_buzzer (  )

Initialises the Piezo Buzzer by setting various parameters (i.e Initial Period and Duty Cycle).

Definition at line 99 of file main.cpp.

void init_K64F (  )

Initialises the Nokia Screen by setting various parameters (i.e Button Pull-Ups/Downs and RGB LEDs).

Definition at line 82 of file main.cpp.

void init_program (  )

Initialises all other aspects surrounding the programme.

Definition at line 106 of file main.cpp.

void LEDs_Distance ( int  d )

Function for turning ON/OFF LEDs depending on the distance from the SRF02 Sensor.

Definition at line 546 of file main.cpp.

void LEDs_Flashing (  )

Uses Software PWM to cause the Red/Yellow/Green LEDs to flash at a specified period.

Used with the Distance Sensor when the distance value is below 15 cm.

Returns:
Bank - Value of Bank (0-5)

Definition at line 522 of file main.cpp.

void LEDs_Temperature ( int  t )

Function for turning ON/OFF LEDs depending on the temperature from the TMP102 Sensor.

Definition at line 580 of file main.cpp.

void mainMenu (  )

Function for displaying text and navigating around the Main Menu (Sensors/Options).

Definition at line 195 of file main.cpp.

void optionsMenu (  )

Function for displaying text and navigating around the Options Menu (LEDs/Sound/Colour).

Definition at line 289 of file main.cpp.

void printCursorPositionMain ( int  cursor )

Prints the Position of the Cursor - Used in the Main and Sensor Menus Only.

The function must be used in conjuction with 'getCursorPosition'.

Parameters:
cursor- The 'Bank' Number (0-5) is written to it

Definition at line 168 of file main.cpp.

void printCursorPositionOptions ( int  cursor,
int  stateOfLEDTrigger,
int  stateOfSoundTrigger 
)

Prints the Position of the Cursor - Used in the OptionsOnly.

The function must be used in conjuction with 'getCursorPosition'.

Parameters:
cursor- The 'Bank' Number (0-5) is written to it
stateOfLEDTrigger- Check LED Trigger for 1 or 0
stateOfSoundTrigger- Check Sound Trigger for 1 or 0

Definition at line 182 of file main.cpp.

void returnToMenu (  )

Returns the programme back to the Main Menu from any screen when the 'backward' Button is pressed.

Definition at line 644 of file main.cpp.

void sensorMenu (  )

Function for displaying text and navigating around the Sensor Menu (Distance/Temperature).

Definition at line 243 of file main.cpp.

void system_isr (  )

ISR Function for the 'systemTicker' Flag (ISR = Interrupt Service Routine).

Definition at line 659 of file main.cpp.

void temperatureDisplay (  )

Function for displaying the output from the temperature sensor numerically and graphically.

Definition at line 420 of file main.cpp.

void toggleColour (  )

After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerColour).

Depending on Trigger status, it changes the colour of the screen: Black-on-White or White-on-Black

Definition at line 492 of file main.cpp.

bool toggleLEDs (  )

After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerLEDs).

Depending on Trigger status, it prevents or enables the LEDs from illuminating in the programme.

Returns:
'stateOfLED' - A 1 or 0 which is used to either fill or unfill the Cursor.

Definition at line 461 of file main.cpp.

bool toggleSound (  )

After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerSound).

Depending on Trigger status, it prevents or enables the Piezo from sounding in the programme.

Returns:
'stateOfSound' - A 1 or 0 which is used to either fill or unfill the Cursor.

Definition at line 476 of file main.cpp.

void welcomeScreen (  )

Contains strings which display an introductory message on the screen before the programme begins.

Definition at line 115 of file main.cpp.


Variable Documentation

volatile int g_backward_flag = 0

Sets the Flag for 'backward' Button Interrupt initially to zero.

Definition at line 382 of file main.h.

volatile int g_forward_flag = 0

Sets the Flag for 'forward' Button Interrupt initially to zero.

Definition at line 377 of file main.h.

volatile int g_system_flag = 0

Sets the Flag for 'systemTicker' initially to zero.

Definition at line 372 of file main.h.

int screenNumber = 0

Each Screen Number denotes a different navigation menu.

Initially set to zero because 'MainMenu' = Screen Number = 0.

Definition at line 352 of file main.h.

bool stateOfLED = 0

Sets the status of the variable from the 'ToggleLED()' function.

Used for filling or unfilling the option 'selector'.

Definition at line 391 of file main.h.

bool stateOfSound = 0

Sets the status of the variable from the 'ToggleSound()' function.

Used for filling or unfilling the option 'selector'.

Definition at line 397 of file main.h.

volatile bool triggerColour = 0

Trigger is used for enable/disable Colour option.

If trigger equals 0 = Black Text/Pixels on White Background. If trigger equals 1 = White Text/Pixels on Black Background.

Definition at line 418 of file main.h.

volatile bool triggerLEDs = 0

Trigger is used for enable/disable LED option.

If trigger equals 0 = disable LEDs. If trigger equals 1 = enable LEDs.

Definition at line 404 of file main.h.

volatile bool triggerSound = 0

Trigger is used for enable/disable Sound option.

If trigger equals 0 = disable Piezo. If trigger equals 1 = enable Piezo.

Definition at line 411 of file main.h.

Converts value of cursor into a pixel number (0-48) - Main Menu or Sensor Menu Only.

Conversion is passed into a function for drawing the option 'selector'.

Definition at line 358 of file main.h.

Converts value of cursor into a pixel number (0-48) - Options Menu Only.

Conversion is passed into a function for drawing the option 'selector'.

Definition at line 364 of file main.h.