
Distance Sensor Embedded Systems Project SID: 200864479 James Erringham-Bruce
Dependencies: N5110 SRF02-JEB mbed
RadarMode/Radar.h@1:f82359c58eda, 2016-05-04 (annotated)
- Committer:
- ll13j7b
- Date:
- Wed May 04 21:20:21 2016 +0000
- Revision:
- 1:f82359c58eda
- Child:
- 2:01f697b856de
working version before adding classes
Who changed what in which revision?
User | Revision | Line number | New 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 | @fn radarMode |
ll13j7b | 1:f82359c58eda | 20 | @param int average - average reading of distance |
ll13j7b | 1:f82359c58eda | 21 | @brief allows the user to visually see a wall of pixels moving with respect to the average 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 | 1:f82359c58eda | 29 | #endif |
ll13j7b | 1:f82359c58eda | 30 | |
ll13j7b | 1:f82359c58eda | 31 | /** |
ll13j7b | 1:f82359c58eda | 32 | @file Radar.cpp |
ll13j7b | 1:f82359c58eda | 33 | @brief Member functions implementations |
ll13j7b | 1:f82359c58eda | 34 | @author James Erringham-Bruce |
ll13j7b | 1:f82359c58eda | 35 | */ |
ll13j7b | 1:f82359c58eda | 36 | //#include "mbed.h" |
ll13j7b | 1:f82359c58eda | 37 | //#include "Radar.h" |
ll13j7b | 1:f82359c58eda | 38 | |
ll13j7b | 1:f82359c58eda | 39 | |
ll13j7b | 1:f82359c58eda | 40 | // FUNCTION TO DISPLAY THE DISTANCE IN A VISUAL WAY |
ll13j7b | 1:f82359c58eda | 41 | void Radar::radarMode() |
ll13j7b | 1:f82359c58eda | 42 | { |
ll13j7b | 1:f82359c58eda | 43 | while (1) { |
ll13j7b | 1:f82359c58eda | 44 | int average = getAverageReadingCm(); |
ll13j7b | 1:f82359c58eda | 45 | if (g_timer_flag) { // firing the timer |
ll13j7b | 1:f82359c58eda | 46 | g_timer_flag = 0; |
ll13j7b | 1:f82359c58eda | 47 | lcd.clear(); // clear the screen ready for this mode to be displayed |
ll13j7b | 1:f82359c58eda | 48 | lcd.drawCircle(42,52,10,1); // printing the users position at the bottom of the screen like a semi-circle |
ll13j7b | 1:f82359c58eda | 49 | lcd.drawCircle(42,52,average,0); // wall of pixels ( circle ) radias changes with respect to average value |
ll13j7b | 1:f82359c58eda | 50 | lcd.refresh(); // refresh the screen to dispaly changes |
ll13j7b | 1:f82359c58eda | 51 | if ( average > 60) { // if the value reaches too high |
ll13j7b | 1:f82359c58eda | 52 | average = 60; // ensure it does not range of screen |
ll13j7b | 1:f82359c58eda | 53 | } else if ( average < 18 ) { // if value goes too low |
ll13j7b | 1:f82359c58eda | 54 | average = 18; // ensure it does not go lower than the users printed position |
ll13j7b | 1:f82359c58eda | 55 | } |
ll13j7b | 1:f82359c58eda | 56 | } |
ll13j7b | 1:f82359c58eda | 57 | sleep(); // sleep before next interrupt |
ll13j7b | 1:f82359c58eda | 58 | } |
ll13j7b | 1:f82359c58eda | 59 | } |