![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
ELEC2645 Year 2 Project Arnau Segura Doncel 200867010
Dependencies: N5110 SRF02 TMP102 mbed
main.h@0:4a66fd16c223, 2016-05-05 (annotated)
- Committer:
- ollie140
- Date:
- Thu May 05 09:41:14 2016 +0000
- Revision:
- 0:4a66fd16c223
Final code for the level 2 year project
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ollie140 | 0:4a66fd16c223 | 1 | /** |
ollie140 | 0:4a66fd16c223 | 2 | @file main.h |
ollie140 | 0:4a66fd16c223 | 3 | @brief Header file containing functions prototypes, defines and global variables. |
ollie140 | 0:4a66fd16c223 | 4 | @brief Parking Sensor Project (Year 2) |
ollie140 | 0:4a66fd16c223 | 5 | @brief ELEC 2645 |
ollie140 | 0:4a66fd16c223 | 6 | @author Arnau Segura Doncel |
ollie140 | 0:4a66fd16c223 | 7 | @date March 2016 |
ollie140 | 0:4a66fd16c223 | 8 | */ |
ollie140 | 0:4a66fd16c223 | 9 | #ifndef MAIN_H |
ollie140 | 0:4a66fd16c223 | 10 | #define MAIN_H |
ollie140 | 0:4a66fd16c223 | 11 | |
ollie140 | 0:4a66fd16c223 | 12 | #include "mbed.h" |
ollie140 | 0:4a66fd16c223 | 13 | #include "N5110.h" |
ollie140 | 0:4a66fd16c223 | 14 | #include "SRF02.h" |
ollie140 | 0:4a66fd16c223 | 15 | #include "TMP102.h" |
ollie140 | 0:4a66fd16c223 | 16 | |
ollie140 | 0:4a66fd16c223 | 17 | //Inputs |
ollie140 | 0:4a66fd16c223 | 18 | |
ollie140 | 0:4a66fd16c223 | 19 | /** |
ollie140 | 0:4a66fd16c223 | 20 | @namespace SRF02 |
ollie140 | 0:4a66fd16c223 | 21 | @brief Ultra sonic distance sensor I2C mode SDA and SCL clock lines (no pull-up resitors required) |
ollie140 | 0:4a66fd16c223 | 22 | */ |
ollie140 | 0:4a66fd16c223 | 23 | SRF02 srf(I2C_SDA,I2C_SCL); |
ollie140 | 0:4a66fd16c223 | 24 | |
ollie140 | 0:4a66fd16c223 | 25 | /** |
ollie140 | 0:4a66fd16c223 | 26 | @namespace TMP102 |
ollie140 | 0:4a66fd16c223 | 27 | @brief Temperature sensor I2C mode SDA and SCL clock lines (no pull-up resitors required) |
ollie140 | 0:4a66fd16c223 | 28 | */ |
ollie140 | 0:4a66fd16c223 | 29 | TMP102 tmp102(I2C_SDA,I2C_SCL); |
ollie140 | 0:4a66fd16c223 | 30 | |
ollie140 | 0:4a66fd16c223 | 31 | /** |
ollie140 | 0:4a66fd16c223 | 32 | @namespace Upper_Button |
ollie140 | 0:4a66fd16c223 | 33 | @brief Interrupt button (top button) |
ollie140 | 0:4a66fd16c223 | 34 | */ |
ollie140 | 0:4a66fd16c223 | 35 | InterruptIn topButton(PTB19); |
ollie140 | 0:4a66fd16c223 | 36 | |
ollie140 | 0:4a66fd16c223 | 37 | /** |
ollie140 | 0:4a66fd16c223 | 38 | @namespace Lower_Button |
ollie140 | 0:4a66fd16c223 | 39 | @brief Interrupt button (bottom button) |
ollie140 | 0:4a66fd16c223 | 40 | */ |
ollie140 | 0:4a66fd16c223 | 41 | InterruptIn botButton(PTB18); |
ollie140 | 0:4a66fd16c223 | 42 | |
ollie140 | 0:4a66fd16c223 | 43 | /** |
ollie140 | 0:4a66fd16c223 | 44 | @namespace sw2 |
ollie140 | 0:4a66fd16c223 | 45 | @brief sw2 on the K64F |
ollie140 | 0:4a66fd16c223 | 46 | */ |
ollie140 | 0:4a66fd16c223 | 47 | InterruptIn sw2(SW2); |
ollie140 | 0:4a66fd16c223 | 48 | |
ollie140 | 0:4a66fd16c223 | 49 | /** |
ollie140 | 0:4a66fd16c223 | 50 | @namespace sw3 |
ollie140 | 0:4a66fd16c223 | 51 | @brief sw3 on the K64F |
ollie140 | 0:4a66fd16c223 | 52 | */ |
ollie140 | 0:4a66fd16c223 | 53 | InterruptIn sw3(SW3); |
ollie140 | 0:4a66fd16c223 | 54 | |
ollie140 | 0:4a66fd16c223 | 55 | /** |
ollie140 | 0:4a66fd16c223 | 56 | @namespace Potentiometer |
ollie140 | 0:4a66fd16c223 | 57 | @brief An analogue input |
ollie140 | 0:4a66fd16c223 | 58 | */ |
ollie140 | 0:4a66fd16c223 | 59 | AnalogIn pot(PTB10); |
ollie140 | 0:4a66fd16c223 | 60 | |
ollie140 | 0:4a66fd16c223 | 61 | //Outputs |
ollie140 | 0:4a66fd16c223 | 62 | |
ollie140 | 0:4a66fd16c223 | 63 | /** |
ollie140 | 0:4a66fd16c223 | 64 | @namespace LCD |
ollie140 | 0:4a66fd16c223 | 65 | @brief LCD screen outputs |
ollie140 | 0:4a66fd16c223 | 66 | */ |
ollie140 | 0:4a66fd16c223 | 67 | N5110 lcd(PTE26,PTA0,PTC4,PTD0,PTD2,PTD1,PTC3); |
ollie140 | 0:4a66fd16c223 | 68 | |
ollie140 | 0:4a66fd16c223 | 69 | /** |
ollie140 | 0:4a66fd16c223 | 70 | @namespace Screens_LED |
ollie140 | 0:4a66fd16c223 | 71 | @brief onboard LED on the nokia N5110 screen |
ollie140 | 0:4a66fd16c223 | 72 | */ |
ollie140 | 0:4a66fd16c223 | 73 | PwmOut screenLED(PTC3); |
ollie140 | 0:4a66fd16c223 | 74 | |
ollie140 | 0:4a66fd16c223 | 75 | /** |
ollie140 | 0:4a66fd16c223 | 76 | @namespace Buzzer |
ollie140 | 0:4a66fd16c223 | 77 | @brief PWM controlled buzzer that serves as sound alert |
ollie140 | 0:4a66fd16c223 | 78 | */ |
ollie140 | 0:4a66fd16c223 | 79 | PwmOut buzzer(PTA2); |
ollie140 | 0:4a66fd16c223 | 80 | |
ollie140 | 0:4a66fd16c223 | 81 | /** |
ollie140 | 0:4a66fd16c223 | 82 | @namespace Warning_LED |
ollie140 | 0:4a66fd16c223 | 83 | @brief LED that will warn the user |
ollie140 | 0:4a66fd16c223 | 84 | */ |
ollie140 | 0:4a66fd16c223 | 85 | DigitalOut LED(PTC2); |
ollie140 | 0:4a66fd16c223 | 86 | |
ollie140 | 0:4a66fd16c223 | 87 | /** |
ollie140 | 0:4a66fd16c223 | 88 | @namespace red_led |
ollie140 | 0:4a66fd16c223 | 89 | @brief red LED on the K64F |
ollie140 | 0:4a66fd16c223 | 90 | */ |
ollie140 | 0:4a66fd16c223 | 91 | DigitalOut r_led(LED_RED); |
ollie140 | 0:4a66fd16c223 | 92 | |
ollie140 | 0:4a66fd16c223 | 93 | /** |
ollie140 | 0:4a66fd16c223 | 94 | @namespace green_led |
ollie140 | 0:4a66fd16c223 | 95 | @brief green LED on the K64F |
ollie140 | 0:4a66fd16c223 | 96 | */ |
ollie140 | 0:4a66fd16c223 | 97 | DigitalOut g_led(LED_GREEN); |
ollie140 | 0:4a66fd16c223 | 98 | |
ollie140 | 0:4a66fd16c223 | 99 | /** |
ollie140 | 0:4a66fd16c223 | 100 | @namespace blue_led |
ollie140 | 0:4a66fd16c223 | 101 | @brief blue LED on the K64F |
ollie140 | 0:4a66fd16c223 | 102 | */ |
ollie140 | 0:4a66fd16c223 | 103 | DigitalOut b_led(LED_BLUE); |
ollie140 | 0:4a66fd16c223 | 104 | |
ollie140 | 0:4a66fd16c223 | 105 | /** |
ollie140 | 0:4a66fd16c223 | 106 | @namespace serial |
ollie140 | 0:4a66fd16c223 | 107 | @brief output serial for USB communication (debugging) |
ollie140 | 0:4a66fd16c223 | 108 | */ |
ollie140 | 0:4a66fd16c223 | 109 | Serial pc(USBTX,USBRX); |
ollie140 | 0:4a66fd16c223 | 110 | |
ollie140 | 0:4a66fd16c223 | 111 | //Rest of objects |
ollie140 | 0:4a66fd16c223 | 112 | /** |
ollie140 | 0:4a66fd16c223 | 113 | @namespace sensorTicker |
ollie140 | 0:4a66fd16c223 | 114 | @brief Sensor ticker that will periodically call for distance and temperature measurements |
ollie140 | 0:4a66fd16c223 | 115 | */ |
ollie140 | 0:4a66fd16c223 | 116 | Ticker sensorTicker; |
ollie140 | 0:4a66fd16c223 | 117 | |
ollie140 | 0:4a66fd16c223 | 118 | /** |
ollie140 | 0:4a66fd16c223 | 119 | @namespace buttonsDebounce |
ollie140 | 0:4a66fd16c223 | 120 | @brief Button Debounce ticker that will periodically call everytime a button has been pressed and will prevent multiple inputs from being recognised |
ollie140 | 0:4a66fd16c223 | 121 | */ |
ollie140 | 0:4a66fd16c223 | 122 | Ticker buttonsDebounce; |
ollie140 | 0:4a66fd16c223 | 123 | |
ollie140 | 0:4a66fd16c223 | 124 | /** |
ollie140 | 0:4a66fd16c223 | 125 | @namespace potTicker |
ollie140 | 0:4a66fd16c223 | 126 | @brief Potetiometer ticker that will periodically call to check the position of the potentiometer |
ollie140 | 0:4a66fd16c223 | 127 | */ |
ollie140 | 0:4a66fd16c223 | 128 | Ticker potTicker; |
ollie140 | 0:4a66fd16c223 | 129 | |
ollie140 | 0:4a66fd16c223 | 130 | //functions |
ollie140 | 0:4a66fd16c223 | 131 | /** |
ollie140 | 0:4a66fd16c223 | 132 | method that will get the average of 10 distance measurements |
ollie140 | 0:4a66fd16c223 | 133 | @returns Average of 10 distance measurements |
ollie140 | 0:4a66fd16c223 | 134 | */ |
ollie140 | 0:4a66fd16c223 | 135 | float getDistance(); |
ollie140 | 0:4a66fd16c223 | 136 | |
ollie140 | 0:4a66fd16c223 | 137 | /** |
ollie140 | 0:4a66fd16c223 | 138 | Method that draws the car on the screen |
ollie140 | 0:4a66fd16c223 | 139 | */ |
ollie140 | 0:4a66fd16c223 | 140 | void drawCar(); |
ollie140 | 0:4a66fd16c223 | 141 | |
ollie140 | 0:4a66fd16c223 | 142 | /** |
ollie140 | 0:4a66fd16c223 | 143 | Method that lets the user know the car is really close to an object |
ollie140 | 0:4a66fd16c223 | 144 | */ |
ollie140 | 0:4a66fd16c223 | 145 | void reallyCloseDistance(); |
ollie140 | 0:4a66fd16c223 | 146 | |
ollie140 | 0:4a66fd16c223 | 147 | /** |
ollie140 | 0:4a66fd16c223 | 148 | Method that lets the user know the car is close to an object |
ollie140 | 0:4a66fd16c223 | 149 | */ |
ollie140 | 0:4a66fd16c223 | 150 | void closeDistance(); |
ollie140 | 0:4a66fd16c223 | 151 | |
ollie140 | 0:4a66fd16c223 | 152 | /** |
ollie140 | 0:4a66fd16c223 | 153 | Method that lets the user know the car is almost close to an object |
ollie140 | 0:4a66fd16c223 | 154 | */ |
ollie140 | 0:4a66fd16c223 | 155 | void mediuDistance(); |
ollie140 | 0:4a66fd16c223 | 156 | |
ollie140 | 0:4a66fd16c223 | 157 | /** |
ollie140 | 0:4a66fd16c223 | 158 | Method that lets the user know the car far from an object |
ollie140 | 0:4a66fd16c223 | 159 | */ |
ollie140 | 0:4a66fd16c223 | 160 | void farDistance(); |
ollie140 | 0:4a66fd16c223 | 161 | |
ollie140 | 0:4a66fd16c223 | 162 | /** |
ollie140 | 0:4a66fd16c223 | 163 | Method that prints the bars to show the user the obstacles distance |
ollie140 | 0:4a66fd16c223 | 164 | */ |
ollie140 | 0:4a66fd16c223 | 165 | void printBars(); |
ollie140 | 0:4a66fd16c223 | 166 | |
ollie140 | 0:4a66fd16c223 | 167 | /** |
ollie140 | 0:4a66fd16c223 | 168 | Method that prints the distance and the temperature on the screen |
ollie140 | 0:4a66fd16c223 | 169 | */ |
ollie140 | 0:4a66fd16c223 | 170 | void numericMode(); |
ollie140 | 0:4a66fd16c223 | 171 | |
ollie140 | 0:4a66fd16c223 | 172 | /** |
ollie140 | 0:4a66fd16c223 | 173 | Initialises serial communication |
ollie140 | 0:4a66fd16c223 | 174 | */ |
ollie140 | 0:4a66fd16c223 | 175 | void init_serial(); |
ollie140 | 0:4a66fd16c223 | 176 | |
ollie140 | 0:4a66fd16c223 | 177 | /** |
ollie140 | 0:4a66fd16c223 | 178 | Initialises all the K64F's on board peripherals |
ollie140 | 0:4a66fd16c223 | 179 | */ |
ollie140 | 0:4a66fd16c223 | 180 | void init_K64F(); |
ollie140 | 0:4a66fd16c223 | 181 | |
ollie140 | 0:4a66fd16c223 | 182 | /** |
ollie140 | 0:4a66fd16c223 | 183 | Sets the buzzers duty cycle to 0 |
ollie140 | 0:4a66fd16c223 | 184 | */ |
ollie140 | 0:4a66fd16c223 | 185 | void buzzerOFF(); |
ollie140 | 0:4a66fd16c223 | 186 | |
ollie140 | 0:4a66fd16c223 | 187 | /** |
ollie140 | 0:4a66fd16c223 | 188 | Sets the buzzers duty cycle to 50% |
ollie140 | 0:4a66fd16c223 | 189 | */ |
ollie140 | 0:4a66fd16c223 | 190 | void buzzerON(); |
ollie140 | 0:4a66fd16c223 | 191 | |
ollie140 | 0:4a66fd16c223 | 192 | /** @name Interrupt Service Routine Functions |
ollie140 | 0:4a66fd16c223 | 193 | * Sets the functions of the ISR |
ollie140 | 0:4a66fd16c223 | 194 | */ |
ollie140 | 0:4a66fd16c223 | 195 | ///@{ |
ollie140 | 0:4a66fd16c223 | 196 | /** |
ollie140 | 0:4a66fd16c223 | 197 | Time triggered interrupt method |
ollie140 | 0:4a66fd16c223 | 198 | */ |
ollie140 | 0:4a66fd16c223 | 199 | void timer_isr(); |
ollie140 | 0:4a66fd16c223 | 200 | |
ollie140 | 0:4a66fd16c223 | 201 | /** |
ollie140 | 0:4a66fd16c223 | 202 | Time triggered interrupt method |
ollie140 | 0:4a66fd16c223 | 203 | */ |
ollie140 | 0:4a66fd16c223 | 204 | void timer1_isr(); |
ollie140 | 0:4a66fd16c223 | 205 | |
ollie140 | 0:4a66fd16c223 | 206 | /** |
ollie140 | 0:4a66fd16c223 | 207 | Time triggered interrupt method |
ollie140 | 0:4a66fd16c223 | 208 | */ |
ollie140 | 0:4a66fd16c223 | 209 | void timer2_isr(); |
ollie140 | 0:4a66fd16c223 | 210 | |
ollie140 | 0:4a66fd16c223 | 211 | /** |
ollie140 | 0:4a66fd16c223 | 212 | Event triggered interrupt method |
ollie140 | 0:4a66fd16c223 | 213 | */ |
ollie140 | 0:4a66fd16c223 | 214 | void botButton_isr(); |
ollie140 | 0:4a66fd16c223 | 215 | |
ollie140 | 0:4a66fd16c223 | 216 | /** |
ollie140 | 0:4a66fd16c223 | 217 | Event triggered interrupt method |
ollie140 | 0:4a66fd16c223 | 218 | */ |
ollie140 | 0:4a66fd16c223 | 219 | void topButton_isr(); |
ollie140 | 0:4a66fd16c223 | 220 | ///@} |
ollie140 | 0:4a66fd16c223 | 221 | |
ollie140 | 0:4a66fd16c223 | 222 | /** @name Menu related functions |
ollie140 | 0:4a66fd16c223 | 223 | * All the functions that set up the menus of the project |
ollie140 | 0:4a66fd16c223 | 224 | */ |
ollie140 | 0:4a66fd16c223 | 225 | ///@{ |
ollie140 | 0:4a66fd16c223 | 226 | /** |
ollie140 | 0:4a66fd16c223 | 227 | Scans the second bank of 6 and inverts all the pixels |
ollie140 | 0:4a66fd16c223 | 228 | */ |
ollie140 | 0:4a66fd16c223 | 229 | void MenuLine1(); |
ollie140 | 0:4a66fd16c223 | 230 | |
ollie140 | 0:4a66fd16c223 | 231 | /** |
ollie140 | 0:4a66fd16c223 | 232 | Scans the second bank of 6 and inverts some of the pixels |
ollie140 | 0:4a66fd16c223 | 233 | */ |
ollie140 | 0:4a66fd16c223 | 234 | void MenuLine1Short(); |
ollie140 | 0:4a66fd16c223 | 235 | |
ollie140 | 0:4a66fd16c223 | 236 | /** |
ollie140 | 0:4a66fd16c223 | 237 | Scans the third bank of 6 and inverts all the pixels |
ollie140 | 0:4a66fd16c223 | 238 | */ |
ollie140 | 0:4a66fd16c223 | 239 | void MenuLine2(); |
ollie140 | 0:4a66fd16c223 | 240 | |
ollie140 | 0:4a66fd16c223 | 241 | /** |
ollie140 | 0:4a66fd16c223 | 242 | Scans the third bank of 6 and inverts some of the pixels |
ollie140 | 0:4a66fd16c223 | 243 | */ |
ollie140 | 0:4a66fd16c223 | 244 | void MenuLine2Short(); |
ollie140 | 0:4a66fd16c223 | 245 | |
ollie140 | 0:4a66fd16c223 | 246 | /** |
ollie140 | 0:4a66fd16c223 | 247 | Scans the fourth bank of 6 and inverts all the pixels |
ollie140 | 0:4a66fd16c223 | 248 | */ |
ollie140 | 0:4a66fd16c223 | 249 | void MenuLine3(); |
ollie140 | 0:4a66fd16c223 | 250 | |
ollie140 | 0:4a66fd16c223 | 251 | /** |
ollie140 | 0:4a66fd16c223 | 252 | Scans the fourth bank of 6 and inverts some of the pixels |
ollie140 | 0:4a66fd16c223 | 253 | */ |
ollie140 | 0:4a66fd16c223 | 254 | void MenuLine3Short(); |
ollie140 | 0:4a66fd16c223 | 255 | |
ollie140 | 0:4a66fd16c223 | 256 | /** |
ollie140 | 0:4a66fd16c223 | 257 | Scans the fifth bank of 6 and inverts all the pixels |
ollie140 | 0:4a66fd16c223 | 258 | */ |
ollie140 | 0:4a66fd16c223 | 259 | void MenuLine4(); |
ollie140 | 0:4a66fd16c223 | 260 | |
ollie140 | 0:4a66fd16c223 | 261 | /** |
ollie140 | 0:4a66fd16c223 | 262 | Scans the fifth bank of 6 and inverts some of the pixels |
ollie140 | 0:4a66fd16c223 | 263 | */ |
ollie140 | 0:4a66fd16c223 | 264 | void MenuLine4Short(); |
ollie140 | 0:4a66fd16c223 | 265 | |
ollie140 | 0:4a66fd16c223 | 266 | /** |
ollie140 | 0:4a66fd16c223 | 267 | Scans the sixth bank of 6 and inverts all the pixels |
ollie140 | 0:4a66fd16c223 | 268 | */ |
ollie140 | 0:4a66fd16c223 | 269 | void MenuLine5(); |
ollie140 | 0:4a66fd16c223 | 270 | |
ollie140 | 0:4a66fd16c223 | 271 | /** |
ollie140 | 0:4a66fd16c223 | 272 | Scans the sixth bank of 6 and inverts some of the pixels |
ollie140 | 0:4a66fd16c223 | 273 | */ |
ollie140 | 0:4a66fd16c223 | 274 | void MenuLine5Short(); |
ollie140 | 0:4a66fd16c223 | 275 | |
ollie140 | 0:4a66fd16c223 | 276 | /** |
ollie140 | 0:4a66fd16c223 | 277 | Sets up the intro screen. |
ollie140 | 0:4a66fd16c223 | 278 | Displays the intro message |
ollie140 | 0:4a66fd16c223 | 279 | */ |
ollie140 | 0:4a66fd16c223 | 280 | void introScreen(); |
ollie140 | 0:4a66fd16c223 | 281 | |
ollie140 | 0:4a66fd16c223 | 282 | /** |
ollie140 | 0:4a66fd16c223 | 283 | Sets up the main menu. |
ollie140 | 0:4a66fd16c223 | 284 | Normalises potentiometer values to the highlighted bank of text |
ollie140 | 0:4a66fd16c223 | 285 | in order to navigate the menus more easily |
ollie140 | 0:4a66fd16c223 | 286 | */ |
ollie140 | 0:4a66fd16c223 | 287 | void mainMenu(); |
ollie140 | 0:4a66fd16c223 | 288 | |
ollie140 | 0:4a66fd16c223 | 289 | /** |
ollie140 | 0:4a66fd16c223 | 290 | Simple function that will send the user back to the main menu whenever the bottom button is pressed |
ollie140 | 0:4a66fd16c223 | 291 | */ |
ollie140 | 0:4a66fd16c223 | 292 | void goToMainMenu(); |
ollie140 | 0:4a66fd16c223 | 293 | |
ollie140 | 0:4a66fd16c223 | 294 | /** |
ollie140 | 0:4a66fd16c223 | 295 | Simple function that will send the user to a certain screen depending on what state it is |
ollie140 | 0:4a66fd16c223 | 296 | */ |
ollie140 | 0:4a66fd16c223 | 297 | void goToSelectedOption(); |
ollie140 | 0:4a66fd16c223 | 298 | |
ollie140 | 0:4a66fd16c223 | 299 | /** |
ollie140 | 0:4a66fd16c223 | 300 | Sets up the peripherals menu. The peripherals are the LED and the buzzer |
ollie140 | 0:4a66fd16c223 | 301 | */ |
ollie140 | 0:4a66fd16c223 | 302 | void peripheralsMenu(); |
ollie140 | 0:4a66fd16c223 | 303 | |
ollie140 | 0:4a66fd16c223 | 304 | /** |
ollie140 | 0:4a66fd16c223 | 305 | Sets up the modes menu. The user will be able to use the parking sensor |
ollie140 | 0:4a66fd16c223 | 306 | or a numerical value sensor that will indicate both temperature and distance. |
ollie140 | 0:4a66fd16c223 | 307 | */ |
ollie140 | 0:4a66fd16c223 | 308 | void modesMenu(); |
ollie140 | 0:4a66fd16c223 | 309 | |
ollie140 | 0:4a66fd16c223 | 310 | /** |
ollie140 | 0:4a66fd16c223 | 311 | Sets up the sound menu. Either turn sound off or on |
ollie140 | 0:4a66fd16c223 | 312 | */ |
ollie140 | 0:4a66fd16c223 | 313 | void soundMenu(); |
ollie140 | 0:4a66fd16c223 | 314 | |
ollie140 | 0:4a66fd16c223 | 315 | /** |
ollie140 | 0:4a66fd16c223 | 316 | Sets up the LED menu. The led will either turn on at |
ollie140 | 0:4a66fd16c223 | 317 | critical distances from an object or it won't |
ollie140 | 0:4a66fd16c223 | 318 | */ |
ollie140 | 0:4a66fd16c223 | 319 | void LEDMenu(); |
ollie140 | 0:4a66fd16c223 | 320 | |
ollie140 | 0:4a66fd16c223 | 321 | /** |
ollie140 | 0:4a66fd16c223 | 322 | Sets up the brightness menu. The backlight led will go from a range of |
ollie140 | 0:4a66fd16c223 | 323 | 0% to 100% brightness. |
ollie140 | 0:4a66fd16c223 | 324 | */ |
ollie140 | 0:4a66fd16c223 | 325 | void brightnessMenu(); |
ollie140 | 0:4a66fd16c223 | 326 | |
ollie140 | 0:4a66fd16c223 | 327 | /** |
ollie140 | 0:4a66fd16c223 | 328 | Sets up the day/night menu. The lcd will change from normal mode to inverse mode |
ollie140 | 0:4a66fd16c223 | 329 | when the user desires so |
ollie140 | 0:4a66fd16c223 | 330 | */ |
ollie140 | 0:4a66fd16c223 | 331 | void nightMenu(); |
ollie140 | 0:4a66fd16c223 | 332 | ///@} |
ollie140 | 0:4a66fd16c223 | 333 | |
ollie140 | 0:4a66fd16c223 | 334 | //Variables |
ollie140 | 0:4a66fd16c223 | 335 | float distance; /*!< @brief Float that stores the average distance measurement from the getDistance function*/ |
ollie140 | 0:4a66fd16c223 | 336 | |
ollie140 | 0:4a66fd16c223 | 337 | float dist; /*!< @brief Float that stores the average distance measurement to be used in the modes functions*/ |
ollie140 | 0:4a66fd16c223 | 338 | |
ollie140 | 0:4a66fd16c223 | 339 | float T; /*!< @brief Float that stores the temperature measurement to be used in the modes functions*/ |
ollie140 | 0:4a66fd16c223 | 340 | |
ollie140 | 0:4a66fd16c223 | 341 | int emptyVariable; /*!< @brief Integer that serves as an empty variable to store the distance average measurements*/ |
ollie140 | 0:4a66fd16c223 | 342 | |
ollie140 | 0:4a66fd16c223 | 343 | int realDistance; /*!< @brief Integer that stores the distance measurements in cm from the distance sensor*/ |
ollie140 | 0:4a66fd16c223 | 344 | |
ollie140 | 0:4a66fd16c223 | 345 | int temp; /*!< @brief Integer that stores the floored temperature measurement to be used in the parking mode function [printBars()]*/ |
ollie140 | 0:4a66fd16c223 | 346 | |
ollie140 | 0:4a66fd16c223 | 347 | int current_screen; /*!< @brief Integer that serves as an empty variable to store the current screen state*/ |
ollie140 | 0:4a66fd16c223 | 348 | |
ollie140 | 0:4a66fd16c223 | 349 | int selected_option; /*!< @brief Integer that serves as an empty variable to store the selected option once an interrupt has occurred*/ |
ollie140 | 0:4a66fd16c223 | 350 | |
ollie140 | 0:4a66fd16c223 | 351 | int led_state; /*!< @brief Integer that serves as an empty variable to store the LED state (either on or off)*/ |
ollie140 | 0:4a66fd16c223 | 352 | |
ollie140 | 0:4a66fd16c223 | 353 | int buzzer_state; /*!< @brief Integer that serves as an empty variable to store the buzzer state (either on or off)*/ |
ollie140 | 0:4a66fd16c223 | 354 | |
ollie140 | 0:4a66fd16c223 | 355 | int circle_position_SOUND = 27; /*!< @brief Integer that stores the initial y value for the circles in the sound menu*/ |
ollie140 | 0:4a66fd16c223 | 356 | |
ollie140 | 0:4a66fd16c223 | 357 | int circle_position_LED = 27; /*!< @brief Integer that stores the initial y value for the circles in the LED menu*/ |
ollie140 | 0:4a66fd16c223 | 358 | |
ollie140 | 0:4a66fd16c223 | 359 | int circle_position_brightness = 43; /*!< @brief Integer that stores the initial y value for the circles in the brightness menu*/ |
ollie140 | 0:4a66fd16c223 | 360 | |
ollie140 | 0:4a66fd16c223 | 361 | int circle_position_NIGHT = 27; /*!< @brief Integer that stores the initial y value for the circles in the night menu*/ |
ollie140 | 0:4a66fd16c223 | 362 | |
ollie140 | 0:4a66fd16c223 | 363 | int length1; /*!< @brief Integer that stores the length of the distance string to be printed in the numeric mode*/ |
ollie140 | 0:4a66fd16c223 | 364 | |
ollie140 | 0:4a66fd16c223 | 365 | int length2; /*!< @brief Integer that stores the length of the temperature string to be printed in the numeric mode*/ |
ollie140 | 0:4a66fd16c223 | 366 | |
ollie140 | 0:4a66fd16c223 | 367 | /** @name Constant integers |
ollie140 | 0:4a66fd16c223 | 368 | * Constant integers used as unchangeable states for menu navigation and states of LED and buzzer |
ollie140 | 0:4a66fd16c223 | 369 | */ |
ollie140 | 0:4a66fd16c223 | 370 | ///@{ |
ollie140 | 0:4a66fd16c223 | 371 | |
ollie140 | 0:4a66fd16c223 | 372 | const int menu_state = 0; /*!< @brief Constant integer that signals the menu state*/ |
ollie140 | 0:4a66fd16c223 | 373 | |
ollie140 | 0:4a66fd16c223 | 374 | const int peripherals_state = 1; /*!< @brief Constant integer that signals the peripherals state*/ |
ollie140 | 0:4a66fd16c223 | 375 | |
ollie140 | 0:4a66fd16c223 | 376 | const int brightness_state = 2; /*!< @brief Constant integer that signals the brightness state*/ |
ollie140 | 0:4a66fd16c223 | 377 | |
ollie140 | 0:4a66fd16c223 | 378 | const int sound_state = 3; /*!< @brief Constant integer that signals the sound menu state*/ |
ollie140 | 0:4a66fd16c223 | 379 | |
ollie140 | 0:4a66fd16c223 | 380 | const int ledMenu_state = 4; /*!< @brief Constant integer that signals the LED menu state*/ |
ollie140 | 0:4a66fd16c223 | 381 | |
ollie140 | 0:4a66fd16c223 | 382 | const int nightMenu_state = 5; /*!< @brief Constant integer that signals the night menu state*/ |
ollie140 | 0:4a66fd16c223 | 383 | |
ollie140 | 0:4a66fd16c223 | 384 | const int modes_state = 6; /*!< @brief Constant integer that signals the modes state state*/ |
ollie140 | 0:4a66fd16c223 | 385 | |
ollie140 | 0:4a66fd16c223 | 386 | const int parkingMode_state = 7; /*!< @brief Constant integer that signals the parking mode state*/ |
ollie140 | 0:4a66fd16c223 | 387 | |
ollie140 | 0:4a66fd16c223 | 388 | const int numericMode_state = 8; /*!< @brief Constant integer that signals the numeric mode state*/ |
ollie140 | 0:4a66fd16c223 | 389 | |
ollie140 | 0:4a66fd16c223 | 390 | const int LEDON_state = 9; /*!< @brief Constant integer that signals the LED is ON state*/ |
ollie140 | 0:4a66fd16c223 | 391 | |
ollie140 | 0:4a66fd16c223 | 392 | const int LEDOFF_state = 10; /*!< @brief Constant integer that signals the LED is OFF state*/ |
ollie140 | 0:4a66fd16c223 | 393 | |
ollie140 | 0:4a66fd16c223 | 394 | const int buzzerON_state = 11; /*!< @brief Constant integer that signals the buzzer is ON state*/ |
ollie140 | 0:4a66fd16c223 | 395 | |
ollie140 | 0:4a66fd16c223 | 396 | const int buzzerOFF_state = 12; /*!< @brief Constant integer that signals the buzzer is OFF state*/ |
ollie140 | 0:4a66fd16c223 | 397 | ///@} |
ollie140 | 0:4a66fd16c223 | 398 | |
ollie140 | 0:4a66fd16c223 | 399 | char buffer[14]; /*!< @brief Char that stores an array of characters to print the distance in the numeric mode*/ |
ollie140 | 0:4a66fd16c223 | 400 | |
ollie140 | 0:4a66fd16c223 | 401 | char buffer2[14]; /*!< @brief Char that stores an array of characters to print the temperature in the numeric mode and parking mode*/ |
ollie140 | 0:4a66fd16c223 | 402 | |
ollie140 | 0:4a66fd16c223 | 403 | //Flags |
ollie140 | 0:4a66fd16c223 | 404 | /** @name Interrupt Service Routine Flags |
ollie140 | 0:4a66fd16c223 | 405 | * Set flags in ISR |
ollie140 | 0:4a66fd16c223 | 406 | */ |
ollie140 | 0:4a66fd16c223 | 407 | ///@{ |
ollie140 | 0:4a66fd16c223 | 408 | volatile int g_timer_flag = 0; /*!< @brief Volatile integer that serves as a time triggered ISR for the sensor ticker*/ |
ollie140 | 0:4a66fd16c223 | 409 | |
ollie140 | 0:4a66fd16c223 | 410 | volatile int g_timer1_flag = 0; /*!< @brief Volatile integer that serves as a time triggered ISR for the button debouncer ticker*/ |
ollie140 | 0:4a66fd16c223 | 411 | |
ollie140 | 0:4a66fd16c223 | 412 | volatile int g_timer2_flag = 0; /*!< @brief Volatile integer that serves as a time triggered ISR for the potentiometer reading ticker*/ |
ollie140 | 0:4a66fd16c223 | 413 | |
ollie140 | 0:4a66fd16c223 | 414 | volatile int g_topButton_flag = 0; /*!< @brief Volatile integer that serves as an event triggered ISR for when the top button is pressed*/ |
ollie140 | 0:4a66fd16c223 | 415 | |
ollie140 | 0:4a66fd16c223 | 416 | volatile int g_botButton_flag = 0; /*!< @brief Volatile integer that serves as an event triggered ISR for when the bottom button is pressed*/ |
ollie140 | 0:4a66fd16c223 | 417 | ///@} |
ollie140 | 0:4a66fd16c223 | 418 | |
ollie140 | 0:4a66fd16c223 | 419 | #endif |