Distance Sensor Embedded Systems Project SID: 200864479 James Erringham-Bruce

Dependencies:   N5110 SRF02-JEB mbed

Committer:
ll13j7b
Date:
Thu May 05 14:22:27 2016 +0000
Revision:
3:ab75e6a12701
Parent:
2:01f697b856de
Final Code Submission

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ll13j7b 1:f82359c58eda 1 /*
ll13j7b 1:f82359c58eda 2 @file Radar.h
ll13j7b 1:f82359c58eda 3 @brief Header file containing member functions and variables
ll13j7b 1:f82359c58eda 4 @author James Erringham-Bruce
ll13j7b 1:f82359c58eda 5 */
ll13j7b 1:f82359c58eda 6
ll13j7b 1:f82359c58eda 7 #ifndef RADAR_H
ll13j7b 1:f82359c58eda 8 #define RADAR_H
ll13j7b 1:f82359c58eda 9
ll13j7b 1:f82359c58eda 10 #include "mbed.h" // mbed library
ll13j7b 1:f82359c58eda 11 #include "DataController.h"
ll13j7b 1:f82359c58eda 12
ll13j7b 1:f82359c58eda 13 // creating the class used in plotting the graph
ll13j7b 1:f82359c58eda 14 class Radar
ll13j7b 1:f82359c58eda 15 {
ll13j7b 1:f82359c58eda 16 // defining the public functions
ll13j7b 1:f82359c58eda 17 public:
ll13j7b 1:f82359c58eda 18 /**
ll13j7b 1:f82359c58eda 19 @param int average - average reading of distance
ll13j7b 2:01f697b856de 20 function that allows the user to visually see a wall of pixels moving with respect to the average distance, interactive moving
ll13j7b 2:01f697b856de 21 radar so they can see how far they are from the set distance
ll13j7b 1:f82359c58eda 22 */
ll13j7b 1:f82359c58eda 23 void radarMode();
ll13j7b 1:f82359c58eda 24
ll13j7b 1:f82359c58eda 25 // defining the private functions
ll13j7b 1:f82359c58eda 26 private:
ll13j7b 1:f82359c58eda 27
ll13j7b 1:f82359c58eda 28 };
ll13j7b 2:01f697b856de 29
ll13j7b 2:01f697b856de 30 //*****************************************************************************************************//
ll13j7b 2:01f697b856de 31
ll13j7b 2:01f697b856de 32 // END OF CLASS //
ll13j7b 2:01f697b856de 33
ll13j7b 2:01f697b856de 34 //*****************************************************************************************************//
ll13j7b 2:01f697b856de 35
ll13j7b 1:f82359c58eda 36 #endif
ll13j7b 1:f82359c58eda 37
ll13j7b 1:f82359c58eda 38 /**
ll13j7b 1:f82359c58eda 39 @file Radar.cpp
ll13j7b 1:f82359c58eda 40 @brief Member functions implementations
ll13j7b 1:f82359c58eda 41 @author James Erringham-Bruce
ll13j7b 1:f82359c58eda 42 */
ll13j7b 1:f82359c58eda 43
ll13j7b 1:f82359c58eda 44 // FUNCTION TO DISPLAY THE DISTANCE IN A VISUAL WAY
ll13j7b 1:f82359c58eda 45 void Radar::radarMode()
ll13j7b 1:f82359c58eda 46 {
ll13j7b 2:01f697b856de 47 /// print a semi-circle at the bottom of the page to act as user position
ll13j7b 2:01f697b856de 48 isInRadar = 1;
ll13j7b 2:01f697b856de 49 while (isInRadar) {
ll13j7b 1:f82359c58eda 50 int average = getAverageReadingCm();
ll13j7b 2:01f697b856de 51
ll13j7b 2:01f697b856de 52 goBackToMenu();
ll13j7b 2:01f697b856de 53 /// then display the outline of another circle that outlines bigger or lower
ll13j7b 2:01f697b856de 54 /// with respect to the distance value
ll13j7b 1:f82359c58eda 55 if (g_timer_flag) { // firing the timer
ll13j7b 1:f82359c58eda 56 g_timer_flag = 0;
ll13j7b 2:01f697b856de 57 int radias = average/(250/48);
ll13j7b 1:f82359c58eda 58 lcd.clear(); // clear the screen ready for this mode to be displayed
ll13j7b 1:f82359c58eda 59 lcd.drawCircle(42,52,10,1); // printing the users position at the bottom of the screen like a semi-circle
ll13j7b 2:01f697b856de 60 lcd.drawCircle(42,52,radias,0); // wall of pixels ( circle ) radias changes with respect to average value
ll13j7b 1:f82359c58eda 61 lcd.refresh(); // refresh the screen to dispaly changes
ll13j7b 1:f82359c58eda 62 }
ll13j7b 1:f82359c58eda 63 sleep(); // sleep before next interrupt
ll13j7b 1:f82359c58eda 64 }
ll13j7b 1:f82359c58eda 65 }
ll13j7b 2:01f697b856de 66
ll13j7b 2:01f697b856de 67 //*****************************************************************************************************//
ll13j7b 2:01f697b856de 68
ll13j7b 2:01f697b856de 69 // END OF FUNCTION IMPLEMENTATIONS //
ll13j7b 2:01f697b856de 70
ll13j7b 2:01f697b856de 71 //*****************************************************************************************************//
ll13j7b 2:01f697b856de 72
ll13j7b 2:01f697b856de 73
ll13j7b 2:01f697b856de 74
ll13j7b 2:01f697b856de 75
ll13j7b 2:01f697b856de 76