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

Dependencies:   N5110 SRF02-JEB mbed

Revision:
1:f82359c58eda
Child:
2:01f697b856de
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RadarMode/Radar.h	Wed May 04 21:20:21 2016 +0000
@@ -0,0 +1,59 @@
+/*
+@file Radar.h
+@brief Header file containing member functions and variables
+@author James Erringham-Bruce
+*/
+
+#ifndef RADAR_H
+#define RADAR_H
+
+#include "mbed.h"           // mbed library
+#include "DataController.h"
+
+// creating the class used in plotting the graph
+class Radar
+{
+    // defining the public functions
+public:
+    /**
+    @fn radarMode
+    @param int average - average reading of distance
+    @brief allows the user to visually see a wall of pixels moving with respect to the average distance
+    */
+    void radarMode();
+
+    // defining the private functions
+private:
+
+};
+#endif
+
+/**
+@file Radar.cpp
+@brief Member functions implementations
+@author James Erringham-Bruce
+*/
+//#include "mbed.h"
+//#include "Radar.h"
+
+
+// FUNCTION TO DISPLAY THE DISTANCE IN A VISUAL WAY
+void Radar::radarMode()
+{
+    while (1) {
+        int average = getAverageReadingCm();
+        if (g_timer_flag) { // firing the timer
+            g_timer_flag = 0;
+            lcd.clear(); // clear the screen ready for this mode to be displayed
+            lcd.drawCircle(42,52,10,1); // printing the users position at the bottom of the screen like a semi-circle
+            lcd.drawCircle(42,52,average,0); // wall of pixels ( circle ) radias changes with respect to average value
+            lcd.refresh(); // refresh the screen to dispaly changes
+            if ( average > 60) { // if the value reaches too high
+                average = 60; // ensure it does not range of screen
+            } else if ( average < 18 ) { // if value goes too low
+                average = 18; // ensure it does not go lower than the users printed position
+            }
+        }
+        sleep(); // sleep before next interrupt
+    }
+}