'Sensor-Matic!' ELEC2645 Jack Berriman - 200836573

Dependencies:   N5110-JDB SRF02 SoftPWM-JDB TMP102 mbed

Committer:
ll13jdb
Date:
Thu May 05 14:55:30 2016 +0000
Revision:
0:e8ca5d36a1e7
Final Project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ll13jdb 0:e8ca5d36a1e7 1 /**
ll13jdb 0:e8ca5d36a1e7 2 @file main.h
ll13jdb 0:e8ca5d36a1e7 3 @brief Header File containing Defines, Function Prototypes and Global Variables.
ll13jdb 0:e8ca5d36a1e7 4 @brief Revision 1.0.
ll13jdb 0:e8ca5d36a1e7 5 @author Jack David Berriman - 200836574
ll13jdb 0:e8ca5d36a1e7 6 @date Summer 2016
ll13jdb 0:e8ca5d36a1e7 7 */
ll13jdb 0:e8ca5d36a1e7 8
ll13jdb 0:e8ca5d36a1e7 9 #ifndef MAIN_H // Define Guard - Prevents Multiple Definitions of Same File.
ll13jdb 0:e8ca5d36a1e7 10 #define MAIN_H
ll13jdb 0:e8ca5d36a1e7 11
ll13jdb 0:e8ca5d36a1e7 12
ll13jdb 0:e8ca5d36a1e7 13 // ------------------------- INCLUDES ------------------------- //
ll13jdb 0:e8ca5d36a1e7 14
ll13jdb 0:e8ca5d36a1e7 15 #include "mbed.h"
ll13jdb 0:e8ca5d36a1e7 16 #include "N5110.h" // Include Library for Nokia N5110 LCD Screen.
ll13jdb 0:e8ca5d36a1e7 17 #include "SRF02.h" // Include Library for SRF02 Distance Sensor.
ll13jdb 0:e8ca5d36a1e7 18 #include "TMP102.h" // Include Library for TMP102 Temperature Sensor.
ll13jdb 0:e8ca5d36a1e7 19 #include "SoftPWM.h" // Include Library for Software PWM.
ll13jdb 0:e8ca5d36a1e7 20
ll13jdb 0:e8ca5d36a1e7 21
ll13jdb 0:e8ca5d36a1e7 22 // ------------------------- DEFINES ------------------------- //
ll13jdb 0:e8ca5d36a1e7 23
ll13jdb 0:e8ca5d36a1e7 24 /** Pixel Per Degree = 46/35... 46 Pixels in 'Thermometer', Max 35º = 1.314285714.
ll13jdb 0:e8ca5d36a1e7 25 */
ll13jdb 0:e8ca5d36a1e7 26 #define PIXEL_PER_DEGREE 1.314285714
ll13jdb 0:e8ca5d36a1e7 27
ll13jdb 0:e8ca5d36a1e7 28 /** Pixels Per CM = 72/250... 72 Pixels in Box, Max 250cm = 0.288.
ll13jdb 0:e8ca5d36a1e7 29 */
ll13jdb 0:e8ca5d36a1e7 30 #define PIXEL_PER_CM 0.288
ll13jdb 0:e8ca5d36a1e7 31
ll13jdb 0:e8ca5d36a1e7 32
ll13jdb 0:e8ca5d36a1e7 33 // ------------------------- CLASS REFERENCES ------------------------- //
ll13jdb 0:e8ca5d36a1e7 34
ll13jdb 0:e8ca5d36a1e7 35 /**
ll13jdb 0:e8ca5d36a1e7 36 @namespace screen
ll13jdb 0:e8ca5d36a1e7 37 @brief Object to Class for Nokia N5110 Library.
ll13jdb 0:e8ca5d36a1e7 38 */
ll13jdb 0:e8ca5d36a1e7 39 N5110 screen(PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3);
ll13jdb 0:e8ca5d36a1e7 40 // VCC, SCE, RST, D/C, MOSI, SCLK, LED
ll13jdb 0:e8ca5d36a1e7 41
ll13jdb 0:e8ca5d36a1e7 42 /**
ll13jdb 0:e8ca5d36a1e7 43 @namespace srf02
ll13jdb 0:e8ca5d36a1e7 44 @brief Object to Class for SRF02 Distance Sensor.
ll13jdb 0:e8ca5d36a1e7 45 */
ll13jdb 0:e8ca5d36a1e7 46 SRF02 srf02(I2C_SDA,I2C_SCL);
ll13jdb 0:e8ca5d36a1e7 47
ll13jdb 0:e8ca5d36a1e7 48 /**
ll13jdb 0:e8ca5d36a1e7 49 @namespace tmp102
ll13jdb 0:e8ca5d36a1e7 50 @brief Object to Class for TMP102 Temperature Sensor.
ll13jdb 0:e8ca5d36a1e7 51 */
ll13jdb 0:e8ca5d36a1e7 52 TMP102 tmp102(I2C_SDA,I2C_SCL);
ll13jdb 0:e8ca5d36a1e7 53
ll13jdb 0:e8ca5d36a1e7 54 /**
ll13jdb 0:e8ca5d36a1e7 55 @namespace pc
ll13jdb 0:e8ca5d36a1e7 56 @brief Object to Class for Serial Library
ll13jdb 0:e8ca5d36a1e7 57 */
ll13jdb 0:e8ca5d36a1e7 58 Serial pc(USBTX,USBRX); // UART Connection for PC - Used for Debugging (Displays Output on 'CoolTerm.exe'.
ll13jdb 0:e8ca5d36a1e7 59
ll13jdb 0:e8ca5d36a1e7 60
ll13jdb 0:e8ca5d36a1e7 61 // ------------------------- TICKERS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 62
ll13jdb 0:e8ca5d36a1e7 63 /**
ll13jdb 0:e8ca5d36a1e7 64 @namespace systemTicker
ll13jdb 0:e8ca5d36a1e7 65 @brief Object for a Ticker which keeps the whole system in time.
ll13jdb 0:e8ca5d36a1e7 66 */
ll13jdb 0:e8ca5d36a1e7 67 Ticker systemTicker;
ll13jdb 0:e8ca5d36a1e7 68
ll13jdb 0:e8ca5d36a1e7 69
ll13jdb 0:e8ca5d36a1e7 70 // ------------------------- SYSTEM INPUTS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 71
ll13jdb 0:e8ca5d36a1e7 72 /**
ll13jdb 0:e8ca5d36a1e7 73 @namespace controller
ll13jdb 0:e8ca5d36a1e7 74 @brief Potentiometer connected to AnalogIn Pin PTB10 (Used to Select Menu Items).
ll13jdb 0:e8ca5d36a1e7 75 */
ll13jdb 0:e8ca5d36a1e7 76 AnalogIn controller(PTB10); // Potentiometer
ll13jdb 0:e8ca5d36a1e7 77
ll13jdb 0:e8ca5d36a1e7 78 /**
ll13jdb 0:e8ca5d36a1e7 79 @namespace backward
ll13jdb 0:e8ca5d36a1e7 80 @brief Push Button connected to InterruptIn Pin PTB19 (Used to Return to Main Menu).
ll13jdb 0:e8ca5d36a1e7 81 */
ll13jdb 0:e8ca5d36a1e7 82 InterruptIn backward(PTB19); // Backward Button
ll13jdb 0:e8ca5d36a1e7 83
ll13jdb 0:e8ca5d36a1e7 84 /**
ll13jdb 0:e8ca5d36a1e7 85 @namespace forward
ll13jdb 0:e8ca5d36a1e7 86 @brief Push Button connected to InterruptIn Pin PTB18 (Various Uses - Menu Selection & Toggling Options...).
ll13jdb 0:e8ca5d36a1e7 87 */
ll13jdb 0:e8ca5d36a1e7 88 InterruptIn forward(PTB18); // Forward Button
ll13jdb 0:e8ca5d36a1e7 89
ll13jdb 0:e8ca5d36a1e7 90
ll13jdb 0:e8ca5d36a1e7 91 // ------------------------- SYSTEM OUTPUTS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 92
ll13jdb 0:e8ca5d36a1e7 93 /**
ll13jdb 0:e8ca5d36a1e7 94 @namespace piezo
ll13jdb 0:e8ca5d36a1e7 95 @brief Piezo Buzzer connected to PwmOut Pin PTA2 (Used w/ Distance Sensor for Audible Warning).
ll13jdb 0:e8ca5d36a1e7 96 */
ll13jdb 0:e8ca5d36a1e7 97 PwmOut piezo(PTA2); // Piezo (PWM)
ll13jdb 0:e8ca5d36a1e7 98
ll13jdb 0:e8ca5d36a1e7 99 /**
ll13jdb 0:e8ca5d36a1e7 100 @namespace red_led
ll13jdb 0:e8ca5d36a1e7 101 @brief Red LED connected to DigitalOut Pin PTC9 (Used w/ Distance and Temperature Sensor for Visual Warning).
ll13jdb 0:e8ca5d36a1e7 102 */
ll13jdb 0:e8ca5d36a1e7 103 DigitalOut red_led(PTC9); // Red LED (Digital)
ll13jdb 0:e8ca5d36a1e7 104
ll13jdb 0:e8ca5d36a1e7 105 /**
ll13jdb 0:e8ca5d36a1e7 106 @namespace yellow_led
ll13jdb 0:e8ca5d36a1e7 107 @brief Yellow LED connected to DigitalOut Pin PTC0 (Used w/ Distance and Temperature Sensor for Visual Warning).
ll13jdb 0:e8ca5d36a1e7 108 */
ll13jdb 0:e8ca5d36a1e7 109 DigitalOut yellow_led(PTC0); // Yellow LED (Digital)
ll13jdb 0:e8ca5d36a1e7 110
ll13jdb 0:e8ca5d36a1e7 111 /**
ll13jdb 0:e8ca5d36a1e7 112 @namespace green_led
ll13jdb 0:e8ca5d36a1e7 113 @brief Green LED connected to DigitalOut Pin PTC7 (Used w/ Distance and Temperature Sensor for Visual Warning).
ll13jdb 0:e8ca5d36a1e7 114 */
ll13jdb 0:e8ca5d36a1e7 115 DigitalOut green_led(PTC7); // Green LED (Digital)
ll13jdb 0:e8ca5d36a1e7 116
ll13jdb 0:e8ca5d36a1e7 117
ll13jdb 0:e8ca5d36a1e7 118 // ------------------------- SOFT PWM ------------------------- //
ll13jdb 0:e8ca5d36a1e7 119
ll13jdb 0:e8ca5d36a1e7 120 // Third Party Library for Generating Software PWM - https://developer.mbed.org/users/komaida424/code/SoftPWM/
ll13jdb 0:e8ca5d36a1e7 121
ll13jdb 0:e8ca5d36a1e7 122 /**
ll13jdb 0:e8ca5d36a1e7 123 @namespace redPWM
ll13jdb 0:e8ca5d36a1e7 124 @brief Red LED connected to DigitalOut Pin PTC9 (BUT used with 'SoftPWM' so it can flash periodically).
ll13jdb 0:e8ca5d36a1e7 125 */
ll13jdb 0:e8ca5d36a1e7 126 SoftPWM redPWM(PTC9);
ll13jdb 0:e8ca5d36a1e7 127
ll13jdb 0:e8ca5d36a1e7 128 /**
ll13jdb 0:e8ca5d36a1e7 129 @namespace yellowPWM
ll13jdb 0:e8ca5d36a1e7 130 @brief Yelow LED connected to DigitalOut Pin PTC0 (BUT used with 'SoftPWM' so it can flash periodically).
ll13jdb 0:e8ca5d36a1e7 131 */
ll13jdb 0:e8ca5d36a1e7 132 SoftPWM yellowPWM(PTC0);
ll13jdb 0:e8ca5d36a1e7 133
ll13jdb 0:e8ca5d36a1e7 134 /**
ll13jdb 0:e8ca5d36a1e7 135 @namespace greenPWM
ll13jdb 0:e8ca5d36a1e7 136 @brief Green LED connected to DigitalOut Pin PTC7 (BUT used with 'SoftPWM' so it can flash periodically).
ll13jdb 0:e8ca5d36a1e7 137 */
ll13jdb 0:e8ca5d36a1e7 138 SoftPWM greenPWM(PTC7);
ll13jdb 0:e8ca5d36a1e7 139
ll13jdb 0:e8ca5d36a1e7 140
ll13jdb 0:e8ca5d36a1e7 141 // ------------------------- K64F ON-BOARD PERIPHERALS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 142
ll13jdb 0:e8ca5d36a1e7 143 /**
ll13jdb 0:e8ca5d36a1e7 144 @namespace r_led
ll13jdb 0:e8ca5d36a1e7 145 @brief Object for the K64F On-Board Red LED - Never used but necessary to turn it off.
ll13jdb 0:e8ca5d36a1e7 146 */
ll13jdb 0:e8ca5d36a1e7 147 DigitalOut r_led(LED_RED);
ll13jdb 0:e8ca5d36a1e7 148
ll13jdb 0:e8ca5d36a1e7 149 /**
ll13jdb 0:e8ca5d36a1e7 150 @namespace g_led
ll13jdb 0:e8ca5d36a1e7 151 @brief Object for the K64F On-Board Green LED - Never used but necessary to turn it off.
ll13jdb 0:e8ca5d36a1e7 152 */
ll13jdb 0:e8ca5d36a1e7 153 DigitalOut g_led(LED_GREEN);
ll13jdb 0:e8ca5d36a1e7 154
ll13jdb 0:e8ca5d36a1e7 155 /**
ll13jdb 0:e8ca5d36a1e7 156 @namespace b_led
ll13jdb 0:e8ca5d36a1e7 157 @brief Object for the K64F On-Board Blue LED - Never used but necessary to turn it off.
ll13jdb 0:e8ca5d36a1e7 158 */
ll13jdb 0:e8ca5d36a1e7 159 DigitalOut b_led(LED_BLUE);
ll13jdb 0:e8ca5d36a1e7 160
ll13jdb 0:e8ca5d36a1e7 161
ll13jdb 0:e8ca5d36a1e7 162 // ------------------------- ISR FUNCTIONS (INTERRUPT SERVICE ROUTINE) ------------------------- //
ll13jdb 0:e8ca5d36a1e7 163
ll13jdb 0:e8ca5d36a1e7 164 /**
ll13jdb 0:e8ca5d36a1e7 165 @brief ISR Function for the 'systemTicker' Flag (ISR = Interrupt Service Routine).
ll13jdb 0:e8ca5d36a1e7 166 */
ll13jdb 0:e8ca5d36a1e7 167 void system_isr();
ll13jdb 0:e8ca5d36a1e7 168
ll13jdb 0:e8ca5d36a1e7 169 /**
ll13jdb 0:e8ca5d36a1e7 170 @brief ISR Function for the 'forward' Button InterruptIn (ISR = Interrupt Service Routine).
ll13jdb 0:e8ca5d36a1e7 171 */
ll13jdb 0:e8ca5d36a1e7 172 void forward_isr();
ll13jdb 0:e8ca5d36a1e7 173
ll13jdb 0:e8ca5d36a1e7 174 /**
ll13jdb 0:e8ca5d36a1e7 175 @brief ISR Function for the 'backward' Button InterruptIn (ISR = Interrupt Service Routine).
ll13jdb 0:e8ca5d36a1e7 176 */
ll13jdb 0:e8ca5d36a1e7 177 void backward_isr();
ll13jdb 0:e8ca5d36a1e7 178
ll13jdb 0:e8ca5d36a1e7 179
ll13jdb 0:e8ca5d36a1e7 180 // ------------------------- VOID/BOOL/INT FUNCTIONS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 181
ll13jdb 0:e8ca5d36a1e7 182 /**
ll13jdb 0:e8ca5d36a1e7 183 @brief Function clears the buffer - Any text or set pixels on the screen.
ll13jdb 0:e8ca5d36a1e7 184 */
ll13jdb 0:e8ca5d36a1e7 185 void clearAll(); // Clears Buffer
ll13jdb 0:e8ca5d36a1e7 186
ll13jdb 0:e8ca5d36a1e7 187 /**
ll13jdb 0:e8ca5d36a1e7 188 @brief Initialises the Nokia Screen by setting various parameters (i.e Button Pull-Ups/Downs and RGB LEDs).
ll13jdb 0:e8ca5d36a1e7 189 */
ll13jdb 0:e8ca5d36a1e7 190 void init_K64F(); // Initialise K64F
ll13jdb 0:e8ca5d36a1e7 191
ll13jdb 0:e8ca5d36a1e7 192 /**
ll13jdb 0:e8ca5d36a1e7 193 @brief Initialises the Piezo Buzzer by setting various parameters (i.e Initial Period and Duty Cycle).
ll13jdb 0:e8ca5d36a1e7 194 */
ll13jdb 0:e8ca5d36a1e7 195 void init_buzzer(); // Initialise Buzzer
ll13jdb 0:e8ca5d36a1e7 196
ll13jdb 0:e8ca5d36a1e7 197 /**
ll13jdb 0:e8ca5d36a1e7 198 @brief Initialises all other aspects surrounding the programme.
ll13jdb 0:e8ca5d36a1e7 199 */
ll13jdb 0:e8ca5d36a1e7 200 void init_program(); // Initialise Program
ll13jdb 0:e8ca5d36a1e7 201
ll13jdb 0:e8ca5d36a1e7 202 /**
ll13jdb 0:e8ca5d36a1e7 203 @brief Contains strings which display an introductory message on the screen before the programme begins.
ll13jdb 0:e8ca5d36a1e7 204 */
ll13jdb 0:e8ca5d36a1e7 205 void welcomeScreen(); // Displays Start-Up Splash Screen
ll13jdb 0:e8ca5d36a1e7 206
ll13jdb 0:e8ca5d36a1e7 207 /**
ll13jdb 0:e8ca5d36a1e7 208 @brief Function for displaying text and navigating around the Main Menu (Sensors/Options).
ll13jdb 0:e8ca5d36a1e7 209 */
ll13jdb 0:e8ca5d36a1e7 210 void mainMenu(); // Function for Main Menu (Sensors/Options)
ll13jdb 0:e8ca5d36a1e7 211
ll13jdb 0:e8ca5d36a1e7 212 /**
ll13jdb 0:e8ca5d36a1e7 213 @brief Function for displaying text and navigating around the Sensor Menu (Distance/Temperature).
ll13jdb 0:e8ca5d36a1e7 214 */
ll13jdb 0:e8ca5d36a1e7 215 void sensorMenu(); // Function for Sensors Menu (Distance/Temperature)
ll13jdb 0:e8ca5d36a1e7 216
ll13jdb 0:e8ca5d36a1e7 217 /**
ll13jdb 0:e8ca5d36a1e7 218 @brief Function for displaying text and navigating around the Options Menu (LEDs/Sound/Colour).
ll13jdb 0:e8ca5d36a1e7 219 */
ll13jdb 0:e8ca5d36a1e7 220 void optionsMenu(); // Function for Options Menu (LEDs/Sound/Colour)
ll13jdb 0:e8ca5d36a1e7 221
ll13jdb 0:e8ca5d36a1e7 222 /**
ll13jdb 0:e8ca5d36a1e7 223 @brief Function for displaying the output from the distance sensor numerically and graphically.
ll13jdb 0:e8ca5d36a1e7 224 */
ll13jdb 0:e8ca5d36a1e7 225 void distanceDisplay(); // Function for Distance Display
ll13jdb 0:e8ca5d36a1e7 226
ll13jdb 0:e8ca5d36a1e7 227 /**
ll13jdb 0:e8ca5d36a1e7 228 @brief Function for displaying the output from the temperature sensor numerically and graphically.
ll13jdb 0:e8ca5d36a1e7 229 */
ll13jdb 0:e8ca5d36a1e7 230 void temperatureDisplay(); // Function for Temperature Screen
ll13jdb 0:e8ca5d36a1e7 231
ll13jdb 0:e8ca5d36a1e7 232 /**
ll13jdb 0:e8ca5d36a1e7 233 @brief Returns the programme back to the Main Menu from any screen when the 'backward' Button is pressed.
ll13jdb 0:e8ca5d36a1e7 234 */
ll13jdb 0:e8ca5d36a1e7 235 void returnToMenu(); // Returns To Main Menu (When Pressed)
ll13jdb 0:e8ca5d36a1e7 236
ll13jdb 0:e8ca5d36a1e7 237 /**
ll13jdb 0:e8ca5d36a1e7 238 @brief Prints the Position of the Cursor - Used in the Main and Sensor Menus Only.
ll13jdb 0:e8ca5d36a1e7 239 @brief The function must be used in conjuction with 'getCursorPosition'.
ll13jdb 0:e8ca5d36a1e7 240 @param cursor - The 'Bank' Number (0-5) is written to it
ll13jdb 0:e8ca5d36a1e7 241 */
ll13jdb 0:e8ca5d36a1e7 242 void printCursorPositionMain(int cursor); // Print the Position of Cursor in Main Menu & Sensor Menu
ll13jdb 0:e8ca5d36a1e7 243
ll13jdb 0:e8ca5d36a1e7 244 /**
ll13jdb 0:e8ca5d36a1e7 245 @brief Prints the Position of the Cursor - Used in the OptionsOnly.
ll13jdb 0:e8ca5d36a1e7 246 @brief The function must be used in conjuction with 'getCursorPosition'.
ll13jdb 0:e8ca5d36a1e7 247 @param cursor - The 'Bank' Number (0-5) is written to it
ll13jdb 0:e8ca5d36a1e7 248 @param stateOfLEDTrigger - Check LED Trigger for 1 or 0
ll13jdb 0:e8ca5d36a1e7 249 @param stateOfSoundTrigger - Check Sound Trigger for 1 or 0
ll13jdb 0:e8ca5d36a1e7 250 */
ll13jdb 0:e8ca5d36a1e7 251 void printCursorPositionOptions(int cursor, int stateOfLEDTrigger, int stateOfSoundTrigger); // Print the Position of Cursor in Options Menu
ll13jdb 0:e8ca5d36a1e7 252
ll13jdb 0:e8ca5d36a1e7 253 /**
ll13jdb 0:e8ca5d36a1e7 254 @brief Reads value of Potentiometer ('controller') and assigns it to a Bank (0-5) through Multiplication.
ll13jdb 0:e8ca5d36a1e7 255 @brief Ensures that cursor is always set to a Bank - Anything greater than 5 is set to Bank 5.
ll13jdb 0:e8ca5d36a1e7 256 */
ll13jdb 0:e8ca5d36a1e7 257 int getCursorPosition(); // Gets Position of Cursor from Potentiometer
ll13jdb 0:e8ca5d36a1e7 258
ll13jdb 0:e8ca5d36a1e7 259 /**
ll13jdb 0:e8ca5d36a1e7 260 @brief Uses Software PWM to cause the Red/Yellow/Green LEDs to flash at a specified period.
ll13jdb 0:e8ca5d36a1e7 261 @brief Used with the Distance Sensor when the distance value is below 15 cm.
ll13jdb 0:e8ca5d36a1e7 262 @returns Bank - Value of Bank (0-5)
ll13jdb 0:e8ca5d36a1e7 263 */
ll13jdb 0:e8ca5d36a1e7 264 void LEDs_Flashing(); // Flashes LEDs Using SoftPWM
ll13jdb 0:e8ca5d36a1e7 265
ll13jdb 0:e8ca5d36a1e7 266 /**
ll13jdb 0:e8ca5d36a1e7 267 @brief Uses Software PWM to cause the Red/Yellow/Green LEDs to stop flashing.
ll13jdb 0:e8ca5d36a1e7 268 @brief Called in order to explicitly tell the K64F to stop using SoftPWM.
ll13jdb 0:e8ca5d36a1e7 269 */
ll13jdb 0:e8ca5d36a1e7 270 void cancel_LEDs_Flashing(); // Stops LEDs Flashing Using SoftPWM
ll13jdb 0:e8ca5d36a1e7 271
ll13jdb 0:e8ca5d36a1e7 272 /**
ll13jdb 0:e8ca5d36a1e7 273 @brief Function for turning ON/OFF LEDs depending on the distance from the SRF02 Sensor.
ll13jdb 0:e8ca5d36a1e7 274 */
ll13jdb 0:e8ca5d36a1e7 275 void LEDs_Distance(int d); // Function for Turning LEDs ON/OFF Depending on Distance
ll13jdb 0:e8ca5d36a1e7 276
ll13jdb 0:e8ca5d36a1e7 277 /**
ll13jdb 0:e8ca5d36a1e7 278 @brief Function for turning ON/OFF LEDs depending on the temperature from the TMP102 Sensor.
ll13jdb 0:e8ca5d36a1e7 279 */
ll13jdb 0:e8ca5d36a1e7 280 void LEDs_Temperature(int t); // Function for Turning LEDs ON/OFF Depending on Temperature
ll13jdb 0:e8ca5d36a1e7 281
ll13jdb 0:e8ca5d36a1e7 282 /**
ll13jdb 0:e8ca5d36a1e7 283 @brief Turns all LEDs ON.
ll13jdb 0:e8ca5d36a1e7 284 */
ll13jdb 0:e8ca5d36a1e7 285 void allLEDOn(); // Turns ON All LEDs
ll13jdb 0:e8ca5d36a1e7 286
ll13jdb 0:e8ca5d36a1e7 287 /**
ll13jdb 0:e8ca5d36a1e7 288 @brief Turns all LEDs OFF.
ll13jdb 0:e8ca5d36a1e7 289 */
ll13jdb 0:e8ca5d36a1e7 290 void allLEDOff(); // Turns OFF All LEDs
ll13jdb 0:e8ca5d36a1e7 291
ll13jdb 0:e8ca5d36a1e7 292 /**
ll13jdb 0:e8ca5d36a1e7 293 @brief Turns ON the Piezo and its outputs a constant noise.
ll13jdb 0:e8ca5d36a1e7 294 */
ll13jdb 0:e8ca5d36a1e7 295 void buzzerOn(); // Turns Buzzer ON
ll13jdb 0:e8ca5d36a1e7 296
ll13jdb 0:e8ca5d36a1e7 297 /**
ll13jdb 0:e8ca5d36a1e7 298 @brief Turns ON the Piezo and uses a period that simulates being 'far away' - Less frequent bleeps.
ll13jdb 0:e8ca5d36a1e7 299 */
ll13jdb 0:e8ca5d36a1e7 300 void buzzerFar(); // 'Beeps' Buzzer Periodically ('Far' Distance)
ll13jdb 0:e8ca5d36a1e7 301
ll13jdb 0:e8ca5d36a1e7 302 /**
ll13jdb 0:e8ca5d36a1e7 303 @brief Turns ON the Piezo and uses a period that simulates being a 'safe, normal' distance - Moderately frequent bleeps.
ll13jdb 0:e8ca5d36a1e7 304 */
ll13jdb 0:e8ca5d36a1e7 305 void buzzerNormal(); // 'Beeps' Buzzer Periodically ('Normal' Distance)
ll13jdb 0:e8ca5d36a1e7 306
ll13jdb 0:e8ca5d36a1e7 307 /**
ll13jdb 0:e8ca5d36a1e7 308 @brief Turns ON the Piezo and uses a period that simulates being 'close' to an object - Highly freqeuent bleeps.
ll13jdb 0:e8ca5d36a1e7 309 */
ll13jdb 0:e8ca5d36a1e7 310 void buzzerClose(); // 'Beeps' Buzzer Periodically ('Close' Distance)
ll13jdb 0:e8ca5d36a1e7 311
ll13jdb 0:e8ca5d36a1e7 312 /**
ll13jdb 0:e8ca5d36a1e7 313 @brief After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerLEDs).
ll13jdb 0:e8ca5d36a1e7 314 @brief Depending on Trigger status, it prevents or enables the LEDs from illuminating in the programme.
ll13jdb 0:e8ca5d36a1e7 315 @returns 'stateOfLED' - A 1 or 0 which is used to either fill or unfill the Cursor.
ll13jdb 0:e8ca5d36a1e7 316 */
ll13jdb 0:e8ca5d36a1e7 317 bool toggleLEDs(); // Toggles LEDs (Options Menu)
ll13jdb 0:e8ca5d36a1e7 318
ll13jdb 0:e8ca5d36a1e7 319 /**
ll13jdb 0:e8ca5d36a1e7 320 @brief After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerSound).
ll13jdb 0:e8ca5d36a1e7 321 @brief Depending on Trigger status, it prevents or enables the Piezo from sounding in the programme.
ll13jdb 0:e8ca5d36a1e7 322 @returns 'stateOfSound' - A 1 or 0 which is used to either fill or unfill the Cursor.
ll13jdb 0:e8ca5d36a1e7 323 */
ll13jdb 0:e8ca5d36a1e7 324 bool toggleSound(); // Toggles Sound (Options Menu)
ll13jdb 0:e8ca5d36a1e7 325
ll13jdb 0:e8ca5d36a1e7 326 /**
ll13jdb 0:e8ca5d36a1e7 327 @brief After the 'forward' Button is pressed - Checks the status of a 'Trigger' (triggerColour).
ll13jdb 0:e8ca5d36a1e7 328 @brief Depending on Trigger status, it changes the colour of the screen: Black-on-White or White-on-Black
ll13jdb 0:e8ca5d36a1e7 329 */
ll13jdb 0:e8ca5d36a1e7 330 void toggleColour(); // Toggles Colour - Black-on-White or White-on-Black (Options Menu)
ll13jdb 0:e8ca5d36a1e7 331
ll13jdb 0:e8ca5d36a1e7 332
ll13jdb 0:e8ca5d36a1e7 333 // ------------------------- STRUCTS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 334
ll13jdb 0:e8ca5d36a1e7 335 /**
ll13jdb 0:e8ca5d36a1e7 336 @struct AverageValues
ll13jdb 0:e8ca5d36a1e7 337 @brief Takes the average over 10 reading from each sensor
ll13jdb 0:e8ca5d36a1e7 338 @brief Precautionary measure to reduce the effect of random errors and improves accuracy.
ll13jdb 0:e8ca5d36a1e7 339 */
ll13jdb 0:e8ca5d36a1e7 340 struct AverageValues { // Struct For Calculating Average Values (Temp/Dist Sensor)
ll13jdb 0:e8ca5d36a1e7 341 int averageTemperature;
ll13jdb 0:e8ca5d36a1e7 342 int averageDistance;
ll13jdb 0:e8ca5d36a1e7 343 };
ll13jdb 0:e8ca5d36a1e7 344
ll13jdb 0:e8ca5d36a1e7 345
ll13jdb 0:e8ca5d36a1e7 346 // ------------------------- GLOBAL VARIABLES ------------------------- //
ll13jdb 0:e8ca5d36a1e7 347
ll13jdb 0:e8ca5d36a1e7 348 /**
ll13jdb 0:e8ca5d36a1e7 349 @brief Each Screen Number denotes a different navigation menu.
ll13jdb 0:e8ca5d36a1e7 350 @brief Initially set to zero because 'MainMenu' = Screen Number = 0.
ll13jdb 0:e8ca5d36a1e7 351 */
ll13jdb 0:e8ca5d36a1e7 352 int screenNumber = 0; // Sets Initial Screen Number to 0 (Main Menu)
ll13jdb 0:e8ca5d36a1e7 353
ll13jdb 0:e8ca5d36a1e7 354 /**
ll13jdb 0:e8ca5d36a1e7 355 @brief Converts value of cursor into a pixel number (0-48) - Main Menu or Sensor Menu Only.
ll13jdb 0:e8ca5d36a1e7 356 @brief Conversion is passed into a function for drawing the option 'selector'.
ll13jdb 0:e8ca5d36a1e7 357 */
ll13jdb 0:e8ca5d36a1e7 358 int y_axis_rect_main; // Y-Position of Screen Cursor (Main Menu & Sensor Menu)
ll13jdb 0:e8ca5d36a1e7 359
ll13jdb 0:e8ca5d36a1e7 360 /**
ll13jdb 0:e8ca5d36a1e7 361 @brief Converts value of cursor into a pixel number (0-48) - Options Menu Only.
ll13jdb 0:e8ca5d36a1e7 362 @brief Conversion is passed into a function for drawing the option 'selector'.
ll13jdb 0:e8ca5d36a1e7 363 */
ll13jdb 0:e8ca5d36a1e7 364 int y_axis_rect_options; // // Y-Position of Screen Cursor (Options Menu)
ll13jdb 0:e8ca5d36a1e7 365
ll13jdb 0:e8ca5d36a1e7 366
ll13jdb 0:e8ca5d36a1e7 367 // ------------------------- GLOBAL FLAGS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 368
ll13jdb 0:e8ca5d36a1e7 369 /**
ll13jdb 0:e8ca5d36a1e7 370 @brief Sets the Flag for 'systemTicker' initially to zero.
ll13jdb 0:e8ca5d36a1e7 371 */
ll13jdb 0:e8ca5d36a1e7 372 volatile int g_system_flag = 0; // Flag for 'systemTicker'
ll13jdb 0:e8ca5d36a1e7 373
ll13jdb 0:e8ca5d36a1e7 374 /**
ll13jdb 0:e8ca5d36a1e7 375 @brief Sets the Flag for 'forward' Button Interrupt initially to zero.
ll13jdb 0:e8ca5d36a1e7 376 */
ll13jdb 0:e8ca5d36a1e7 377 volatile int g_forward_flag = 0; // Flag for Forward Button Interrupt
ll13jdb 0:e8ca5d36a1e7 378
ll13jdb 0:e8ca5d36a1e7 379 /**
ll13jdb 0:e8ca5d36a1e7 380 @brief Sets the Flag for 'backward' Button Interrupt initially to zero.
ll13jdb 0:e8ca5d36a1e7 381 */
ll13jdb 0:e8ca5d36a1e7 382 volatile int g_backward_flag = 0; // Flag for Backward Button Interrupt
ll13jdb 0:e8ca5d36a1e7 383
ll13jdb 0:e8ca5d36a1e7 384
ll13jdb 0:e8ca5d36a1e7 385 // ------------------------- VOLATILE & NON-VOLATILE BOOLS ------------------------- //
ll13jdb 0:e8ca5d36a1e7 386
ll13jdb 0:e8ca5d36a1e7 387 /**
ll13jdb 0:e8ca5d36a1e7 388 @brief Sets the status of the variable from the 'ToggleLED()' function.
ll13jdb 0:e8ca5d36a1e7 389 @brief Used for filling or unfilling the option 'selector'.
ll13jdb 0:e8ca5d36a1e7 390 */
ll13jdb 0:e8ca5d36a1e7 391 bool stateOfLED = 0; // Initial State of LED = 0
ll13jdb 0:e8ca5d36a1e7 392
ll13jdb 0:e8ca5d36a1e7 393 /**
ll13jdb 0:e8ca5d36a1e7 394 @brief Sets the status of the variable from the 'ToggleSound()' function.
ll13jdb 0:e8ca5d36a1e7 395 @brief Used for filling or unfilling the option 'selector'.
ll13jdb 0:e8ca5d36a1e7 396 */
ll13jdb 0:e8ca5d36a1e7 397 bool stateOfSound = 0; // Initial State of Sound = 0
ll13jdb 0:e8ca5d36a1e7 398
ll13jdb 0:e8ca5d36a1e7 399 /**
ll13jdb 0:e8ca5d36a1e7 400 @brief Trigger is used for enable/disable LED option.
ll13jdb 0:e8ca5d36a1e7 401 @brief If trigger equals 0 = disable LEDs.
ll13jdb 0:e8ca5d36a1e7 402 @brief If trigger equals 1 = enable LEDs.
ll13jdb 0:e8ca5d36a1e7 403 */
ll13jdb 0:e8ca5d36a1e7 404 volatile bool triggerLEDs = 0; // Trigger Set to 0 for LED
ll13jdb 0:e8ca5d36a1e7 405
ll13jdb 0:e8ca5d36a1e7 406 /**
ll13jdb 0:e8ca5d36a1e7 407 @brief Trigger is used for enable/disable Sound option.
ll13jdb 0:e8ca5d36a1e7 408 @brief If trigger equals 0 = disable Piezo.
ll13jdb 0:e8ca5d36a1e7 409 @brief If trigger equals 1 = enable Piezo.
ll13jdb 0:e8ca5d36a1e7 410 */
ll13jdb 0:e8ca5d36a1e7 411 volatile bool triggerSound = 0; // Trigger Set to 0 for Sound
ll13jdb 0:e8ca5d36a1e7 412
ll13jdb 0:e8ca5d36a1e7 413 /**
ll13jdb 0:e8ca5d36a1e7 414 @brief Trigger is used for enable/disable Colour option.
ll13jdb 0:e8ca5d36a1e7 415 @brief If trigger equals 0 = Black Text/Pixels on White Background.
ll13jdb 0:e8ca5d36a1e7 416 @brief If trigger equals 1 = White Text/Pixels on Black Background.
ll13jdb 0:e8ca5d36a1e7 417 */
ll13jdb 0:e8ca5d36a1e7 418 volatile bool triggerColour = 0; // Trigger Set to 0 for Colour
ll13jdb 0:e8ca5d36a1e7 419
ll13jdb 0:e8ca5d36a1e7 420 #endif